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.
 
 
 

2248 line
86 KiB

  1. // Package cloudmonitoring provides access to the Cloud Monitoring API.
  2. //
  3. // See https://cloud.google.com/monitoring/v2beta2/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/cloudmonitoring/v2beta2"
  8. // ...
  9. // cloudmonitoringService, err := cloudmonitoring.New(oauthHttpClient)
  10. package cloudmonitoring // import "google.golang.org/api/cloudmonitoring/v2beta2"
  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 = "cloudmonitoring:v2beta2"
  41. const apiName = "cloudmonitoring"
  42. const apiVersion = "v2beta2"
  43. const basePath = "https://www.googleapis.com/cloudmonitoring/v2beta2/projects/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. // View and write monitoring data for all of your Google and third-party
  49. // Cloud and API projects
  50. MonitoringScope = "https://www.googleapis.com/auth/monitoring"
  51. )
  52. func New(client *http.Client) (*Service, error) {
  53. if client == nil {
  54. return nil, errors.New("client is nil")
  55. }
  56. s := &Service{client: client, BasePath: basePath}
  57. s.MetricDescriptors = NewMetricDescriptorsService(s)
  58. s.Timeseries = NewTimeseriesService(s)
  59. s.TimeseriesDescriptors = NewTimeseriesDescriptorsService(s)
  60. return s, nil
  61. }
  62. type Service struct {
  63. client *http.Client
  64. BasePath string // API endpoint base URL
  65. UserAgent string // optional additional User-Agent fragment
  66. MetricDescriptors *MetricDescriptorsService
  67. Timeseries *TimeseriesService
  68. TimeseriesDescriptors *TimeseriesDescriptorsService
  69. }
  70. func (s *Service) userAgent() string {
  71. if s.UserAgent == "" {
  72. return googleapi.UserAgent
  73. }
  74. return googleapi.UserAgent + " " + s.UserAgent
  75. }
  76. func NewMetricDescriptorsService(s *Service) *MetricDescriptorsService {
  77. rs := &MetricDescriptorsService{s: s}
  78. return rs
  79. }
  80. type MetricDescriptorsService struct {
  81. s *Service
  82. }
  83. func NewTimeseriesService(s *Service) *TimeseriesService {
  84. rs := &TimeseriesService{s: s}
  85. return rs
  86. }
  87. type TimeseriesService struct {
  88. s *Service
  89. }
  90. func NewTimeseriesDescriptorsService(s *Service) *TimeseriesDescriptorsService {
  91. rs := &TimeseriesDescriptorsService{s: s}
  92. return rs
  93. }
  94. type TimeseriesDescriptorsService struct {
  95. s *Service
  96. }
  97. // DeleteMetricDescriptorResponse: The response of
  98. // cloudmonitoring.metricDescriptors.delete.
  99. type DeleteMetricDescriptorResponse struct {
  100. // Kind: Identifies what kind of resource this is. Value: the fixed
  101. // string "cloudmonitoring#deleteMetricDescriptorResponse".
  102. Kind string `json:"kind,omitempty"`
  103. // ServerResponse contains the HTTP response code and headers from the
  104. // server.
  105. googleapi.ServerResponse `json:"-"`
  106. // ForceSendFields is a list of field names (e.g. "Kind") to
  107. // unconditionally include in API requests. By default, fields with
  108. // empty values are omitted from API requests. However, any non-pointer,
  109. // non-interface field appearing in ForceSendFields will be sent to the
  110. // server regardless of whether the field is empty or not. This may be
  111. // used to include empty fields in Patch requests.
  112. ForceSendFields []string `json:"-"`
  113. // NullFields is a list of field names (e.g. "Kind") to include in API
  114. // requests with the JSON null value. By default, fields with empty
  115. // values are omitted from API requests. However, any field with an
  116. // empty value appearing in NullFields will be sent to the server as
  117. // null. It is an error if a field in this list has a non-empty value.
  118. // This may be used to include null fields in Patch requests.
  119. NullFields []string `json:"-"`
  120. }
  121. func (s *DeleteMetricDescriptorResponse) MarshalJSON() ([]byte, error) {
  122. type NoMethod DeleteMetricDescriptorResponse
  123. raw := NoMethod(*s)
  124. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  125. }
  126. // ListMetricDescriptorsRequest: The request of
  127. // cloudmonitoring.metricDescriptors.list.
  128. type ListMetricDescriptorsRequest struct {
  129. // Kind: Identifies what kind of resource this is. Value: the fixed
  130. // string "cloudmonitoring#listMetricDescriptorsRequest".
  131. Kind string `json:"kind,omitempty"`
  132. // ForceSendFields is a list of field names (e.g. "Kind") to
  133. // unconditionally include in API requests. By default, fields with
  134. // empty values are omitted from API requests. However, any non-pointer,
  135. // non-interface field appearing in ForceSendFields will be sent to the
  136. // server regardless of whether the field is empty or not. This may be
  137. // used to include empty fields in Patch requests.
  138. ForceSendFields []string `json:"-"`
  139. // NullFields is a list of field names (e.g. "Kind") to include in API
  140. // requests with the JSON null value. By default, fields with empty
  141. // values are omitted from API requests. However, any field with an
  142. // empty value appearing in NullFields will be sent to the server as
  143. // null. It is an error if a field in this list has a non-empty value.
  144. // This may be used to include null fields in Patch requests.
  145. NullFields []string `json:"-"`
  146. }
  147. func (s *ListMetricDescriptorsRequest) MarshalJSON() ([]byte, error) {
  148. type NoMethod ListMetricDescriptorsRequest
  149. raw := NoMethod(*s)
  150. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  151. }
  152. // ListMetricDescriptorsResponse: The response of
  153. // cloudmonitoring.metricDescriptors.list.
  154. type ListMetricDescriptorsResponse struct {
  155. // Kind: Identifies what kind of resource this is. Value: the fixed
  156. // string "cloudmonitoring#listMetricDescriptorsResponse".
  157. Kind string `json:"kind,omitempty"`
  158. // Metrics: The returned metric descriptors.
  159. Metrics []*MetricDescriptor `json:"metrics,omitempty"`
  160. // NextPageToken: Pagination token. If present, indicates that
  161. // additional results are available for retrieval. To access the results
  162. // past the pagination limit, pass this value to the pageToken query
  163. // parameter.
  164. NextPageToken string `json:"nextPageToken,omitempty"`
  165. // ServerResponse contains the HTTP response code and headers from the
  166. // server.
  167. googleapi.ServerResponse `json:"-"`
  168. // ForceSendFields is a list of field names (e.g. "Kind") to
  169. // unconditionally include in API requests. By default, fields with
  170. // empty values are omitted from API requests. However, any non-pointer,
  171. // non-interface field appearing in ForceSendFields will be sent to the
  172. // server regardless of whether the field is empty or not. This may be
  173. // used to include empty fields in Patch requests.
  174. ForceSendFields []string `json:"-"`
  175. // NullFields is a list of field names (e.g. "Kind") to include in API
  176. // requests with the JSON null value. By default, fields with empty
  177. // values are omitted from API requests. However, any field with an
  178. // empty value appearing in NullFields will be sent to the server as
  179. // null. It is an error if a field in this list has a non-empty value.
  180. // This may be used to include null fields in Patch requests.
  181. NullFields []string `json:"-"`
  182. }
  183. func (s *ListMetricDescriptorsResponse) MarshalJSON() ([]byte, error) {
  184. type NoMethod ListMetricDescriptorsResponse
  185. raw := NoMethod(*s)
  186. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  187. }
  188. // ListTimeseriesDescriptorsRequest: The request of
  189. // cloudmonitoring.timeseriesDescriptors.list
  190. type ListTimeseriesDescriptorsRequest struct {
  191. // Kind: Identifies what kind of resource this is. Value: the fixed
  192. // string "cloudmonitoring#listTimeseriesDescriptorsRequest".
  193. Kind string `json:"kind,omitempty"`
  194. // ForceSendFields is a list of field names (e.g. "Kind") to
  195. // unconditionally include in API requests. By default, fields with
  196. // empty values are omitted from API requests. However, any non-pointer,
  197. // non-interface field appearing in ForceSendFields will be sent to the
  198. // server regardless of whether the field is empty or not. This may be
  199. // used to include empty fields in Patch requests.
  200. ForceSendFields []string `json:"-"`
  201. // NullFields is a list of field names (e.g. "Kind") to include in API
  202. // requests with the JSON null value. By default, fields with empty
  203. // values are omitted from API requests. However, any field with an
  204. // empty value appearing in NullFields will be sent to the server as
  205. // null. It is an error if a field in this list has a non-empty value.
  206. // This may be used to include null fields in Patch requests.
  207. NullFields []string `json:"-"`
  208. }
  209. func (s *ListTimeseriesDescriptorsRequest) MarshalJSON() ([]byte, error) {
  210. type NoMethod ListTimeseriesDescriptorsRequest
  211. raw := NoMethod(*s)
  212. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  213. }
  214. // ListTimeseriesDescriptorsResponse: The response of
  215. // cloudmonitoring.timeseriesDescriptors.list
  216. type ListTimeseriesDescriptorsResponse struct {
  217. // Kind: Identifies what kind of resource this is. Value: the fixed
  218. // string "cloudmonitoring#listTimeseriesDescriptorsResponse".
  219. Kind string `json:"kind,omitempty"`
  220. // NextPageToken: Pagination token. If present, indicates that
  221. // additional results are available for retrieval. To access the results
  222. // past the pagination limit, set this value to the pageToken query
  223. // parameter.
  224. NextPageToken string `json:"nextPageToken,omitempty"`
  225. // Oldest: The oldest timestamp of the interval of this query, as an RFC
  226. // 3339 string.
  227. Oldest string `json:"oldest,omitempty"`
  228. // Timeseries: The returned time series descriptors.
  229. Timeseries []*TimeseriesDescriptor `json:"timeseries,omitempty"`
  230. // Youngest: The youngest timestamp of the interval of this query, as an
  231. // RFC 3339 string.
  232. Youngest string `json:"youngest,omitempty"`
  233. // ServerResponse contains the HTTP response code and headers from the
  234. // server.
  235. googleapi.ServerResponse `json:"-"`
  236. // ForceSendFields is a list of field names (e.g. "Kind") to
  237. // unconditionally include in API requests. By default, fields with
  238. // empty values are omitted from API requests. However, any non-pointer,
  239. // non-interface field appearing in ForceSendFields will be sent to the
  240. // server regardless of whether the field is empty or not. This may be
  241. // used to include empty fields in Patch requests.
  242. ForceSendFields []string `json:"-"`
  243. // NullFields is a list of field names (e.g. "Kind") to include in API
  244. // requests with the JSON null value. By default, fields with empty
  245. // values are omitted from API requests. However, any field with an
  246. // empty value appearing in NullFields will be sent to the server as
  247. // null. It is an error if a field in this list has a non-empty value.
  248. // This may be used to include null fields in Patch requests.
  249. NullFields []string `json:"-"`
  250. }
  251. func (s *ListTimeseriesDescriptorsResponse) MarshalJSON() ([]byte, error) {
  252. type NoMethod ListTimeseriesDescriptorsResponse
  253. raw := NoMethod(*s)
  254. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  255. }
  256. // ListTimeseriesRequest: The request of cloudmonitoring.timeseries.list
  257. type ListTimeseriesRequest struct {
  258. // Kind: Identifies what kind of resource this is. Value: the fixed
  259. // string "cloudmonitoring#listTimeseriesRequest".
  260. Kind string `json:"kind,omitempty"`
  261. // ForceSendFields is a list of field names (e.g. "Kind") to
  262. // unconditionally include in API requests. By default, fields with
  263. // empty values are omitted from API requests. However, any non-pointer,
  264. // non-interface field appearing in ForceSendFields will be sent to the
  265. // server regardless of whether the field is empty or not. This may be
  266. // used to include empty fields in Patch requests.
  267. ForceSendFields []string `json:"-"`
  268. // NullFields is a list of field names (e.g. "Kind") to include in API
  269. // requests with the JSON null value. By default, fields with empty
  270. // values are omitted from API requests. However, any field with an
  271. // empty value appearing in NullFields will be sent to the server as
  272. // null. It is an error if a field in this list has a non-empty value.
  273. // This may be used to include null fields in Patch requests.
  274. NullFields []string `json:"-"`
  275. }
  276. func (s *ListTimeseriesRequest) MarshalJSON() ([]byte, error) {
  277. type NoMethod ListTimeseriesRequest
  278. raw := NoMethod(*s)
  279. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  280. }
  281. // ListTimeseriesResponse: The response of
  282. // cloudmonitoring.timeseries.list
  283. type ListTimeseriesResponse struct {
  284. // Kind: Identifies what kind of resource this is. Value: the fixed
  285. // string "cloudmonitoring#listTimeseriesResponse".
  286. Kind string `json:"kind,omitempty"`
  287. // NextPageToken: Pagination token. If present, indicates that
  288. // additional results are available for retrieval. To access the results
  289. // past the pagination limit, set the pageToken query parameter to this
  290. // value. All of the points of a time series will be returned before
  291. // returning any point of the subsequent time series.
  292. NextPageToken string `json:"nextPageToken,omitempty"`
  293. // Oldest: The oldest timestamp of the interval of this query as an RFC
  294. // 3339 string.
  295. Oldest string `json:"oldest,omitempty"`
  296. // Timeseries: The returned time series.
  297. Timeseries []*Timeseries `json:"timeseries,omitempty"`
  298. // Youngest: The youngest timestamp of the interval of this query as an
  299. // RFC 3339 string.
  300. Youngest string `json:"youngest,omitempty"`
  301. // ServerResponse contains the HTTP response code and headers from the
  302. // server.
  303. googleapi.ServerResponse `json:"-"`
  304. // ForceSendFields is a list of field names (e.g. "Kind") to
  305. // unconditionally include in API requests. By default, fields with
  306. // empty values are omitted from API requests. However, any non-pointer,
  307. // non-interface field appearing in ForceSendFields will be sent to the
  308. // server regardless of whether the field is empty or not. This may be
  309. // used to include empty fields in Patch requests.
  310. ForceSendFields []string `json:"-"`
  311. // NullFields is a list of field names (e.g. "Kind") to include in API
  312. // requests with the JSON null value. By default, fields with empty
  313. // values are omitted from API requests. However, any field with an
  314. // empty value appearing in NullFields will be sent to the server as
  315. // null. It is an error if a field in this list has a non-empty value.
  316. // This may be used to include null fields in Patch requests.
  317. NullFields []string `json:"-"`
  318. }
  319. func (s *ListTimeseriesResponse) MarshalJSON() ([]byte, error) {
  320. type NoMethod ListTimeseriesResponse
  321. raw := NoMethod(*s)
  322. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  323. }
  324. // MetricDescriptor: A metricDescriptor defines the name, label keys,
  325. // and data type of a particular metric.
  326. type MetricDescriptor struct {
  327. // Description: Description of this metric.
  328. Description string `json:"description,omitempty"`
  329. // Labels: Labels defined for this metric.
  330. Labels []*MetricDescriptorLabelDescriptor `json:"labels,omitempty"`
  331. // Name: The name of this metric.
  332. Name string `json:"name,omitempty"`
  333. // Project: The project ID to which the metric belongs.
  334. Project string `json:"project,omitempty"`
  335. // TypeDescriptor: Type description for this metric.
  336. TypeDescriptor *MetricDescriptorTypeDescriptor `json:"typeDescriptor,omitempty"`
  337. // ServerResponse contains the HTTP response code and headers from the
  338. // server.
  339. googleapi.ServerResponse `json:"-"`
  340. // ForceSendFields is a list of field names (e.g. "Description") to
  341. // unconditionally include in API requests. By default, fields with
  342. // empty values are omitted from API requests. However, any non-pointer,
  343. // non-interface field appearing in ForceSendFields will be sent to the
  344. // server regardless of whether the field is empty or not. This may be
  345. // used to include empty fields in Patch requests.
  346. ForceSendFields []string `json:"-"`
  347. // NullFields is a list of field names (e.g. "Description") to include
  348. // in API requests with the JSON null value. By default, fields with
  349. // empty values are omitted from API requests. However, any field with
  350. // an empty value appearing in NullFields will be sent to the server as
  351. // null. It is an error if a field in this list has a non-empty value.
  352. // This may be used to include null fields in Patch requests.
  353. NullFields []string `json:"-"`
  354. }
  355. func (s *MetricDescriptor) MarshalJSON() ([]byte, error) {
  356. type NoMethod MetricDescriptor
  357. raw := NoMethod(*s)
  358. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  359. }
  360. // MetricDescriptorLabelDescriptor: A label in a metric is a description
  361. // of this metric, including the key of this description (what the
  362. // description is), and the value for this description.
  363. type MetricDescriptorLabelDescriptor struct {
  364. // Description: Label description.
  365. Description string `json:"description,omitempty"`
  366. // Key: Label key.
  367. Key string `json:"key,omitempty"`
  368. // ForceSendFields is a list of field names (e.g. "Description") to
  369. // unconditionally include in API requests. By default, fields with
  370. // empty values are omitted from API requests. However, any non-pointer,
  371. // non-interface field appearing in ForceSendFields will be sent to the
  372. // server regardless of whether the field is empty or not. This may be
  373. // used to include empty fields in Patch requests.
  374. ForceSendFields []string `json:"-"`
  375. // NullFields is a list of field names (e.g. "Description") to include
  376. // in API requests with the JSON null value. By default, fields with
  377. // empty values are omitted from API requests. However, any field with
  378. // an empty value appearing in NullFields will be sent to the server as
  379. // null. It is an error if a field in this list has a non-empty value.
  380. // This may be used to include null fields in Patch requests.
  381. NullFields []string `json:"-"`
  382. }
  383. func (s *MetricDescriptorLabelDescriptor) MarshalJSON() ([]byte, error) {
  384. type NoMethod MetricDescriptorLabelDescriptor
  385. raw := NoMethod(*s)
  386. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  387. }
  388. // MetricDescriptorTypeDescriptor: A type in a metric contains
  389. // information about how the metric is collected and what its data
  390. // points look like.
  391. type MetricDescriptorTypeDescriptor struct {
  392. // MetricType: The method of collecting data for the metric. See Metric
  393. // types.
  394. MetricType string `json:"metricType,omitempty"`
  395. // ValueType: The data type of of individual points in the metric's time
  396. // series. See Metric value types.
  397. ValueType string `json:"valueType,omitempty"`
  398. // ForceSendFields is a list of field names (e.g. "MetricType") to
  399. // unconditionally include in API requests. By default, fields with
  400. // empty values are omitted from API requests. However, any non-pointer,
  401. // non-interface field appearing in ForceSendFields will be sent to the
  402. // server regardless of whether the field is empty or not. This may be
  403. // used to include empty fields in Patch requests.
  404. ForceSendFields []string `json:"-"`
  405. // NullFields is a list of field names (e.g. "MetricType") to include in
  406. // API requests with the JSON null value. By default, fields with empty
  407. // values are omitted from API requests. However, any field with an
  408. // empty value appearing in NullFields will be sent to the server as
  409. // null. It is an error if a field in this list has a non-empty value.
  410. // This may be used to include null fields in Patch requests.
  411. NullFields []string `json:"-"`
  412. }
  413. func (s *MetricDescriptorTypeDescriptor) MarshalJSON() ([]byte, error) {
  414. type NoMethod MetricDescriptorTypeDescriptor
  415. raw := NoMethod(*s)
  416. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  417. }
  418. // Point: Point is a single point in a time series. It consists of a
  419. // start time, an end time, and a value.
  420. type Point struct {
  421. // BoolValue: The value of this data point. Either "true" or "false".
  422. BoolValue *bool `json:"boolValue,omitempty"`
  423. // DistributionValue: The value of this data point as a distribution. A
  424. // distribution value can contain a list of buckets and/or an
  425. // underflowBucket and an overflowBucket. The values of these points can
  426. // be used to create a histogram.
  427. DistributionValue *PointDistribution `json:"distributionValue,omitempty"`
  428. // DoubleValue: The value of this data point as a double-precision
  429. // floating-point number.
  430. DoubleValue *float64 `json:"doubleValue,omitempty"`
  431. // End: The interval [start, end] is the time period to which the
  432. // point's value applies. For gauge metrics, whose values are
  433. // instantaneous measurements, this interval should be empty (start
  434. // should equal end). For cumulative metrics (of which deltas and rates
  435. // are special cases), the interval should be non-empty. Both start and
  436. // end are RFC 3339 strings.
  437. End string `json:"end,omitempty"`
  438. // Int64Value: The value of this data point as a 64-bit integer.
  439. Int64Value *int64 `json:"int64Value,omitempty,string"`
  440. // Start: The interval [start, end] is the time period to which the
  441. // point's value applies. For gauge metrics, whose values are
  442. // instantaneous measurements, this interval should be empty (start
  443. // should equal end). For cumulative metrics (of which deltas and rates
  444. // are special cases), the interval should be non-empty. Both start and
  445. // end are RFC 3339 strings.
  446. Start string `json:"start,omitempty"`
  447. // StringValue: The value of this data point in string format.
  448. StringValue *string `json:"stringValue,omitempty"`
  449. // ForceSendFields is a list of field names (e.g. "BoolValue") to
  450. // unconditionally include in API requests. By default, fields with
  451. // empty values are omitted from API requests. However, any non-pointer,
  452. // non-interface field appearing in ForceSendFields will be sent to the
  453. // server regardless of whether the field is empty or not. This may be
  454. // used to include empty fields in Patch requests.
  455. ForceSendFields []string `json:"-"`
  456. // NullFields is a list of field names (e.g. "BoolValue") to include in
  457. // API requests with the JSON null value. By default, fields with empty
  458. // values are omitted from API requests. However, any field with an
  459. // empty value appearing in NullFields will be sent to the server as
  460. // null. It is an error if a field in this list has a non-empty value.
  461. // This may be used to include null fields in Patch requests.
  462. NullFields []string `json:"-"`
  463. }
  464. func (s *Point) MarshalJSON() ([]byte, error) {
  465. type NoMethod Point
  466. raw := NoMethod(*s)
  467. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  468. }
  469. func (s *Point) UnmarshalJSON(data []byte) error {
  470. type NoMethod Point
  471. var s1 struct {
  472. DoubleValue *gensupport.JSONFloat64 `json:"doubleValue"`
  473. *NoMethod
  474. }
  475. s1.NoMethod = (*NoMethod)(s)
  476. if err := json.Unmarshal(data, &s1); err != nil {
  477. return err
  478. }
  479. if s1.DoubleValue != nil {
  480. s.DoubleValue = (*float64)(s1.DoubleValue)
  481. }
  482. return nil
  483. }
  484. // PointDistribution: Distribution data point value type. When writing
  485. // distribution points, try to be consistent with the boundaries of your
  486. // buckets. If you must modify the bucket boundaries, then do so by
  487. // merging, partitioning, or appending rather than skewing them.
  488. type PointDistribution struct {
  489. // Buckets: The finite buckets.
  490. Buckets []*PointDistributionBucket `json:"buckets,omitempty"`
  491. // OverflowBucket: The overflow bucket.
  492. OverflowBucket *PointDistributionOverflowBucket `json:"overflowBucket,omitempty"`
  493. // UnderflowBucket: The underflow bucket.
  494. UnderflowBucket *PointDistributionUnderflowBucket `json:"underflowBucket,omitempty"`
  495. // ForceSendFields is a list of field names (e.g. "Buckets") to
  496. // unconditionally include in API requests. By default, fields with
  497. // empty values are omitted from API requests. However, any non-pointer,
  498. // non-interface field appearing in ForceSendFields will be sent to the
  499. // server regardless of whether the field is empty or not. This may be
  500. // used to include empty fields in Patch requests.
  501. ForceSendFields []string `json:"-"`
  502. // NullFields is a list of field names (e.g. "Buckets") to include in
  503. // API requests with the JSON null value. By default, fields with empty
  504. // values are omitted from API requests. However, any field with an
  505. // empty value appearing in NullFields will be sent to the server as
  506. // null. It is an error if a field in this list has a non-empty value.
  507. // This may be used to include null fields in Patch requests.
  508. NullFields []string `json:"-"`
  509. }
  510. func (s *PointDistribution) MarshalJSON() ([]byte, error) {
  511. type NoMethod PointDistribution
  512. raw := NoMethod(*s)
  513. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  514. }
  515. // PointDistributionBucket: The histogram's bucket. Buckets that form
  516. // the histogram of a distribution value. If the upper bound of a
  517. // bucket, say U1, does not equal the lower bound of the next bucket,
  518. // say L2, this means that there is no event in [U1, L2).
  519. type PointDistributionBucket struct {
  520. // Count: The number of events whose values are in the interval defined
  521. // by this bucket.
  522. Count int64 `json:"count,omitempty,string"`
  523. // LowerBound: The lower bound of the value interval of this bucket
  524. // (inclusive).
  525. LowerBound float64 `json:"lowerBound,omitempty"`
  526. // UpperBound: The upper bound of the value interval of this bucket
  527. // (exclusive).
  528. UpperBound float64 `json:"upperBound,omitempty"`
  529. // ForceSendFields is a list of field names (e.g. "Count") to
  530. // unconditionally include in API requests. By default, fields with
  531. // empty values are omitted from API requests. However, any non-pointer,
  532. // non-interface field appearing in ForceSendFields will be sent to the
  533. // server regardless of whether the field is empty or not. This may be
  534. // used to include empty fields in Patch requests.
  535. ForceSendFields []string `json:"-"`
  536. // NullFields is a list of field names (e.g. "Count") to include in API
  537. // requests with the JSON null value. By default, fields with empty
  538. // values are omitted from API requests. However, any field with an
  539. // empty value appearing in NullFields will be sent to the server as
  540. // null. It is an error if a field in this list has a non-empty value.
  541. // This may be used to include null fields in Patch requests.
  542. NullFields []string `json:"-"`
  543. }
  544. func (s *PointDistributionBucket) MarshalJSON() ([]byte, error) {
  545. type NoMethod PointDistributionBucket
  546. raw := NoMethod(*s)
  547. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  548. }
  549. func (s *PointDistributionBucket) UnmarshalJSON(data []byte) error {
  550. type NoMethod PointDistributionBucket
  551. var s1 struct {
  552. LowerBound gensupport.JSONFloat64 `json:"lowerBound"`
  553. UpperBound gensupport.JSONFloat64 `json:"upperBound"`
  554. *NoMethod
  555. }
  556. s1.NoMethod = (*NoMethod)(s)
  557. if err := json.Unmarshal(data, &s1); err != nil {
  558. return err
  559. }
  560. s.LowerBound = float64(s1.LowerBound)
  561. s.UpperBound = float64(s1.UpperBound)
  562. return nil
  563. }
  564. // PointDistributionOverflowBucket: The overflow bucket is a special
  565. // bucket that does not have the upperBound field; it includes all of
  566. // the events that are no less than its lower bound.
  567. type PointDistributionOverflowBucket struct {
  568. // Count: The number of events whose values are in the interval defined
  569. // by this bucket.
  570. Count int64 `json:"count,omitempty,string"`
  571. // LowerBound: The lower bound of the value interval of this bucket
  572. // (inclusive).
  573. LowerBound float64 `json:"lowerBound,omitempty"`
  574. // ForceSendFields is a list of field names (e.g. "Count") to
  575. // unconditionally include in API requests. By default, fields with
  576. // empty values are omitted from API requests. However, any non-pointer,
  577. // non-interface field appearing in ForceSendFields will be sent to the
  578. // server regardless of whether the field is empty or not. This may be
  579. // used to include empty fields in Patch requests.
  580. ForceSendFields []string `json:"-"`
  581. // NullFields is a list of field names (e.g. "Count") to include in API
  582. // requests with the JSON null value. By default, fields with empty
  583. // values are omitted from API requests. However, any field with an
  584. // empty value appearing in NullFields will be sent to the server as
  585. // null. It is an error if a field in this list has a non-empty value.
  586. // This may be used to include null fields in Patch requests.
  587. NullFields []string `json:"-"`
  588. }
  589. func (s *PointDistributionOverflowBucket) MarshalJSON() ([]byte, error) {
  590. type NoMethod PointDistributionOverflowBucket
  591. raw := NoMethod(*s)
  592. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  593. }
  594. func (s *PointDistributionOverflowBucket) UnmarshalJSON(data []byte) error {
  595. type NoMethod PointDistributionOverflowBucket
  596. var s1 struct {
  597. LowerBound gensupport.JSONFloat64 `json:"lowerBound"`
  598. *NoMethod
  599. }
  600. s1.NoMethod = (*NoMethod)(s)
  601. if err := json.Unmarshal(data, &s1); err != nil {
  602. return err
  603. }
  604. s.LowerBound = float64(s1.LowerBound)
  605. return nil
  606. }
  607. // PointDistributionUnderflowBucket: The underflow bucket is a special
  608. // bucket that does not have the lowerBound field; it includes all of
  609. // the events that are less than its upper bound.
  610. type PointDistributionUnderflowBucket struct {
  611. // Count: The number of events whose values are in the interval defined
  612. // by this bucket.
  613. Count int64 `json:"count,omitempty,string"`
  614. // UpperBound: The upper bound of the value interval of this bucket
  615. // (exclusive).
  616. UpperBound float64 `json:"upperBound,omitempty"`
  617. // ForceSendFields is a list of field names (e.g. "Count") to
  618. // unconditionally include in API requests. By default, fields with
  619. // empty values are omitted from API requests. However, any non-pointer,
  620. // non-interface field appearing in ForceSendFields will be sent to the
  621. // server regardless of whether the field is empty or not. This may be
  622. // used to include empty fields in Patch requests.
  623. ForceSendFields []string `json:"-"`
  624. // NullFields is a list of field names (e.g. "Count") to include in API
  625. // requests with the JSON null value. By default, fields with empty
  626. // values are omitted from API requests. However, any field with an
  627. // empty value appearing in NullFields will be sent to the server as
  628. // null. It is an error if a field in this list has a non-empty value.
  629. // This may be used to include null fields in Patch requests.
  630. NullFields []string `json:"-"`
  631. }
  632. func (s *PointDistributionUnderflowBucket) MarshalJSON() ([]byte, error) {
  633. type NoMethod PointDistributionUnderflowBucket
  634. raw := NoMethod(*s)
  635. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  636. }
  637. func (s *PointDistributionUnderflowBucket) UnmarshalJSON(data []byte) error {
  638. type NoMethod PointDistributionUnderflowBucket
  639. var s1 struct {
  640. UpperBound gensupport.JSONFloat64 `json:"upperBound"`
  641. *NoMethod
  642. }
  643. s1.NoMethod = (*NoMethod)(s)
  644. if err := json.Unmarshal(data, &s1); err != nil {
  645. return err
  646. }
  647. s.UpperBound = float64(s1.UpperBound)
  648. return nil
  649. }
  650. // Timeseries: The monitoring data is organized as metrics and stored as
  651. // data points that are recorded over time. Each data point represents
  652. // information like the CPU utilization of your virtual machine. A
  653. // historical record of these data points is called a time series.
  654. type Timeseries struct {
  655. // Points: The data points of this time series. The points are listed in
  656. // order of their end timestamp, from younger to older.
  657. Points []*Point `json:"points,omitempty"`
  658. // TimeseriesDesc: The descriptor of this time series.
  659. TimeseriesDesc *TimeseriesDescriptor `json:"timeseriesDesc,omitempty"`
  660. // ForceSendFields is a list of field names (e.g. "Points") to
  661. // unconditionally include in API requests. By default, fields with
  662. // empty values are omitted from API requests. However, any non-pointer,
  663. // non-interface field appearing in ForceSendFields will be sent to the
  664. // server regardless of whether the field is empty or not. This may be
  665. // used to include empty fields in Patch requests.
  666. ForceSendFields []string `json:"-"`
  667. // NullFields is a list of field names (e.g. "Points") to include in API
  668. // requests with the JSON null value. By default, fields with empty
  669. // values are omitted from API requests. However, any field with an
  670. // empty value appearing in NullFields will be sent to the server as
  671. // null. It is an error if a field in this list has a non-empty value.
  672. // This may be used to include null fields in Patch requests.
  673. NullFields []string `json:"-"`
  674. }
  675. func (s *Timeseries) MarshalJSON() ([]byte, error) {
  676. type NoMethod Timeseries
  677. raw := NoMethod(*s)
  678. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  679. }
  680. // TimeseriesDescriptor: TimeseriesDescriptor identifies a single time
  681. // series.
  682. type TimeseriesDescriptor struct {
  683. // Labels: The label's name.
  684. Labels map[string]string `json:"labels,omitempty"`
  685. // Metric: The name of the metric.
  686. Metric string `json:"metric,omitempty"`
  687. // Project: The Developers Console project number to which this time
  688. // series belongs.
  689. Project string `json:"project,omitempty"`
  690. // ForceSendFields is a list of field names (e.g. "Labels") to
  691. // unconditionally include in API requests. By default, fields with
  692. // empty values are omitted from API requests. However, any non-pointer,
  693. // non-interface field appearing in ForceSendFields will be sent to the
  694. // server regardless of whether the field is empty or not. This may be
  695. // used to include empty fields in Patch requests.
  696. ForceSendFields []string `json:"-"`
  697. // NullFields is a list of field names (e.g. "Labels") to include in API
  698. // requests with the JSON null value. By default, fields with empty
  699. // values are omitted from API requests. However, any field with an
  700. // empty value appearing in NullFields will be sent to the server as
  701. // null. It is an error if a field in this list has a non-empty value.
  702. // This may be used to include null fields in Patch requests.
  703. NullFields []string `json:"-"`
  704. }
  705. func (s *TimeseriesDescriptor) MarshalJSON() ([]byte, error) {
  706. type NoMethod TimeseriesDescriptor
  707. raw := NoMethod(*s)
  708. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  709. }
  710. type TimeseriesDescriptorLabel struct {
  711. // Key: The label's name.
  712. Key string `json:"key,omitempty"`
  713. // Value: The label's value.
  714. Value string `json:"value,omitempty"`
  715. // ForceSendFields is a list of field names (e.g. "Key") to
  716. // unconditionally include in API requests. By default, fields with
  717. // empty values are omitted from API requests. However, any non-pointer,
  718. // non-interface field appearing in ForceSendFields will be sent to the
  719. // server regardless of whether the field is empty or not. This may be
  720. // used to include empty fields in Patch requests.
  721. ForceSendFields []string `json:"-"`
  722. // NullFields is a list of field names (e.g. "Key") to include in API
  723. // requests with the JSON null value. By default, fields with empty
  724. // values are omitted from API requests. However, any field with an
  725. // empty value appearing in NullFields will be sent to the server as
  726. // null. It is an error if a field in this list has a non-empty value.
  727. // This may be used to include null fields in Patch requests.
  728. NullFields []string `json:"-"`
  729. }
  730. func (s *TimeseriesDescriptorLabel) MarshalJSON() ([]byte, error) {
  731. type NoMethod TimeseriesDescriptorLabel
  732. raw := NoMethod(*s)
  733. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  734. }
  735. // TimeseriesPoint: When writing time series, TimeseriesPoint should be
  736. // used instead of Timeseries, to enforce single point for each time
  737. // series in the timeseries.write request.
  738. type TimeseriesPoint struct {
  739. // Point: The data point in this time series snapshot.
  740. Point *Point `json:"point,omitempty"`
  741. // TimeseriesDesc: The descriptor of this time series.
  742. TimeseriesDesc *TimeseriesDescriptor `json:"timeseriesDesc,omitempty"`
  743. // ForceSendFields is a list of field names (e.g. "Point") to
  744. // unconditionally include in API requests. By default, fields with
  745. // empty values are omitted from API requests. However, any non-pointer,
  746. // non-interface field appearing in ForceSendFields will be sent to the
  747. // server regardless of whether the field is empty or not. This may be
  748. // used to include empty fields in Patch requests.
  749. ForceSendFields []string `json:"-"`
  750. // NullFields is a list of field names (e.g. "Point") to include in API
  751. // requests with the JSON null value. By default, fields with empty
  752. // values are omitted from API requests. However, any field with an
  753. // empty value appearing in NullFields will be sent to the server as
  754. // null. It is an error if a field in this list has a non-empty value.
  755. // This may be used to include null fields in Patch requests.
  756. NullFields []string `json:"-"`
  757. }
  758. func (s *TimeseriesPoint) MarshalJSON() ([]byte, error) {
  759. type NoMethod TimeseriesPoint
  760. raw := NoMethod(*s)
  761. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  762. }
  763. // WriteTimeseriesRequest: The request of
  764. // cloudmonitoring.timeseries.write
  765. type WriteTimeseriesRequest struct {
  766. // CommonLabels: The label's name.
  767. CommonLabels map[string]string `json:"commonLabels,omitempty"`
  768. // Timeseries: Provide time series specific labels and the data points
  769. // for each time series. The labels in timeseries and the common_labels
  770. // should form a complete list of labels that required by the metric.
  771. Timeseries []*TimeseriesPoint `json:"timeseries,omitempty"`
  772. // ForceSendFields is a list of field names (e.g. "CommonLabels") to
  773. // unconditionally include in API requests. By default, fields with
  774. // empty values are omitted from API requests. However, any non-pointer,
  775. // non-interface field appearing in ForceSendFields will be sent to the
  776. // server regardless of whether the field is empty or not. This may be
  777. // used to include empty fields in Patch requests.
  778. ForceSendFields []string `json:"-"`
  779. // NullFields is a list of field names (e.g. "CommonLabels") to include
  780. // in API requests with the JSON null value. By default, fields with
  781. // empty values are omitted from API requests. However, any field with
  782. // an empty value appearing in NullFields will be sent to the server as
  783. // null. It is an error if a field in this list has a non-empty value.
  784. // This may be used to include null fields in Patch requests.
  785. NullFields []string `json:"-"`
  786. }
  787. func (s *WriteTimeseriesRequest) MarshalJSON() ([]byte, error) {
  788. type NoMethod WriteTimeseriesRequest
  789. raw := NoMethod(*s)
  790. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  791. }
  792. // WriteTimeseriesResponse: The response of
  793. // cloudmonitoring.timeseries.write
  794. type WriteTimeseriesResponse struct {
  795. // Kind: Identifies what kind of resource this is. Value: the fixed
  796. // string "cloudmonitoring#writeTimeseriesResponse".
  797. Kind string `json:"kind,omitempty"`
  798. // ServerResponse contains the HTTP response code and headers from the
  799. // server.
  800. googleapi.ServerResponse `json:"-"`
  801. // ForceSendFields is a list of field names (e.g. "Kind") to
  802. // unconditionally include in API requests. By default, fields with
  803. // empty values are omitted from API requests. However, any non-pointer,
  804. // non-interface field appearing in ForceSendFields will be sent to the
  805. // server regardless of whether the field is empty or not. This may be
  806. // used to include empty fields in Patch requests.
  807. ForceSendFields []string `json:"-"`
  808. // NullFields is a list of field names (e.g. "Kind") to include in API
  809. // requests with the JSON null value. By default, fields with empty
  810. // values are omitted from API requests. However, any field with an
  811. // empty value appearing in NullFields will be sent to the server as
  812. // null. It is an error if a field in this list has a non-empty value.
  813. // This may be used to include null fields in Patch requests.
  814. NullFields []string `json:"-"`
  815. }
  816. func (s *WriteTimeseriesResponse) MarshalJSON() ([]byte, error) {
  817. type NoMethod WriteTimeseriesResponse
  818. raw := NoMethod(*s)
  819. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  820. }
  821. // method id "cloudmonitoring.metricDescriptors.create":
  822. type MetricDescriptorsCreateCall struct {
  823. s *Service
  824. project string
  825. metricdescriptor *MetricDescriptor
  826. urlParams_ gensupport.URLParams
  827. ctx_ context.Context
  828. header_ http.Header
  829. }
  830. // Create: Create a new metric.
  831. func (r *MetricDescriptorsService) Create(project string, metricdescriptor *MetricDescriptor) *MetricDescriptorsCreateCall {
  832. c := &MetricDescriptorsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  833. c.project = project
  834. c.metricdescriptor = metricdescriptor
  835. return c
  836. }
  837. // Fields allows partial responses to be retrieved. See
  838. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  839. // for more information.
  840. func (c *MetricDescriptorsCreateCall) Fields(s ...googleapi.Field) *MetricDescriptorsCreateCall {
  841. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  842. return c
  843. }
  844. // Context sets the context to be used in this call's Do method. Any
  845. // pending HTTP request will be aborted if the provided context is
  846. // canceled.
  847. func (c *MetricDescriptorsCreateCall) Context(ctx context.Context) *MetricDescriptorsCreateCall {
  848. c.ctx_ = ctx
  849. return c
  850. }
  851. // Header returns an http.Header that can be modified by the caller to
  852. // add HTTP headers to the request.
  853. func (c *MetricDescriptorsCreateCall) Header() http.Header {
  854. if c.header_ == nil {
  855. c.header_ = make(http.Header)
  856. }
  857. return c.header_
  858. }
  859. func (c *MetricDescriptorsCreateCall) doRequest(alt string) (*http.Response, error) {
  860. reqHeaders := make(http.Header)
  861. for k, v := range c.header_ {
  862. reqHeaders[k] = v
  863. }
  864. reqHeaders.Set("User-Agent", c.s.userAgent())
  865. var body io.Reader = nil
  866. body, err := googleapi.WithoutDataWrapper.JSONReader(c.metricdescriptor)
  867. if err != nil {
  868. return nil, err
  869. }
  870. reqHeaders.Set("Content-Type", "application/json")
  871. c.urlParams_.Set("alt", alt)
  872. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/metricDescriptors")
  873. urls += "?" + c.urlParams_.Encode()
  874. req, _ := http.NewRequest("POST", urls, body)
  875. req.Header = reqHeaders
  876. googleapi.Expand(req.URL, map[string]string{
  877. "project": c.project,
  878. })
  879. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  880. }
  881. // Do executes the "cloudmonitoring.metricDescriptors.create" call.
  882. // Exactly one of *MetricDescriptor or error will be non-nil. Any
  883. // non-2xx status code is an error. Response headers are in either
  884. // *MetricDescriptor.ServerResponse.Header or (if a response was
  885. // returned at all) in error.(*googleapi.Error).Header. Use
  886. // googleapi.IsNotModified to check whether the returned error was
  887. // because http.StatusNotModified was returned.
  888. func (c *MetricDescriptorsCreateCall) Do(opts ...googleapi.CallOption) (*MetricDescriptor, error) {
  889. gensupport.SetOptions(c.urlParams_, opts...)
  890. res, err := c.doRequest("json")
  891. if res != nil && res.StatusCode == http.StatusNotModified {
  892. if res.Body != nil {
  893. res.Body.Close()
  894. }
  895. return nil, &googleapi.Error{
  896. Code: res.StatusCode,
  897. Header: res.Header,
  898. }
  899. }
  900. if err != nil {
  901. return nil, err
  902. }
  903. defer googleapi.CloseBody(res)
  904. if err := googleapi.CheckResponse(res); err != nil {
  905. return nil, err
  906. }
  907. ret := &MetricDescriptor{
  908. ServerResponse: googleapi.ServerResponse{
  909. Header: res.Header,
  910. HTTPStatusCode: res.StatusCode,
  911. },
  912. }
  913. target := &ret
  914. if err := gensupport.DecodeResponse(target, res); err != nil {
  915. return nil, err
  916. }
  917. return ret, nil
  918. // {
  919. // "description": "Create a new metric.",
  920. // "httpMethod": "POST",
  921. // "id": "cloudmonitoring.metricDescriptors.create",
  922. // "parameterOrder": [
  923. // "project"
  924. // ],
  925. // "parameters": {
  926. // "project": {
  927. // "description": "The project id. The value can be the numeric project ID or string-based project name.",
  928. // "location": "path",
  929. // "required": true,
  930. // "type": "string"
  931. // }
  932. // },
  933. // "path": "{project}/metricDescriptors",
  934. // "request": {
  935. // "$ref": "MetricDescriptor"
  936. // },
  937. // "response": {
  938. // "$ref": "MetricDescriptor"
  939. // },
  940. // "scopes": [
  941. // "https://www.googleapis.com/auth/cloud-platform",
  942. // "https://www.googleapis.com/auth/monitoring"
  943. // ]
  944. // }
  945. }
  946. // method id "cloudmonitoring.metricDescriptors.delete":
  947. type MetricDescriptorsDeleteCall struct {
  948. s *Service
  949. project string
  950. metric string
  951. urlParams_ gensupport.URLParams
  952. ctx_ context.Context
  953. header_ http.Header
  954. }
  955. // Delete: Delete an existing metric.
  956. func (r *MetricDescriptorsService) Delete(project string, metric string) *MetricDescriptorsDeleteCall {
  957. c := &MetricDescriptorsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  958. c.project = project
  959. c.metric = metric
  960. return c
  961. }
  962. // Fields allows partial responses to be retrieved. See
  963. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  964. // for more information.
  965. func (c *MetricDescriptorsDeleteCall) Fields(s ...googleapi.Field) *MetricDescriptorsDeleteCall {
  966. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  967. return c
  968. }
  969. // Context sets the context to be used in this call's Do method. Any
  970. // pending HTTP request will be aborted if the provided context is
  971. // canceled.
  972. func (c *MetricDescriptorsDeleteCall) Context(ctx context.Context) *MetricDescriptorsDeleteCall {
  973. c.ctx_ = ctx
  974. return c
  975. }
  976. // Header returns an http.Header that can be modified by the caller to
  977. // add HTTP headers to the request.
  978. func (c *MetricDescriptorsDeleteCall) Header() http.Header {
  979. if c.header_ == nil {
  980. c.header_ = make(http.Header)
  981. }
  982. return c.header_
  983. }
  984. func (c *MetricDescriptorsDeleteCall) doRequest(alt string) (*http.Response, error) {
  985. reqHeaders := make(http.Header)
  986. for k, v := range c.header_ {
  987. reqHeaders[k] = v
  988. }
  989. reqHeaders.Set("User-Agent", c.s.userAgent())
  990. var body io.Reader = nil
  991. c.urlParams_.Set("alt", alt)
  992. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/metricDescriptors/{metric}")
  993. urls += "?" + c.urlParams_.Encode()
  994. req, _ := http.NewRequest("DELETE", urls, body)
  995. req.Header = reqHeaders
  996. googleapi.Expand(req.URL, map[string]string{
  997. "project": c.project,
  998. "metric": c.metric,
  999. })
  1000. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1001. }
  1002. // Do executes the "cloudmonitoring.metricDescriptors.delete" call.
  1003. // Exactly one of *DeleteMetricDescriptorResponse or error will be
  1004. // non-nil. Any non-2xx status code is an error. Response headers are in
  1005. // either *DeleteMetricDescriptorResponse.ServerResponse.Header or (if a
  1006. // response was returned at all) in error.(*googleapi.Error).Header. Use
  1007. // googleapi.IsNotModified to check whether the returned error was
  1008. // because http.StatusNotModified was returned.
  1009. func (c *MetricDescriptorsDeleteCall) Do(opts ...googleapi.CallOption) (*DeleteMetricDescriptorResponse, error) {
  1010. gensupport.SetOptions(c.urlParams_, opts...)
  1011. res, err := c.doRequest("json")
  1012. if res != nil && res.StatusCode == http.StatusNotModified {
  1013. if res.Body != nil {
  1014. res.Body.Close()
  1015. }
  1016. return nil, &googleapi.Error{
  1017. Code: res.StatusCode,
  1018. Header: res.Header,
  1019. }
  1020. }
  1021. if err != nil {
  1022. return nil, err
  1023. }
  1024. defer googleapi.CloseBody(res)
  1025. if err := googleapi.CheckResponse(res); err != nil {
  1026. return nil, err
  1027. }
  1028. ret := &DeleteMetricDescriptorResponse{
  1029. ServerResponse: googleapi.ServerResponse{
  1030. Header: res.Header,
  1031. HTTPStatusCode: res.StatusCode,
  1032. },
  1033. }
  1034. target := &ret
  1035. if err := gensupport.DecodeResponse(target, res); err != nil {
  1036. return nil, err
  1037. }
  1038. return ret, nil
  1039. // {
  1040. // "description": "Delete an existing metric.",
  1041. // "httpMethod": "DELETE",
  1042. // "id": "cloudmonitoring.metricDescriptors.delete",
  1043. // "parameterOrder": [
  1044. // "project",
  1045. // "metric"
  1046. // ],
  1047. // "parameters": {
  1048. // "metric": {
  1049. // "description": "Name of the metric.",
  1050. // "location": "path",
  1051. // "required": true,
  1052. // "type": "string"
  1053. // },
  1054. // "project": {
  1055. // "description": "The project ID to which the metric belongs.",
  1056. // "location": "path",
  1057. // "required": true,
  1058. // "type": "string"
  1059. // }
  1060. // },
  1061. // "path": "{project}/metricDescriptors/{metric}",
  1062. // "response": {
  1063. // "$ref": "DeleteMetricDescriptorResponse"
  1064. // },
  1065. // "scopes": [
  1066. // "https://www.googleapis.com/auth/cloud-platform",
  1067. // "https://www.googleapis.com/auth/monitoring"
  1068. // ]
  1069. // }
  1070. }
  1071. // method id "cloudmonitoring.metricDescriptors.list":
  1072. type MetricDescriptorsListCall struct {
  1073. s *Service
  1074. project string
  1075. listmetricdescriptorsrequest *ListMetricDescriptorsRequest
  1076. urlParams_ gensupport.URLParams
  1077. ifNoneMatch_ string
  1078. ctx_ context.Context
  1079. header_ http.Header
  1080. }
  1081. // List: List metric descriptors that match the query. If the query is
  1082. // not set, then all of the metric descriptors will be returned. Large
  1083. // responses will be paginated, use the nextPageToken returned in the
  1084. // response to request subsequent pages of results by setting the
  1085. // pageToken query parameter to the value of the nextPageToken.
  1086. func (r *MetricDescriptorsService) List(project string, listmetricdescriptorsrequest *ListMetricDescriptorsRequest) *MetricDescriptorsListCall {
  1087. c := &MetricDescriptorsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1088. c.project = project
  1089. c.listmetricdescriptorsrequest = listmetricdescriptorsrequest
  1090. return c
  1091. }
  1092. // Count sets the optional parameter "count": Maximum number of metric
  1093. // descriptors per page. Used for pagination. If not specified, count =
  1094. // 100.
  1095. func (c *MetricDescriptorsListCall) Count(count int64) *MetricDescriptorsListCall {
  1096. c.urlParams_.Set("count", fmt.Sprint(count))
  1097. return c
  1098. }
  1099. // PageToken sets the optional parameter "pageToken": The pagination
  1100. // token, which is used to page through large result sets. Set this
  1101. // value to the value of the nextPageToken to retrieve the next page of
  1102. // results.
  1103. func (c *MetricDescriptorsListCall) PageToken(pageToken string) *MetricDescriptorsListCall {
  1104. c.urlParams_.Set("pageToken", pageToken)
  1105. return c
  1106. }
  1107. // Query sets the optional parameter "query": The query used to search
  1108. // against existing metrics. Separate keywords with a space; the service
  1109. // joins all keywords with AND, meaning that all keywords must match for
  1110. // a metric to be returned. If this field is omitted, all metrics are
  1111. // returned. If an empty string is passed with this field, no metrics
  1112. // are returned.
  1113. func (c *MetricDescriptorsListCall) Query(query string) *MetricDescriptorsListCall {
  1114. c.urlParams_.Set("query", query)
  1115. return c
  1116. }
  1117. // Fields allows partial responses to be retrieved. See
  1118. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1119. // for more information.
  1120. func (c *MetricDescriptorsListCall) Fields(s ...googleapi.Field) *MetricDescriptorsListCall {
  1121. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1122. return c
  1123. }
  1124. // IfNoneMatch sets the optional parameter which makes the operation
  1125. // fail if the object's ETag matches the given value. This is useful for
  1126. // getting updates only after the object has changed since the last
  1127. // request. Use googleapi.IsNotModified to check whether the response
  1128. // error from Do is the result of In-None-Match.
  1129. func (c *MetricDescriptorsListCall) IfNoneMatch(entityTag string) *MetricDescriptorsListCall {
  1130. c.ifNoneMatch_ = entityTag
  1131. return c
  1132. }
  1133. // Context sets the context to be used in this call's Do method. Any
  1134. // pending HTTP request will be aborted if the provided context is
  1135. // canceled.
  1136. func (c *MetricDescriptorsListCall) Context(ctx context.Context) *MetricDescriptorsListCall {
  1137. c.ctx_ = ctx
  1138. return c
  1139. }
  1140. // Header returns an http.Header that can be modified by the caller to
  1141. // add HTTP headers to the request.
  1142. func (c *MetricDescriptorsListCall) Header() http.Header {
  1143. if c.header_ == nil {
  1144. c.header_ = make(http.Header)
  1145. }
  1146. return c.header_
  1147. }
  1148. func (c *MetricDescriptorsListCall) doRequest(alt string) (*http.Response, error) {
  1149. reqHeaders := make(http.Header)
  1150. for k, v := range c.header_ {
  1151. reqHeaders[k] = v
  1152. }
  1153. reqHeaders.Set("User-Agent", c.s.userAgent())
  1154. if c.ifNoneMatch_ != "" {
  1155. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1156. }
  1157. var body io.Reader = nil
  1158. c.urlParams_.Set("alt", alt)
  1159. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/metricDescriptors")
  1160. urls += "?" + c.urlParams_.Encode()
  1161. req, _ := http.NewRequest("GET", urls, body)
  1162. req.Header = reqHeaders
  1163. googleapi.Expand(req.URL, map[string]string{
  1164. "project": c.project,
  1165. })
  1166. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1167. }
  1168. // Do executes the "cloudmonitoring.metricDescriptors.list" call.
  1169. // Exactly one of *ListMetricDescriptorsResponse or error will be
  1170. // non-nil. Any non-2xx status code is an error. Response headers are in
  1171. // either *ListMetricDescriptorsResponse.ServerResponse.Header or (if a
  1172. // response was returned at all) in error.(*googleapi.Error).Header. Use
  1173. // googleapi.IsNotModified to check whether the returned error was
  1174. // because http.StatusNotModified was returned.
  1175. func (c *MetricDescriptorsListCall) Do(opts ...googleapi.CallOption) (*ListMetricDescriptorsResponse, error) {
  1176. gensupport.SetOptions(c.urlParams_, opts...)
  1177. res, err := c.doRequest("json")
  1178. if res != nil && res.StatusCode == http.StatusNotModified {
  1179. if res.Body != nil {
  1180. res.Body.Close()
  1181. }
  1182. return nil, &googleapi.Error{
  1183. Code: res.StatusCode,
  1184. Header: res.Header,
  1185. }
  1186. }
  1187. if err != nil {
  1188. return nil, err
  1189. }
  1190. defer googleapi.CloseBody(res)
  1191. if err := googleapi.CheckResponse(res); err != nil {
  1192. return nil, err
  1193. }
  1194. ret := &ListMetricDescriptorsResponse{
  1195. ServerResponse: googleapi.ServerResponse{
  1196. Header: res.Header,
  1197. HTTPStatusCode: res.StatusCode,
  1198. },
  1199. }
  1200. target := &ret
  1201. if err := gensupport.DecodeResponse(target, res); err != nil {
  1202. return nil, err
  1203. }
  1204. return ret, nil
  1205. // {
  1206. // "description": "List metric descriptors that match the query. If the query is not set, then all of the metric descriptors will be returned. Large responses will be paginated, use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.",
  1207. // "httpMethod": "GET",
  1208. // "id": "cloudmonitoring.metricDescriptors.list",
  1209. // "parameterOrder": [
  1210. // "project"
  1211. // ],
  1212. // "parameters": {
  1213. // "count": {
  1214. // "default": "100",
  1215. // "description": "Maximum number of metric descriptors per page. Used for pagination. If not specified, count = 100.",
  1216. // "format": "int32",
  1217. // "location": "query",
  1218. // "maximum": "1000",
  1219. // "minimum": "1",
  1220. // "type": "integer"
  1221. // },
  1222. // "pageToken": {
  1223. // "description": "The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.",
  1224. // "location": "query",
  1225. // "type": "string"
  1226. // },
  1227. // "project": {
  1228. // "description": "The project id. The value can be the numeric project ID or string-based project name.",
  1229. // "location": "path",
  1230. // "required": true,
  1231. // "type": "string"
  1232. // },
  1233. // "query": {
  1234. // "description": "The query used to search against existing metrics. Separate keywords with a space; the service joins all keywords with AND, meaning that all keywords must match for a metric to be returned. If this field is omitted, all metrics are returned. If an empty string is passed with this field, no metrics are returned.",
  1235. // "location": "query",
  1236. // "type": "string"
  1237. // }
  1238. // },
  1239. // "path": "{project}/metricDescriptors",
  1240. // "request": {
  1241. // "$ref": "ListMetricDescriptorsRequest"
  1242. // },
  1243. // "response": {
  1244. // "$ref": "ListMetricDescriptorsResponse"
  1245. // },
  1246. // "scopes": [
  1247. // "https://www.googleapis.com/auth/cloud-platform",
  1248. // "https://www.googleapis.com/auth/monitoring"
  1249. // ]
  1250. // }
  1251. }
  1252. // Pages invokes f for each page of results.
  1253. // A non-nil error returned from f will halt the iteration.
  1254. // The provided context supersedes any context provided to the Context method.
  1255. func (c *MetricDescriptorsListCall) Pages(ctx context.Context, f func(*ListMetricDescriptorsResponse) error) error {
  1256. c.ctx_ = ctx
  1257. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1258. for {
  1259. x, err := c.Do()
  1260. if err != nil {
  1261. return err
  1262. }
  1263. if err := f(x); err != nil {
  1264. return err
  1265. }
  1266. if x.NextPageToken == "" {
  1267. return nil
  1268. }
  1269. c.PageToken(x.NextPageToken)
  1270. }
  1271. }
  1272. // method id "cloudmonitoring.timeseries.list":
  1273. type TimeseriesListCall struct {
  1274. s *Service
  1275. project string
  1276. metric string
  1277. listtimeseriesrequest *ListTimeseriesRequest
  1278. urlParams_ gensupport.URLParams
  1279. ifNoneMatch_ string
  1280. ctx_ context.Context
  1281. header_ http.Header
  1282. }
  1283. // List: List the data points of the time series that match the metric
  1284. // and labels values and that have data points in the interval. Large
  1285. // responses are paginated; use the nextPageToken returned in the
  1286. // response to request subsequent pages of results by setting the
  1287. // pageToken query parameter to the value of the nextPageToken.
  1288. func (r *TimeseriesService) List(project string, metric string, youngest string, listtimeseriesrequest *ListTimeseriesRequest) *TimeseriesListCall {
  1289. c := &TimeseriesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1290. c.project = project
  1291. c.metric = metric
  1292. c.urlParams_.Set("youngest", youngest)
  1293. c.listtimeseriesrequest = listtimeseriesrequest
  1294. return c
  1295. }
  1296. // Aggregator sets the optional parameter "aggregator": The aggregation
  1297. // function that will reduce the data points in each window to a single
  1298. // point. This parameter is only valid for non-cumulative metrics with a
  1299. // value type of INT64 or DOUBLE.
  1300. //
  1301. // Possible values:
  1302. // "max"
  1303. // "mean"
  1304. // "min"
  1305. // "sum"
  1306. func (c *TimeseriesListCall) Aggregator(aggregator string) *TimeseriesListCall {
  1307. c.urlParams_.Set("aggregator", aggregator)
  1308. return c
  1309. }
  1310. // Count sets the optional parameter "count": Maximum number of data
  1311. // points per page, which is used for pagination of results.
  1312. func (c *TimeseriesListCall) Count(count int64) *TimeseriesListCall {
  1313. c.urlParams_.Set("count", fmt.Sprint(count))
  1314. return c
  1315. }
  1316. // Labels sets the optional parameter "labels": A collection of labels
  1317. // for the matching time series, which are represented as:
  1318. // - key==value: key equals the value
  1319. // - key=~value: key regex matches the value
  1320. // - key!=value: key does not equal the value
  1321. // - key!~value: key regex does not match the value For example, to
  1322. // list all of the time series descriptors for the region us-central1,
  1323. // you could
  1324. // specify:
  1325. // label=cloud.googleapis.com%2Flocation=~us-central1.*
  1326. func (c *TimeseriesListCall) Labels(labels ...string) *TimeseriesListCall {
  1327. c.urlParams_.SetMulti("labels", append([]string{}, labels...))
  1328. return c
  1329. }
  1330. // Oldest sets the optional parameter "oldest": Start of the time
  1331. // interval (exclusive), which is expressed as an RFC 3339 timestamp. If
  1332. // neither oldest nor timespan is specified, the default time interval
  1333. // will be (youngest - 4 hours, youngest]
  1334. func (c *TimeseriesListCall) Oldest(oldest string) *TimeseriesListCall {
  1335. c.urlParams_.Set("oldest", oldest)
  1336. return c
  1337. }
  1338. // PageToken sets the optional parameter "pageToken": The pagination
  1339. // token, which is used to page through large result sets. Set this
  1340. // value to the value of the nextPageToken to retrieve the next page of
  1341. // results.
  1342. func (c *TimeseriesListCall) PageToken(pageToken string) *TimeseriesListCall {
  1343. c.urlParams_.Set("pageToken", pageToken)
  1344. return c
  1345. }
  1346. // Timespan sets the optional parameter "timespan": Length of the time
  1347. // interval to query, which is an alternative way to declare the
  1348. // interval: (youngest - timespan, youngest]. The timespan and oldest
  1349. // parameters should not be used together. Units:
  1350. // - s: second
  1351. // - m: minute
  1352. // - h: hour
  1353. // - d: day
  1354. // - w: week Examples: 2s, 3m, 4w. Only one unit is allowed, for
  1355. // example: 2w3d is not allowed; you should use 17d instead.
  1356. //
  1357. // If neither oldest nor timespan is specified, the default time
  1358. // interval will be (youngest - 4 hours, youngest].
  1359. func (c *TimeseriesListCall) Timespan(timespan string) *TimeseriesListCall {
  1360. c.urlParams_.Set("timespan", timespan)
  1361. return c
  1362. }
  1363. // Window sets the optional parameter "window": The sampling window. At
  1364. // most one data point will be returned for each window in the requested
  1365. // time interval. This parameter is only valid for non-cumulative metric
  1366. // types. Units:
  1367. // - m: minute
  1368. // - h: hour
  1369. // - d: day
  1370. // - w: week Examples: 3m, 4w. Only one unit is allowed, for example:
  1371. // 2w3d is not allowed; you should use 17d instead.
  1372. func (c *TimeseriesListCall) Window(window string) *TimeseriesListCall {
  1373. c.urlParams_.Set("window", window)
  1374. return c
  1375. }
  1376. // Fields allows partial responses to be retrieved. See
  1377. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1378. // for more information.
  1379. func (c *TimeseriesListCall) Fields(s ...googleapi.Field) *TimeseriesListCall {
  1380. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1381. return c
  1382. }
  1383. // IfNoneMatch sets the optional parameter which makes the operation
  1384. // fail if the object's ETag matches the given value. This is useful for
  1385. // getting updates only after the object has changed since the last
  1386. // request. Use googleapi.IsNotModified to check whether the response
  1387. // error from Do is the result of In-None-Match.
  1388. func (c *TimeseriesListCall) IfNoneMatch(entityTag string) *TimeseriesListCall {
  1389. c.ifNoneMatch_ = entityTag
  1390. return c
  1391. }
  1392. // Context sets the context to be used in this call's Do method. Any
  1393. // pending HTTP request will be aborted if the provided context is
  1394. // canceled.
  1395. func (c *TimeseriesListCall) Context(ctx context.Context) *TimeseriesListCall {
  1396. c.ctx_ = ctx
  1397. return c
  1398. }
  1399. // Header returns an http.Header that can be modified by the caller to
  1400. // add HTTP headers to the request.
  1401. func (c *TimeseriesListCall) Header() http.Header {
  1402. if c.header_ == nil {
  1403. c.header_ = make(http.Header)
  1404. }
  1405. return c.header_
  1406. }
  1407. func (c *TimeseriesListCall) doRequest(alt string) (*http.Response, error) {
  1408. reqHeaders := make(http.Header)
  1409. for k, v := range c.header_ {
  1410. reqHeaders[k] = v
  1411. }
  1412. reqHeaders.Set("User-Agent", c.s.userAgent())
  1413. if c.ifNoneMatch_ != "" {
  1414. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1415. }
  1416. var body io.Reader = nil
  1417. c.urlParams_.Set("alt", alt)
  1418. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/timeseries/{metric}")
  1419. urls += "?" + c.urlParams_.Encode()
  1420. req, _ := http.NewRequest("GET", urls, body)
  1421. req.Header = reqHeaders
  1422. googleapi.Expand(req.URL, map[string]string{
  1423. "project": c.project,
  1424. "metric": c.metric,
  1425. })
  1426. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1427. }
  1428. // Do executes the "cloudmonitoring.timeseries.list" call.
  1429. // Exactly one of *ListTimeseriesResponse or error will be non-nil. Any
  1430. // non-2xx status code is an error. Response headers are in either
  1431. // *ListTimeseriesResponse.ServerResponse.Header or (if a response was
  1432. // returned at all) in error.(*googleapi.Error).Header. Use
  1433. // googleapi.IsNotModified to check whether the returned error was
  1434. // because http.StatusNotModified was returned.
  1435. func (c *TimeseriesListCall) Do(opts ...googleapi.CallOption) (*ListTimeseriesResponse, error) {
  1436. gensupport.SetOptions(c.urlParams_, opts...)
  1437. res, err := c.doRequest("json")
  1438. if res != nil && res.StatusCode == http.StatusNotModified {
  1439. if res.Body != nil {
  1440. res.Body.Close()
  1441. }
  1442. return nil, &googleapi.Error{
  1443. Code: res.StatusCode,
  1444. Header: res.Header,
  1445. }
  1446. }
  1447. if err != nil {
  1448. return nil, err
  1449. }
  1450. defer googleapi.CloseBody(res)
  1451. if err := googleapi.CheckResponse(res); err != nil {
  1452. return nil, err
  1453. }
  1454. ret := &ListTimeseriesResponse{
  1455. ServerResponse: googleapi.ServerResponse{
  1456. Header: res.Header,
  1457. HTTPStatusCode: res.StatusCode,
  1458. },
  1459. }
  1460. target := &ret
  1461. if err := gensupport.DecodeResponse(target, res); err != nil {
  1462. return nil, err
  1463. }
  1464. return ret, nil
  1465. // {
  1466. // "description": "List the data points of the time series that match the metric and labels values and that have data points in the interval. Large responses are paginated; use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.",
  1467. // "httpMethod": "GET",
  1468. // "id": "cloudmonitoring.timeseries.list",
  1469. // "parameterOrder": [
  1470. // "project",
  1471. // "metric",
  1472. // "youngest"
  1473. // ],
  1474. // "parameters": {
  1475. // "aggregator": {
  1476. // "description": "The aggregation function that will reduce the data points in each window to a single point. This parameter is only valid for non-cumulative metrics with a value type of INT64 or DOUBLE.",
  1477. // "enum": [
  1478. // "max",
  1479. // "mean",
  1480. // "min",
  1481. // "sum"
  1482. // ],
  1483. // "enumDescriptions": [
  1484. // "",
  1485. // "",
  1486. // "",
  1487. // ""
  1488. // ],
  1489. // "location": "query",
  1490. // "type": "string"
  1491. // },
  1492. // "count": {
  1493. // "default": "6000",
  1494. // "description": "Maximum number of data points per page, which is used for pagination of results.",
  1495. // "format": "int32",
  1496. // "location": "query",
  1497. // "maximum": "12000",
  1498. // "minimum": "1",
  1499. // "type": "integer"
  1500. // },
  1501. // "labels": {
  1502. // "description": "A collection of labels for the matching time series, which are represented as: \n- key==value: key equals the value \n- key=~value: key regex matches the value \n- key!=value: key does not equal the value \n- key!~value: key regex does not match the value For example, to list all of the time series descriptors for the region us-central1, you could specify:\nlabel=cloud.googleapis.com%2Flocation=~us-central1.*",
  1503. // "location": "query",
  1504. // "pattern": "(.+?)(==|=~|!=|!~)(.+)",
  1505. // "repeated": true,
  1506. // "type": "string"
  1507. // },
  1508. // "metric": {
  1509. // "description": "Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count.",
  1510. // "location": "path",
  1511. // "required": true,
  1512. // "type": "string"
  1513. // },
  1514. // "oldest": {
  1515. // "description": "Start of the time interval (exclusive), which is expressed as an RFC 3339 timestamp. If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest]",
  1516. // "location": "query",
  1517. // "type": "string"
  1518. // },
  1519. // "pageToken": {
  1520. // "description": "The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.",
  1521. // "location": "query",
  1522. // "type": "string"
  1523. // },
  1524. // "project": {
  1525. // "description": "The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name.",
  1526. // "location": "path",
  1527. // "required": true,
  1528. // "type": "string"
  1529. // },
  1530. // "timespan": {
  1531. // "description": "Length of the time interval to query, which is an alternative way to declare the interval: (youngest - timespan, youngest]. The timespan and oldest parameters should not be used together. Units: \n- s: second \n- m: minute \n- h: hour \n- d: day \n- w: week Examples: 2s, 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.\n\nIf neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest].",
  1532. // "location": "query",
  1533. // "pattern": "[0-9]+[smhdw]?",
  1534. // "type": "string"
  1535. // },
  1536. // "window": {
  1537. // "description": "The sampling window. At most one data point will be returned for each window in the requested time interval. This parameter is only valid for non-cumulative metric types. Units: \n- m: minute \n- h: hour \n- d: day \n- w: week Examples: 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.",
  1538. // "location": "query",
  1539. // "pattern": "[0-9]+[mhdw]?",
  1540. // "type": "string"
  1541. // },
  1542. // "youngest": {
  1543. // "description": "End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp.",
  1544. // "location": "query",
  1545. // "required": true,
  1546. // "type": "string"
  1547. // }
  1548. // },
  1549. // "path": "{project}/timeseries/{metric}",
  1550. // "request": {
  1551. // "$ref": "ListTimeseriesRequest"
  1552. // },
  1553. // "response": {
  1554. // "$ref": "ListTimeseriesResponse"
  1555. // },
  1556. // "scopes": [
  1557. // "https://www.googleapis.com/auth/cloud-platform",
  1558. // "https://www.googleapis.com/auth/monitoring"
  1559. // ]
  1560. // }
  1561. }
  1562. // Pages invokes f for each page of results.
  1563. // A non-nil error returned from f will halt the iteration.
  1564. // The provided context supersedes any context provided to the Context method.
  1565. func (c *TimeseriesListCall) Pages(ctx context.Context, f func(*ListTimeseriesResponse) error) error {
  1566. c.ctx_ = ctx
  1567. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1568. for {
  1569. x, err := c.Do()
  1570. if err != nil {
  1571. return err
  1572. }
  1573. if err := f(x); err != nil {
  1574. return err
  1575. }
  1576. if x.NextPageToken == "" {
  1577. return nil
  1578. }
  1579. c.PageToken(x.NextPageToken)
  1580. }
  1581. }
  1582. // method id "cloudmonitoring.timeseries.write":
  1583. type TimeseriesWriteCall struct {
  1584. s *Service
  1585. project string
  1586. writetimeseriesrequest *WriteTimeseriesRequest
  1587. urlParams_ gensupport.URLParams
  1588. ctx_ context.Context
  1589. header_ http.Header
  1590. }
  1591. // Write: Put data points to one or more time series for one or more
  1592. // metrics. If a time series does not exist, a new time series will be
  1593. // created. It is not allowed to write a time series point that is older
  1594. // than the existing youngest point of that time series. Points that are
  1595. // older than the existing youngest point of that time series will be
  1596. // discarded silently. Therefore, users should make sure that points of
  1597. // a time series are written sequentially in the order of their end
  1598. // time.
  1599. func (r *TimeseriesService) Write(project string, writetimeseriesrequest *WriteTimeseriesRequest) *TimeseriesWriteCall {
  1600. c := &TimeseriesWriteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1601. c.project = project
  1602. c.writetimeseriesrequest = writetimeseriesrequest
  1603. return c
  1604. }
  1605. // Fields allows partial responses to be retrieved. See
  1606. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1607. // for more information.
  1608. func (c *TimeseriesWriteCall) Fields(s ...googleapi.Field) *TimeseriesWriteCall {
  1609. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1610. return c
  1611. }
  1612. // Context sets the context to be used in this call's Do method. Any
  1613. // pending HTTP request will be aborted if the provided context is
  1614. // canceled.
  1615. func (c *TimeseriesWriteCall) Context(ctx context.Context) *TimeseriesWriteCall {
  1616. c.ctx_ = ctx
  1617. return c
  1618. }
  1619. // Header returns an http.Header that can be modified by the caller to
  1620. // add HTTP headers to the request.
  1621. func (c *TimeseriesWriteCall) Header() http.Header {
  1622. if c.header_ == nil {
  1623. c.header_ = make(http.Header)
  1624. }
  1625. return c.header_
  1626. }
  1627. func (c *TimeseriesWriteCall) doRequest(alt string) (*http.Response, error) {
  1628. reqHeaders := make(http.Header)
  1629. for k, v := range c.header_ {
  1630. reqHeaders[k] = v
  1631. }
  1632. reqHeaders.Set("User-Agent", c.s.userAgent())
  1633. var body io.Reader = nil
  1634. body, err := googleapi.WithoutDataWrapper.JSONReader(c.writetimeseriesrequest)
  1635. if err != nil {
  1636. return nil, err
  1637. }
  1638. reqHeaders.Set("Content-Type", "application/json")
  1639. c.urlParams_.Set("alt", alt)
  1640. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/timeseries:write")
  1641. urls += "?" + c.urlParams_.Encode()
  1642. req, _ := http.NewRequest("POST", urls, body)
  1643. req.Header = reqHeaders
  1644. googleapi.Expand(req.URL, map[string]string{
  1645. "project": c.project,
  1646. })
  1647. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1648. }
  1649. // Do executes the "cloudmonitoring.timeseries.write" call.
  1650. // Exactly one of *WriteTimeseriesResponse or error will be non-nil. Any
  1651. // non-2xx status code is an error. Response headers are in either
  1652. // *WriteTimeseriesResponse.ServerResponse.Header or (if a response was
  1653. // returned at all) in error.(*googleapi.Error).Header. Use
  1654. // googleapi.IsNotModified to check whether the returned error was
  1655. // because http.StatusNotModified was returned.
  1656. func (c *TimeseriesWriteCall) Do(opts ...googleapi.CallOption) (*WriteTimeseriesResponse, error) {
  1657. gensupport.SetOptions(c.urlParams_, opts...)
  1658. res, err := c.doRequest("json")
  1659. if res != nil && res.StatusCode == http.StatusNotModified {
  1660. if res.Body != nil {
  1661. res.Body.Close()
  1662. }
  1663. return nil, &googleapi.Error{
  1664. Code: res.StatusCode,
  1665. Header: res.Header,
  1666. }
  1667. }
  1668. if err != nil {
  1669. return nil, err
  1670. }
  1671. defer googleapi.CloseBody(res)
  1672. if err := googleapi.CheckResponse(res); err != nil {
  1673. return nil, err
  1674. }
  1675. ret := &WriteTimeseriesResponse{
  1676. ServerResponse: googleapi.ServerResponse{
  1677. Header: res.Header,
  1678. HTTPStatusCode: res.StatusCode,
  1679. },
  1680. }
  1681. target := &ret
  1682. if err := gensupport.DecodeResponse(target, res); err != nil {
  1683. return nil, err
  1684. }
  1685. return ret, nil
  1686. // {
  1687. // "description": "Put data points to one or more time series for one or more metrics. If a time series does not exist, a new time series will be created. It is not allowed to write a time series point that is older than the existing youngest point of that time series. Points that are older than the existing youngest point of that time series will be discarded silently. Therefore, users should make sure that points of a time series are written sequentially in the order of their end time.",
  1688. // "httpMethod": "POST",
  1689. // "id": "cloudmonitoring.timeseries.write",
  1690. // "parameterOrder": [
  1691. // "project"
  1692. // ],
  1693. // "parameters": {
  1694. // "project": {
  1695. // "description": "The project ID. The value can be the numeric project ID or string-based project name.",
  1696. // "location": "path",
  1697. // "required": true,
  1698. // "type": "string"
  1699. // }
  1700. // },
  1701. // "path": "{project}/timeseries:write",
  1702. // "request": {
  1703. // "$ref": "WriteTimeseriesRequest"
  1704. // },
  1705. // "response": {
  1706. // "$ref": "WriteTimeseriesResponse"
  1707. // },
  1708. // "scopes": [
  1709. // "https://www.googleapis.com/auth/cloud-platform",
  1710. // "https://www.googleapis.com/auth/monitoring"
  1711. // ]
  1712. // }
  1713. }
  1714. // method id "cloudmonitoring.timeseriesDescriptors.list":
  1715. type TimeseriesDescriptorsListCall struct {
  1716. s *Service
  1717. project string
  1718. metric string
  1719. listtimeseriesdescriptorsrequest *ListTimeseriesDescriptorsRequest
  1720. urlParams_ gensupport.URLParams
  1721. ifNoneMatch_ string
  1722. ctx_ context.Context
  1723. header_ http.Header
  1724. }
  1725. // List: List the descriptors of the time series that match the metric
  1726. // and labels values and that have data points in the interval. Large
  1727. // responses are paginated; use the nextPageToken returned in the
  1728. // response to request subsequent pages of results by setting the
  1729. // pageToken query parameter to the value of the nextPageToken.
  1730. func (r *TimeseriesDescriptorsService) List(project string, metric string, youngest string, listtimeseriesdescriptorsrequest *ListTimeseriesDescriptorsRequest) *TimeseriesDescriptorsListCall {
  1731. c := &TimeseriesDescriptorsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1732. c.project = project
  1733. c.metric = metric
  1734. c.urlParams_.Set("youngest", youngest)
  1735. c.listtimeseriesdescriptorsrequest = listtimeseriesdescriptorsrequest
  1736. return c
  1737. }
  1738. // Aggregator sets the optional parameter "aggregator": The aggregation
  1739. // function that will reduce the data points in each window to a single
  1740. // point. This parameter is only valid for non-cumulative metrics with a
  1741. // value type of INT64 or DOUBLE.
  1742. //
  1743. // Possible values:
  1744. // "max"
  1745. // "mean"
  1746. // "min"
  1747. // "sum"
  1748. func (c *TimeseriesDescriptorsListCall) Aggregator(aggregator string) *TimeseriesDescriptorsListCall {
  1749. c.urlParams_.Set("aggregator", aggregator)
  1750. return c
  1751. }
  1752. // Count sets the optional parameter "count": Maximum number of time
  1753. // series descriptors per page. Used for pagination. If not specified,
  1754. // count = 100.
  1755. func (c *TimeseriesDescriptorsListCall) Count(count int64) *TimeseriesDescriptorsListCall {
  1756. c.urlParams_.Set("count", fmt.Sprint(count))
  1757. return c
  1758. }
  1759. // Labels sets the optional parameter "labels": A collection of labels
  1760. // for the matching time series, which are represented as:
  1761. // - key==value: key equals the value
  1762. // - key=~value: key regex matches the value
  1763. // - key!=value: key does not equal the value
  1764. // - key!~value: key regex does not match the value For example, to
  1765. // list all of the time series descriptors for the region us-central1,
  1766. // you could
  1767. // specify:
  1768. // label=cloud.googleapis.com%2Flocation=~us-central1.*
  1769. func (c *TimeseriesDescriptorsListCall) Labels(labels ...string) *TimeseriesDescriptorsListCall {
  1770. c.urlParams_.SetMulti("labels", append([]string{}, labels...))
  1771. return c
  1772. }
  1773. // Oldest sets the optional parameter "oldest": Start of the time
  1774. // interval (exclusive), which is expressed as an RFC 3339 timestamp. If
  1775. // neither oldest nor timespan is specified, the default time interval
  1776. // will be (youngest - 4 hours, youngest]
  1777. func (c *TimeseriesDescriptorsListCall) Oldest(oldest string) *TimeseriesDescriptorsListCall {
  1778. c.urlParams_.Set("oldest", oldest)
  1779. return c
  1780. }
  1781. // PageToken sets the optional parameter "pageToken": The pagination
  1782. // token, which is used to page through large result sets. Set this
  1783. // value to the value of the nextPageToken to retrieve the next page of
  1784. // results.
  1785. func (c *TimeseriesDescriptorsListCall) PageToken(pageToken string) *TimeseriesDescriptorsListCall {
  1786. c.urlParams_.Set("pageToken", pageToken)
  1787. return c
  1788. }
  1789. // Timespan sets the optional parameter "timespan": Length of the time
  1790. // interval to query, which is an alternative way to declare the
  1791. // interval: (youngest - timespan, youngest]. The timespan and oldest
  1792. // parameters should not be used together. Units:
  1793. // - s: second
  1794. // - m: minute
  1795. // - h: hour
  1796. // - d: day
  1797. // - w: week Examples: 2s, 3m, 4w. Only one unit is allowed, for
  1798. // example: 2w3d is not allowed; you should use 17d instead.
  1799. //
  1800. // If neither oldest nor timespan is specified, the default time
  1801. // interval will be (youngest - 4 hours, youngest].
  1802. func (c *TimeseriesDescriptorsListCall) Timespan(timespan string) *TimeseriesDescriptorsListCall {
  1803. c.urlParams_.Set("timespan", timespan)
  1804. return c
  1805. }
  1806. // Window sets the optional parameter "window": The sampling window. At
  1807. // most one data point will be returned for each window in the requested
  1808. // time interval. This parameter is only valid for non-cumulative metric
  1809. // types. Units:
  1810. // - m: minute
  1811. // - h: hour
  1812. // - d: day
  1813. // - w: week Examples: 3m, 4w. Only one unit is allowed, for example:
  1814. // 2w3d is not allowed; you should use 17d instead.
  1815. func (c *TimeseriesDescriptorsListCall) Window(window string) *TimeseriesDescriptorsListCall {
  1816. c.urlParams_.Set("window", window)
  1817. return c
  1818. }
  1819. // Fields allows partial responses to be retrieved. See
  1820. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1821. // for more information.
  1822. func (c *TimeseriesDescriptorsListCall) Fields(s ...googleapi.Field) *TimeseriesDescriptorsListCall {
  1823. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1824. return c
  1825. }
  1826. // IfNoneMatch sets the optional parameter which makes the operation
  1827. // fail if the object's ETag matches the given value. This is useful for
  1828. // getting updates only after the object has changed since the last
  1829. // request. Use googleapi.IsNotModified to check whether the response
  1830. // error from Do is the result of In-None-Match.
  1831. func (c *TimeseriesDescriptorsListCall) IfNoneMatch(entityTag string) *TimeseriesDescriptorsListCall {
  1832. c.ifNoneMatch_ = entityTag
  1833. return c
  1834. }
  1835. // Context sets the context to be used in this call's Do method. Any
  1836. // pending HTTP request will be aborted if the provided context is
  1837. // canceled.
  1838. func (c *TimeseriesDescriptorsListCall) Context(ctx context.Context) *TimeseriesDescriptorsListCall {
  1839. c.ctx_ = ctx
  1840. return c
  1841. }
  1842. // Header returns an http.Header that can be modified by the caller to
  1843. // add HTTP headers to the request.
  1844. func (c *TimeseriesDescriptorsListCall) Header() http.Header {
  1845. if c.header_ == nil {
  1846. c.header_ = make(http.Header)
  1847. }
  1848. return c.header_
  1849. }
  1850. func (c *TimeseriesDescriptorsListCall) doRequest(alt string) (*http.Response, error) {
  1851. reqHeaders := make(http.Header)
  1852. for k, v := range c.header_ {
  1853. reqHeaders[k] = v
  1854. }
  1855. reqHeaders.Set("User-Agent", c.s.userAgent())
  1856. if c.ifNoneMatch_ != "" {
  1857. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1858. }
  1859. var body io.Reader = nil
  1860. c.urlParams_.Set("alt", alt)
  1861. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/timeseriesDescriptors/{metric}")
  1862. urls += "?" + c.urlParams_.Encode()
  1863. req, _ := http.NewRequest("GET", urls, body)
  1864. req.Header = reqHeaders
  1865. googleapi.Expand(req.URL, map[string]string{
  1866. "project": c.project,
  1867. "metric": c.metric,
  1868. })
  1869. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1870. }
  1871. // Do executes the "cloudmonitoring.timeseriesDescriptors.list" call.
  1872. // Exactly one of *ListTimeseriesDescriptorsResponse or error will be
  1873. // non-nil. Any non-2xx status code is an error. Response headers are in
  1874. // either *ListTimeseriesDescriptorsResponse.ServerResponse.Header or
  1875. // (if a response was returned at all) in
  1876. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1877. // whether the returned error was because http.StatusNotModified was
  1878. // returned.
  1879. func (c *TimeseriesDescriptorsListCall) Do(opts ...googleapi.CallOption) (*ListTimeseriesDescriptorsResponse, error) {
  1880. gensupport.SetOptions(c.urlParams_, opts...)
  1881. res, err := c.doRequest("json")
  1882. if res != nil && res.StatusCode == http.StatusNotModified {
  1883. if res.Body != nil {
  1884. res.Body.Close()
  1885. }
  1886. return nil, &googleapi.Error{
  1887. Code: res.StatusCode,
  1888. Header: res.Header,
  1889. }
  1890. }
  1891. if err != nil {
  1892. return nil, err
  1893. }
  1894. defer googleapi.CloseBody(res)
  1895. if err := googleapi.CheckResponse(res); err != nil {
  1896. return nil, err
  1897. }
  1898. ret := &ListTimeseriesDescriptorsResponse{
  1899. ServerResponse: googleapi.ServerResponse{
  1900. Header: res.Header,
  1901. HTTPStatusCode: res.StatusCode,
  1902. },
  1903. }
  1904. target := &ret
  1905. if err := gensupport.DecodeResponse(target, res); err != nil {
  1906. return nil, err
  1907. }
  1908. return ret, nil
  1909. // {
  1910. // "description": "List the descriptors of the time series that match the metric and labels values and that have data points in the interval. Large responses are paginated; use the nextPageToken returned in the response to request subsequent pages of results by setting the pageToken query parameter to the value of the nextPageToken.",
  1911. // "httpMethod": "GET",
  1912. // "id": "cloudmonitoring.timeseriesDescriptors.list",
  1913. // "parameterOrder": [
  1914. // "project",
  1915. // "metric",
  1916. // "youngest"
  1917. // ],
  1918. // "parameters": {
  1919. // "aggregator": {
  1920. // "description": "The aggregation function that will reduce the data points in each window to a single point. This parameter is only valid for non-cumulative metrics with a value type of INT64 or DOUBLE.",
  1921. // "enum": [
  1922. // "max",
  1923. // "mean",
  1924. // "min",
  1925. // "sum"
  1926. // ],
  1927. // "enumDescriptions": [
  1928. // "",
  1929. // "",
  1930. // "",
  1931. // ""
  1932. // ],
  1933. // "location": "query",
  1934. // "type": "string"
  1935. // },
  1936. // "count": {
  1937. // "default": "100",
  1938. // "description": "Maximum number of time series descriptors per page. Used for pagination. If not specified, count = 100.",
  1939. // "format": "int32",
  1940. // "location": "query",
  1941. // "maximum": "1000",
  1942. // "minimum": "1",
  1943. // "type": "integer"
  1944. // },
  1945. // "labels": {
  1946. // "description": "A collection of labels for the matching time series, which are represented as: \n- key==value: key equals the value \n- key=~value: key regex matches the value \n- key!=value: key does not equal the value \n- key!~value: key regex does not match the value For example, to list all of the time series descriptors for the region us-central1, you could specify:\nlabel=cloud.googleapis.com%2Flocation=~us-central1.*",
  1947. // "location": "query",
  1948. // "pattern": "(.+?)(==|=~|!=|!~)(.+)",
  1949. // "repeated": true,
  1950. // "type": "string"
  1951. // },
  1952. // "metric": {
  1953. // "description": "Metric names are protocol-free URLs as listed in the Supported Metrics page. For example, compute.googleapis.com/instance/disk/read_ops_count.",
  1954. // "location": "path",
  1955. // "required": true,
  1956. // "type": "string"
  1957. // },
  1958. // "oldest": {
  1959. // "description": "Start of the time interval (exclusive), which is expressed as an RFC 3339 timestamp. If neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest]",
  1960. // "location": "query",
  1961. // "type": "string"
  1962. // },
  1963. // "pageToken": {
  1964. // "description": "The pagination token, which is used to page through large result sets. Set this value to the value of the nextPageToken to retrieve the next page of results.",
  1965. // "location": "query",
  1966. // "type": "string"
  1967. // },
  1968. // "project": {
  1969. // "description": "The project ID to which this time series belongs. The value can be the numeric project ID or string-based project name.",
  1970. // "location": "path",
  1971. // "required": true,
  1972. // "type": "string"
  1973. // },
  1974. // "timespan": {
  1975. // "description": "Length of the time interval to query, which is an alternative way to declare the interval: (youngest - timespan, youngest]. The timespan and oldest parameters should not be used together. Units: \n- s: second \n- m: minute \n- h: hour \n- d: day \n- w: week Examples: 2s, 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.\n\nIf neither oldest nor timespan is specified, the default time interval will be (youngest - 4 hours, youngest].",
  1976. // "location": "query",
  1977. // "pattern": "[0-9]+[smhdw]?",
  1978. // "type": "string"
  1979. // },
  1980. // "window": {
  1981. // "description": "The sampling window. At most one data point will be returned for each window in the requested time interval. This parameter is only valid for non-cumulative metric types. Units: \n- m: minute \n- h: hour \n- d: day \n- w: week Examples: 3m, 4w. Only one unit is allowed, for example: 2w3d is not allowed; you should use 17d instead.",
  1982. // "location": "query",
  1983. // "pattern": "[0-9]+[mhdw]?",
  1984. // "type": "string"
  1985. // },
  1986. // "youngest": {
  1987. // "description": "End of the time interval (inclusive), which is expressed as an RFC 3339 timestamp.",
  1988. // "location": "query",
  1989. // "required": true,
  1990. // "type": "string"
  1991. // }
  1992. // },
  1993. // "path": "{project}/timeseriesDescriptors/{metric}",
  1994. // "request": {
  1995. // "$ref": "ListTimeseriesDescriptorsRequest"
  1996. // },
  1997. // "response": {
  1998. // "$ref": "ListTimeseriesDescriptorsResponse"
  1999. // },
  2000. // "scopes": [
  2001. // "https://www.googleapis.com/auth/cloud-platform",
  2002. // "https://www.googleapis.com/auth/monitoring"
  2003. // ]
  2004. // }
  2005. }
  2006. // Pages invokes f for each page of results.
  2007. // A non-nil error returned from f will halt the iteration.
  2008. // The provided context supersedes any context provided to the Context method.
  2009. func (c *TimeseriesDescriptorsListCall) Pages(ctx context.Context, f func(*ListTimeseriesDescriptorsResponse) error) error {
  2010. c.ctx_ = ctx
  2011. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2012. for {
  2013. x, err := c.Do()
  2014. if err != nil {
  2015. return err
  2016. }
  2017. if err := f(x); err != nil {
  2018. return err
  2019. }
  2020. if x.NextPageToken == "" {
  2021. return nil
  2022. }
  2023. c.PageToken(x.NextPageToken)
  2024. }
  2025. }