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.
 
 
 

1036 lines
36 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 cloudtrace provides access to the Stackdriver Trace API.
  6. //
  7. // For product documentation, see: https://cloud.google.com/trace
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/cloudtrace/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // cloudtraceService, err := cloudtrace.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. // cloudtraceService, err := cloudtrace.NewService(ctx, option.WithScopes(cloudtrace.TraceReadonlyScope))
  27. //
  28. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  29. //
  30. // cloudtraceService, err := cloudtrace.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. // cloudtraceService, err := cloudtrace.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 cloudtrace // import "google.golang.org/api/cloudtrace/v1"
  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 = "cloudtrace:v1"
  71. const apiName = "cloudtrace"
  72. const apiVersion = "v1"
  73. const basePath = "https://cloudtrace.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. // Write Trace data for a project or application
  79. TraceAppendScope = "https://www.googleapis.com/auth/trace.append"
  80. // Read Trace data for a project or application
  81. TraceReadonlyScope = "https://www.googleapis.com/auth/trace.readonly"
  82. )
  83. // NewService creates a new Service.
  84. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  85. scopesOption := option.WithScopes(
  86. "https://www.googleapis.com/auth/cloud-platform",
  87. "https://www.googleapis.com/auth/trace.append",
  88. "https://www.googleapis.com/auth/trace.readonly",
  89. )
  90. // NOTE: prepend, so we don't override user-specified scopes.
  91. opts = append([]option.ClientOption{scopesOption}, opts...)
  92. client, endpoint, err := htransport.NewClient(ctx, opts...)
  93. if err != nil {
  94. return nil, err
  95. }
  96. s, err := New(client)
  97. if err != nil {
  98. return nil, err
  99. }
  100. if endpoint != "" {
  101. s.BasePath = endpoint
  102. }
  103. return s, nil
  104. }
  105. // New creates a new Service. It uses the provided http.Client for requests.
  106. //
  107. // Deprecated: please use NewService instead.
  108. // To provide a custom HTTP client, use option.WithHTTPClient.
  109. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  110. func New(client *http.Client) (*Service, error) {
  111. if client == nil {
  112. return nil, errors.New("client is nil")
  113. }
  114. s := &Service{client: client, BasePath: basePath}
  115. s.Projects = NewProjectsService(s)
  116. return s, nil
  117. }
  118. type Service struct {
  119. client *http.Client
  120. BasePath string // API endpoint base URL
  121. UserAgent string // optional additional User-Agent fragment
  122. Projects *ProjectsService
  123. }
  124. func (s *Service) userAgent() string {
  125. if s.UserAgent == "" {
  126. return googleapi.UserAgent
  127. }
  128. return googleapi.UserAgent + " " + s.UserAgent
  129. }
  130. func NewProjectsService(s *Service) *ProjectsService {
  131. rs := &ProjectsService{s: s}
  132. rs.Traces = NewProjectsTracesService(s)
  133. return rs
  134. }
  135. type ProjectsService struct {
  136. s *Service
  137. Traces *ProjectsTracesService
  138. }
  139. func NewProjectsTracesService(s *Service) *ProjectsTracesService {
  140. rs := &ProjectsTracesService{s: s}
  141. return rs
  142. }
  143. type ProjectsTracesService struct {
  144. s *Service
  145. }
  146. // Empty: A generic empty message that you can re-use to avoid defining
  147. // duplicated
  148. // empty messages in your APIs. A typical example is to use it as the
  149. // request
  150. // or the response type of an API method. For instance:
  151. //
  152. // service Foo {
  153. // rpc Bar(google.protobuf.Empty) returns
  154. // (google.protobuf.Empty);
  155. // }
  156. //
  157. // The JSON representation for `Empty` is empty JSON object `{}`.
  158. type Empty struct {
  159. // ServerResponse contains the HTTP response code and headers from the
  160. // server.
  161. googleapi.ServerResponse `json:"-"`
  162. }
  163. // ListTracesResponse: The response message for the `ListTraces` method.
  164. type ListTracesResponse struct {
  165. // NextPageToken: If defined, indicates that there are more traces that
  166. // match the request
  167. // and that this value should be passed to the next request to
  168. // continue
  169. // retrieving additional traces.
  170. NextPageToken string `json:"nextPageToken,omitempty"`
  171. // Traces: List of trace records as specified by the view parameter.
  172. Traces []*Trace `json:"traces,omitempty"`
  173. // ServerResponse contains the HTTP response code and headers from the
  174. // server.
  175. googleapi.ServerResponse `json:"-"`
  176. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  177. // unconditionally include in API requests. By default, fields with
  178. // empty values are omitted from API requests. However, any non-pointer,
  179. // non-interface field appearing in ForceSendFields will be sent to the
  180. // server regardless of whether the field is empty or not. This may be
  181. // used to include empty fields in Patch requests.
  182. ForceSendFields []string `json:"-"`
  183. // NullFields is a list of field names (e.g. "NextPageToken") to include
  184. // in API requests with the JSON null value. By default, fields with
  185. // empty values are omitted from API requests. However, any field with
  186. // an empty value appearing in NullFields will be sent to the server as
  187. // null. It is an error if a field in this list has a non-empty value.
  188. // This may be used to include null fields in Patch requests.
  189. NullFields []string `json:"-"`
  190. }
  191. func (s *ListTracesResponse) MarshalJSON() ([]byte, error) {
  192. type NoMethod ListTracesResponse
  193. raw := NoMethod(*s)
  194. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  195. }
  196. // Trace: A trace describes how long it takes for an application to
  197. // perform an
  198. // operation. It consists of a set of spans, each of which represent a
  199. // single
  200. // timed event within the operation.
  201. type Trace struct {
  202. // ProjectId: Project ID of the Cloud project where the trace data is
  203. // stored.
  204. ProjectId string `json:"projectId,omitempty"`
  205. // Spans: Collection of spans in the trace.
  206. Spans []*TraceSpan `json:"spans,omitempty"`
  207. // TraceId: Globally unique identifier for the trace. This identifier is
  208. // a 128-bit
  209. // numeric value formatted as a 32-byte hex string. For
  210. // example,
  211. // `382d4f4c6b7bb2f4a972559d9085001d`.
  212. TraceId string `json:"traceId,omitempty"`
  213. // ServerResponse contains the HTTP response code and headers from the
  214. // server.
  215. googleapi.ServerResponse `json:"-"`
  216. // ForceSendFields is a list of field names (e.g. "ProjectId") to
  217. // unconditionally include in API requests. By default, fields with
  218. // empty values are omitted from API requests. However, any non-pointer,
  219. // non-interface field appearing in ForceSendFields will be sent to the
  220. // server regardless of whether the field is empty or not. This may be
  221. // used to include empty fields in Patch requests.
  222. ForceSendFields []string `json:"-"`
  223. // NullFields is a list of field names (e.g. "ProjectId") to include in
  224. // API requests with the JSON null value. By default, fields with empty
  225. // values are omitted from API requests. However, any field with an
  226. // empty value appearing in NullFields will be sent to the server as
  227. // null. It is an error if a field in this list has a non-empty value.
  228. // This may be used to include null fields in Patch requests.
  229. NullFields []string `json:"-"`
  230. }
  231. func (s *Trace) MarshalJSON() ([]byte, error) {
  232. type NoMethod Trace
  233. raw := NoMethod(*s)
  234. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  235. }
  236. // TraceSpan: A span represents a single timed event within a trace.
  237. // Spans can be nested
  238. // and form a trace tree. Often, a trace contains a root span that
  239. // describes the
  240. // end-to-end latency of an operation and, optionally, one or more
  241. // subspans for
  242. // its suboperations. Spans do not need to be contiguous. There may be
  243. // gaps
  244. // between spans in a trace.
  245. type TraceSpan struct {
  246. // EndTime: End time of the span in nanoseconds from the UNIX epoch.
  247. EndTime string `json:"endTime,omitempty"`
  248. // Kind: Distinguishes between spans generated in a particular context.
  249. // For example,
  250. // two spans with the same name may be distinguished using
  251. // `RPC_CLIENT`
  252. // and `RPC_SERVER` to identify queueing latency associated with the
  253. // span.
  254. //
  255. // Possible values:
  256. // "SPAN_KIND_UNSPECIFIED" - Unspecified.
  257. // "RPC_SERVER" - Indicates that the span covers server-side handling
  258. // of an RPC or other
  259. // remote network request.
  260. // "RPC_CLIENT" - Indicates that the span covers the client-side
  261. // wrapper around an RPC or
  262. // other remote request.
  263. Kind string `json:"kind,omitempty"`
  264. // Labels: Collection of labels associated with the span. Label keys
  265. // must be less than
  266. // 128 bytes. Label values must be less than 16 kilobytes (10MB
  267. // for
  268. // `/stacktrace` values).
  269. //
  270. // Some predefined label keys exist, or you may create your own. When
  271. // creating
  272. // your own, we recommend the following formats:
  273. //
  274. // * `/category/product/key` for agents of well-known products (e.g.
  275. // `/db/mongodb/read_size`).
  276. // * `short_host/path/key` for domain-specific keys (e.g.
  277. // `foo.com/myproduct/bar`)
  278. //
  279. // Predefined labels include:
  280. //
  281. // * `/agent`
  282. // * `/component`
  283. // * `/error/message`
  284. // * `/error/name`
  285. // * `/http/client_city`
  286. // * `/http/client_country`
  287. // * `/http/client_protocol`
  288. // * `/http/client_region`
  289. // * `/http/host`
  290. // * `/http/method`
  291. // * `/http/path`
  292. // * `/http/redirected_url`
  293. // * `/http/request/size`
  294. // * `/http/response/size`
  295. // * `/http/route`
  296. // * `/http/status_code`
  297. // * `/http/url`
  298. // * `/http/user_agent`
  299. // * `/pid`
  300. // * `/stacktrace`
  301. // * `/tid`
  302. Labels map[string]string `json:"labels,omitempty"`
  303. // Name: Name of the span. Must be less than 128 bytes. The span name is
  304. // sanitized
  305. // and displayed in the Stackdriver Trace tool in the
  306. // Google Cloud Platform Console.
  307. // The name may be a method name or some other per-call site name.
  308. // For the same executable and the same call point, a best practice
  309. // is
  310. // to use a consistent name, which makes it easier to
  311. // correlate
  312. // cross-trace spans.
  313. Name string `json:"name,omitempty"`
  314. // ParentSpanId: ID of the parent span, if any. Optional.
  315. ParentSpanId uint64 `json:"parentSpanId,omitempty,string"`
  316. // SpanId: Identifier for the span. Must be a 64-bit integer other than
  317. // 0 and
  318. // unique within a trace. For example, `2205310701640571284`.
  319. SpanId uint64 `json:"spanId,omitempty,string"`
  320. // StartTime: Start time of the span in nanoseconds from the UNIX epoch.
  321. StartTime string `json:"startTime,omitempty"`
  322. // ForceSendFields is a list of field names (e.g. "EndTime") to
  323. // unconditionally include in API requests. By default, fields with
  324. // empty values are omitted from API requests. However, any non-pointer,
  325. // non-interface field appearing in ForceSendFields will be sent to the
  326. // server regardless of whether the field is empty or not. This may be
  327. // used to include empty fields in Patch requests.
  328. ForceSendFields []string `json:"-"`
  329. // NullFields is a list of field names (e.g. "EndTime") to include in
  330. // API requests with the JSON null value. By default, fields with empty
  331. // values are omitted from API requests. However, any field with an
  332. // empty value appearing in NullFields will be sent to the server as
  333. // null. It is an error if a field in this list has a non-empty value.
  334. // This may be used to include null fields in Patch requests.
  335. NullFields []string `json:"-"`
  336. }
  337. func (s *TraceSpan) MarshalJSON() ([]byte, error) {
  338. type NoMethod TraceSpan
  339. raw := NoMethod(*s)
  340. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  341. }
  342. // Traces: List of new or updated traces.
  343. type Traces struct {
  344. // Traces: List of traces.
  345. Traces []*Trace `json:"traces,omitempty"`
  346. // ForceSendFields is a list of field names (e.g. "Traces") to
  347. // unconditionally include in API requests. By default, fields with
  348. // empty values are omitted from API requests. However, any non-pointer,
  349. // non-interface field appearing in ForceSendFields will be sent to the
  350. // server regardless of whether the field is empty or not. This may be
  351. // used to include empty fields in Patch requests.
  352. ForceSendFields []string `json:"-"`
  353. // NullFields is a list of field names (e.g. "Traces") to include in API
  354. // requests with the JSON null value. By default, fields with empty
  355. // values are omitted from API requests. However, any field with an
  356. // empty value appearing in NullFields will be sent to the server as
  357. // null. It is an error if a field in this list has a non-empty value.
  358. // This may be used to include null fields in Patch requests.
  359. NullFields []string `json:"-"`
  360. }
  361. func (s *Traces) MarshalJSON() ([]byte, error) {
  362. type NoMethod Traces
  363. raw := NoMethod(*s)
  364. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  365. }
  366. // method id "cloudtrace.projects.patchTraces":
  367. type ProjectsPatchTracesCall struct {
  368. s *Service
  369. projectId string
  370. traces *Traces
  371. urlParams_ gensupport.URLParams
  372. ctx_ context.Context
  373. header_ http.Header
  374. }
  375. // PatchTraces: Sends new traces to Stackdriver Trace or updates
  376. // existing traces. If the ID
  377. // of a trace that you send matches that of an existing trace, any
  378. // fields
  379. // in the existing trace and its spans are overwritten by the provided
  380. // values,
  381. // and any new fields provided are merged with the existing trace data.
  382. // If the
  383. // ID does not match, a new trace is created.
  384. func (r *ProjectsService) PatchTraces(projectId string, traces *Traces) *ProjectsPatchTracesCall {
  385. c := &ProjectsPatchTracesCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  386. c.projectId = projectId
  387. c.traces = traces
  388. return c
  389. }
  390. // Fields allows partial responses to be retrieved. See
  391. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  392. // for more information.
  393. func (c *ProjectsPatchTracesCall) Fields(s ...googleapi.Field) *ProjectsPatchTracesCall {
  394. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  395. return c
  396. }
  397. // Context sets the context to be used in this call's Do method. Any
  398. // pending HTTP request will be aborted if the provided context is
  399. // canceled.
  400. func (c *ProjectsPatchTracesCall) Context(ctx context.Context) *ProjectsPatchTracesCall {
  401. c.ctx_ = ctx
  402. return c
  403. }
  404. // Header returns an http.Header that can be modified by the caller to
  405. // add HTTP headers to the request.
  406. func (c *ProjectsPatchTracesCall) Header() http.Header {
  407. if c.header_ == nil {
  408. c.header_ = make(http.Header)
  409. }
  410. return c.header_
  411. }
  412. func (c *ProjectsPatchTracesCall) doRequest(alt string) (*http.Response, error) {
  413. reqHeaders := make(http.Header)
  414. for k, v := range c.header_ {
  415. reqHeaders[k] = v
  416. }
  417. reqHeaders.Set("User-Agent", c.s.userAgent())
  418. var body io.Reader = nil
  419. body, err := googleapi.WithoutDataWrapper.JSONReader(c.traces)
  420. if err != nil {
  421. return nil, err
  422. }
  423. reqHeaders.Set("Content-Type", "application/json")
  424. c.urlParams_.Set("alt", alt)
  425. c.urlParams_.Set("prettyPrint", "false")
  426. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces")
  427. urls += "?" + c.urlParams_.Encode()
  428. req, err := http.NewRequest("PATCH", urls, body)
  429. if err != nil {
  430. return nil, err
  431. }
  432. req.Header = reqHeaders
  433. googleapi.Expand(req.URL, map[string]string{
  434. "projectId": c.projectId,
  435. })
  436. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  437. }
  438. // Do executes the "cloudtrace.projects.patchTraces" call.
  439. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  440. // code is an error. Response headers are in either
  441. // *Empty.ServerResponse.Header or (if a response was returned at all)
  442. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  443. // check whether the returned error was because http.StatusNotModified
  444. // was returned.
  445. func (c *ProjectsPatchTracesCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  446. gensupport.SetOptions(c.urlParams_, opts...)
  447. res, err := c.doRequest("json")
  448. if res != nil && res.StatusCode == http.StatusNotModified {
  449. if res.Body != nil {
  450. res.Body.Close()
  451. }
  452. return nil, &googleapi.Error{
  453. Code: res.StatusCode,
  454. Header: res.Header,
  455. }
  456. }
  457. if err != nil {
  458. return nil, err
  459. }
  460. defer googleapi.CloseBody(res)
  461. if err := googleapi.CheckResponse(res); err != nil {
  462. return nil, err
  463. }
  464. ret := &Empty{
  465. ServerResponse: googleapi.ServerResponse{
  466. Header: res.Header,
  467. HTTPStatusCode: res.StatusCode,
  468. },
  469. }
  470. target := &ret
  471. if err := gensupport.DecodeResponse(target, res); err != nil {
  472. return nil, err
  473. }
  474. return ret, nil
  475. // {
  476. // "description": "Sends new traces to Stackdriver Trace or updates existing traces. If the ID\nof a trace that you send matches that of an existing trace, any fields\nin the existing trace and its spans are overwritten by the provided values,\nand any new fields provided are merged with the existing trace data. If the\nID does not match, a new trace is created.",
  477. // "flatPath": "v1/projects/{projectId}/traces",
  478. // "httpMethod": "PATCH",
  479. // "id": "cloudtrace.projects.patchTraces",
  480. // "parameterOrder": [
  481. // "projectId"
  482. // ],
  483. // "parameters": {
  484. // "projectId": {
  485. // "description": "ID of the Cloud project where the trace data is stored.",
  486. // "location": "path",
  487. // "required": true,
  488. // "type": "string"
  489. // }
  490. // },
  491. // "path": "v1/projects/{projectId}/traces",
  492. // "request": {
  493. // "$ref": "Traces"
  494. // },
  495. // "response": {
  496. // "$ref": "Empty"
  497. // },
  498. // "scopes": [
  499. // "https://www.googleapis.com/auth/cloud-platform",
  500. // "https://www.googleapis.com/auth/trace.append"
  501. // ]
  502. // }
  503. }
  504. // method id "cloudtrace.projects.traces.get":
  505. type ProjectsTracesGetCall struct {
  506. s *Service
  507. projectId string
  508. traceId string
  509. urlParams_ gensupport.URLParams
  510. ifNoneMatch_ string
  511. ctx_ context.Context
  512. header_ http.Header
  513. }
  514. // Get: Gets a single trace by its ID.
  515. func (r *ProjectsTracesService) Get(projectId string, traceId string) *ProjectsTracesGetCall {
  516. c := &ProjectsTracesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  517. c.projectId = projectId
  518. c.traceId = traceId
  519. return c
  520. }
  521. // Fields allows partial responses to be retrieved. See
  522. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  523. // for more information.
  524. func (c *ProjectsTracesGetCall) Fields(s ...googleapi.Field) *ProjectsTracesGetCall {
  525. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  526. return c
  527. }
  528. // IfNoneMatch sets the optional parameter which makes the operation
  529. // fail if the object's ETag matches the given value. This is useful for
  530. // getting updates only after the object has changed since the last
  531. // request. Use googleapi.IsNotModified to check whether the response
  532. // error from Do is the result of In-None-Match.
  533. func (c *ProjectsTracesGetCall) IfNoneMatch(entityTag string) *ProjectsTracesGetCall {
  534. c.ifNoneMatch_ = entityTag
  535. return c
  536. }
  537. // Context sets the context to be used in this call's Do method. Any
  538. // pending HTTP request will be aborted if the provided context is
  539. // canceled.
  540. func (c *ProjectsTracesGetCall) Context(ctx context.Context) *ProjectsTracesGetCall {
  541. c.ctx_ = ctx
  542. return c
  543. }
  544. // Header returns an http.Header that can be modified by the caller to
  545. // add HTTP headers to the request.
  546. func (c *ProjectsTracesGetCall) Header() http.Header {
  547. if c.header_ == nil {
  548. c.header_ = make(http.Header)
  549. }
  550. return c.header_
  551. }
  552. func (c *ProjectsTracesGetCall) doRequest(alt string) (*http.Response, error) {
  553. reqHeaders := make(http.Header)
  554. for k, v := range c.header_ {
  555. reqHeaders[k] = v
  556. }
  557. reqHeaders.Set("User-Agent", c.s.userAgent())
  558. if c.ifNoneMatch_ != "" {
  559. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  560. }
  561. var body io.Reader = nil
  562. c.urlParams_.Set("alt", alt)
  563. c.urlParams_.Set("prettyPrint", "false")
  564. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces/{traceId}")
  565. urls += "?" + c.urlParams_.Encode()
  566. req, err := http.NewRequest("GET", urls, body)
  567. if err != nil {
  568. return nil, err
  569. }
  570. req.Header = reqHeaders
  571. googleapi.Expand(req.URL, map[string]string{
  572. "projectId": c.projectId,
  573. "traceId": c.traceId,
  574. })
  575. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  576. }
  577. // Do executes the "cloudtrace.projects.traces.get" call.
  578. // Exactly one of *Trace or error will be non-nil. Any non-2xx status
  579. // code is an error. Response headers are in either
  580. // *Trace.ServerResponse.Header or (if a response was returned at all)
  581. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  582. // check whether the returned error was because http.StatusNotModified
  583. // was returned.
  584. func (c *ProjectsTracesGetCall) Do(opts ...googleapi.CallOption) (*Trace, error) {
  585. gensupport.SetOptions(c.urlParams_, opts...)
  586. res, err := c.doRequest("json")
  587. if res != nil && res.StatusCode == http.StatusNotModified {
  588. if res.Body != nil {
  589. res.Body.Close()
  590. }
  591. return nil, &googleapi.Error{
  592. Code: res.StatusCode,
  593. Header: res.Header,
  594. }
  595. }
  596. if err != nil {
  597. return nil, err
  598. }
  599. defer googleapi.CloseBody(res)
  600. if err := googleapi.CheckResponse(res); err != nil {
  601. return nil, err
  602. }
  603. ret := &Trace{
  604. ServerResponse: googleapi.ServerResponse{
  605. Header: res.Header,
  606. HTTPStatusCode: res.StatusCode,
  607. },
  608. }
  609. target := &ret
  610. if err := gensupport.DecodeResponse(target, res); err != nil {
  611. return nil, err
  612. }
  613. return ret, nil
  614. // {
  615. // "description": "Gets a single trace by its ID.",
  616. // "flatPath": "v1/projects/{projectId}/traces/{traceId}",
  617. // "httpMethod": "GET",
  618. // "id": "cloudtrace.projects.traces.get",
  619. // "parameterOrder": [
  620. // "projectId",
  621. // "traceId"
  622. // ],
  623. // "parameters": {
  624. // "projectId": {
  625. // "description": "ID of the Cloud project where the trace data is stored.",
  626. // "location": "path",
  627. // "required": true,
  628. // "type": "string"
  629. // },
  630. // "traceId": {
  631. // "description": "ID of the trace to return.",
  632. // "location": "path",
  633. // "required": true,
  634. // "type": "string"
  635. // }
  636. // },
  637. // "path": "v1/projects/{projectId}/traces/{traceId}",
  638. // "response": {
  639. // "$ref": "Trace"
  640. // },
  641. // "scopes": [
  642. // "https://www.googleapis.com/auth/cloud-platform",
  643. // "https://www.googleapis.com/auth/trace.readonly"
  644. // ]
  645. // }
  646. }
  647. // method id "cloudtrace.projects.traces.list":
  648. type ProjectsTracesListCall struct {
  649. s *Service
  650. projectId string
  651. urlParams_ gensupport.URLParams
  652. ifNoneMatch_ string
  653. ctx_ context.Context
  654. header_ http.Header
  655. }
  656. // List: Returns of a list of traces that match the specified filter
  657. // conditions.
  658. func (r *ProjectsTracesService) List(projectId string) *ProjectsTracesListCall {
  659. c := &ProjectsTracesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  660. c.projectId = projectId
  661. return c
  662. }
  663. // EndTime sets the optional parameter "endTime": End of the time
  664. // interval (inclusive) during which the trace data was
  665. // collected from the application.
  666. func (c *ProjectsTracesListCall) EndTime(endTime string) *ProjectsTracesListCall {
  667. c.urlParams_.Set("endTime", endTime)
  668. return c
  669. }
  670. // Filter sets the optional parameter "filter": An optional filter
  671. // against labels for the request.
  672. //
  673. // By default, searches use prefix matching. To specify exact match,
  674. // prepend
  675. // a plus symbol (`+`) to the search term.
  676. // Multiple terms are ANDed. Syntax:
  677. //
  678. // * `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any
  679. // root
  680. // span starts with `NAME_PREFIX`.
  681. // * `+root:NAME` or `+NAME`: Return traces where any root span's name
  682. // is
  683. // exactly `NAME`.
  684. // * `span:NAME_PREFIX`: Return traces where any span starts with
  685. // `NAME_PREFIX`.
  686. // * `+span:NAME`: Return traces where any span's name is exactly
  687. // `NAME`.
  688. // * `latency:DURATION`: Return traces whose overall latency is
  689. // greater or equal to than `DURATION`. Accepted units are
  690. // nanoseconds
  691. // (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`.
  692. // For
  693. // example, `latency:24ms` returns traces whose overall latency
  694. // is greater than or equal to 24 milliseconds.
  695. // * `label:LABEL_KEY`: Return all traces containing the specified
  696. // label key (exact match, case-sensitive) regardless of the
  697. // key:value
  698. // pair's value (including empty values).
  699. // * `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the
  700. // specified
  701. // label key (exact match, case-sensitive) whose value starts with
  702. // `VALUE_PREFIX`. Both a key and a value must be specified.
  703. // * `+LABEL_KEY:VALUE`: Return all traces containing a key:value
  704. // pair
  705. // exactly matching the specified text. Both a key and a value must
  706. // be
  707. // specified.
  708. // * `method:VALUE`: Equivalent to `/http/method:VALUE`.
  709. // * `url:VALUE`: Equivalent to `/http/url:VALUE`.
  710. func (c *ProjectsTracesListCall) Filter(filter string) *ProjectsTracesListCall {
  711. c.urlParams_.Set("filter", filter)
  712. return c
  713. }
  714. // OrderBy sets the optional parameter "orderBy": Field used to sort the
  715. // returned traces.
  716. // Can be one of the following:
  717. //
  718. // * `trace_id`
  719. // * `name` (`name` field of root span in the trace)
  720. // * `duration` (difference between `end_time` and `start_time` fields
  721. // of
  722. // the root span)
  723. // * `start` (`start_time` field of the root span)
  724. //
  725. // Descending order can be specified by appending `desc` to the sort
  726. // field
  727. // (for example, `name desc`).
  728. //
  729. // Only one sort field is permitted.
  730. func (c *ProjectsTracesListCall) OrderBy(orderBy string) *ProjectsTracesListCall {
  731. c.urlParams_.Set("orderBy", orderBy)
  732. return c
  733. }
  734. // PageSize sets the optional parameter "pageSize": Maximum number of
  735. // traces to return. If not specified or <= 0, the
  736. // implementation selects a reasonable value. The implementation
  737. // may
  738. // return fewer traces than the requested page size.
  739. func (c *ProjectsTracesListCall) PageSize(pageSize int64) *ProjectsTracesListCall {
  740. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  741. return c
  742. }
  743. // PageToken sets the optional parameter "pageToken": Token identifying
  744. // the page of results to return. If provided, use the
  745. // value of the `next_page_token` field from a previous request.
  746. func (c *ProjectsTracesListCall) PageToken(pageToken string) *ProjectsTracesListCall {
  747. c.urlParams_.Set("pageToken", pageToken)
  748. return c
  749. }
  750. // StartTime sets the optional parameter "startTime": Start of the time
  751. // interval (inclusive) during which the trace data was
  752. // collected from the application.
  753. func (c *ProjectsTracesListCall) StartTime(startTime string) *ProjectsTracesListCall {
  754. c.urlParams_.Set("startTime", startTime)
  755. return c
  756. }
  757. // View sets the optional parameter "view": Type of data returned for
  758. // traces in the list. Default is
  759. // `MINIMAL`.
  760. //
  761. // Possible values:
  762. // "VIEW_TYPE_UNSPECIFIED"
  763. // "MINIMAL"
  764. // "ROOTSPAN"
  765. // "COMPLETE"
  766. func (c *ProjectsTracesListCall) View(view string) *ProjectsTracesListCall {
  767. c.urlParams_.Set("view", view)
  768. return c
  769. }
  770. // Fields allows partial responses to be retrieved. See
  771. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  772. // for more information.
  773. func (c *ProjectsTracesListCall) Fields(s ...googleapi.Field) *ProjectsTracesListCall {
  774. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  775. return c
  776. }
  777. // IfNoneMatch sets the optional parameter which makes the operation
  778. // fail if the object's ETag matches the given value. This is useful for
  779. // getting updates only after the object has changed since the last
  780. // request. Use googleapi.IsNotModified to check whether the response
  781. // error from Do is the result of In-None-Match.
  782. func (c *ProjectsTracesListCall) IfNoneMatch(entityTag string) *ProjectsTracesListCall {
  783. c.ifNoneMatch_ = entityTag
  784. return c
  785. }
  786. // Context sets the context to be used in this call's Do method. Any
  787. // pending HTTP request will be aborted if the provided context is
  788. // canceled.
  789. func (c *ProjectsTracesListCall) Context(ctx context.Context) *ProjectsTracesListCall {
  790. c.ctx_ = ctx
  791. return c
  792. }
  793. // Header returns an http.Header that can be modified by the caller to
  794. // add HTTP headers to the request.
  795. func (c *ProjectsTracesListCall) Header() http.Header {
  796. if c.header_ == nil {
  797. c.header_ = make(http.Header)
  798. }
  799. return c.header_
  800. }
  801. func (c *ProjectsTracesListCall) doRequest(alt string) (*http.Response, error) {
  802. reqHeaders := make(http.Header)
  803. for k, v := range c.header_ {
  804. reqHeaders[k] = v
  805. }
  806. reqHeaders.Set("User-Agent", c.s.userAgent())
  807. if c.ifNoneMatch_ != "" {
  808. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  809. }
  810. var body io.Reader = nil
  811. c.urlParams_.Set("alt", alt)
  812. c.urlParams_.Set("prettyPrint", "false")
  813. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces")
  814. urls += "?" + c.urlParams_.Encode()
  815. req, err := http.NewRequest("GET", urls, body)
  816. if err != nil {
  817. return nil, err
  818. }
  819. req.Header = reqHeaders
  820. googleapi.Expand(req.URL, map[string]string{
  821. "projectId": c.projectId,
  822. })
  823. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  824. }
  825. // Do executes the "cloudtrace.projects.traces.list" call.
  826. // Exactly one of *ListTracesResponse or error will be non-nil. Any
  827. // non-2xx status code is an error. Response headers are in either
  828. // *ListTracesResponse.ServerResponse.Header or (if a response was
  829. // returned at all) in error.(*googleapi.Error).Header. Use
  830. // googleapi.IsNotModified to check whether the returned error was
  831. // because http.StatusNotModified was returned.
  832. func (c *ProjectsTracesListCall) Do(opts ...googleapi.CallOption) (*ListTracesResponse, error) {
  833. gensupport.SetOptions(c.urlParams_, opts...)
  834. res, err := c.doRequest("json")
  835. if res != nil && res.StatusCode == http.StatusNotModified {
  836. if res.Body != nil {
  837. res.Body.Close()
  838. }
  839. return nil, &googleapi.Error{
  840. Code: res.StatusCode,
  841. Header: res.Header,
  842. }
  843. }
  844. if err != nil {
  845. return nil, err
  846. }
  847. defer googleapi.CloseBody(res)
  848. if err := googleapi.CheckResponse(res); err != nil {
  849. return nil, err
  850. }
  851. ret := &ListTracesResponse{
  852. ServerResponse: googleapi.ServerResponse{
  853. Header: res.Header,
  854. HTTPStatusCode: res.StatusCode,
  855. },
  856. }
  857. target := &ret
  858. if err := gensupport.DecodeResponse(target, res); err != nil {
  859. return nil, err
  860. }
  861. return ret, nil
  862. // {
  863. // "description": "Returns of a list of traces that match the specified filter conditions.",
  864. // "flatPath": "v1/projects/{projectId}/traces",
  865. // "httpMethod": "GET",
  866. // "id": "cloudtrace.projects.traces.list",
  867. // "parameterOrder": [
  868. // "projectId"
  869. // ],
  870. // "parameters": {
  871. // "endTime": {
  872. // "description": "End of the time interval (inclusive) during which the trace data was\ncollected from the application.",
  873. // "format": "google-datetime",
  874. // "location": "query",
  875. // "type": "string"
  876. // },
  877. // "filter": {
  878. // "description": "An optional filter against labels for the request.\n\nBy default, searches use prefix matching. To specify exact match, prepend\na plus symbol (`+`) to the search term.\nMultiple terms are ANDed. Syntax:\n\n* `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any root\n span starts with `NAME_PREFIX`.\n* `+root:NAME` or `+NAME`: Return traces where any root span's name is\n exactly `NAME`.\n* `span:NAME_PREFIX`: Return traces where any span starts with\n `NAME_PREFIX`.\n* `+span:NAME`: Return traces where any span's name is exactly\n `NAME`.\n* `latency:DURATION`: Return traces whose overall latency is\n greater or equal to than `DURATION`. Accepted units are nanoseconds\n (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For\n example, `latency:24ms` returns traces whose overall latency\n is greater than or equal to 24 milliseconds.\n* `label:LABEL_KEY`: Return all traces containing the specified\n label key (exact match, case-sensitive) regardless of the key:value\n pair's value (including empty values).\n* `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the specified\n label key (exact match, case-sensitive) whose value starts with\n `VALUE_PREFIX`. Both a key and a value must be specified.\n* `+LABEL_KEY:VALUE`: Return all traces containing a key:value pair\n exactly matching the specified text. Both a key and a value must be\n specified.\n* `method:VALUE`: Equivalent to `/http/method:VALUE`.\n* `url:VALUE`: Equivalent to `/http/url:VALUE`.",
  879. // "location": "query",
  880. // "type": "string"
  881. // },
  882. // "orderBy": {
  883. // "description": "Field used to sort the returned traces. Optional.\nCan be one of the following:\n\n* `trace_id`\n* `name` (`name` field of root span in the trace)\n* `duration` (difference between `end_time` and `start_time` fields of\n the root span)\n* `start` (`start_time` field of the root span)\n\nDescending order can be specified by appending `desc` to the sort field\n(for example, `name desc`).\n\nOnly one sort field is permitted.",
  884. // "location": "query",
  885. // "type": "string"
  886. // },
  887. // "pageSize": {
  888. // "description": "Maximum number of traces to return. If not specified or \u003c= 0, the\nimplementation selects a reasonable value. The implementation may\nreturn fewer traces than the requested page size. Optional.",
  889. // "format": "int32",
  890. // "location": "query",
  891. // "type": "integer"
  892. // },
  893. // "pageToken": {
  894. // "description": "Token identifying the page of results to return. If provided, use the\nvalue of the `next_page_token` field from a previous request. Optional.",
  895. // "location": "query",
  896. // "type": "string"
  897. // },
  898. // "projectId": {
  899. // "description": "ID of the Cloud project where the trace data is stored.",
  900. // "location": "path",
  901. // "required": true,
  902. // "type": "string"
  903. // },
  904. // "startTime": {
  905. // "description": "Start of the time interval (inclusive) during which the trace data was\ncollected from the application.",
  906. // "format": "google-datetime",
  907. // "location": "query",
  908. // "type": "string"
  909. // },
  910. // "view": {
  911. // "description": "Type of data returned for traces in the list. Optional. Default is\n`MINIMAL`.",
  912. // "enum": [
  913. // "VIEW_TYPE_UNSPECIFIED",
  914. // "MINIMAL",
  915. // "ROOTSPAN",
  916. // "COMPLETE"
  917. // ],
  918. // "location": "query",
  919. // "type": "string"
  920. // }
  921. // },
  922. // "path": "v1/projects/{projectId}/traces",
  923. // "response": {
  924. // "$ref": "ListTracesResponse"
  925. // },
  926. // "scopes": [
  927. // "https://www.googleapis.com/auth/cloud-platform",
  928. // "https://www.googleapis.com/auth/trace.readonly"
  929. // ]
  930. // }
  931. }
  932. // Pages invokes f for each page of results.
  933. // A non-nil error returned from f will halt the iteration.
  934. // The provided context supersedes any context provided to the Context method.
  935. func (c *ProjectsTracesListCall) Pages(ctx context.Context, f func(*ListTracesResponse) error) error {
  936. c.ctx_ = ctx
  937. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  938. for {
  939. x, err := c.Do()
  940. if err != nil {
  941. return err
  942. }
  943. if err := f(x); err != nil {
  944. return err
  945. }
  946. if x.NextPageToken == "" {
  947. return nil
  948. }
  949. c.PageToken(x.NextPageToken)
  950. }
  951. }