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.
 
 
 

345 lines
12 KiB

  1. // Package getwithoutbody provides access to the Example API.
  2. //
  3. // Usage example:
  4. //
  5. // import "google.golang.org/api/getwithoutbody/v1"
  6. // ...
  7. // getwithoutbodyService, err := getwithoutbody.New(oauthHttpClient)
  8. package getwithoutbody // import "google.golang.org/api/getwithoutbody/v1"
  9. import (
  10. "bytes"
  11. "encoding/json"
  12. "errors"
  13. "fmt"
  14. context "golang.org/x/net/context"
  15. ctxhttp "golang.org/x/net/context/ctxhttp"
  16. gensupport "google.golang.org/api/gensupport"
  17. googleapi "google.golang.org/api/googleapi"
  18. "io"
  19. "net/http"
  20. "net/url"
  21. "strconv"
  22. "strings"
  23. )
  24. // Always reference these packages, just in case the auto-generated code
  25. // below doesn't.
  26. var _ = bytes.NewBuffer
  27. var _ = strconv.Itoa
  28. var _ = fmt.Sprintf
  29. var _ = json.NewDecoder
  30. var _ = io.Copy
  31. var _ = url.Parse
  32. var _ = gensupport.MarshalJSON
  33. var _ = googleapi.Version
  34. var _ = errors.New
  35. var _ = strings.Replace
  36. var _ = context.Canceled
  37. var _ = ctxhttp.Do
  38. const apiId = "getwithoutbody:v1"
  39. const apiName = "getwithoutbody"
  40. const apiVersion = "v1"
  41. const basePath = "https://www.googleapis.com/discovery/v1/apis"
  42. func New(client *http.Client) (*Service, error) {
  43. if client == nil {
  44. return nil, errors.New("client is nil")
  45. }
  46. s := &Service{client: client, BasePath: basePath}
  47. s.MetricDescriptors = NewMetricDescriptorsService(s)
  48. return s, nil
  49. }
  50. type Service struct {
  51. client *http.Client
  52. BasePath string // API endpoint base URL
  53. UserAgent string // optional additional User-Agent fragment
  54. MetricDescriptors *MetricDescriptorsService
  55. }
  56. func (s *Service) userAgent() string {
  57. if s.UserAgent == "" {
  58. return googleapi.UserAgent
  59. }
  60. return googleapi.UserAgent + " " + s.UserAgent
  61. }
  62. func NewMetricDescriptorsService(s *Service) *MetricDescriptorsService {
  63. rs := &MetricDescriptorsService{s: s}
  64. return rs
  65. }
  66. type MetricDescriptorsService struct {
  67. s *Service
  68. }
  69. // ListMetricRequest: The request of
  70. // getwithoutbody.metricDescriptors.list.
  71. type ListMetricRequest struct {
  72. // Kind: Identifies what kind of resource this is. Value: the fixed
  73. // string "getwithoutbody#listMetricRequest".
  74. Kind string `json:"kind,omitempty"`
  75. // ForceSendFields is a list of field names (e.g. "Kind") to
  76. // unconditionally include in API requests. By default, fields with
  77. // empty values are omitted from API requests. However, any non-pointer,
  78. // non-interface field appearing in ForceSendFields will be sent to the
  79. // server regardless of whether the field is empty or not. This may be
  80. // used to include empty fields in Patch requests.
  81. ForceSendFields []string `json:"-"`
  82. // NullFields is a list of field names (e.g. "Kind") to include in API
  83. // requests with the JSON null value. By default, fields with empty
  84. // values are omitted from API requests. However, any field with an
  85. // empty value appearing in NullFields will be sent to the server as
  86. // null. It is an error if a field in this list has a non-empty value.
  87. // This may be used to include null fields in Patch requests.
  88. NullFields []string `json:"-"`
  89. }
  90. func (s *ListMetricRequest) MarshalJSON() ([]byte, error) {
  91. type NoMethod ListMetricRequest
  92. raw := NoMethod(*s)
  93. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  94. }
  95. // ListMetricResponse: The response of
  96. // getwithoutbody.metricDescriptors.list.
  97. type ListMetricResponse struct {
  98. // Kind: Identifies what kind of resource this is. Value: the fixed
  99. // string "getwithoutbody#listMetricResponse".
  100. Kind string `json:"kind,omitempty"`
  101. // NextPageToken: Pagination token. If present, indicates that
  102. // additional results are available for retrieval. To access the results
  103. // past the pagination limit, set this value to the pageToken query
  104. // parameter.
  105. NextPageToken string `json:"nextPageToken,omitempty"`
  106. // ServerResponse contains the HTTP response code and headers from the
  107. // server.
  108. googleapi.ServerResponse `json:"-"`
  109. // ForceSendFields is a list of field names (e.g. "Kind") to
  110. // unconditionally include in API requests. By default, fields with
  111. // empty values are omitted from API requests. However, any non-pointer,
  112. // non-interface field appearing in ForceSendFields will be sent to the
  113. // server regardless of whether the field is empty or not. This may be
  114. // used to include empty fields in Patch requests.
  115. ForceSendFields []string `json:"-"`
  116. // NullFields is a list of field names (e.g. "Kind") to include in API
  117. // requests with the JSON null value. By default, fields with empty
  118. // values are omitted from API requests. However, any field with an
  119. // empty value appearing in NullFields will be sent to the server as
  120. // null. It is an error if a field in this list has a non-empty value.
  121. // This may be used to include null fields in Patch requests.
  122. NullFields []string `json:"-"`
  123. }
  124. func (s *ListMetricResponse) MarshalJSON() ([]byte, error) {
  125. type NoMethod ListMetricResponse
  126. raw := NoMethod(*s)
  127. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  128. }
  129. // method id "getwithoutbody.metricDescriptors.list":
  130. type MetricDescriptorsListCall struct {
  131. s *Service
  132. project string
  133. listmetricrequest *ListMetricRequest
  134. urlParams_ gensupport.URLParams
  135. ifNoneMatch_ string
  136. ctx_ context.Context
  137. header_ http.Header
  138. }
  139. // List: List all of the available metric descriptors. Large number of
  140. // metric descriptors will be paginated, use the nextPageToken returned
  141. // in the response to request subsequent pages of results by setting the
  142. // pageToken query parameter to the value of the nextPageToken.
  143. func (r *MetricDescriptorsService) List(project string, listmetricrequest *ListMetricRequest) *MetricDescriptorsListCall {
  144. c := &MetricDescriptorsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  145. c.project = project
  146. c.listmetricrequest = listmetricrequest
  147. return c
  148. }
  149. // Count sets the optional parameter "count": Maximum number of metric
  150. // descriptors per page. Used for pagination. If not specified, count =
  151. // 100.
  152. func (c *MetricDescriptorsListCall) Count(count int64) *MetricDescriptorsListCall {
  153. c.urlParams_.Set("count", fmt.Sprint(count))
  154. return c
  155. }
  156. // PageToken sets the optional parameter "pageToken": The pagination
  157. // token, which is used to page through large result sets. Set this
  158. // value to the value of the nextPageToken to retrieve the next page of
  159. // results.
  160. func (c *MetricDescriptorsListCall) PageToken(pageToken string) *MetricDescriptorsListCall {
  161. c.urlParams_.Set("pageToken", pageToken)
  162. return c
  163. }
  164. // Fields allows partial responses to be retrieved. See
  165. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  166. // for more information.
  167. func (c *MetricDescriptorsListCall) Fields(s ...googleapi.Field) *MetricDescriptorsListCall {
  168. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  169. return c
  170. }
  171. // IfNoneMatch sets the optional parameter which makes the operation
  172. // fail if the object's ETag matches the given value. This is useful for
  173. // getting updates only after the object has changed since the last
  174. // request. Use googleapi.IsNotModified to check whether the response
  175. // error from Do is the result of In-None-Match.
  176. func (c *MetricDescriptorsListCall) IfNoneMatch(entityTag string) *MetricDescriptorsListCall {
  177. c.ifNoneMatch_ = entityTag
  178. return c
  179. }
  180. // Context sets the context to be used in this call's Do method. Any
  181. // pending HTTP request will be aborted if the provided context is
  182. // canceled.
  183. func (c *MetricDescriptorsListCall) Context(ctx context.Context) *MetricDescriptorsListCall {
  184. c.ctx_ = ctx
  185. return c
  186. }
  187. // Header returns an http.Header that can be modified by the caller to
  188. // add HTTP headers to the request.
  189. func (c *MetricDescriptorsListCall) Header() http.Header {
  190. if c.header_ == nil {
  191. c.header_ = make(http.Header)
  192. }
  193. return c.header_
  194. }
  195. func (c *MetricDescriptorsListCall) doRequest(alt string) (*http.Response, error) {
  196. reqHeaders := make(http.Header)
  197. for k, v := range c.header_ {
  198. reqHeaders[k] = v
  199. }
  200. reqHeaders.Set("User-Agent", c.s.userAgent())
  201. if c.ifNoneMatch_ != "" {
  202. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  203. }
  204. var body io.Reader = nil
  205. c.urlParams_.Set("alt", alt)
  206. urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/metricDescriptors")
  207. urls += "?" + c.urlParams_.Encode()
  208. req, _ := http.NewRequest("GET", urls, body)
  209. req.Header = reqHeaders
  210. googleapi.Expand(req.URL, map[string]string{
  211. "project": c.project,
  212. })
  213. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  214. }
  215. // Do executes the "getwithoutbody.metricDescriptors.list" call.
  216. // Exactly one of *ListMetricResponse or error will be non-nil. Any
  217. // non-2xx status code is an error. Response headers are in either
  218. // *ListMetricResponse.ServerResponse.Header or (if a response was
  219. // returned at all) in error.(*googleapi.Error).Header. Use
  220. // googleapi.IsNotModified to check whether the returned error was
  221. // because http.StatusNotModified was returned.
  222. func (c *MetricDescriptorsListCall) Do(opts ...googleapi.CallOption) (*ListMetricResponse, error) {
  223. gensupport.SetOptions(c.urlParams_, opts...)
  224. res, err := c.doRequest("json")
  225. if res != nil && res.StatusCode == http.StatusNotModified {
  226. if res.Body != nil {
  227. res.Body.Close()
  228. }
  229. return nil, &googleapi.Error{
  230. Code: res.StatusCode,
  231. Header: res.Header,
  232. }
  233. }
  234. if err != nil {
  235. return nil, err
  236. }
  237. defer googleapi.CloseBody(res)
  238. if err := googleapi.CheckResponse(res); err != nil {
  239. return nil, err
  240. }
  241. ret := &ListMetricResponse{
  242. ServerResponse: googleapi.ServerResponse{
  243. Header: res.Header,
  244. HTTPStatusCode: res.StatusCode,
  245. },
  246. }
  247. target := &ret
  248. if err := gensupport.DecodeResponse(target, res); err != nil {
  249. return nil, err
  250. }
  251. return ret, nil
  252. // {
  253. // "description": "List all of the available metric descriptors. Large number of metric descriptors 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.",
  254. // "httpMethod": "GET",
  255. // "id": "getwithoutbody.metricDescriptors.list",
  256. // "parameterOrder": [
  257. // "project"
  258. // ],
  259. // "parameters": {
  260. // "count": {
  261. // "default": "100",
  262. // "description": "Maximum number of metric descriptors per page. Used for pagination. If not specified, count = 100.",
  263. // "format": "int32",
  264. // "location": "query",
  265. // "maximum": "1000",
  266. // "minimum": "1",
  267. // "type": "integer"
  268. // },
  269. // "pageToken": {
  270. // "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.",
  271. // "location": "query",
  272. // "type": "string"
  273. // },
  274. // "project": {
  275. // "description": "The project id. The value can be the numeric project ID or string-based project name.",
  276. // "location": "path",
  277. // "required": true,
  278. // "type": "string"
  279. // }
  280. // },
  281. // "path": "{project}/metricDescriptors",
  282. // "request": {
  283. // "$ref": "ListMetricRequest"
  284. // },
  285. // "response": {
  286. // "$ref": "ListMetricResponse"
  287. // },
  288. // "scopes": [
  289. // "https://www.googleapis.com/auth/getwithoutbody.readonly"
  290. // ]
  291. // }
  292. }
  293. // Pages invokes f for each page of results.
  294. // A non-nil error returned from f will halt the iteration.
  295. // The provided context supersedes any context provided to the Context method.
  296. func (c *MetricDescriptorsListCall) Pages(ctx context.Context, f func(*ListMetricResponse) error) error {
  297. c.ctx_ = ctx
  298. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  299. for {
  300. x, err := c.Do()
  301. if err != nil {
  302. return err
  303. }
  304. if err := f(x); err != nil {
  305. return err
  306. }
  307. if x.NextPageToken == "" {
  308. return nil
  309. }
  310. c.PageToken(x.NextPageToken)
  311. }
  312. }