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.

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