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.
 
 
 

849 lines
29 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package cloudprofiler provides access to the Stackdriver Profiler API.
  6. //
  7. // For product documentation, see: https://cloud.google.com/profiler/
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/cloudprofiler/v2"
  14. // ...
  15. // ctx := context.Background()
  16. // cloudprofilerService, err := cloudprofiler.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes:
  25. //
  26. // cloudprofilerService, err := cloudprofiler.NewService(ctx, option.WithScopes(cloudprofiler.MonitoringWriteScope))
  27. //
  28. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  29. //
  30. // cloudprofilerService, err := cloudprofiler.NewService(ctx, option.WithAPIKey("AIza..."))
  31. //
  32. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  33. //
  34. // config := &oauth2.Config{...}
  35. // // ...
  36. // token, err := config.Exchange(ctx, ...)
  37. // cloudprofilerService, err := cloudprofiler.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  38. //
  39. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  40. package cloudprofiler // import "google.golang.org/api/cloudprofiler/v2"
  41. import (
  42. "bytes"
  43. "context"
  44. "encoding/json"
  45. "errors"
  46. "fmt"
  47. "io"
  48. "net/http"
  49. "net/url"
  50. "strconv"
  51. "strings"
  52. gensupport "google.golang.org/api/gensupport"
  53. googleapi "google.golang.org/api/googleapi"
  54. option "google.golang.org/api/option"
  55. htransport "google.golang.org/api/transport/http"
  56. )
  57. // Always reference these packages, just in case the auto-generated code
  58. // below doesn't.
  59. var _ = bytes.NewBuffer
  60. var _ = strconv.Itoa
  61. var _ = fmt.Sprintf
  62. var _ = json.NewDecoder
  63. var _ = io.Copy
  64. var _ = url.Parse
  65. var _ = gensupport.MarshalJSON
  66. var _ = googleapi.Version
  67. var _ = errors.New
  68. var _ = strings.Replace
  69. var _ = context.Canceled
  70. const apiId = "cloudprofiler:v2"
  71. const apiName = "cloudprofiler"
  72. const apiVersion = "v2"
  73. const basePath = "https://cloudprofiler.googleapis.com/"
  74. // OAuth2 scopes used by this API.
  75. const (
  76. // View and manage your data across Google Cloud Platform services
  77. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  78. // View and write monitoring data for all of your Google and third-party
  79. // Cloud and API projects
  80. MonitoringScope = "https://www.googleapis.com/auth/monitoring"
  81. // Publish metric data to your Google Cloud projects
  82. MonitoringWriteScope = "https://www.googleapis.com/auth/monitoring.write"
  83. )
  84. // NewService creates a new Service.
  85. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  86. scopesOption := option.WithScopes(
  87. "https://www.googleapis.com/auth/cloud-platform",
  88. "https://www.googleapis.com/auth/monitoring",
  89. "https://www.googleapis.com/auth/monitoring.write",
  90. )
  91. // NOTE: prepend, so we don't override user-specified scopes.
  92. opts = append([]option.ClientOption{scopesOption}, opts...)
  93. client, endpoint, err := htransport.NewClient(ctx, opts...)
  94. if err != nil {
  95. return nil, err
  96. }
  97. s, err := New(client)
  98. if err != nil {
  99. return nil, err
  100. }
  101. if endpoint != "" {
  102. s.BasePath = endpoint
  103. }
  104. return s, nil
  105. }
  106. // New creates a new Service. It uses the provided http.Client for requests.
  107. //
  108. // Deprecated: please use NewService instead.
  109. // To provide a custom HTTP client, use option.WithHTTPClient.
  110. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  111. func New(client *http.Client) (*Service, error) {
  112. if client == nil {
  113. return nil, errors.New("client is nil")
  114. }
  115. s := &Service{client: client, BasePath: basePath}
  116. s.Projects = NewProjectsService(s)
  117. return s, nil
  118. }
  119. type Service struct {
  120. client *http.Client
  121. BasePath string // API endpoint base URL
  122. UserAgent string // optional additional User-Agent fragment
  123. Projects *ProjectsService
  124. }
  125. func (s *Service) userAgent() string {
  126. if s.UserAgent == "" {
  127. return googleapi.UserAgent
  128. }
  129. return googleapi.UserAgent + " " + s.UserAgent
  130. }
  131. func NewProjectsService(s *Service) *ProjectsService {
  132. rs := &ProjectsService{s: s}
  133. rs.Profiles = NewProjectsProfilesService(s)
  134. return rs
  135. }
  136. type ProjectsService struct {
  137. s *Service
  138. Profiles *ProjectsProfilesService
  139. }
  140. func NewProjectsProfilesService(s *Service) *ProjectsProfilesService {
  141. rs := &ProjectsProfilesService{s: s}
  142. return rs
  143. }
  144. type ProjectsProfilesService struct {
  145. s *Service
  146. }
  147. // CreateProfileRequest: CreateProfileRequest describes a profile
  148. // resource online creation request.
  149. // The deployment field must be populated. The profile_type specifies
  150. // the list
  151. // of profile types supported by the agent. The creation call will hang
  152. // until a
  153. // profile of one of these types needs to be collected.
  154. type CreateProfileRequest struct {
  155. // Deployment: Deployment details.
  156. Deployment *Deployment `json:"deployment,omitempty"`
  157. // ProfileType: One or more profile types that the agent is capable of
  158. // providing.
  159. //
  160. // Possible values:
  161. // "PROFILE_TYPE_UNSPECIFIED" - Unspecified profile type.
  162. // "CPU" - Thread CPU time sampling.
  163. // "WALL" - Wallclock time sampling. More expensive as stops all
  164. // threads.
  165. // "HEAP" - In-use heap profile. Represents a snapshot of the
  166. // allocations that are
  167. // live at the time of the profiling.
  168. // "THREADS" - Single-shot collection of all thread stacks.
  169. // "CONTENTION" - Synchronization contention profile.
  170. // "PEAK_HEAP" - Peak heap profile.
  171. // "HEAP_ALLOC" - Heap allocation profile. It represents the
  172. // aggregation of all allocations
  173. // made over the duration of the profile. All allocations are
  174. // included,
  175. // including those that might have been freed by the end of the
  176. // profiling
  177. // interval. The profile is in particular useful for garbage
  178. // collecting
  179. // languages to understand which parts of the code create most of the
  180. // garbage
  181. // collection pressure to see if those can be optimized.
  182. ProfileType []string `json:"profileType,omitempty"`
  183. // ForceSendFields is a list of field names (e.g. "Deployment") to
  184. // unconditionally include in API requests. By default, fields with
  185. // empty values are omitted from API requests. However, any non-pointer,
  186. // non-interface field appearing in ForceSendFields will be sent to the
  187. // server regardless of whether the field is empty or not. This may be
  188. // used to include empty fields in Patch requests.
  189. ForceSendFields []string `json:"-"`
  190. // NullFields is a list of field names (e.g. "Deployment") to include in
  191. // API requests with the JSON null value. By default, fields with empty
  192. // values are omitted from API requests. However, any field with an
  193. // empty value appearing in NullFields will be sent to the server as
  194. // null. It is an error if a field in this list has a non-empty value.
  195. // This may be used to include null fields in Patch requests.
  196. NullFields []string `json:"-"`
  197. }
  198. func (s *CreateProfileRequest) MarshalJSON() ([]byte, error) {
  199. type NoMethod CreateProfileRequest
  200. raw := NoMethod(*s)
  201. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  202. }
  203. // Deployment: Deployment contains the deployment identification
  204. // information.
  205. type Deployment struct {
  206. // Labels: Labels identify the deployment within the user universe and
  207. // same target.
  208. // Validation regex for label names:
  209. // `^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`.
  210. // Value for an individual label must be <= 512 bytes, the total
  211. // size of all label names and values must be <= 1024 bytes.
  212. //
  213. // Label named "language" can be used to record the programming language
  214. // of
  215. // the profiled deployment. The standard choices for the value include
  216. // "java",
  217. // "go", "python", "ruby", "nodejs", "php", "dotnet".
  218. //
  219. // For deployments running on Google Cloud Platform, "zone" or "region"
  220. // label
  221. // should be present describing the deployment location. An example of a
  222. // zone
  223. // is "us-central1-a", an example of a region is "us-central1"
  224. // or
  225. // "us-central".
  226. Labels map[string]string `json:"labels,omitempty"`
  227. // ProjectId: Project ID is the ID of a cloud project.
  228. // Validation regex: `^a-z{4,61}[a-z0-9]$`.
  229. ProjectId string `json:"projectId,omitempty"`
  230. // Target: Target is the service name used to group related
  231. // deployments:
  232. // * Service name for GAE Flex / Standard.
  233. // * Cluster and container name for GKE.
  234. // * User-specified string for direct GCE profiling (e.g. Java).
  235. // * Job name for Dataflow.
  236. // Validation regex: `^[a-z]([-a-z0-9_.]{0,253}[a-z0-9])?$`.
  237. Target string `json:"target,omitempty"`
  238. // ForceSendFields is a list of field names (e.g. "Labels") to
  239. // unconditionally include in API requests. By default, fields with
  240. // empty values are omitted from API requests. However, any non-pointer,
  241. // non-interface field appearing in ForceSendFields will be sent to the
  242. // server regardless of whether the field is empty or not. This may be
  243. // used to include empty fields in Patch requests.
  244. ForceSendFields []string `json:"-"`
  245. // NullFields is a list of field names (e.g. "Labels") to include in API
  246. // requests with the JSON null value. By default, fields with empty
  247. // values are omitted from API requests. However, any field with an
  248. // empty value appearing in NullFields will be sent to the server as
  249. // null. It is an error if a field in this list has a non-empty value.
  250. // This may be used to include null fields in Patch requests.
  251. NullFields []string `json:"-"`
  252. }
  253. func (s *Deployment) MarshalJSON() ([]byte, error) {
  254. type NoMethod Deployment
  255. raw := NoMethod(*s)
  256. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  257. }
  258. // Profile: Profile resource.
  259. type Profile struct {
  260. // Deployment: Deployment this profile corresponds to.
  261. Deployment *Deployment `json:"deployment,omitempty"`
  262. // Duration: Duration of the profiling session.
  263. // Input (for the offline mode) or output (for the online mode).
  264. // The field represents requested profiling duration. It may slightly
  265. // differ
  266. // from the effective profiling duration, which is recorded in the
  267. // profile
  268. // data, in case the profiling can't be stopped immediately (e.g. in
  269. // case
  270. // stopping the profiling is handled asynchronously).
  271. Duration string `json:"duration,omitempty"`
  272. // Labels: Input only. Labels associated to this specific profile. These
  273. // labels will
  274. // get merged with the deployment labels for the final data set.
  275. // See
  276. // documentation on deployment labels for validation rules and limits.
  277. Labels map[string]string `json:"labels,omitempty"`
  278. // Name: Output only. Opaque, server-assigned, unique ID for this
  279. // profile.
  280. Name string `json:"name,omitempty"`
  281. // ProfileBytes: Input only. Profile bytes, as a gzip compressed
  282. // serialized proto, the
  283. // format is
  284. // https://github.com/google/pprof/blob/master/proto/profile.proto.
  285. ProfileBytes string `json:"profileBytes,omitempty"`
  286. // ProfileType: Type of profile.
  287. // For offline mode, this must be specified when creating the profile.
  288. // For
  289. // online mode it is assigned and returned by the server.
  290. //
  291. // Possible values:
  292. // "PROFILE_TYPE_UNSPECIFIED" - Unspecified profile type.
  293. // "CPU" - Thread CPU time sampling.
  294. // "WALL" - Wallclock time sampling. More expensive as stops all
  295. // threads.
  296. // "HEAP" - In-use heap profile. Represents a snapshot of the
  297. // allocations that are
  298. // live at the time of the profiling.
  299. // "THREADS" - Single-shot collection of all thread stacks.
  300. // "CONTENTION" - Synchronization contention profile.
  301. // "PEAK_HEAP" - Peak heap profile.
  302. // "HEAP_ALLOC" - Heap allocation profile. It represents the
  303. // aggregation of all allocations
  304. // made over the duration of the profile. All allocations are
  305. // included,
  306. // including those that might have been freed by the end of the
  307. // profiling
  308. // interval. The profile is in particular useful for garbage
  309. // collecting
  310. // languages to understand which parts of the code create most of the
  311. // garbage
  312. // collection pressure to see if those can be optimized.
  313. ProfileType string `json:"profileType,omitempty"`
  314. // ServerResponse contains the HTTP response code and headers from the
  315. // server.
  316. googleapi.ServerResponse `json:"-"`
  317. // ForceSendFields is a list of field names (e.g. "Deployment") to
  318. // unconditionally include in API requests. By default, fields with
  319. // empty values are omitted from API requests. However, any non-pointer,
  320. // non-interface field appearing in ForceSendFields will be sent to the
  321. // server regardless of whether the field is empty or not. This may be
  322. // used to include empty fields in Patch requests.
  323. ForceSendFields []string `json:"-"`
  324. // NullFields is a list of field names (e.g. "Deployment") to include in
  325. // API requests with the JSON null value. By default, fields with empty
  326. // values are omitted from API requests. However, any field with an
  327. // empty value appearing in NullFields will be sent to the server as
  328. // null. It is an error if a field in this list has a non-empty value.
  329. // This may be used to include null fields in Patch requests.
  330. NullFields []string `json:"-"`
  331. }
  332. func (s *Profile) MarshalJSON() ([]byte, error) {
  333. type NoMethod Profile
  334. raw := NoMethod(*s)
  335. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  336. }
  337. // method id "cloudprofiler.projects.profiles.create":
  338. type ProjectsProfilesCreateCall struct {
  339. s *Service
  340. parent string
  341. createprofilerequest *CreateProfileRequest
  342. urlParams_ gensupport.URLParams
  343. ctx_ context.Context
  344. header_ http.Header
  345. }
  346. // Create: CreateProfile creates a new profile resource in the online
  347. // mode.
  348. //
  349. // The server ensures that the new profiles are created at a constant
  350. // rate per
  351. // deployment, so the creation request may hang for some time until the
  352. // next
  353. // profile session is available.
  354. //
  355. // The request may fail with ABORTED error if the creation is not
  356. // available
  357. // within ~1m, the response will indicate the duration of the backoff
  358. // the
  359. // client should take before attempting creating a profile again. The
  360. // backoff
  361. // duration is returned in google.rpc.RetryInfo extension on the
  362. // response
  363. // status. To a gRPC client, the extension will be return as
  364. // a
  365. // binary-serialized proto in the trailing metadata item
  366. // named
  367. // "google.rpc.retryinfo-bin".
  368. func (r *ProjectsProfilesService) Create(parent string, createprofilerequest *CreateProfileRequest) *ProjectsProfilesCreateCall {
  369. c := &ProjectsProfilesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  370. c.parent = parent
  371. c.createprofilerequest = createprofilerequest
  372. return c
  373. }
  374. // Fields allows partial responses to be retrieved. See
  375. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  376. // for more information.
  377. func (c *ProjectsProfilesCreateCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateCall {
  378. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  379. return c
  380. }
  381. // Context sets the context to be used in this call's Do method. Any
  382. // pending HTTP request will be aborted if the provided context is
  383. // canceled.
  384. func (c *ProjectsProfilesCreateCall) Context(ctx context.Context) *ProjectsProfilesCreateCall {
  385. c.ctx_ = ctx
  386. return c
  387. }
  388. // Header returns an http.Header that can be modified by the caller to
  389. // add HTTP headers to the request.
  390. func (c *ProjectsProfilesCreateCall) Header() http.Header {
  391. if c.header_ == nil {
  392. c.header_ = make(http.Header)
  393. }
  394. return c.header_
  395. }
  396. func (c *ProjectsProfilesCreateCall) doRequest(alt string) (*http.Response, error) {
  397. reqHeaders := make(http.Header)
  398. for k, v := range c.header_ {
  399. reqHeaders[k] = v
  400. }
  401. reqHeaders.Set("User-Agent", c.s.userAgent())
  402. var body io.Reader = nil
  403. body, err := googleapi.WithoutDataWrapper.JSONReader(c.createprofilerequest)
  404. if err != nil {
  405. return nil, err
  406. }
  407. reqHeaders.Set("Content-Type", "application/json")
  408. c.urlParams_.Set("alt", alt)
  409. c.urlParams_.Set("prettyPrint", "false")
  410. urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/profiles")
  411. urls += "?" + c.urlParams_.Encode()
  412. req, err := http.NewRequest("POST", urls, body)
  413. if err != nil {
  414. return nil, err
  415. }
  416. req.Header = reqHeaders
  417. googleapi.Expand(req.URL, map[string]string{
  418. "parent": c.parent,
  419. })
  420. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  421. }
  422. // Do executes the "cloudprofiler.projects.profiles.create" call.
  423. // Exactly one of *Profile or error will be non-nil. Any non-2xx status
  424. // code is an error. Response headers are in either
  425. // *Profile.ServerResponse.Header or (if a response was returned at all)
  426. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  427. // check whether the returned error was because http.StatusNotModified
  428. // was returned.
  429. func (c *ProjectsProfilesCreateCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
  430. gensupport.SetOptions(c.urlParams_, opts...)
  431. res, err := c.doRequest("json")
  432. if res != nil && res.StatusCode == http.StatusNotModified {
  433. if res.Body != nil {
  434. res.Body.Close()
  435. }
  436. return nil, &googleapi.Error{
  437. Code: res.StatusCode,
  438. Header: res.Header,
  439. }
  440. }
  441. if err != nil {
  442. return nil, err
  443. }
  444. defer googleapi.CloseBody(res)
  445. if err := googleapi.CheckResponse(res); err != nil {
  446. return nil, err
  447. }
  448. ret := &Profile{
  449. ServerResponse: googleapi.ServerResponse{
  450. Header: res.Header,
  451. HTTPStatusCode: res.StatusCode,
  452. },
  453. }
  454. target := &ret
  455. if err := gensupport.DecodeResponse(target, res); err != nil {
  456. return nil, err
  457. }
  458. return ret, nil
  459. // {
  460. // "description": "CreateProfile creates a new profile resource in the online mode.\n\nThe server ensures that the new profiles are created at a constant rate per\ndeployment, so the creation request may hang for some time until the next\nprofile session is available.\n\nThe request may fail with ABORTED error if the creation is not available\nwithin ~1m, the response will indicate the duration of the backoff the\nclient should take before attempting creating a profile again. The backoff\nduration is returned in google.rpc.RetryInfo extension on the response\nstatus. To a gRPC client, the extension will be return as a\nbinary-serialized proto in the trailing metadata item named\n\"google.rpc.retryinfo-bin\".",
  461. // "flatPath": "v2/projects/{projectsId}/profiles",
  462. // "httpMethod": "POST",
  463. // "id": "cloudprofiler.projects.profiles.create",
  464. // "parameterOrder": [
  465. // "parent"
  466. // ],
  467. // "parameters": {
  468. // "parent": {
  469. // "description": "Parent project to create the profile in.",
  470. // "location": "path",
  471. // "pattern": "^projects/[^/]+$",
  472. // "required": true,
  473. // "type": "string"
  474. // }
  475. // },
  476. // "path": "v2/{+parent}/profiles",
  477. // "request": {
  478. // "$ref": "CreateProfileRequest"
  479. // },
  480. // "response": {
  481. // "$ref": "Profile"
  482. // },
  483. // "scopes": [
  484. // "https://www.googleapis.com/auth/cloud-platform",
  485. // "https://www.googleapis.com/auth/monitoring",
  486. // "https://www.googleapis.com/auth/monitoring.write"
  487. // ]
  488. // }
  489. }
  490. // method id "cloudprofiler.projects.profiles.createOffline":
  491. type ProjectsProfilesCreateOfflineCall struct {
  492. s *Service
  493. parent string
  494. profile *Profile
  495. urlParams_ gensupport.URLParams
  496. ctx_ context.Context
  497. header_ http.Header
  498. }
  499. // CreateOffline: CreateOfflineProfile creates a new profile resource in
  500. // the offline mode.
  501. // The client provides the profile to create along with the profile
  502. // bytes, the
  503. // server records it.
  504. func (r *ProjectsProfilesService) CreateOffline(parent string, profile *Profile) *ProjectsProfilesCreateOfflineCall {
  505. c := &ProjectsProfilesCreateOfflineCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  506. c.parent = parent
  507. c.profile = profile
  508. return c
  509. }
  510. // Fields allows partial responses to be retrieved. See
  511. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  512. // for more information.
  513. func (c *ProjectsProfilesCreateOfflineCall) Fields(s ...googleapi.Field) *ProjectsProfilesCreateOfflineCall {
  514. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  515. return c
  516. }
  517. // Context sets the context to be used in this call's Do method. Any
  518. // pending HTTP request will be aborted if the provided context is
  519. // canceled.
  520. func (c *ProjectsProfilesCreateOfflineCall) Context(ctx context.Context) *ProjectsProfilesCreateOfflineCall {
  521. c.ctx_ = ctx
  522. return c
  523. }
  524. // Header returns an http.Header that can be modified by the caller to
  525. // add HTTP headers to the request.
  526. func (c *ProjectsProfilesCreateOfflineCall) Header() http.Header {
  527. if c.header_ == nil {
  528. c.header_ = make(http.Header)
  529. }
  530. return c.header_
  531. }
  532. func (c *ProjectsProfilesCreateOfflineCall) doRequest(alt string) (*http.Response, error) {
  533. reqHeaders := make(http.Header)
  534. for k, v := range c.header_ {
  535. reqHeaders[k] = v
  536. }
  537. reqHeaders.Set("User-Agent", c.s.userAgent())
  538. var body io.Reader = nil
  539. body, err := googleapi.WithoutDataWrapper.JSONReader(c.profile)
  540. if err != nil {
  541. return nil, err
  542. }
  543. reqHeaders.Set("Content-Type", "application/json")
  544. c.urlParams_.Set("alt", alt)
  545. c.urlParams_.Set("prettyPrint", "false")
  546. urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+parent}/profiles:createOffline")
  547. urls += "?" + c.urlParams_.Encode()
  548. req, err := http.NewRequest("POST", urls, body)
  549. if err != nil {
  550. return nil, err
  551. }
  552. req.Header = reqHeaders
  553. googleapi.Expand(req.URL, map[string]string{
  554. "parent": c.parent,
  555. })
  556. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  557. }
  558. // Do executes the "cloudprofiler.projects.profiles.createOffline" call.
  559. // Exactly one of *Profile or error will be non-nil. Any non-2xx status
  560. // code is an error. Response headers are in either
  561. // *Profile.ServerResponse.Header or (if a response was returned at all)
  562. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  563. // check whether the returned error was because http.StatusNotModified
  564. // was returned.
  565. func (c *ProjectsProfilesCreateOfflineCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
  566. gensupport.SetOptions(c.urlParams_, opts...)
  567. res, err := c.doRequest("json")
  568. if res != nil && res.StatusCode == http.StatusNotModified {
  569. if res.Body != nil {
  570. res.Body.Close()
  571. }
  572. return nil, &googleapi.Error{
  573. Code: res.StatusCode,
  574. Header: res.Header,
  575. }
  576. }
  577. if err != nil {
  578. return nil, err
  579. }
  580. defer googleapi.CloseBody(res)
  581. if err := googleapi.CheckResponse(res); err != nil {
  582. return nil, err
  583. }
  584. ret := &Profile{
  585. ServerResponse: googleapi.ServerResponse{
  586. Header: res.Header,
  587. HTTPStatusCode: res.StatusCode,
  588. },
  589. }
  590. target := &ret
  591. if err := gensupport.DecodeResponse(target, res); err != nil {
  592. return nil, err
  593. }
  594. return ret, nil
  595. // {
  596. // "description": "CreateOfflineProfile creates a new profile resource in the offline mode.\nThe client provides the profile to create along with the profile bytes, the\nserver records it.",
  597. // "flatPath": "v2/projects/{projectsId}/profiles:createOffline",
  598. // "httpMethod": "POST",
  599. // "id": "cloudprofiler.projects.profiles.createOffline",
  600. // "parameterOrder": [
  601. // "parent"
  602. // ],
  603. // "parameters": {
  604. // "parent": {
  605. // "description": "Parent project to create the profile in.",
  606. // "location": "path",
  607. // "pattern": "^projects/[^/]+$",
  608. // "required": true,
  609. // "type": "string"
  610. // }
  611. // },
  612. // "path": "v2/{+parent}/profiles:createOffline",
  613. // "request": {
  614. // "$ref": "Profile"
  615. // },
  616. // "response": {
  617. // "$ref": "Profile"
  618. // },
  619. // "scopes": [
  620. // "https://www.googleapis.com/auth/cloud-platform",
  621. // "https://www.googleapis.com/auth/monitoring",
  622. // "https://www.googleapis.com/auth/monitoring.write"
  623. // ]
  624. // }
  625. }
  626. // method id "cloudprofiler.projects.profiles.patch":
  627. type ProjectsProfilesPatchCall struct {
  628. s *Service
  629. name string
  630. profile *Profile
  631. urlParams_ gensupport.URLParams
  632. ctx_ context.Context
  633. header_ http.Header
  634. }
  635. // Patch: UpdateProfile updates the profile bytes and labels on the
  636. // profile resource
  637. // created in the online mode. Updating the bytes for profiles created
  638. // in the
  639. // offline mode is currently not supported: the profile content must
  640. // be
  641. // provided at the time of the profile creation.
  642. func (r *ProjectsProfilesService) Patch(name string, profile *Profile) *ProjectsProfilesPatchCall {
  643. c := &ProjectsProfilesPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  644. c.name = name
  645. c.profile = profile
  646. return c
  647. }
  648. // UpdateMask sets the optional parameter "updateMask": Field mask used
  649. // to specify the fields to be overwritten. Currently only
  650. // profile_bytes and labels fields are supported by UpdateProfile, so
  651. // only
  652. // those fields can be specified in the mask. When no mask is provided,
  653. // all
  654. // fields are overwritten.
  655. func (c *ProjectsProfilesPatchCall) UpdateMask(updateMask string) *ProjectsProfilesPatchCall {
  656. c.urlParams_.Set("updateMask", updateMask)
  657. return c
  658. }
  659. // Fields allows partial responses to be retrieved. See
  660. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  661. // for more information.
  662. func (c *ProjectsProfilesPatchCall) Fields(s ...googleapi.Field) *ProjectsProfilesPatchCall {
  663. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  664. return c
  665. }
  666. // Context sets the context to be used in this call's Do method. Any
  667. // pending HTTP request will be aborted if the provided context is
  668. // canceled.
  669. func (c *ProjectsProfilesPatchCall) Context(ctx context.Context) *ProjectsProfilesPatchCall {
  670. c.ctx_ = ctx
  671. return c
  672. }
  673. // Header returns an http.Header that can be modified by the caller to
  674. // add HTTP headers to the request.
  675. func (c *ProjectsProfilesPatchCall) Header() http.Header {
  676. if c.header_ == nil {
  677. c.header_ = make(http.Header)
  678. }
  679. return c.header_
  680. }
  681. func (c *ProjectsProfilesPatchCall) doRequest(alt string) (*http.Response, error) {
  682. reqHeaders := make(http.Header)
  683. for k, v := range c.header_ {
  684. reqHeaders[k] = v
  685. }
  686. reqHeaders.Set("User-Agent", c.s.userAgent())
  687. var body io.Reader = nil
  688. body, err := googleapi.WithoutDataWrapper.JSONReader(c.profile)
  689. if err != nil {
  690. return nil, err
  691. }
  692. reqHeaders.Set("Content-Type", "application/json")
  693. c.urlParams_.Set("alt", alt)
  694. c.urlParams_.Set("prettyPrint", "false")
  695. urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}")
  696. urls += "?" + c.urlParams_.Encode()
  697. req, err := http.NewRequest("PATCH", urls, body)
  698. if err != nil {
  699. return nil, err
  700. }
  701. req.Header = reqHeaders
  702. googleapi.Expand(req.URL, map[string]string{
  703. "name": c.name,
  704. })
  705. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  706. }
  707. // Do executes the "cloudprofiler.projects.profiles.patch" call.
  708. // Exactly one of *Profile or error will be non-nil. Any non-2xx status
  709. // code is an error. Response headers are in either
  710. // *Profile.ServerResponse.Header or (if a response was returned at all)
  711. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  712. // check whether the returned error was because http.StatusNotModified
  713. // was returned.
  714. func (c *ProjectsProfilesPatchCall) Do(opts ...googleapi.CallOption) (*Profile, error) {
  715. gensupport.SetOptions(c.urlParams_, opts...)
  716. res, err := c.doRequest("json")
  717. if res != nil && res.StatusCode == http.StatusNotModified {
  718. if res.Body != nil {
  719. res.Body.Close()
  720. }
  721. return nil, &googleapi.Error{
  722. Code: res.StatusCode,
  723. Header: res.Header,
  724. }
  725. }
  726. if err != nil {
  727. return nil, err
  728. }
  729. defer googleapi.CloseBody(res)
  730. if err := googleapi.CheckResponse(res); err != nil {
  731. return nil, err
  732. }
  733. ret := &Profile{
  734. ServerResponse: googleapi.ServerResponse{
  735. Header: res.Header,
  736. HTTPStatusCode: res.StatusCode,
  737. },
  738. }
  739. target := &ret
  740. if err := gensupport.DecodeResponse(target, res); err != nil {
  741. return nil, err
  742. }
  743. return ret, nil
  744. // {
  745. // "description": "UpdateProfile updates the profile bytes and labels on the profile resource\ncreated in the online mode. Updating the bytes for profiles created in the\noffline mode is currently not supported: the profile content must be\nprovided at the time of the profile creation.",
  746. // "flatPath": "v2/projects/{projectsId}/profiles/{profilesId}",
  747. // "httpMethod": "PATCH",
  748. // "id": "cloudprofiler.projects.profiles.patch",
  749. // "parameterOrder": [
  750. // "name"
  751. // ],
  752. // "parameters": {
  753. // "name": {
  754. // "description": "Output only. Opaque, server-assigned, unique ID for this profile.",
  755. // "location": "path",
  756. // "pattern": "^projects/[^/]+/profiles/[^/]+$",
  757. // "required": true,
  758. // "type": "string"
  759. // },
  760. // "updateMask": {
  761. // "description": "Field mask used to specify the fields to be overwritten. Currently only\nprofile_bytes and labels fields are supported by UpdateProfile, so only\nthose fields can be specified in the mask. When no mask is provided, all\nfields are overwritten.",
  762. // "format": "google-fieldmask",
  763. // "location": "query",
  764. // "type": "string"
  765. // }
  766. // },
  767. // "path": "v2/{+name}",
  768. // "request": {
  769. // "$ref": "Profile"
  770. // },
  771. // "response": {
  772. // "$ref": "Profile"
  773. // },
  774. // "scopes": [
  775. // "https://www.googleapis.com/auth/cloud-platform",
  776. // "https://www.googleapis.com/auth/monitoring",
  777. // "https://www.googleapis.com/auth/monitoring.write"
  778. // ]
  779. // }
  780. }