You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1152 lines
37 KiB

  1. // Package oslogin provides access to the Cloud OS Login API.
  2. //
  3. // See https://cloud.google.com/compute/docs/oslogin/rest/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/oslogin/v1"
  8. // ...
  9. // osloginService, err := oslogin.New(oauthHttpClient)
  10. package oslogin // import "google.golang.org/api/oslogin/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "oslogin:v1"
  41. const apiName = "oslogin"
  42. const apiVersion = "v1"
  43. const basePath = "https://oslogin.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. // View and manage your Google Compute Engine resources
  49. ComputeScope = "https://www.googleapis.com/auth/compute"
  50. )
  51. func New(client *http.Client) (*Service, error) {
  52. if client == nil {
  53. return nil, errors.New("client is nil")
  54. }
  55. s := &Service{client: client, BasePath: basePath}
  56. s.Users = NewUsersService(s)
  57. return s, nil
  58. }
  59. type Service struct {
  60. client *http.Client
  61. BasePath string // API endpoint base URL
  62. UserAgent string // optional additional User-Agent fragment
  63. Users *UsersService
  64. }
  65. func (s *Service) userAgent() string {
  66. if s.UserAgent == "" {
  67. return googleapi.UserAgent
  68. }
  69. return googleapi.UserAgent + " " + s.UserAgent
  70. }
  71. func NewUsersService(s *Service) *UsersService {
  72. rs := &UsersService{s: s}
  73. rs.Projects = NewUsersProjectsService(s)
  74. rs.SshPublicKeys = NewUsersSshPublicKeysService(s)
  75. return rs
  76. }
  77. type UsersService struct {
  78. s *Service
  79. Projects *UsersProjectsService
  80. SshPublicKeys *UsersSshPublicKeysService
  81. }
  82. func NewUsersProjectsService(s *Service) *UsersProjectsService {
  83. rs := &UsersProjectsService{s: s}
  84. return rs
  85. }
  86. type UsersProjectsService struct {
  87. s *Service
  88. }
  89. func NewUsersSshPublicKeysService(s *Service) *UsersSshPublicKeysService {
  90. rs := &UsersSshPublicKeysService{s: s}
  91. return rs
  92. }
  93. type UsersSshPublicKeysService struct {
  94. s *Service
  95. }
  96. // Empty: A generic empty message that you can re-use to avoid defining
  97. // duplicated
  98. // empty messages in your APIs. A typical example is to use it as the
  99. // request
  100. // or the response type of an API method. For instance:
  101. //
  102. // service Foo {
  103. // rpc Bar(google.protobuf.Empty) returns
  104. // (google.protobuf.Empty);
  105. // }
  106. //
  107. // The JSON representation for `Empty` is empty JSON object `{}`.
  108. type Empty struct {
  109. // ServerResponse contains the HTTP response code and headers from the
  110. // server.
  111. googleapi.ServerResponse `json:"-"`
  112. }
  113. // ImportSshPublicKeyResponse: A response message for importing an SSH
  114. // public key.
  115. type ImportSshPublicKeyResponse struct {
  116. // LoginProfile: The login profile information for the user.
  117. LoginProfile *LoginProfile `json:"loginProfile,omitempty"`
  118. // ServerResponse contains the HTTP response code and headers from the
  119. // server.
  120. googleapi.ServerResponse `json:"-"`
  121. // ForceSendFields is a list of field names (e.g. "LoginProfile") to
  122. // unconditionally include in API requests. By default, fields with
  123. // empty values are omitted from API requests. However, any non-pointer,
  124. // non-interface field appearing in ForceSendFields will be sent to the
  125. // server regardless of whether the field is empty or not. This may be
  126. // used to include empty fields in Patch requests.
  127. ForceSendFields []string `json:"-"`
  128. // NullFields is a list of field names (e.g. "LoginProfile") to include
  129. // in API requests with the JSON null value. By default, fields with
  130. // empty values are omitted from API requests. However, any field with
  131. // an empty value appearing in NullFields will be sent to the server as
  132. // null. It is an error if a field in this list has a non-empty value.
  133. // This may be used to include null fields in Patch requests.
  134. NullFields []string `json:"-"`
  135. }
  136. func (s *ImportSshPublicKeyResponse) MarshalJSON() ([]byte, error) {
  137. type NoMethod ImportSshPublicKeyResponse
  138. raw := NoMethod(*s)
  139. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  140. }
  141. // LoginProfile: The user profile information used for logging in to a
  142. // virtual machine on
  143. // Google Compute Engine.
  144. type LoginProfile struct {
  145. // Name: A unique user ID.
  146. Name string `json:"name,omitempty"`
  147. // PosixAccounts: The list of POSIX accounts associated with the user.
  148. PosixAccounts []*PosixAccount `json:"posixAccounts,omitempty"`
  149. // SshPublicKeys: A map from SSH public key fingerprint to the
  150. // associated key object.
  151. SshPublicKeys map[string]SshPublicKey `json:"sshPublicKeys,omitempty"`
  152. // ServerResponse contains the HTTP response code and headers from the
  153. // server.
  154. googleapi.ServerResponse `json:"-"`
  155. // ForceSendFields is a list of field names (e.g. "Name") to
  156. // unconditionally include in API requests. By default, fields with
  157. // empty values are omitted from API requests. However, any non-pointer,
  158. // non-interface field appearing in ForceSendFields will be sent to the
  159. // server regardless of whether the field is empty or not. This may be
  160. // used to include empty fields in Patch requests.
  161. ForceSendFields []string `json:"-"`
  162. // NullFields is a list of field names (e.g. "Name") to include in API
  163. // requests with the JSON null value. By default, fields with empty
  164. // values are omitted from API requests. However, any field with an
  165. // empty value appearing in NullFields will be sent to the server as
  166. // null. It is an error if a field in this list has a non-empty value.
  167. // This may be used to include null fields in Patch requests.
  168. NullFields []string `json:"-"`
  169. }
  170. func (s *LoginProfile) MarshalJSON() ([]byte, error) {
  171. type NoMethod LoginProfile
  172. raw := NoMethod(*s)
  173. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  174. }
  175. // PosixAccount: The POSIX account information associated with a Google
  176. // account.
  177. type PosixAccount struct {
  178. // AccountId: Output only. A POSIX account identifier.
  179. AccountId string `json:"accountId,omitempty"`
  180. // Gecos: The GECOS (user information) entry for this account.
  181. Gecos string `json:"gecos,omitempty"`
  182. // Gid: The default group ID.
  183. Gid int64 `json:"gid,omitempty,string"`
  184. // HomeDirectory: The path to the home directory for this account.
  185. HomeDirectory string `json:"homeDirectory,omitempty"`
  186. // OperatingSystemType: The operating system type where this account
  187. // applies.
  188. //
  189. // Possible values:
  190. // "OPERATING_SYSTEM_TYPE_UNSPECIFIED" - The operating system type
  191. // associated with the user account information is
  192. // unspecified.
  193. // "LINUX" - Linux user account information.
  194. // "WINDOWS" - Windows user account information.
  195. OperatingSystemType string `json:"operatingSystemType,omitempty"`
  196. // Primary: Only one POSIX account can be marked as primary.
  197. Primary bool `json:"primary,omitempty"`
  198. // Shell: The path to the logic shell for this account.
  199. Shell string `json:"shell,omitempty"`
  200. // SystemId: System identifier for which account the username or uid
  201. // applies to.
  202. // By default, the empty value is used.
  203. SystemId string `json:"systemId,omitempty"`
  204. // Uid: The user ID.
  205. Uid int64 `json:"uid,omitempty,string"`
  206. // Username: The username of the POSIX account.
  207. Username string `json:"username,omitempty"`
  208. // ForceSendFields is a list of field names (e.g. "AccountId") to
  209. // unconditionally include in API requests. By default, fields with
  210. // empty values are omitted from API requests. However, any non-pointer,
  211. // non-interface field appearing in ForceSendFields will be sent to the
  212. // server regardless of whether the field is empty or not. This may be
  213. // used to include empty fields in Patch requests.
  214. ForceSendFields []string `json:"-"`
  215. // NullFields is a list of field names (e.g. "AccountId") to include in
  216. // API requests with the JSON null value. By default, fields with empty
  217. // values are omitted from API requests. However, any field with an
  218. // empty value appearing in NullFields will be sent to the server as
  219. // null. It is an error if a field in this list has a non-empty value.
  220. // This may be used to include null fields in Patch requests.
  221. NullFields []string `json:"-"`
  222. }
  223. func (s *PosixAccount) MarshalJSON() ([]byte, error) {
  224. type NoMethod PosixAccount
  225. raw := NoMethod(*s)
  226. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  227. }
  228. // SshPublicKey: The SSH public key information associated with a Google
  229. // account.
  230. type SshPublicKey struct {
  231. // ExpirationTimeUsec: An expiration time in microseconds since epoch.
  232. ExpirationTimeUsec int64 `json:"expirationTimeUsec,omitempty,string"`
  233. // Fingerprint: Output only. The SHA-256 fingerprint of the SSH public
  234. // key.
  235. Fingerprint string `json:"fingerprint,omitempty"`
  236. // Key: Public key text in SSH format, defined by
  237. // <a href="https://www.ietf.org/rfc/rfc4253.txt"
  238. // target="_blank">RFC4253</a>
  239. // section 6.6.
  240. Key string `json:"key,omitempty"`
  241. // ServerResponse contains the HTTP response code and headers from the
  242. // server.
  243. googleapi.ServerResponse `json:"-"`
  244. // ForceSendFields is a list of field names (e.g. "ExpirationTimeUsec")
  245. // to unconditionally include in API requests. By default, fields with
  246. // empty values are omitted from API requests. However, any non-pointer,
  247. // non-interface field appearing in ForceSendFields will be sent to the
  248. // server regardless of whether the field is empty or not. This may be
  249. // used to include empty fields in Patch requests.
  250. ForceSendFields []string `json:"-"`
  251. // NullFields is a list of field names (e.g. "ExpirationTimeUsec") to
  252. // include in API requests with the JSON null value. By default, fields
  253. // with empty values are omitted from API requests. However, any field
  254. // with an empty value appearing in NullFields will be sent to the
  255. // server as null. It is an error if a field in this list has a
  256. // non-empty value. This may be used to include null fields in Patch
  257. // requests.
  258. NullFields []string `json:"-"`
  259. }
  260. func (s *SshPublicKey) MarshalJSON() ([]byte, error) {
  261. type NoMethod SshPublicKey
  262. raw := NoMethod(*s)
  263. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  264. }
  265. // method id "oslogin.users.getLoginProfile":
  266. type UsersGetLoginProfileCall struct {
  267. s *Service
  268. name string
  269. urlParams_ gensupport.URLParams
  270. ifNoneMatch_ string
  271. ctx_ context.Context
  272. header_ http.Header
  273. }
  274. // GetLoginProfile: Retrieves the profile information used for logging
  275. // in to a virtual machine
  276. // on Google Compute Engine.
  277. func (r *UsersService) GetLoginProfile(name string) *UsersGetLoginProfileCall {
  278. c := &UsersGetLoginProfileCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  279. c.name = name
  280. return c
  281. }
  282. // Fields allows partial responses to be retrieved. See
  283. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  284. // for more information.
  285. func (c *UsersGetLoginProfileCall) Fields(s ...googleapi.Field) *UsersGetLoginProfileCall {
  286. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  287. return c
  288. }
  289. // IfNoneMatch sets the optional parameter which makes the operation
  290. // fail if the object's ETag matches the given value. This is useful for
  291. // getting updates only after the object has changed since the last
  292. // request. Use googleapi.IsNotModified to check whether the response
  293. // error from Do is the result of In-None-Match.
  294. func (c *UsersGetLoginProfileCall) IfNoneMatch(entityTag string) *UsersGetLoginProfileCall {
  295. c.ifNoneMatch_ = entityTag
  296. return c
  297. }
  298. // Context sets the context to be used in this call's Do method. Any
  299. // pending HTTP request will be aborted if the provided context is
  300. // canceled.
  301. func (c *UsersGetLoginProfileCall) Context(ctx context.Context) *UsersGetLoginProfileCall {
  302. c.ctx_ = ctx
  303. return c
  304. }
  305. // Header returns an http.Header that can be modified by the caller to
  306. // add HTTP headers to the request.
  307. func (c *UsersGetLoginProfileCall) Header() http.Header {
  308. if c.header_ == nil {
  309. c.header_ = make(http.Header)
  310. }
  311. return c.header_
  312. }
  313. func (c *UsersGetLoginProfileCall) doRequest(alt string) (*http.Response, error) {
  314. reqHeaders := make(http.Header)
  315. for k, v := range c.header_ {
  316. reqHeaders[k] = v
  317. }
  318. reqHeaders.Set("User-Agent", c.s.userAgent())
  319. if c.ifNoneMatch_ != "" {
  320. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  321. }
  322. var body io.Reader = nil
  323. c.urlParams_.Set("alt", alt)
  324. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/loginProfile")
  325. urls += "?" + c.urlParams_.Encode()
  326. req, _ := http.NewRequest("GET", urls, body)
  327. req.Header = reqHeaders
  328. googleapi.Expand(req.URL, map[string]string{
  329. "name": c.name,
  330. })
  331. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  332. }
  333. // Do executes the "oslogin.users.getLoginProfile" call.
  334. // Exactly one of *LoginProfile or error will be non-nil. Any non-2xx
  335. // status code is an error. Response headers are in either
  336. // *LoginProfile.ServerResponse.Header or (if a response was returned at
  337. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  338. // to check whether the returned error was because
  339. // http.StatusNotModified was returned.
  340. func (c *UsersGetLoginProfileCall) Do(opts ...googleapi.CallOption) (*LoginProfile, error) {
  341. gensupport.SetOptions(c.urlParams_, opts...)
  342. res, err := c.doRequest("json")
  343. if res != nil && res.StatusCode == http.StatusNotModified {
  344. if res.Body != nil {
  345. res.Body.Close()
  346. }
  347. return nil, &googleapi.Error{
  348. Code: res.StatusCode,
  349. Header: res.Header,
  350. }
  351. }
  352. if err != nil {
  353. return nil, err
  354. }
  355. defer googleapi.CloseBody(res)
  356. if err := googleapi.CheckResponse(res); err != nil {
  357. return nil, err
  358. }
  359. ret := &LoginProfile{
  360. ServerResponse: googleapi.ServerResponse{
  361. Header: res.Header,
  362. HTTPStatusCode: res.StatusCode,
  363. },
  364. }
  365. target := &ret
  366. if err := gensupport.DecodeResponse(target, res); err != nil {
  367. return nil, err
  368. }
  369. return ret, nil
  370. // {
  371. // "description": "Retrieves the profile information used for logging in to a virtual machine\non Google Compute Engine.",
  372. // "flatPath": "v1/users/{usersId}/loginProfile",
  373. // "httpMethod": "GET",
  374. // "id": "oslogin.users.getLoginProfile",
  375. // "parameterOrder": [
  376. // "name"
  377. // ],
  378. // "parameters": {
  379. // "name": {
  380. // "description": "The unique ID for the user in format `users/{user}`.",
  381. // "location": "path",
  382. // "pattern": "^users/[^/]+$",
  383. // "required": true,
  384. // "type": "string"
  385. // }
  386. // },
  387. // "path": "v1/{+name}/loginProfile",
  388. // "response": {
  389. // "$ref": "LoginProfile"
  390. // },
  391. // "scopes": [
  392. // "https://www.googleapis.com/auth/cloud-platform",
  393. // "https://www.googleapis.com/auth/compute"
  394. // ]
  395. // }
  396. }
  397. // method id "oslogin.users.importSshPublicKey":
  398. type UsersImportSshPublicKeyCall struct {
  399. s *Service
  400. parent string
  401. sshpublickey *SshPublicKey
  402. urlParams_ gensupport.URLParams
  403. ctx_ context.Context
  404. header_ http.Header
  405. }
  406. // ImportSshPublicKey: Adds an SSH public key and returns the profile
  407. // information. Default POSIX
  408. // account information is set when no username and UID exist as part of
  409. // the
  410. // login profile.
  411. func (r *UsersService) ImportSshPublicKey(parent string, sshpublickey *SshPublicKey) *UsersImportSshPublicKeyCall {
  412. c := &UsersImportSshPublicKeyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  413. c.parent = parent
  414. c.sshpublickey = sshpublickey
  415. return c
  416. }
  417. // ProjectId sets the optional parameter "projectId": The project ID of
  418. // the Google Cloud Platform project.
  419. func (c *UsersImportSshPublicKeyCall) ProjectId(projectId string) *UsersImportSshPublicKeyCall {
  420. c.urlParams_.Set("projectId", projectId)
  421. return c
  422. }
  423. // Fields allows partial responses to be retrieved. See
  424. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  425. // for more information.
  426. func (c *UsersImportSshPublicKeyCall) Fields(s ...googleapi.Field) *UsersImportSshPublicKeyCall {
  427. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  428. return c
  429. }
  430. // Context sets the context to be used in this call's Do method. Any
  431. // pending HTTP request will be aborted if the provided context is
  432. // canceled.
  433. func (c *UsersImportSshPublicKeyCall) Context(ctx context.Context) *UsersImportSshPublicKeyCall {
  434. c.ctx_ = ctx
  435. return c
  436. }
  437. // Header returns an http.Header that can be modified by the caller to
  438. // add HTTP headers to the request.
  439. func (c *UsersImportSshPublicKeyCall) Header() http.Header {
  440. if c.header_ == nil {
  441. c.header_ = make(http.Header)
  442. }
  443. return c.header_
  444. }
  445. func (c *UsersImportSshPublicKeyCall) doRequest(alt string) (*http.Response, error) {
  446. reqHeaders := make(http.Header)
  447. for k, v := range c.header_ {
  448. reqHeaders[k] = v
  449. }
  450. reqHeaders.Set("User-Agent", c.s.userAgent())
  451. var body io.Reader = nil
  452. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sshpublickey)
  453. if err != nil {
  454. return nil, err
  455. }
  456. reqHeaders.Set("Content-Type", "application/json")
  457. c.urlParams_.Set("alt", alt)
  458. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}:importSshPublicKey")
  459. urls += "?" + c.urlParams_.Encode()
  460. req, _ := http.NewRequest("POST", urls, body)
  461. req.Header = reqHeaders
  462. googleapi.Expand(req.URL, map[string]string{
  463. "parent": c.parent,
  464. })
  465. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  466. }
  467. // Do executes the "oslogin.users.importSshPublicKey" call.
  468. // Exactly one of *ImportSshPublicKeyResponse or error will be non-nil.
  469. // Any non-2xx status code is an error. Response headers are in either
  470. // *ImportSshPublicKeyResponse.ServerResponse.Header or (if a response
  471. // was returned at all) in error.(*googleapi.Error).Header. Use
  472. // googleapi.IsNotModified to check whether the returned error was
  473. // because http.StatusNotModified was returned.
  474. func (c *UsersImportSshPublicKeyCall) Do(opts ...googleapi.CallOption) (*ImportSshPublicKeyResponse, error) {
  475. gensupport.SetOptions(c.urlParams_, opts...)
  476. res, err := c.doRequest("json")
  477. if res != nil && res.StatusCode == http.StatusNotModified {
  478. if res.Body != nil {
  479. res.Body.Close()
  480. }
  481. return nil, &googleapi.Error{
  482. Code: res.StatusCode,
  483. Header: res.Header,
  484. }
  485. }
  486. if err != nil {
  487. return nil, err
  488. }
  489. defer googleapi.CloseBody(res)
  490. if err := googleapi.CheckResponse(res); err != nil {
  491. return nil, err
  492. }
  493. ret := &ImportSshPublicKeyResponse{
  494. ServerResponse: googleapi.ServerResponse{
  495. Header: res.Header,
  496. HTTPStatusCode: res.StatusCode,
  497. },
  498. }
  499. target := &ret
  500. if err := gensupport.DecodeResponse(target, res); err != nil {
  501. return nil, err
  502. }
  503. return ret, nil
  504. // {
  505. // "description": "Adds an SSH public key and returns the profile information. Default POSIX\naccount information is set when no username and UID exist as part of the\nlogin profile.",
  506. // "flatPath": "v1/users/{usersId}:importSshPublicKey",
  507. // "httpMethod": "POST",
  508. // "id": "oslogin.users.importSshPublicKey",
  509. // "parameterOrder": [
  510. // "parent"
  511. // ],
  512. // "parameters": {
  513. // "parent": {
  514. // "description": "The unique ID for the user in format `users/{user}`.",
  515. // "location": "path",
  516. // "pattern": "^users/[^/]+$",
  517. // "required": true,
  518. // "type": "string"
  519. // },
  520. // "projectId": {
  521. // "description": "The project ID of the Google Cloud Platform project.",
  522. // "location": "query",
  523. // "type": "string"
  524. // }
  525. // },
  526. // "path": "v1/{+parent}:importSshPublicKey",
  527. // "request": {
  528. // "$ref": "SshPublicKey"
  529. // },
  530. // "response": {
  531. // "$ref": "ImportSshPublicKeyResponse"
  532. // },
  533. // "scopes": [
  534. // "https://www.googleapis.com/auth/cloud-platform",
  535. // "https://www.googleapis.com/auth/compute"
  536. // ]
  537. // }
  538. }
  539. // method id "oslogin.users.projects.delete":
  540. type UsersProjectsDeleteCall struct {
  541. s *Service
  542. name string
  543. urlParams_ gensupport.URLParams
  544. ctx_ context.Context
  545. header_ http.Header
  546. }
  547. // Delete: Deletes a POSIX account.
  548. func (r *UsersProjectsService) Delete(name string) *UsersProjectsDeleteCall {
  549. c := &UsersProjectsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  550. c.name = name
  551. return c
  552. }
  553. // Fields allows partial responses to be retrieved. See
  554. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  555. // for more information.
  556. func (c *UsersProjectsDeleteCall) Fields(s ...googleapi.Field) *UsersProjectsDeleteCall {
  557. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  558. return c
  559. }
  560. // Context sets the context to be used in this call's Do method. Any
  561. // pending HTTP request will be aborted if the provided context is
  562. // canceled.
  563. func (c *UsersProjectsDeleteCall) Context(ctx context.Context) *UsersProjectsDeleteCall {
  564. c.ctx_ = ctx
  565. return c
  566. }
  567. // Header returns an http.Header that can be modified by the caller to
  568. // add HTTP headers to the request.
  569. func (c *UsersProjectsDeleteCall) Header() http.Header {
  570. if c.header_ == nil {
  571. c.header_ = make(http.Header)
  572. }
  573. return c.header_
  574. }
  575. func (c *UsersProjectsDeleteCall) doRequest(alt string) (*http.Response, error) {
  576. reqHeaders := make(http.Header)
  577. for k, v := range c.header_ {
  578. reqHeaders[k] = v
  579. }
  580. reqHeaders.Set("User-Agent", c.s.userAgent())
  581. var body io.Reader = nil
  582. c.urlParams_.Set("alt", alt)
  583. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  584. urls += "?" + c.urlParams_.Encode()
  585. req, _ := http.NewRequest("DELETE", urls, body)
  586. req.Header = reqHeaders
  587. googleapi.Expand(req.URL, map[string]string{
  588. "name": c.name,
  589. })
  590. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  591. }
  592. // Do executes the "oslogin.users.projects.delete" call.
  593. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  594. // code is an error. Response headers are in either
  595. // *Empty.ServerResponse.Header or (if a response was returned at all)
  596. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  597. // check whether the returned error was because http.StatusNotModified
  598. // was returned.
  599. func (c *UsersProjectsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  600. gensupport.SetOptions(c.urlParams_, opts...)
  601. res, err := c.doRequest("json")
  602. if res != nil && res.StatusCode == http.StatusNotModified {
  603. if res.Body != nil {
  604. res.Body.Close()
  605. }
  606. return nil, &googleapi.Error{
  607. Code: res.StatusCode,
  608. Header: res.Header,
  609. }
  610. }
  611. if err != nil {
  612. return nil, err
  613. }
  614. defer googleapi.CloseBody(res)
  615. if err := googleapi.CheckResponse(res); err != nil {
  616. return nil, err
  617. }
  618. ret := &Empty{
  619. ServerResponse: googleapi.ServerResponse{
  620. Header: res.Header,
  621. HTTPStatusCode: res.StatusCode,
  622. },
  623. }
  624. target := &ret
  625. if err := gensupport.DecodeResponse(target, res); err != nil {
  626. return nil, err
  627. }
  628. return ret, nil
  629. // {
  630. // "description": "Deletes a POSIX account.",
  631. // "flatPath": "v1/users/{usersId}/projects/{projectsId}",
  632. // "httpMethod": "DELETE",
  633. // "id": "oslogin.users.projects.delete",
  634. // "parameterOrder": [
  635. // "name"
  636. // ],
  637. // "parameters": {
  638. // "name": {
  639. // "description": "A reference to the POSIX account to update. POSIX accounts are identified\nby the project ID they are associated with. A reference to the POSIX\naccount is in format `users/{user}/projects/{project}`.",
  640. // "location": "path",
  641. // "pattern": "^users/[^/]+/projects/[^/]+$",
  642. // "required": true,
  643. // "type": "string"
  644. // }
  645. // },
  646. // "path": "v1/{+name}",
  647. // "response": {
  648. // "$ref": "Empty"
  649. // },
  650. // "scopes": [
  651. // "https://www.googleapis.com/auth/cloud-platform",
  652. // "https://www.googleapis.com/auth/compute"
  653. // ]
  654. // }
  655. }
  656. // method id "oslogin.users.sshPublicKeys.delete":
  657. type UsersSshPublicKeysDeleteCall struct {
  658. s *Service
  659. name string
  660. urlParams_ gensupport.URLParams
  661. ctx_ context.Context
  662. header_ http.Header
  663. }
  664. // Delete: Deletes an SSH public key.
  665. func (r *UsersSshPublicKeysService) Delete(name string) *UsersSshPublicKeysDeleteCall {
  666. c := &UsersSshPublicKeysDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  667. c.name = name
  668. return c
  669. }
  670. // Fields allows partial responses to be retrieved. See
  671. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  672. // for more information.
  673. func (c *UsersSshPublicKeysDeleteCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysDeleteCall {
  674. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  675. return c
  676. }
  677. // Context sets the context to be used in this call's Do method. Any
  678. // pending HTTP request will be aborted if the provided context is
  679. // canceled.
  680. func (c *UsersSshPublicKeysDeleteCall) Context(ctx context.Context) *UsersSshPublicKeysDeleteCall {
  681. c.ctx_ = ctx
  682. return c
  683. }
  684. // Header returns an http.Header that can be modified by the caller to
  685. // add HTTP headers to the request.
  686. func (c *UsersSshPublicKeysDeleteCall) Header() http.Header {
  687. if c.header_ == nil {
  688. c.header_ = make(http.Header)
  689. }
  690. return c.header_
  691. }
  692. func (c *UsersSshPublicKeysDeleteCall) doRequest(alt string) (*http.Response, error) {
  693. reqHeaders := make(http.Header)
  694. for k, v := range c.header_ {
  695. reqHeaders[k] = v
  696. }
  697. reqHeaders.Set("User-Agent", c.s.userAgent())
  698. var body io.Reader = nil
  699. c.urlParams_.Set("alt", alt)
  700. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  701. urls += "?" + c.urlParams_.Encode()
  702. req, _ := http.NewRequest("DELETE", urls, body)
  703. req.Header = reqHeaders
  704. googleapi.Expand(req.URL, map[string]string{
  705. "name": c.name,
  706. })
  707. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  708. }
  709. // Do executes the "oslogin.users.sshPublicKeys.delete" call.
  710. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  711. // code is an error. Response headers are in either
  712. // *Empty.ServerResponse.Header or (if a response was returned at all)
  713. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  714. // check whether the returned error was because http.StatusNotModified
  715. // was returned.
  716. func (c *UsersSshPublicKeysDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  717. gensupport.SetOptions(c.urlParams_, opts...)
  718. res, err := c.doRequest("json")
  719. if res != nil && res.StatusCode == http.StatusNotModified {
  720. if res.Body != nil {
  721. res.Body.Close()
  722. }
  723. return nil, &googleapi.Error{
  724. Code: res.StatusCode,
  725. Header: res.Header,
  726. }
  727. }
  728. if err != nil {
  729. return nil, err
  730. }
  731. defer googleapi.CloseBody(res)
  732. if err := googleapi.CheckResponse(res); err != nil {
  733. return nil, err
  734. }
  735. ret := &Empty{
  736. ServerResponse: googleapi.ServerResponse{
  737. Header: res.Header,
  738. HTTPStatusCode: res.StatusCode,
  739. },
  740. }
  741. target := &ret
  742. if err := gensupport.DecodeResponse(target, res); err != nil {
  743. return nil, err
  744. }
  745. return ret, nil
  746. // {
  747. // "description": "Deletes an SSH public key.",
  748. // "flatPath": "v1/users/{usersId}/sshPublicKeys/{sshPublicKeysId}",
  749. // "httpMethod": "DELETE",
  750. // "id": "oslogin.users.sshPublicKeys.delete",
  751. // "parameterOrder": [
  752. // "name"
  753. // ],
  754. // "parameters": {
  755. // "name": {
  756. // "description": "The fingerprint of the public key to update. Public keys are identified by\ntheir SHA-256 fingerprint. The fingerprint of the public key is in format\n`users/{user}/sshPublicKeys/{fingerprint}`.",
  757. // "location": "path",
  758. // "pattern": "^users/[^/]+/sshPublicKeys/[^/]+$",
  759. // "required": true,
  760. // "type": "string"
  761. // }
  762. // },
  763. // "path": "v1/{+name}",
  764. // "response": {
  765. // "$ref": "Empty"
  766. // },
  767. // "scopes": [
  768. // "https://www.googleapis.com/auth/cloud-platform",
  769. // "https://www.googleapis.com/auth/compute"
  770. // ]
  771. // }
  772. }
  773. // method id "oslogin.users.sshPublicKeys.get":
  774. type UsersSshPublicKeysGetCall struct {
  775. s *Service
  776. name string
  777. urlParams_ gensupport.URLParams
  778. ifNoneMatch_ string
  779. ctx_ context.Context
  780. header_ http.Header
  781. }
  782. // Get: Retrieves an SSH public key.
  783. func (r *UsersSshPublicKeysService) Get(name string) *UsersSshPublicKeysGetCall {
  784. c := &UsersSshPublicKeysGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  785. c.name = name
  786. return c
  787. }
  788. // Fields allows partial responses to be retrieved. See
  789. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  790. // for more information.
  791. func (c *UsersSshPublicKeysGetCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysGetCall {
  792. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  793. return c
  794. }
  795. // IfNoneMatch sets the optional parameter which makes the operation
  796. // fail if the object's ETag matches the given value. This is useful for
  797. // getting updates only after the object has changed since the last
  798. // request. Use googleapi.IsNotModified to check whether the response
  799. // error from Do is the result of In-None-Match.
  800. func (c *UsersSshPublicKeysGetCall) IfNoneMatch(entityTag string) *UsersSshPublicKeysGetCall {
  801. c.ifNoneMatch_ = entityTag
  802. return c
  803. }
  804. // Context sets the context to be used in this call's Do method. Any
  805. // pending HTTP request will be aborted if the provided context is
  806. // canceled.
  807. func (c *UsersSshPublicKeysGetCall) Context(ctx context.Context) *UsersSshPublicKeysGetCall {
  808. c.ctx_ = ctx
  809. return c
  810. }
  811. // Header returns an http.Header that can be modified by the caller to
  812. // add HTTP headers to the request.
  813. func (c *UsersSshPublicKeysGetCall) Header() http.Header {
  814. if c.header_ == nil {
  815. c.header_ = make(http.Header)
  816. }
  817. return c.header_
  818. }
  819. func (c *UsersSshPublicKeysGetCall) doRequest(alt string) (*http.Response, error) {
  820. reqHeaders := make(http.Header)
  821. for k, v := range c.header_ {
  822. reqHeaders[k] = v
  823. }
  824. reqHeaders.Set("User-Agent", c.s.userAgent())
  825. if c.ifNoneMatch_ != "" {
  826. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  827. }
  828. var body io.Reader = nil
  829. c.urlParams_.Set("alt", alt)
  830. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  831. urls += "?" + c.urlParams_.Encode()
  832. req, _ := http.NewRequest("GET", urls, body)
  833. req.Header = reqHeaders
  834. googleapi.Expand(req.URL, map[string]string{
  835. "name": c.name,
  836. })
  837. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  838. }
  839. // Do executes the "oslogin.users.sshPublicKeys.get" call.
  840. // Exactly one of *SshPublicKey or error will be non-nil. Any non-2xx
  841. // status code is an error. Response headers are in either
  842. // *SshPublicKey.ServerResponse.Header or (if a response was returned at
  843. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  844. // to check whether the returned error was because
  845. // http.StatusNotModified was returned.
  846. func (c *UsersSshPublicKeysGetCall) Do(opts ...googleapi.CallOption) (*SshPublicKey, error) {
  847. gensupport.SetOptions(c.urlParams_, opts...)
  848. res, err := c.doRequest("json")
  849. if res != nil && res.StatusCode == http.StatusNotModified {
  850. if res.Body != nil {
  851. res.Body.Close()
  852. }
  853. return nil, &googleapi.Error{
  854. Code: res.StatusCode,
  855. Header: res.Header,
  856. }
  857. }
  858. if err != nil {
  859. return nil, err
  860. }
  861. defer googleapi.CloseBody(res)
  862. if err := googleapi.CheckResponse(res); err != nil {
  863. return nil, err
  864. }
  865. ret := &SshPublicKey{
  866. ServerResponse: googleapi.ServerResponse{
  867. Header: res.Header,
  868. HTTPStatusCode: res.StatusCode,
  869. },
  870. }
  871. target := &ret
  872. if err := gensupport.DecodeResponse(target, res); err != nil {
  873. return nil, err
  874. }
  875. return ret, nil
  876. // {
  877. // "description": "Retrieves an SSH public key.",
  878. // "flatPath": "v1/users/{usersId}/sshPublicKeys/{sshPublicKeysId}",
  879. // "httpMethod": "GET",
  880. // "id": "oslogin.users.sshPublicKeys.get",
  881. // "parameterOrder": [
  882. // "name"
  883. // ],
  884. // "parameters": {
  885. // "name": {
  886. // "description": "The fingerprint of the public key to retrieve. Public keys are identified\nby their SHA-256 fingerprint. The fingerprint of the public key is in\nformat `users/{user}/sshPublicKeys/{fingerprint}`.",
  887. // "location": "path",
  888. // "pattern": "^users/[^/]+/sshPublicKeys/[^/]+$",
  889. // "required": true,
  890. // "type": "string"
  891. // }
  892. // },
  893. // "path": "v1/{+name}",
  894. // "response": {
  895. // "$ref": "SshPublicKey"
  896. // },
  897. // "scopes": [
  898. // "https://www.googleapis.com/auth/cloud-platform",
  899. // "https://www.googleapis.com/auth/compute"
  900. // ]
  901. // }
  902. }
  903. // method id "oslogin.users.sshPublicKeys.patch":
  904. type UsersSshPublicKeysPatchCall struct {
  905. s *Service
  906. name string
  907. sshpublickey *SshPublicKey
  908. urlParams_ gensupport.URLParams
  909. ctx_ context.Context
  910. header_ http.Header
  911. }
  912. // Patch: Updates an SSH public key and returns the profile information.
  913. // This method
  914. // supports patch semantics.
  915. func (r *UsersSshPublicKeysService) Patch(name string, sshpublickey *SshPublicKey) *UsersSshPublicKeysPatchCall {
  916. c := &UsersSshPublicKeysPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  917. c.name = name
  918. c.sshpublickey = sshpublickey
  919. return c
  920. }
  921. // UpdateMask sets the optional parameter "updateMask": Mask to control
  922. // which fields get updated. Updates all if not present.
  923. func (c *UsersSshPublicKeysPatchCall) UpdateMask(updateMask string) *UsersSshPublicKeysPatchCall {
  924. c.urlParams_.Set("updateMask", updateMask)
  925. return c
  926. }
  927. // Fields allows partial responses to be retrieved. See
  928. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  929. // for more information.
  930. func (c *UsersSshPublicKeysPatchCall) Fields(s ...googleapi.Field) *UsersSshPublicKeysPatchCall {
  931. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  932. return c
  933. }
  934. // Context sets the context to be used in this call's Do method. Any
  935. // pending HTTP request will be aborted if the provided context is
  936. // canceled.
  937. func (c *UsersSshPublicKeysPatchCall) Context(ctx context.Context) *UsersSshPublicKeysPatchCall {
  938. c.ctx_ = ctx
  939. return c
  940. }
  941. // Header returns an http.Header that can be modified by the caller to
  942. // add HTTP headers to the request.
  943. func (c *UsersSshPublicKeysPatchCall) Header() http.Header {
  944. if c.header_ == nil {
  945. c.header_ = make(http.Header)
  946. }
  947. return c.header_
  948. }
  949. func (c *UsersSshPublicKeysPatchCall) doRequest(alt string) (*http.Response, error) {
  950. reqHeaders := make(http.Header)
  951. for k, v := range c.header_ {
  952. reqHeaders[k] = v
  953. }
  954. reqHeaders.Set("User-Agent", c.s.userAgent())
  955. var body io.Reader = nil
  956. body, err := googleapi.WithoutDataWrapper.JSONReader(c.sshpublickey)
  957. if err != nil {
  958. return nil, err
  959. }
  960. reqHeaders.Set("Content-Type", "application/json")
  961. c.urlParams_.Set("alt", alt)
  962. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  963. urls += "?" + c.urlParams_.Encode()
  964. req, _ := http.NewRequest("PATCH", urls, body)
  965. req.Header = reqHeaders
  966. googleapi.Expand(req.URL, map[string]string{
  967. "name": c.name,
  968. })
  969. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  970. }
  971. // Do executes the "oslogin.users.sshPublicKeys.patch" call.
  972. // Exactly one of *SshPublicKey or error will be non-nil. Any non-2xx
  973. // status code is an error. Response headers are in either
  974. // *SshPublicKey.ServerResponse.Header or (if a response was returned at
  975. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  976. // to check whether the returned error was because
  977. // http.StatusNotModified was returned.
  978. func (c *UsersSshPublicKeysPatchCall) Do(opts ...googleapi.CallOption) (*SshPublicKey, error) {
  979. gensupport.SetOptions(c.urlParams_, opts...)
  980. res, err := c.doRequest("json")
  981. if res != nil && res.StatusCode == http.StatusNotModified {
  982. if res.Body != nil {
  983. res.Body.Close()
  984. }
  985. return nil, &googleapi.Error{
  986. Code: res.StatusCode,
  987. Header: res.Header,
  988. }
  989. }
  990. if err != nil {
  991. return nil, err
  992. }
  993. defer googleapi.CloseBody(res)
  994. if err := googleapi.CheckResponse(res); err != nil {
  995. return nil, err
  996. }
  997. ret := &SshPublicKey{
  998. ServerResponse: googleapi.ServerResponse{
  999. Header: res.Header,
  1000. HTTPStatusCode: res.StatusCode,
  1001. },
  1002. }
  1003. target := &ret
  1004. if err := gensupport.DecodeResponse(target, res); err != nil {
  1005. return nil, err
  1006. }
  1007. return ret, nil
  1008. // {
  1009. // "description": "Updates an SSH public key and returns the profile information. This method\nsupports patch semantics.",
  1010. // "flatPath": "v1/users/{usersId}/sshPublicKeys/{sshPublicKeysId}",
  1011. // "httpMethod": "PATCH",
  1012. // "id": "oslogin.users.sshPublicKeys.patch",
  1013. // "parameterOrder": [
  1014. // "name"
  1015. // ],
  1016. // "parameters": {
  1017. // "name": {
  1018. // "description": "The fingerprint of the public key to update. Public keys are identified by\ntheir SHA-256 fingerprint. The fingerprint of the public key is in format\n`users/{user}/sshPublicKeys/{fingerprint}`.",
  1019. // "location": "path",
  1020. // "pattern": "^users/[^/]+/sshPublicKeys/[^/]+$",
  1021. // "required": true,
  1022. // "type": "string"
  1023. // },
  1024. // "updateMask": {
  1025. // "description": "Mask to control which fields get updated. Updates all if not present.",
  1026. // "format": "google-fieldmask",
  1027. // "location": "query",
  1028. // "type": "string"
  1029. // }
  1030. // },
  1031. // "path": "v1/{+name}",
  1032. // "request": {
  1033. // "$ref": "SshPublicKey"
  1034. // },
  1035. // "response": {
  1036. // "$ref": "SshPublicKey"
  1037. // },
  1038. // "scopes": [
  1039. // "https://www.googleapis.com/auth/cloud-platform",
  1040. // "https://www.googleapis.com/auth/compute"
  1041. // ]
  1042. // }
  1043. }