Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

1205 рядки
41 KiB

  1. // Package cloudshell provides access to the Cloud Shell API.
  2. //
  3. // See https://cloud.google.com/shell/docs/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/cloudshell/v1"
  8. // ...
  9. // cloudshellService, err := cloudshell.New(oauthHttpClient)
  10. package cloudshell // import "google.golang.org/api/cloudshell/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 = "cloudshell:v1"
  41. const apiName = "cloudshell"
  42. const apiVersion = "v1"
  43. const basePath = "https://cloudshell.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. )
  49. func New(client *http.Client) (*Service, error) {
  50. if client == nil {
  51. return nil, errors.New("client is nil")
  52. }
  53. s := &Service{client: client, BasePath: basePath}
  54. s.Operations = NewOperationsService(s)
  55. return s, nil
  56. }
  57. type Service struct {
  58. client *http.Client
  59. BasePath string // API endpoint base URL
  60. UserAgent string // optional additional User-Agent fragment
  61. Operations *OperationsService
  62. }
  63. func (s *Service) userAgent() string {
  64. if s.UserAgent == "" {
  65. return googleapi.UserAgent
  66. }
  67. return googleapi.UserAgent + " " + s.UserAgent
  68. }
  69. func NewOperationsService(s *Service) *OperationsService {
  70. rs := &OperationsService{s: s}
  71. return rs
  72. }
  73. type OperationsService struct {
  74. s *Service
  75. }
  76. // CancelOperationRequest: The request message for
  77. // Operations.CancelOperation.
  78. type CancelOperationRequest struct {
  79. }
  80. // Empty: A generic empty message that you can re-use to avoid defining
  81. // duplicated
  82. // empty messages in your APIs. A typical example is to use it as the
  83. // request
  84. // or the response type of an API method. For instance:
  85. //
  86. // service Foo {
  87. // rpc Bar(google.protobuf.Empty) returns
  88. // (google.protobuf.Empty);
  89. // }
  90. //
  91. // The JSON representation for `Empty` is empty JSON object `{}`.
  92. type Empty struct {
  93. // ServerResponse contains the HTTP response code and headers from the
  94. // server.
  95. googleapi.ServerResponse `json:"-"`
  96. }
  97. // Environment: A Cloud Shell environment, which is defined as the
  98. // combination of a Docker
  99. // image specifying what is installed on the environment and a home
  100. // directory
  101. // containing the user's data that will remain across sessions. Each
  102. // user has a
  103. // single environment with the ID "default".
  104. type Environment struct {
  105. // DockerImage: Required. Full path to the Docker image used to run this
  106. // environment, e.g.
  107. // "gcr.io/dev-con/cloud-devshell:latest".
  108. DockerImage string `json:"dockerImage,omitempty"`
  109. // Id: Output only. The environment's identifier, which is always
  110. // "default".
  111. Id string `json:"id,omitempty"`
  112. // Name: Output only. Full name of this resource, in the
  113. // format
  114. // `users/{owner_email}/environments/{environment_id}`. `{owner_email}`
  115. // is the
  116. // email address of the user to whom this environment belongs,
  117. // and
  118. // `{environment_id}` is the identifier of this environment. For
  119. // example,
  120. // `users/someone@example.com/environments/default`.
  121. Name string `json:"name,omitempty"`
  122. // PublicKeys: Output only. Public keys associated with the environment.
  123. // Clients can
  124. // connect to this environment via SSH only if they possess a private
  125. // key
  126. // corresponding to at least one of these public keys. Keys can be added
  127. // to or
  128. // removed from the environment using the CreatePublicKey and
  129. // DeletePublicKey
  130. // methods.
  131. PublicKeys []*PublicKey `json:"publicKeys,omitempty"`
  132. // SshHost: Output only. Host to which clients can connect to initiate
  133. // SSH sessions
  134. // with the environment.
  135. SshHost string `json:"sshHost,omitempty"`
  136. // SshPort: Output only. Port to which clients can connect to initiate
  137. // SSH sessions
  138. // with the environment.
  139. SshPort int64 `json:"sshPort,omitempty"`
  140. // SshUsername: Output only. Username that clients should use when
  141. // initiating SSH sessions
  142. // with the environment.
  143. SshUsername string `json:"sshUsername,omitempty"`
  144. // State: Output only. Current execution state of this environment.
  145. //
  146. // Possible values:
  147. // "STATE_UNSPECIFIED" - The environment's states is unknown.
  148. // "DISABLED" - The environment is not running and can't be connected
  149. // to. Starting the
  150. // environment will transition it to the STARTING state.
  151. // "STARTING" - The environment is being started but is not yet ready
  152. // to accept
  153. // connections.
  154. // "RUNNING" - The environment is running and ready to accept
  155. // connections. It will
  156. // automatically transition back to DISABLED after a period of
  157. // inactivity or
  158. // if another environment is started.
  159. State string `json:"state,omitempty"`
  160. // ForceSendFields is a list of field names (e.g. "DockerImage") to
  161. // unconditionally include in API requests. By default, fields with
  162. // empty values are omitted from API requests. However, any non-pointer,
  163. // non-interface field appearing in ForceSendFields will be sent to the
  164. // server regardless of whether the field is empty or not. This may be
  165. // used to include empty fields in Patch requests.
  166. ForceSendFields []string `json:"-"`
  167. // NullFields is a list of field names (e.g. "DockerImage") to include
  168. // in API requests with the JSON null value. By default, fields with
  169. // empty values are omitted from API requests. However, any field with
  170. // an empty value appearing in NullFields will be sent to the server as
  171. // null. It is an error if a field in this list has a non-empty value.
  172. // This may be used to include null fields in Patch requests.
  173. NullFields []string `json:"-"`
  174. }
  175. func (s *Environment) MarshalJSON() ([]byte, error) {
  176. type NoMethod Environment
  177. raw := NoMethod(*s)
  178. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  179. }
  180. // ListOperationsResponse: The response message for
  181. // Operations.ListOperations.
  182. type ListOperationsResponse struct {
  183. // NextPageToken: The standard List next-page token.
  184. NextPageToken string `json:"nextPageToken,omitempty"`
  185. // Operations: A list of operations that matches the specified filter in
  186. // the request.
  187. Operations []*Operation `json:"operations,omitempty"`
  188. // ServerResponse contains the HTTP response code and headers from the
  189. // server.
  190. googleapi.ServerResponse `json:"-"`
  191. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  192. // unconditionally include in API requests. By default, fields with
  193. // empty values are omitted from API requests. However, any non-pointer,
  194. // non-interface field appearing in ForceSendFields will be sent to the
  195. // server regardless of whether the field is empty or not. This may be
  196. // used to include empty fields in Patch requests.
  197. ForceSendFields []string `json:"-"`
  198. // NullFields is a list of field names (e.g. "NextPageToken") to include
  199. // in API requests with the JSON null value. By default, fields with
  200. // empty values are omitted from API requests. However, any field with
  201. // an empty value appearing in NullFields will be sent to the server as
  202. // null. It is an error if a field in this list has a non-empty value.
  203. // This may be used to include null fields in Patch requests.
  204. NullFields []string `json:"-"`
  205. }
  206. func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) {
  207. type NoMethod ListOperationsResponse
  208. raw := NoMethod(*s)
  209. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  210. }
  211. // Operation: This resource represents a long-running operation that is
  212. // the result of a
  213. // network API call.
  214. type Operation struct {
  215. // Done: If the value is `false`, it means the operation is still in
  216. // progress.
  217. // If `true`, the operation is completed, and either `error` or
  218. // `response` is
  219. // available.
  220. Done bool `json:"done,omitempty"`
  221. // Error: The error result of the operation in case of failure or
  222. // cancellation.
  223. Error *Status `json:"error,omitempty"`
  224. // Metadata: Service-specific metadata associated with the operation.
  225. // It typically
  226. // contains progress information and common metadata such as create
  227. // time.
  228. // Some services might not provide such metadata. Any method that
  229. // returns a
  230. // long-running operation should document the metadata type, if any.
  231. Metadata googleapi.RawMessage `json:"metadata,omitempty"`
  232. // Name: The server-assigned name, which is only unique within the same
  233. // service that
  234. // originally returns it. If you use the default HTTP mapping,
  235. // the
  236. // `name` should have the format of `operations/some/unique/name`.
  237. Name string `json:"name,omitempty"`
  238. // Response: The normal response of the operation in case of success.
  239. // If the original
  240. // method returns no data on success, such as `Delete`, the response
  241. // is
  242. // `google.protobuf.Empty`. If the original method is
  243. // standard
  244. // `Get`/`Create`/`Update`, the response should be the resource. For
  245. // other
  246. // methods, the response should have the type `XxxResponse`, where
  247. // `Xxx`
  248. // is the original method name. For example, if the original method
  249. // name
  250. // is `TakeSnapshot()`, the inferred response type
  251. // is
  252. // `TakeSnapshotResponse`.
  253. Response googleapi.RawMessage `json:"response,omitempty"`
  254. // ServerResponse contains the HTTP response code and headers from the
  255. // server.
  256. googleapi.ServerResponse `json:"-"`
  257. // ForceSendFields is a list of field names (e.g. "Done") to
  258. // unconditionally include in API requests. By default, fields with
  259. // empty values are omitted from API requests. However, any non-pointer,
  260. // non-interface field appearing in ForceSendFields will be sent to the
  261. // server regardless of whether the field is empty or not. This may be
  262. // used to include empty fields in Patch requests.
  263. ForceSendFields []string `json:"-"`
  264. // NullFields is a list of field names (e.g. "Done") to include in API
  265. // requests with the JSON null value. By default, fields with empty
  266. // values are omitted from API requests. However, any field with an
  267. // empty value appearing in NullFields will be sent to the server as
  268. // null. It is an error if a field in this list has a non-empty value.
  269. // This may be used to include null fields in Patch requests.
  270. NullFields []string `json:"-"`
  271. }
  272. func (s *Operation) MarshalJSON() ([]byte, error) {
  273. type NoMethod Operation
  274. raw := NoMethod(*s)
  275. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  276. }
  277. // PublicKey: A public SSH key, corresponding to a private SSH key held
  278. // by the client.
  279. type PublicKey struct {
  280. // Format: Required. Format of this key's content.
  281. //
  282. // Possible values:
  283. // "FORMAT_UNSPECIFIED" - Unknown format. Do not use.
  284. // "SSH_DSS" - `ssh-dss` key format (see RFC4253).
  285. // "SSH_RSA" - `ssh-rsa` key format (see RFC4253).
  286. // "ECDSA_SHA2_NISTP256" - `ecdsa-sha2-nistp256` key format (see
  287. // RFC5656).
  288. // "ECDSA_SHA2_NISTP384" - `ecdsa-sha2-nistp384` key format (see
  289. // RFC5656).
  290. // "ECDSA_SHA2_NISTP521" - `ecdsa-sha2-nistp521` key format (see
  291. // RFC5656).
  292. Format string `json:"format,omitempty"`
  293. // Key: Required. Content of this key.
  294. Key string `json:"key,omitempty"`
  295. // Name: Output only. Full name of this resource, in the
  296. // format
  297. // `users/{owner_email}/environments/{environment_id}/publicKeys/{
  298. // key_id}`.
  299. // `{owner_email}` is the email address of the user to whom the key
  300. // belongs.
  301. // `{environment_id}` is the identifier of the environment to which the
  302. // key
  303. // grants access. `{key_id}` is the unique identifier of the key. For
  304. // example,
  305. // `users/someone@example.com/environments/default/publicKeys/my
  306. // Key`.
  307. Name string `json:"name,omitempty"`
  308. // ForceSendFields is a list of field names (e.g. "Format") to
  309. // unconditionally include in API requests. By default, fields with
  310. // empty values are omitted from API requests. However, any non-pointer,
  311. // non-interface field appearing in ForceSendFields will be sent to the
  312. // server regardless of whether the field is empty or not. This may be
  313. // used to include empty fields in Patch requests.
  314. ForceSendFields []string `json:"-"`
  315. // NullFields is a list of field names (e.g. "Format") to include in API
  316. // requests with the JSON null value. By default, fields with empty
  317. // values are omitted from API requests. However, any field with an
  318. // empty value appearing in NullFields will be sent to the server as
  319. // null. It is an error if a field in this list has a non-empty value.
  320. // This may be used to include null fields in Patch requests.
  321. NullFields []string `json:"-"`
  322. }
  323. func (s *PublicKey) MarshalJSON() ([]byte, error) {
  324. type NoMethod PublicKey
  325. raw := NoMethod(*s)
  326. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  327. }
  328. // StartEnvironmentMetadata: Message included in the metadata field of
  329. // operations returned from
  330. // StartEnvironment.
  331. type StartEnvironmentMetadata struct {
  332. // State: Current state of the environment being started.
  333. //
  334. // Possible values:
  335. // "STATE_UNSPECIFIED" - The environment's start state is unknown.
  336. // "STARTING" - The environment is in the process of being started,
  337. // but no additional
  338. // details are available.
  339. // "UNARCHIVING_DISK" - Startup is waiting for the user's disk to be
  340. // unarchived. This can happen
  341. // when the user returns to Cloud Shell after not having used it for
  342. // a
  343. // while, and suggests that startup will take longer than normal.
  344. // "FINISHED" - Startup is complete and the user should be able to
  345. // establish an SSH
  346. // connection to their environment.
  347. State string `json:"state,omitempty"`
  348. // ForceSendFields is a list of field names (e.g. "State") to
  349. // unconditionally include in API requests. By default, fields with
  350. // empty values are omitted from API requests. However, any non-pointer,
  351. // non-interface field appearing in ForceSendFields will be sent to the
  352. // server regardless of whether the field is empty or not. This may be
  353. // used to include empty fields in Patch requests.
  354. ForceSendFields []string `json:"-"`
  355. // NullFields is a list of field names (e.g. "State") to include in API
  356. // requests with the JSON null value. By default, fields with empty
  357. // values are omitted from API requests. However, any field with an
  358. // empty value appearing in NullFields will be sent to the server as
  359. // null. It is an error if a field in this list has a non-empty value.
  360. // This may be used to include null fields in Patch requests.
  361. NullFields []string `json:"-"`
  362. }
  363. func (s *StartEnvironmentMetadata) MarshalJSON() ([]byte, error) {
  364. type NoMethod StartEnvironmentMetadata
  365. raw := NoMethod(*s)
  366. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  367. }
  368. // StartEnvironmentResponse: Message included in the response field of
  369. // operations returned from
  370. // StartEnvironment once the
  371. // operation is complete.
  372. type StartEnvironmentResponse struct {
  373. // Environment: Environment that was started.
  374. Environment *Environment `json:"environment,omitempty"`
  375. // ForceSendFields is a list of field names (e.g. "Environment") to
  376. // unconditionally include in API requests. By default, fields with
  377. // empty values are omitted from API requests. However, any non-pointer,
  378. // non-interface field appearing in ForceSendFields will be sent to the
  379. // server regardless of whether the field is empty or not. This may be
  380. // used to include empty fields in Patch requests.
  381. ForceSendFields []string `json:"-"`
  382. // NullFields is a list of field names (e.g. "Environment") to include
  383. // in API requests with the JSON null value. By default, fields with
  384. // empty values are omitted from API requests. However, any field with
  385. // an empty value appearing in NullFields will be sent to the server as
  386. // null. It is an error if a field in this list has a non-empty value.
  387. // This may be used to include null fields in Patch requests.
  388. NullFields []string `json:"-"`
  389. }
  390. func (s *StartEnvironmentResponse) MarshalJSON() ([]byte, error) {
  391. type NoMethod StartEnvironmentResponse
  392. raw := NoMethod(*s)
  393. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  394. }
  395. // Status: The `Status` type defines a logical error model that is
  396. // suitable for different
  397. // programming environments, including REST APIs and RPC APIs. It is
  398. // used by
  399. // [gRPC](https://github.com/grpc). The error model is designed to
  400. // be:
  401. //
  402. // - Simple to use and understand for most users
  403. // - Flexible enough to meet unexpected needs
  404. //
  405. // # Overview
  406. //
  407. // The `Status` message contains three pieces of data: error code, error
  408. // message,
  409. // and error details. The error code should be an enum value
  410. // of
  411. // google.rpc.Code, but it may accept additional error codes if needed.
  412. // The
  413. // error message should be a developer-facing English message that
  414. // helps
  415. // developers *understand* and *resolve* the error. If a localized
  416. // user-facing
  417. // error message is needed, put the localized message in the error
  418. // details or
  419. // localize it in the client. The optional error details may contain
  420. // arbitrary
  421. // information about the error. There is a predefined set of error
  422. // detail types
  423. // in the package `google.rpc` that can be used for common error
  424. // conditions.
  425. //
  426. // # Language mapping
  427. //
  428. // The `Status` message is the logical representation of the error
  429. // model, but it
  430. // is not necessarily the actual wire format. When the `Status` message
  431. // is
  432. // exposed in different client libraries and different wire protocols,
  433. // it can be
  434. // mapped differently. For example, it will likely be mapped to some
  435. // exceptions
  436. // in Java, but more likely mapped to some error codes in C.
  437. //
  438. // # Other uses
  439. //
  440. // The error model and the `Status` message can be used in a variety
  441. // of
  442. // environments, either with or without APIs, to provide a
  443. // consistent developer experience across different
  444. // environments.
  445. //
  446. // Example uses of this error model include:
  447. //
  448. // - Partial errors. If a service needs to return partial errors to the
  449. // client,
  450. // it may embed the `Status` in the normal response to indicate the
  451. // partial
  452. // errors.
  453. //
  454. // - Workflow errors. A typical workflow has multiple steps. Each step
  455. // may
  456. // have a `Status` message for error reporting.
  457. //
  458. // - Batch operations. If a client uses batch request and batch
  459. // response, the
  460. // `Status` message should be used directly inside batch response,
  461. // one for
  462. // each error sub-response.
  463. //
  464. // - Asynchronous operations. If an API call embeds asynchronous
  465. // operation
  466. // results in its response, the status of those operations should
  467. // be
  468. // represented directly using the `Status` message.
  469. //
  470. // - Logging. If some API errors are stored in logs, the message
  471. // `Status` could
  472. // be used directly after any stripping needed for security/privacy
  473. // reasons.
  474. type Status struct {
  475. // Code: The status code, which should be an enum value of
  476. // google.rpc.Code.
  477. Code int64 `json:"code,omitempty"`
  478. // Details: A list of messages that carry the error details. There is a
  479. // common set of
  480. // message types for APIs to use.
  481. Details []googleapi.RawMessage `json:"details,omitempty"`
  482. // Message: A developer-facing error message, which should be in
  483. // English. Any
  484. // user-facing error message should be localized and sent in
  485. // the
  486. // google.rpc.Status.details field, or localized by the client.
  487. Message string `json:"message,omitempty"`
  488. // ForceSendFields is a list of field names (e.g. "Code") to
  489. // unconditionally include in API requests. By default, fields with
  490. // empty values are omitted from API requests. However, any non-pointer,
  491. // non-interface field appearing in ForceSendFields will be sent to the
  492. // server regardless of whether the field is empty or not. This may be
  493. // used to include empty fields in Patch requests.
  494. ForceSendFields []string `json:"-"`
  495. // NullFields is a list of field names (e.g. "Code") to include in API
  496. // requests with the JSON null value. By default, fields with empty
  497. // values are omitted from API requests. However, any field with an
  498. // empty value appearing in NullFields will be sent to the server as
  499. // null. It is an error if a field in this list has a non-empty value.
  500. // This may be used to include null fields in Patch requests.
  501. NullFields []string `json:"-"`
  502. }
  503. func (s *Status) MarshalJSON() ([]byte, error) {
  504. type NoMethod Status
  505. raw := NoMethod(*s)
  506. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  507. }
  508. // method id "cloudshell.operations.cancel":
  509. type OperationsCancelCall struct {
  510. s *Service
  511. name string
  512. canceloperationrequest *CancelOperationRequest
  513. urlParams_ gensupport.URLParams
  514. ctx_ context.Context
  515. header_ http.Header
  516. }
  517. // Cancel: Starts asynchronous cancellation on a long-running operation.
  518. // The server
  519. // makes a best effort to cancel the operation, but success is
  520. // not
  521. // guaranteed. If the server doesn't support this method, it
  522. // returns
  523. // `google.rpc.Code.UNIMPLEMENTED`. Clients can
  524. // use
  525. // Operations.GetOperation or
  526. // other methods to check whether the cancellation succeeded or whether
  527. // the
  528. // operation completed despite cancellation. On successful
  529. // cancellation,
  530. // the operation is not deleted; instead, it becomes an operation
  531. // with
  532. // an Operation.error value with a google.rpc.Status.code of
  533. // 1,
  534. // corresponding to `Code.CANCELLED`.
  535. func (r *OperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *OperationsCancelCall {
  536. c := &OperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  537. c.name = name
  538. c.canceloperationrequest = canceloperationrequest
  539. return c
  540. }
  541. // Fields allows partial responses to be retrieved. See
  542. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  543. // for more information.
  544. func (c *OperationsCancelCall) Fields(s ...googleapi.Field) *OperationsCancelCall {
  545. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  546. return c
  547. }
  548. // Context sets the context to be used in this call's Do method. Any
  549. // pending HTTP request will be aborted if the provided context is
  550. // canceled.
  551. func (c *OperationsCancelCall) Context(ctx context.Context) *OperationsCancelCall {
  552. c.ctx_ = ctx
  553. return c
  554. }
  555. // Header returns an http.Header that can be modified by the caller to
  556. // add HTTP headers to the request.
  557. func (c *OperationsCancelCall) Header() http.Header {
  558. if c.header_ == nil {
  559. c.header_ = make(http.Header)
  560. }
  561. return c.header_
  562. }
  563. func (c *OperationsCancelCall) doRequest(alt string) (*http.Response, error) {
  564. reqHeaders := make(http.Header)
  565. for k, v := range c.header_ {
  566. reqHeaders[k] = v
  567. }
  568. reqHeaders.Set("User-Agent", c.s.userAgent())
  569. var body io.Reader = nil
  570. body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest)
  571. if err != nil {
  572. return nil, err
  573. }
  574. reqHeaders.Set("Content-Type", "application/json")
  575. c.urlParams_.Set("alt", alt)
  576. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:cancel")
  577. urls += "?" + c.urlParams_.Encode()
  578. req, _ := http.NewRequest("POST", urls, body)
  579. req.Header = reqHeaders
  580. googleapi.Expand(req.URL, map[string]string{
  581. "name": c.name,
  582. })
  583. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  584. }
  585. // Do executes the "cloudshell.operations.cancel" call.
  586. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  587. // code is an error. Response headers are in either
  588. // *Empty.ServerResponse.Header or (if a response was returned at all)
  589. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  590. // check whether the returned error was because http.StatusNotModified
  591. // was returned.
  592. func (c *OperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  593. gensupport.SetOptions(c.urlParams_, opts...)
  594. res, err := c.doRequest("json")
  595. if res != nil && res.StatusCode == http.StatusNotModified {
  596. if res.Body != nil {
  597. res.Body.Close()
  598. }
  599. return nil, &googleapi.Error{
  600. Code: res.StatusCode,
  601. Header: res.Header,
  602. }
  603. }
  604. if err != nil {
  605. return nil, err
  606. }
  607. defer googleapi.CloseBody(res)
  608. if err := googleapi.CheckResponse(res); err != nil {
  609. return nil, err
  610. }
  611. ret := &Empty{
  612. ServerResponse: googleapi.ServerResponse{
  613. Header: res.Header,
  614. HTTPStatusCode: res.StatusCode,
  615. },
  616. }
  617. target := &ret
  618. if err := gensupport.DecodeResponse(target, res); err != nil {
  619. return nil, err
  620. }
  621. return ret, nil
  622. // {
  623. // "description": "Starts asynchronous cancellation on a long-running operation. The server\nmakes a best effort to cancel the operation, but success is not\nguaranteed. If the server doesn't support this method, it returns\n`google.rpc.Code.UNIMPLEMENTED`. Clients can use\nOperations.GetOperation or\nother methods to check whether the cancellation succeeded or whether the\noperation completed despite cancellation. On successful cancellation,\nthe operation is not deleted; instead, it becomes an operation with\nan Operation.error value with a google.rpc.Status.code of 1,\ncorresponding to `Code.CANCELLED`.",
  624. // "flatPath": "v1/operations/{operationsId}:cancel",
  625. // "httpMethod": "POST",
  626. // "id": "cloudshell.operations.cancel",
  627. // "parameterOrder": [
  628. // "name"
  629. // ],
  630. // "parameters": {
  631. // "name": {
  632. // "description": "The name of the operation resource to be cancelled.",
  633. // "location": "path",
  634. // "pattern": "^operations/.+$",
  635. // "required": true,
  636. // "type": "string"
  637. // }
  638. // },
  639. // "path": "v1/{+name}:cancel",
  640. // "request": {
  641. // "$ref": "CancelOperationRequest"
  642. // },
  643. // "response": {
  644. // "$ref": "Empty"
  645. // },
  646. // "scopes": [
  647. // "https://www.googleapis.com/auth/cloud-platform"
  648. // ]
  649. // }
  650. }
  651. // method id "cloudshell.operations.delete":
  652. type OperationsDeleteCall struct {
  653. s *Service
  654. name string
  655. urlParams_ gensupport.URLParams
  656. ctx_ context.Context
  657. header_ http.Header
  658. }
  659. // Delete: Deletes a long-running operation. This method indicates that
  660. // the client is
  661. // no longer interested in the operation result. It does not cancel
  662. // the
  663. // operation. If the server doesn't support this method, it
  664. // returns
  665. // `google.rpc.Code.UNIMPLEMENTED`.
  666. func (r *OperationsService) Delete(name string) *OperationsDeleteCall {
  667. c := &OperationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  668. c.name = name
  669. return c
  670. }
  671. // Fields allows partial responses to be retrieved. See
  672. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  673. // for more information.
  674. func (c *OperationsDeleteCall) Fields(s ...googleapi.Field) *OperationsDeleteCall {
  675. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  676. return c
  677. }
  678. // Context sets the context to be used in this call's Do method. Any
  679. // pending HTTP request will be aborted if the provided context is
  680. // canceled.
  681. func (c *OperationsDeleteCall) Context(ctx context.Context) *OperationsDeleteCall {
  682. c.ctx_ = ctx
  683. return c
  684. }
  685. // Header returns an http.Header that can be modified by the caller to
  686. // add HTTP headers to the request.
  687. func (c *OperationsDeleteCall) Header() http.Header {
  688. if c.header_ == nil {
  689. c.header_ = make(http.Header)
  690. }
  691. return c.header_
  692. }
  693. func (c *OperationsDeleteCall) doRequest(alt string) (*http.Response, error) {
  694. reqHeaders := make(http.Header)
  695. for k, v := range c.header_ {
  696. reqHeaders[k] = v
  697. }
  698. reqHeaders.Set("User-Agent", c.s.userAgent())
  699. var body io.Reader = nil
  700. c.urlParams_.Set("alt", alt)
  701. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  702. urls += "?" + c.urlParams_.Encode()
  703. req, _ := http.NewRequest("DELETE", urls, body)
  704. req.Header = reqHeaders
  705. googleapi.Expand(req.URL, map[string]string{
  706. "name": c.name,
  707. })
  708. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  709. }
  710. // Do executes the "cloudshell.operations.delete" call.
  711. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  712. // code is an error. Response headers are in either
  713. // *Empty.ServerResponse.Header or (if a response was returned at all)
  714. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  715. // check whether the returned error was because http.StatusNotModified
  716. // was returned.
  717. func (c *OperationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  718. gensupport.SetOptions(c.urlParams_, opts...)
  719. res, err := c.doRequest("json")
  720. if res != nil && res.StatusCode == http.StatusNotModified {
  721. if res.Body != nil {
  722. res.Body.Close()
  723. }
  724. return nil, &googleapi.Error{
  725. Code: res.StatusCode,
  726. Header: res.Header,
  727. }
  728. }
  729. if err != nil {
  730. return nil, err
  731. }
  732. defer googleapi.CloseBody(res)
  733. if err := googleapi.CheckResponse(res); err != nil {
  734. return nil, err
  735. }
  736. ret := &Empty{
  737. ServerResponse: googleapi.ServerResponse{
  738. Header: res.Header,
  739. HTTPStatusCode: res.StatusCode,
  740. },
  741. }
  742. target := &ret
  743. if err := gensupport.DecodeResponse(target, res); err != nil {
  744. return nil, err
  745. }
  746. return ret, nil
  747. // {
  748. // "description": "Deletes a long-running operation. This method indicates that the client is\nno longer interested in the operation result. It does not cancel the\noperation. If the server doesn't support this method, it returns\n`google.rpc.Code.UNIMPLEMENTED`.",
  749. // "flatPath": "v1/operations/{operationsId}",
  750. // "httpMethod": "DELETE",
  751. // "id": "cloudshell.operations.delete",
  752. // "parameterOrder": [
  753. // "name"
  754. // ],
  755. // "parameters": {
  756. // "name": {
  757. // "description": "The name of the operation resource to be deleted.",
  758. // "location": "path",
  759. // "pattern": "^operations/.+$",
  760. // "required": true,
  761. // "type": "string"
  762. // }
  763. // },
  764. // "path": "v1/{+name}",
  765. // "response": {
  766. // "$ref": "Empty"
  767. // },
  768. // "scopes": [
  769. // "https://www.googleapis.com/auth/cloud-platform"
  770. // ]
  771. // }
  772. }
  773. // method id "cloudshell.operations.get":
  774. type OperationsGetCall 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: Gets the latest state of a long-running operation. Clients can
  783. // use this
  784. // method to poll the operation result at intervals as recommended by
  785. // the API
  786. // service.
  787. func (r *OperationsService) Get(name string) *OperationsGetCall {
  788. c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  789. c.name = name
  790. return c
  791. }
  792. // Fields allows partial responses to be retrieved. See
  793. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  794. // for more information.
  795. func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall {
  796. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  797. return c
  798. }
  799. // IfNoneMatch sets the optional parameter which makes the operation
  800. // fail if the object's ETag matches the given value. This is useful for
  801. // getting updates only after the object has changed since the last
  802. // request. Use googleapi.IsNotModified to check whether the response
  803. // error from Do is the result of In-None-Match.
  804. func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall {
  805. c.ifNoneMatch_ = entityTag
  806. return c
  807. }
  808. // Context sets the context to be used in this call's Do method. Any
  809. // pending HTTP request will be aborted if the provided context is
  810. // canceled.
  811. func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall {
  812. c.ctx_ = ctx
  813. return c
  814. }
  815. // Header returns an http.Header that can be modified by the caller to
  816. // add HTTP headers to the request.
  817. func (c *OperationsGetCall) Header() http.Header {
  818. if c.header_ == nil {
  819. c.header_ = make(http.Header)
  820. }
  821. return c.header_
  822. }
  823. func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) {
  824. reqHeaders := make(http.Header)
  825. for k, v := range c.header_ {
  826. reqHeaders[k] = v
  827. }
  828. reqHeaders.Set("User-Agent", c.s.userAgent())
  829. if c.ifNoneMatch_ != "" {
  830. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  831. }
  832. var body io.Reader = nil
  833. c.urlParams_.Set("alt", alt)
  834. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  835. urls += "?" + c.urlParams_.Encode()
  836. req, _ := http.NewRequest("GET", urls, body)
  837. req.Header = reqHeaders
  838. googleapi.Expand(req.URL, map[string]string{
  839. "name": c.name,
  840. })
  841. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  842. }
  843. // Do executes the "cloudshell.operations.get" call.
  844. // Exactly one of *Operation or error will be non-nil. Any non-2xx
  845. // status code is an error. Response headers are in either
  846. // *Operation.ServerResponse.Header or (if a response was returned at
  847. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  848. // to check whether the returned error was because
  849. // http.StatusNotModified was returned.
  850. func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  851. gensupport.SetOptions(c.urlParams_, opts...)
  852. res, err := c.doRequest("json")
  853. if res != nil && res.StatusCode == http.StatusNotModified {
  854. if res.Body != nil {
  855. res.Body.Close()
  856. }
  857. return nil, &googleapi.Error{
  858. Code: res.StatusCode,
  859. Header: res.Header,
  860. }
  861. }
  862. if err != nil {
  863. return nil, err
  864. }
  865. defer googleapi.CloseBody(res)
  866. if err := googleapi.CheckResponse(res); err != nil {
  867. return nil, err
  868. }
  869. ret := &Operation{
  870. ServerResponse: googleapi.ServerResponse{
  871. Header: res.Header,
  872. HTTPStatusCode: res.StatusCode,
  873. },
  874. }
  875. target := &ret
  876. if err := gensupport.DecodeResponse(target, res); err != nil {
  877. return nil, err
  878. }
  879. return ret, nil
  880. // {
  881. // "description": "Gets the latest state of a long-running operation. Clients can use this\nmethod to poll the operation result at intervals as recommended by the API\nservice.",
  882. // "flatPath": "v1/operations/{operationsId}",
  883. // "httpMethod": "GET",
  884. // "id": "cloudshell.operations.get",
  885. // "parameterOrder": [
  886. // "name"
  887. // ],
  888. // "parameters": {
  889. // "name": {
  890. // "description": "The name of the operation resource.",
  891. // "location": "path",
  892. // "pattern": "^operations/.+$",
  893. // "required": true,
  894. // "type": "string"
  895. // }
  896. // },
  897. // "path": "v1/{+name}",
  898. // "response": {
  899. // "$ref": "Operation"
  900. // },
  901. // "scopes": [
  902. // "https://www.googleapis.com/auth/cloud-platform"
  903. // ]
  904. // }
  905. }
  906. // method id "cloudshell.operations.list":
  907. type OperationsListCall struct {
  908. s *Service
  909. name string
  910. urlParams_ gensupport.URLParams
  911. ifNoneMatch_ string
  912. ctx_ context.Context
  913. header_ http.Header
  914. }
  915. // List: Lists operations that match the specified filter in the
  916. // request. If the
  917. // server doesn't support this method, it returns
  918. // `UNIMPLEMENTED`.
  919. //
  920. // NOTE: the `name` binding allows API services to override the
  921. // binding
  922. // to use different resource name schemes, such as `users/*/operations`.
  923. // To
  924. // override the binding, API services can add a binding such
  925. // as
  926. // "/v1/{name=users/*}/operations" to their service configuration.
  927. // For backwards compatibility, the default name includes the
  928. // operations
  929. // collection id, however overriding users must ensure the name
  930. // binding
  931. // is the parent resource, without the operations collection id.
  932. func (r *OperationsService) List(name string) *OperationsListCall {
  933. c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  934. c.name = name
  935. return c
  936. }
  937. // Filter sets the optional parameter "filter": The standard list
  938. // filter.
  939. func (c *OperationsListCall) Filter(filter string) *OperationsListCall {
  940. c.urlParams_.Set("filter", filter)
  941. return c
  942. }
  943. // PageSize sets the optional parameter "pageSize": The standard list
  944. // page size.
  945. func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall {
  946. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  947. return c
  948. }
  949. // PageToken sets the optional parameter "pageToken": The standard list
  950. // page token.
  951. func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall {
  952. c.urlParams_.Set("pageToken", pageToken)
  953. return c
  954. }
  955. // Fields allows partial responses to be retrieved. See
  956. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  957. // for more information.
  958. func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall {
  959. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  960. return c
  961. }
  962. // IfNoneMatch sets the optional parameter which makes the operation
  963. // fail if the object's ETag matches the given value. This is useful for
  964. // getting updates only after the object has changed since the last
  965. // request. Use googleapi.IsNotModified to check whether the response
  966. // error from Do is the result of In-None-Match.
  967. func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall {
  968. c.ifNoneMatch_ = entityTag
  969. return c
  970. }
  971. // Context sets the context to be used in this call's Do method. Any
  972. // pending HTTP request will be aborted if the provided context is
  973. // canceled.
  974. func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall {
  975. c.ctx_ = ctx
  976. return c
  977. }
  978. // Header returns an http.Header that can be modified by the caller to
  979. // add HTTP headers to the request.
  980. func (c *OperationsListCall) Header() http.Header {
  981. if c.header_ == nil {
  982. c.header_ = make(http.Header)
  983. }
  984. return c.header_
  985. }
  986. func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) {
  987. reqHeaders := make(http.Header)
  988. for k, v := range c.header_ {
  989. reqHeaders[k] = v
  990. }
  991. reqHeaders.Set("User-Agent", c.s.userAgent())
  992. if c.ifNoneMatch_ != "" {
  993. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  994. }
  995. var body io.Reader = nil
  996. c.urlParams_.Set("alt", alt)
  997. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  998. urls += "?" + c.urlParams_.Encode()
  999. req, _ := http.NewRequest("GET", urls, body)
  1000. req.Header = reqHeaders
  1001. googleapi.Expand(req.URL, map[string]string{
  1002. "name": c.name,
  1003. })
  1004. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1005. }
  1006. // Do executes the "cloudshell.operations.list" call.
  1007. // Exactly one of *ListOperationsResponse or error will be non-nil. Any
  1008. // non-2xx status code is an error. Response headers are in either
  1009. // *ListOperationsResponse.ServerResponse.Header or (if a response was
  1010. // returned at all) in error.(*googleapi.Error).Header. Use
  1011. // googleapi.IsNotModified to check whether the returned error was
  1012. // because http.StatusNotModified was returned.
  1013. func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
  1014. gensupport.SetOptions(c.urlParams_, opts...)
  1015. res, err := c.doRequest("json")
  1016. if res != nil && res.StatusCode == http.StatusNotModified {
  1017. if res.Body != nil {
  1018. res.Body.Close()
  1019. }
  1020. return nil, &googleapi.Error{
  1021. Code: res.StatusCode,
  1022. Header: res.Header,
  1023. }
  1024. }
  1025. if err != nil {
  1026. return nil, err
  1027. }
  1028. defer googleapi.CloseBody(res)
  1029. if err := googleapi.CheckResponse(res); err != nil {
  1030. return nil, err
  1031. }
  1032. ret := &ListOperationsResponse{
  1033. ServerResponse: googleapi.ServerResponse{
  1034. Header: res.Header,
  1035. HTTPStatusCode: res.StatusCode,
  1036. },
  1037. }
  1038. target := &ret
  1039. if err := gensupport.DecodeResponse(target, res); err != nil {
  1040. return nil, err
  1041. }
  1042. return ret, nil
  1043. // {
  1044. // "description": "Lists operations that match the specified filter in the request. If the\nserver doesn't support this method, it returns `UNIMPLEMENTED`.\n\nNOTE: the `name` binding allows API services to override the binding\nto use different resource name schemes, such as `users/*/operations`. To\noverride the binding, API services can add a binding such as\n`\"/v1/{name=users/*}/operations\"` to their service configuration.\nFor backwards compatibility, the default name includes the operations\ncollection id, however overriding users must ensure the name binding\nis the parent resource, without the operations collection id.",
  1045. // "flatPath": "v1/operations",
  1046. // "httpMethod": "GET",
  1047. // "id": "cloudshell.operations.list",
  1048. // "parameterOrder": [
  1049. // "name"
  1050. // ],
  1051. // "parameters": {
  1052. // "filter": {
  1053. // "description": "The standard list filter.",
  1054. // "location": "query",
  1055. // "type": "string"
  1056. // },
  1057. // "name": {
  1058. // "description": "The name of the operation's parent resource.",
  1059. // "location": "path",
  1060. // "pattern": "^operations$",
  1061. // "required": true,
  1062. // "type": "string"
  1063. // },
  1064. // "pageSize": {
  1065. // "description": "The standard list page size.",
  1066. // "format": "int32",
  1067. // "location": "query",
  1068. // "type": "integer"
  1069. // },
  1070. // "pageToken": {
  1071. // "description": "The standard list page token.",
  1072. // "location": "query",
  1073. // "type": "string"
  1074. // }
  1075. // },
  1076. // "path": "v1/{+name}",
  1077. // "response": {
  1078. // "$ref": "ListOperationsResponse"
  1079. // },
  1080. // "scopes": [
  1081. // "https://www.googleapis.com/auth/cloud-platform"
  1082. // ]
  1083. // }
  1084. }
  1085. // Pages invokes f for each page of results.
  1086. // A non-nil error returned from f will halt the iteration.
  1087. // The provided context supersedes any context provided to the Context method.
  1088. func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
  1089. c.ctx_ = ctx
  1090. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1091. for {
  1092. x, err := c.Do()
  1093. if err != nil {
  1094. return err
  1095. }
  1096. if err := f(x); err != nil {
  1097. return err
  1098. }
  1099. if x.NextPageToken == "" {
  1100. return nil
  1101. }
  1102. c.PageToken(x.NextPageToken)
  1103. }
  1104. }