cloudtrace-gen.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. // Package cloudtrace provides access to the Google Cloud Trace API.
  2. //
  3. // See https://cloud.google.com/tools/cloud-trace
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/cloudtrace/v1"
  8. // ...
  9. // cloudtraceService, err := cloudtrace.New(oauthHttpClient)
  10. package cloudtrace // import "google.golang.org/api/cloudtrace/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 = "cloudtrace:v1"
  41. const apiName = "cloudtrace"
  42. const apiVersion = "v1"
  43. const basePath = "https://cloudtrace.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.Projects = NewProjectsService(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. Projects *ProjectsService
  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 NewProjectsService(s *Service) *ProjectsService {
  70. rs := &ProjectsService{s: s}
  71. rs.Traces = NewProjectsTracesService(s)
  72. return rs
  73. }
  74. type ProjectsService struct {
  75. s *Service
  76. Traces *ProjectsTracesService
  77. }
  78. func NewProjectsTracesService(s *Service) *ProjectsTracesService {
  79. rs := &ProjectsTracesService{s: s}
  80. return rs
  81. }
  82. type ProjectsTracesService struct {
  83. s *Service
  84. }
  85. // Empty: A generic empty message that you can re-use to avoid defining
  86. // duplicated empty messages in your APIs. A typical example is to use
  87. // it as the request or the response type of an API method. For
  88. // instance: service Foo { rpc Bar(google.protobuf.Empty) returns
  89. // (google.protobuf.Empty); } The JSON representation for `Empty` is
  90. // empty JSON object `{}`.
  91. type Empty struct {
  92. // ServerResponse contains the HTTP response code and headers from the
  93. // server.
  94. googleapi.ServerResponse `json:"-"`
  95. }
  96. // ListTracesResponse: The response message for the `ListTraces` method.
  97. type ListTracesResponse struct {
  98. // NextPageToken: If defined, indicates that there are more traces that
  99. // match the request and that this value should be passed to the next
  100. // request to continue retrieving additional traces.
  101. NextPageToken string `json:"nextPageToken,omitempty"`
  102. // Traces: List of trace records returned.
  103. Traces []*Trace `json:"traces,omitempty"`
  104. // ServerResponse contains the HTTP response code and headers from the
  105. // server.
  106. googleapi.ServerResponse `json:"-"`
  107. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  108. // unconditionally include in API requests. By default, fields with
  109. // empty values are omitted from API requests. However, any non-pointer,
  110. // non-interface field appearing in ForceSendFields will be sent to the
  111. // server regardless of whether the field is empty or not. This may be
  112. // used to include empty fields in Patch requests.
  113. ForceSendFields []string `json:"-"`
  114. }
  115. func (s *ListTracesResponse) MarshalJSON() ([]byte, error) {
  116. type noMethod ListTracesResponse
  117. raw := noMethod(*s)
  118. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  119. }
  120. // Trace: A trace describes how long it takes for an application to
  121. // perform an operation. It consists of a set of spans, each of which
  122. // represent a single timed event within the operation.
  123. type Trace struct {
  124. // ProjectId: Project ID of the Cloud project where the trace data is
  125. // stored.
  126. ProjectId string `json:"projectId,omitempty"`
  127. // Spans: Collection of spans in the trace.
  128. Spans []*TraceSpan `json:"spans,omitempty"`
  129. // TraceId: Globally unique identifier for the trace. This identifier is
  130. // a 128-bit numeric value formatted as a 32-byte hex string.
  131. TraceId string `json:"traceId,omitempty"`
  132. // ServerResponse contains the HTTP response code and headers from the
  133. // server.
  134. googleapi.ServerResponse `json:"-"`
  135. // ForceSendFields is a list of field names (e.g. "ProjectId") to
  136. // unconditionally include in API requests. By default, fields with
  137. // empty values are omitted from API requests. However, any non-pointer,
  138. // non-interface field appearing in ForceSendFields will be sent to the
  139. // server regardless of whether the field is empty or not. This may be
  140. // used to include empty fields in Patch requests.
  141. ForceSendFields []string `json:"-"`
  142. }
  143. func (s *Trace) MarshalJSON() ([]byte, error) {
  144. type noMethod Trace
  145. raw := noMethod(*s)
  146. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  147. }
  148. // TraceSpan: A span represents a single timed event within a trace.
  149. // Spans can be nested and form a trace tree. Often, a trace contains a
  150. // root span that describes the end-to-end latency of an operation and,
  151. // optionally, one or more subspans for its suboperations. Spans do not
  152. // need to be contiguous. There may be gaps between spans in a trace.
  153. type TraceSpan struct {
  154. // EndTime: End time of the span in nanoseconds from the UNIX epoch.
  155. EndTime string `json:"endTime,omitempty"`
  156. // Kind: Distinguishes between spans generated in a particular context.
  157. // For example, two spans with the same name may be distinguished using
  158. // `RPC_CLIENT` and `RPC_SERVER` to identify queueing latency associated
  159. // with the span.
  160. //
  161. // Possible values:
  162. // "SPAN_KIND_UNSPECIFIED"
  163. // "RPC_SERVER"
  164. // "RPC_CLIENT"
  165. Kind string `json:"kind,omitempty"`
  166. // Labels: Collection of labels associated with the span.
  167. Labels map[string]string `json:"labels,omitempty"`
  168. // Name: Name of the trace. The trace name is sanitized and displayed in
  169. // the Cloud Trace tool in the Google Developers Console. The name may
  170. // be a method name or some other per-call site name. For the same
  171. // executable and the same call point, a best practice is to use a
  172. // consistent name, which makes it easier to correlate cross-trace
  173. // spans.
  174. Name string `json:"name,omitempty"`
  175. // ParentSpanId: ID of the parent span, if any. Optional.
  176. ParentSpanId uint64 `json:"parentSpanId,omitempty,string"`
  177. // SpanId: Identifier for the span. This identifier must be unique
  178. // within a trace.
  179. SpanId uint64 `json:"spanId,omitempty,string"`
  180. // StartTime: Start time of the span in nanoseconds from the UNIX epoch.
  181. StartTime string `json:"startTime,omitempty"`
  182. // ForceSendFields is a list of field names (e.g. "EndTime") to
  183. // unconditionally include in API requests. By default, fields with
  184. // empty values are omitted from API requests. However, any non-pointer,
  185. // non-interface field appearing in ForceSendFields will be sent to the
  186. // server regardless of whether the field is empty or not. This may be
  187. // used to include empty fields in Patch requests.
  188. ForceSendFields []string `json:"-"`
  189. }
  190. func (s *TraceSpan) MarshalJSON() ([]byte, error) {
  191. type noMethod TraceSpan
  192. raw := noMethod(*s)
  193. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  194. }
  195. // Traces: List of new or updated traces.
  196. type Traces struct {
  197. // Traces: List of traces.
  198. Traces []*Trace `json:"traces,omitempty"`
  199. // ForceSendFields is a list of field names (e.g. "Traces") to
  200. // unconditionally include in API requests. By default, fields with
  201. // empty values are omitted from API requests. However, any non-pointer,
  202. // non-interface field appearing in ForceSendFields will be sent to the
  203. // server regardless of whether the field is empty or not. This may be
  204. // used to include empty fields in Patch requests.
  205. ForceSendFields []string `json:"-"`
  206. }
  207. func (s *Traces) MarshalJSON() ([]byte, error) {
  208. type noMethod Traces
  209. raw := noMethod(*s)
  210. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  211. }
  212. // method id "cloudtrace.projects.patchTraces":
  213. type ProjectsPatchTracesCall struct {
  214. s *Service
  215. projectId string
  216. traces *Traces
  217. urlParams_ gensupport.URLParams
  218. ctx_ context.Context
  219. }
  220. // PatchTraces: Sends new traces to Cloud Trace or updates existing
  221. // traces. If the ID of a trace that you send matches that of an
  222. // existing trace, any fields in the existing trace and its spans are
  223. // overwritten by the provided values, and any new fields provided are
  224. // merged with the existing trace data. If the ID does not match, a new
  225. // trace is created.
  226. func (r *ProjectsService) PatchTraces(projectId string, traces *Traces) *ProjectsPatchTracesCall {
  227. c := &ProjectsPatchTracesCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  228. c.projectId = projectId
  229. c.traces = traces
  230. return c
  231. }
  232. // Fields allows partial responses to be retrieved. See
  233. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  234. // for more information.
  235. func (c *ProjectsPatchTracesCall) Fields(s ...googleapi.Field) *ProjectsPatchTracesCall {
  236. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  237. return c
  238. }
  239. // Context sets the context to be used in this call's Do method. Any
  240. // pending HTTP request will be aborted if the provided context is
  241. // canceled.
  242. func (c *ProjectsPatchTracesCall) Context(ctx context.Context) *ProjectsPatchTracesCall {
  243. c.ctx_ = ctx
  244. return c
  245. }
  246. func (c *ProjectsPatchTracesCall) doRequest(alt string) (*http.Response, error) {
  247. var body io.Reader = nil
  248. body, err := googleapi.WithoutDataWrapper.JSONReader(c.traces)
  249. if err != nil {
  250. return nil, err
  251. }
  252. ctype := "application/json"
  253. c.urlParams_.Set("alt", alt)
  254. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces")
  255. urls += "?" + c.urlParams_.Encode()
  256. req, _ := http.NewRequest("PATCH", urls, body)
  257. googleapi.Expand(req.URL, map[string]string{
  258. "projectId": c.projectId,
  259. })
  260. req.Header.Set("Content-Type", ctype)
  261. req.Header.Set("User-Agent", c.s.userAgent())
  262. if c.ctx_ != nil {
  263. return ctxhttp.Do(c.ctx_, c.s.client, req)
  264. }
  265. return c.s.client.Do(req)
  266. }
  267. // Do executes the "cloudtrace.projects.patchTraces" call.
  268. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  269. // code is an error. Response headers are in either
  270. // *Empty.ServerResponse.Header or (if a response was returned at all)
  271. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  272. // check whether the returned error was because http.StatusNotModified
  273. // was returned.
  274. func (c *ProjectsPatchTracesCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  275. gensupport.SetOptions(c.urlParams_, opts...)
  276. res, err := c.doRequest("json")
  277. if res != nil && res.StatusCode == http.StatusNotModified {
  278. if res.Body != nil {
  279. res.Body.Close()
  280. }
  281. return nil, &googleapi.Error{
  282. Code: res.StatusCode,
  283. Header: res.Header,
  284. }
  285. }
  286. if err != nil {
  287. return nil, err
  288. }
  289. defer googleapi.CloseBody(res)
  290. if err := googleapi.CheckResponse(res); err != nil {
  291. return nil, err
  292. }
  293. ret := &Empty{
  294. ServerResponse: googleapi.ServerResponse{
  295. Header: res.Header,
  296. HTTPStatusCode: res.StatusCode,
  297. },
  298. }
  299. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  300. return nil, err
  301. }
  302. return ret, nil
  303. // {
  304. // "description": "Sends new traces to Cloud Trace or updates existing traces. If the ID of a trace that you send matches that of an existing trace, any fields in the existing trace and its spans are overwritten by the provided values, and any new fields provided are merged with the existing trace data. If the ID does not match, a new trace is created.",
  305. // "httpMethod": "PATCH",
  306. // "id": "cloudtrace.projects.patchTraces",
  307. // "parameterOrder": [
  308. // "projectId"
  309. // ],
  310. // "parameters": {
  311. // "projectId": {
  312. // "description": "ID of the Cloud project where the trace data is stored.",
  313. // "location": "path",
  314. // "required": true,
  315. // "type": "string"
  316. // }
  317. // },
  318. // "path": "v1/projects/{projectId}/traces",
  319. // "request": {
  320. // "$ref": "Traces"
  321. // },
  322. // "response": {
  323. // "$ref": "Empty"
  324. // },
  325. // "scopes": [
  326. // "https://www.googleapis.com/auth/cloud-platform"
  327. // ]
  328. // }
  329. }
  330. // method id "cloudtrace.projects.traces.get":
  331. type ProjectsTracesGetCall struct {
  332. s *Service
  333. projectId string
  334. traceId string
  335. urlParams_ gensupport.URLParams
  336. ifNoneMatch_ string
  337. ctx_ context.Context
  338. }
  339. // Get: Gets a single trace by its ID.
  340. func (r *ProjectsTracesService) Get(projectId string, traceId string) *ProjectsTracesGetCall {
  341. c := &ProjectsTracesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  342. c.projectId = projectId
  343. c.traceId = traceId
  344. return c
  345. }
  346. // Fields allows partial responses to be retrieved. See
  347. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  348. // for more information.
  349. func (c *ProjectsTracesGetCall) Fields(s ...googleapi.Field) *ProjectsTracesGetCall {
  350. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  351. return c
  352. }
  353. // IfNoneMatch sets the optional parameter which makes the operation
  354. // fail if the object's ETag matches the given value. This is useful for
  355. // getting updates only after the object has changed since the last
  356. // request. Use googleapi.IsNotModified to check whether the response
  357. // error from Do is the result of In-None-Match.
  358. func (c *ProjectsTracesGetCall) IfNoneMatch(entityTag string) *ProjectsTracesGetCall {
  359. c.ifNoneMatch_ = entityTag
  360. return c
  361. }
  362. // Context sets the context to be used in this call's Do method. Any
  363. // pending HTTP request will be aborted if the provided context is
  364. // canceled.
  365. func (c *ProjectsTracesGetCall) Context(ctx context.Context) *ProjectsTracesGetCall {
  366. c.ctx_ = ctx
  367. return c
  368. }
  369. func (c *ProjectsTracesGetCall) doRequest(alt string) (*http.Response, error) {
  370. var body io.Reader = nil
  371. c.urlParams_.Set("alt", alt)
  372. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces/{traceId}")
  373. urls += "?" + c.urlParams_.Encode()
  374. req, _ := http.NewRequest("GET", urls, body)
  375. googleapi.Expand(req.URL, map[string]string{
  376. "projectId": c.projectId,
  377. "traceId": c.traceId,
  378. })
  379. req.Header.Set("User-Agent", c.s.userAgent())
  380. if c.ifNoneMatch_ != "" {
  381. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  382. }
  383. if c.ctx_ != nil {
  384. return ctxhttp.Do(c.ctx_, c.s.client, req)
  385. }
  386. return c.s.client.Do(req)
  387. }
  388. // Do executes the "cloudtrace.projects.traces.get" call.
  389. // Exactly one of *Trace or error will be non-nil. Any non-2xx status
  390. // code is an error. Response headers are in either
  391. // *Trace.ServerResponse.Header or (if a response was returned at all)
  392. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  393. // check whether the returned error was because http.StatusNotModified
  394. // was returned.
  395. func (c *ProjectsTracesGetCall) Do(opts ...googleapi.CallOption) (*Trace, error) {
  396. gensupport.SetOptions(c.urlParams_, opts...)
  397. res, err := c.doRequest("json")
  398. if res != nil && res.StatusCode == http.StatusNotModified {
  399. if res.Body != nil {
  400. res.Body.Close()
  401. }
  402. return nil, &googleapi.Error{
  403. Code: res.StatusCode,
  404. Header: res.Header,
  405. }
  406. }
  407. if err != nil {
  408. return nil, err
  409. }
  410. defer googleapi.CloseBody(res)
  411. if err := googleapi.CheckResponse(res); err != nil {
  412. return nil, err
  413. }
  414. ret := &Trace{
  415. ServerResponse: googleapi.ServerResponse{
  416. Header: res.Header,
  417. HTTPStatusCode: res.StatusCode,
  418. },
  419. }
  420. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  421. return nil, err
  422. }
  423. return ret, nil
  424. // {
  425. // "description": "Gets a single trace by its ID.",
  426. // "httpMethod": "GET",
  427. // "id": "cloudtrace.projects.traces.get",
  428. // "parameterOrder": [
  429. // "projectId",
  430. // "traceId"
  431. // ],
  432. // "parameters": {
  433. // "projectId": {
  434. // "description": "ID of the Cloud project where the trace data is stored.",
  435. // "location": "path",
  436. // "required": true,
  437. // "type": "string"
  438. // },
  439. // "traceId": {
  440. // "description": "ID of the trace to return.",
  441. // "location": "path",
  442. // "required": true,
  443. // "type": "string"
  444. // }
  445. // },
  446. // "path": "v1/projects/{projectId}/traces/{traceId}",
  447. // "response": {
  448. // "$ref": "Trace"
  449. // },
  450. // "scopes": [
  451. // "https://www.googleapis.com/auth/cloud-platform"
  452. // ]
  453. // }
  454. }
  455. // method id "cloudtrace.projects.traces.list":
  456. type ProjectsTracesListCall struct {
  457. s *Service
  458. projectId string
  459. urlParams_ gensupport.URLParams
  460. ifNoneMatch_ string
  461. ctx_ context.Context
  462. }
  463. // List: Returns of a list of traces that match the specified filter
  464. // conditions.
  465. func (r *ProjectsTracesService) List(projectId string) *ProjectsTracesListCall {
  466. c := &ProjectsTracesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  467. c.projectId = projectId
  468. return c
  469. }
  470. // EndTime sets the optional parameter "endTime": Start of the time
  471. // interval (inclusive) during which the trace data was collected from
  472. // the application.
  473. func (c *ProjectsTracesListCall) EndTime(endTime string) *ProjectsTracesListCall {
  474. c.urlParams_.Set("endTime", endTime)
  475. return c
  476. }
  477. // Filter sets the optional parameter "filter": An optional filter for
  478. // the request.
  479. func (c *ProjectsTracesListCall) Filter(filter string) *ProjectsTracesListCall {
  480. c.urlParams_.Set("filter", filter)
  481. return c
  482. }
  483. // OrderBy sets the optional parameter "orderBy": Field used to sort the
  484. // returned traces. Can be one of the following: * `trace_id` * `name`
  485. // (`name` field of root span in the trace) * `duration` (difference
  486. // between `end_time` and `start_time` fields of the root span) *
  487. // `start` (`start_time` field of the root span) Descending order can be
  488. // specified by appending `desc` to the sort field (for example, `name
  489. // desc`). Only one sort field is permitted.
  490. func (c *ProjectsTracesListCall) OrderBy(orderBy string) *ProjectsTracesListCall {
  491. c.urlParams_.Set("orderBy", orderBy)
  492. return c
  493. }
  494. // PageSize sets the optional parameter "pageSize": Maximum number of
  495. // traces to return. If not specified or <= 0, the implementation
  496. // selects a reasonable value. The implementation may return fewer
  497. // traces than the requested page size.
  498. func (c *ProjectsTracesListCall) PageSize(pageSize int64) *ProjectsTracesListCall {
  499. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  500. return c
  501. }
  502. // PageToken sets the optional parameter "pageToken": Token identifying
  503. // the page of results to return. If provided, use the value of the
  504. // `next_page_token` field from a previous request.
  505. func (c *ProjectsTracesListCall) PageToken(pageToken string) *ProjectsTracesListCall {
  506. c.urlParams_.Set("pageToken", pageToken)
  507. return c
  508. }
  509. // StartTime sets the optional parameter "startTime": End of the time
  510. // interval (inclusive) during which the trace data was collected from
  511. // the application.
  512. func (c *ProjectsTracesListCall) StartTime(startTime string) *ProjectsTracesListCall {
  513. c.urlParams_.Set("startTime", startTime)
  514. return c
  515. }
  516. // View sets the optional parameter "view": Type of data returned for
  517. // traces in the list. Default is `MINIMAL`.
  518. //
  519. // Possible values:
  520. // "VIEW_TYPE_UNSPECIFIED"
  521. // "MINIMAL"
  522. // "ROOTSPAN"
  523. // "COMPLETE"
  524. func (c *ProjectsTracesListCall) View(view string) *ProjectsTracesListCall {
  525. c.urlParams_.Set("view", view)
  526. return c
  527. }
  528. // Fields allows partial responses to be retrieved. See
  529. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  530. // for more information.
  531. func (c *ProjectsTracesListCall) Fields(s ...googleapi.Field) *ProjectsTracesListCall {
  532. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  533. return c
  534. }
  535. // IfNoneMatch sets the optional parameter which makes the operation
  536. // fail if the object's ETag matches the given value. This is useful for
  537. // getting updates only after the object has changed since the last
  538. // request. Use googleapi.IsNotModified to check whether the response
  539. // error from Do is the result of In-None-Match.
  540. func (c *ProjectsTracesListCall) IfNoneMatch(entityTag string) *ProjectsTracesListCall {
  541. c.ifNoneMatch_ = entityTag
  542. return c
  543. }
  544. // Context sets the context to be used in this call's Do method. Any
  545. // pending HTTP request will be aborted if the provided context is
  546. // canceled.
  547. func (c *ProjectsTracesListCall) Context(ctx context.Context) *ProjectsTracesListCall {
  548. c.ctx_ = ctx
  549. return c
  550. }
  551. func (c *ProjectsTracesListCall) doRequest(alt string) (*http.Response, error) {
  552. var body io.Reader = nil
  553. c.urlParams_.Set("alt", alt)
  554. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces")
  555. urls += "?" + c.urlParams_.Encode()
  556. req, _ := http.NewRequest("GET", urls, body)
  557. googleapi.Expand(req.URL, map[string]string{
  558. "projectId": c.projectId,
  559. })
  560. req.Header.Set("User-Agent", c.s.userAgent())
  561. if c.ifNoneMatch_ != "" {
  562. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  563. }
  564. if c.ctx_ != nil {
  565. return ctxhttp.Do(c.ctx_, c.s.client, req)
  566. }
  567. return c.s.client.Do(req)
  568. }
  569. // Do executes the "cloudtrace.projects.traces.list" call.
  570. // Exactly one of *ListTracesResponse or error will be non-nil. Any
  571. // non-2xx status code is an error. Response headers are in either
  572. // *ListTracesResponse.ServerResponse.Header or (if a response was
  573. // returned at all) in error.(*googleapi.Error).Header. Use
  574. // googleapi.IsNotModified to check whether the returned error was
  575. // because http.StatusNotModified was returned.
  576. func (c *ProjectsTracesListCall) Do(opts ...googleapi.CallOption) (*ListTracesResponse, error) {
  577. gensupport.SetOptions(c.urlParams_, opts...)
  578. res, err := c.doRequest("json")
  579. if res != nil && res.StatusCode == http.StatusNotModified {
  580. if res.Body != nil {
  581. res.Body.Close()
  582. }
  583. return nil, &googleapi.Error{
  584. Code: res.StatusCode,
  585. Header: res.Header,
  586. }
  587. }
  588. if err != nil {
  589. return nil, err
  590. }
  591. defer googleapi.CloseBody(res)
  592. if err := googleapi.CheckResponse(res); err != nil {
  593. return nil, err
  594. }
  595. ret := &ListTracesResponse{
  596. ServerResponse: googleapi.ServerResponse{
  597. Header: res.Header,
  598. HTTPStatusCode: res.StatusCode,
  599. },
  600. }
  601. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  602. return nil, err
  603. }
  604. return ret, nil
  605. // {
  606. // "description": "Returns of a list of traces that match the specified filter conditions.",
  607. // "httpMethod": "GET",
  608. // "id": "cloudtrace.projects.traces.list",
  609. // "parameterOrder": [
  610. // "projectId"
  611. // ],
  612. // "parameters": {
  613. // "endTime": {
  614. // "description": "Start of the time interval (inclusive) during which the trace data was collected from the application.",
  615. // "location": "query",
  616. // "type": "string"
  617. // },
  618. // "filter": {
  619. // "description": "An optional filter for the request.",
  620. // "location": "query",
  621. // "type": "string"
  622. // },
  623. // "orderBy": {
  624. // "description": "Field used to sort the returned traces. Optional. Can be one of the following: * `trace_id` * `name` (`name` field of root span in the trace) * `duration` (difference between `end_time` and `start_time` fields of the root span) * `start` (`start_time` field of the root span) Descending order can be specified by appending `desc` to the sort field (for example, `name desc`). Only one sort field is permitted.",
  625. // "location": "query",
  626. // "type": "string"
  627. // },
  628. // "pageSize": {
  629. // "description": "Maximum number of traces to return. If not specified or \u003c= 0, the implementation selects a reasonable value. The implementation may return fewer traces than the requested page size. Optional.",
  630. // "format": "int32",
  631. // "location": "query",
  632. // "type": "integer"
  633. // },
  634. // "pageToken": {
  635. // "description": "Token identifying the page of results to return. If provided, use the value of the `next_page_token` field from a previous request. Optional.",
  636. // "location": "query",
  637. // "type": "string"
  638. // },
  639. // "projectId": {
  640. // "description": "ID of the Cloud project where the trace data is stored.",
  641. // "location": "path",
  642. // "required": true,
  643. // "type": "string"
  644. // },
  645. // "startTime": {
  646. // "description": "End of the time interval (inclusive) during which the trace data was collected from the application.",
  647. // "location": "query",
  648. // "type": "string"
  649. // },
  650. // "view": {
  651. // "description": "Type of data returned for traces in the list. Optional. Default is `MINIMAL`.",
  652. // "enum": [
  653. // "VIEW_TYPE_UNSPECIFIED",
  654. // "MINIMAL",
  655. // "ROOTSPAN",
  656. // "COMPLETE"
  657. // ],
  658. // "location": "query",
  659. // "type": "string"
  660. // }
  661. // },
  662. // "path": "v1/projects/{projectId}/traces",
  663. // "response": {
  664. // "$ref": "ListTracesResponse"
  665. // },
  666. // "scopes": [
  667. // "https://www.googleapis.com/auth/cloud-platform"
  668. // ]
  669. // }
  670. }
  671. // Pages invokes f for each page of results.
  672. // A non-nil error returned from f will halt the iteration.
  673. // The provided context supersedes any context provided to the Context method.
  674. func (c *ProjectsTracesListCall) Pages(ctx context.Context, f func(*ListTracesResponse) error) error {
  675. c.ctx_ = ctx
  676. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  677. for {
  678. x, err := c.Do()
  679. if err != nil {
  680. return err
  681. }
  682. if err := f(x); err != nil {
  683. return err
  684. }
  685. if x.NextPageToken == "" {
  686. return nil
  687. }
  688. c.PageToken(x.NextPageToken)
  689. }
  690. }