blob: ba278e2d5f34425e720c3d090e80ddbb969a1a98 [file] [log] [blame]
// Package getwithoutbody provides access to the Example API.
//
// Usage example:
//
// import "google.golang.org/api/getwithoutbody/v1"
// ...
// getwithoutbodyService, err := getwithoutbody.New(oauthHttpClient)
package getwithoutbody
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
"google.golang.org/api/googleapi"
"google.golang.org/api/internal"
"io"
"net/http"
"net/url"
"strconv"
"strings"
)
// Always reference these packages, just in case the auto-generated code
// below doesn't.
var _ = bytes.NewBuffer
var _ = strconv.Itoa
var _ = fmt.Sprintf
var _ = json.NewDecoder
var _ = io.Copy
var _ = url.Parse
var _ = googleapi.Version
var _ = errors.New
var _ = strings.Replace
var _ = internal.MarshalJSON
const apiId = "getwithoutbody:v1"
const apiName = "getwithoutbody"
const apiVersion = "v1"
const basePath = "https://www.googleapis.com/discovery/v1/apis"
func New(client *http.Client) (*Service, error) {
if client == nil {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.MetricDescriptors = NewMetricDescriptorsService(s)
return s, nil
}
type Service struct {
client *http.Client
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
MetricDescriptors *MetricDescriptorsService
}
func (s *Service) userAgent() string {
if s.UserAgent == "" {
return googleapi.UserAgent
}
return googleapi.UserAgent + " " + s.UserAgent
}
func NewMetricDescriptorsService(s *Service) *MetricDescriptorsService {
rs := &MetricDescriptorsService{s: s}
return rs
}
type MetricDescriptorsService struct {
s *Service
}
// ListMetricRequest: The request of
// getwithoutbody.metricDescriptors.list.
type ListMetricRequest struct {
// Kind: Identifies what kind of resource this is. Value: the fixed
// string "getwithoutbody#listMetricRequest".
Kind string `json:"kind,omitempty"`
// ForceSendFields is a list of field names (e.g. "Kind") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}
func (s *ListMetricRequest) MarshalJSON() ([]byte, error) {
type noMethod ListMetricRequest
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}
// ListMetricResponse: The response of
// getwithoutbody.metricDescriptors.list.
type ListMetricResponse struct {
// Kind: Identifies what kind of resource this is. Value: the fixed
// string "getwithoutbody#listMetricResponse".
Kind string `json:"kind,omitempty"`
// NextPageToken: Pagination token. If present, indicates that
// additional results are available for retrieval. To access the results
// past the pagination limit, set this value to the pageToken query
// parameter.
NextPageToken string `json:"nextPageToken,omitempty"`
// ForceSendFields is a list of field names (e.g. "Kind") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}
func (s *ListMetricResponse) MarshalJSON() ([]byte, error) {
type noMethod ListMetricResponse
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}
// method id "getwithoutbody.metricDescriptors.list":
type MetricDescriptorsListCall struct {
s *Service
project string
listmetricrequest *ListMetricRequest
opt_ map[string]interface{}
ctx_ context.Context
}
// List: 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.
func (r *MetricDescriptorsService) List(project string, listmetricrequest *ListMetricRequest) *MetricDescriptorsListCall {
c := &MetricDescriptorsListCall{s: r.s, opt_: make(map[string]interface{})}
c.project = project
c.listmetricrequest = listmetricrequest
return c
}
// Count sets the optional parameter "count": Maximum number of metric
// descriptors per page. Used for pagination. If not specified, count =
// 100.
func (c *MetricDescriptorsListCall) Count(count int64) *MetricDescriptorsListCall {
c.opt_["count"] = count
return c
}
// PageToken sets the optional parameter "pageToken": 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.
func (c *MetricDescriptorsListCall) PageToken(pageToken string) *MetricDescriptorsListCall {
c.opt_["pageToken"] = pageToken
return c
}
// Fields allows partial responses to be retrieved.
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
// for more information.
func (c *MetricDescriptorsListCall) Fields(s ...googleapi.Field) *MetricDescriptorsListCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
// Context sets the context to be used in this call's Do method.
// Any pending HTTP request will be aborted if the provided context
// is canceled.
func (c *MetricDescriptorsListCall) Context(ctx context.Context) *MetricDescriptorsListCall {
c.ctx_ = ctx
return c
}
func (c *MetricDescriptorsListCall) doRequest(alt string) (*http.Response, error) {
var body io.Reader = nil
params := make(url.Values)
params.Set("alt", alt)
if v, ok := c.opt_["count"]; ok {
params.Set("count", fmt.Sprintf("%v", v))
}
if v, ok := c.opt_["pageToken"]; ok {
params.Set("pageToken", fmt.Sprintf("%v", v))
}
if v, ok := c.opt_["fields"]; ok {
params.Set("fields", fmt.Sprintf("%v", v))
}
urls := googleapi.ResolveRelative(c.s.BasePath, "{project}/metricDescriptors")
urls += "?" + params.Encode()
req, _ := http.NewRequest("GET", urls, body)
googleapi.Expand(req.URL, map[string]string{
"project": c.project,
})
req.Header.Set("User-Agent", c.s.userAgent())
if c.ctx_ != nil {
return ctxhttp.Do(c.ctx_, c.s.client, req)
}
return c.s.client.Do(req)
}
func (c *MetricDescriptorsListCall) Do() (*ListMetricResponse, error) {
res, err := c.doRequest("json")
if err != nil {
return nil, err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return nil, err
}
var ret *ListMetricResponse
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
return nil, err
}
return ret, nil
// {
// "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.",
// "httpMethod": "GET",
// "id": "getwithoutbody.metricDescriptors.list",
// "parameterOrder": [
// "project"
// ],
// "parameters": {
// "count": {
// "default": "100",
// "description": "Maximum number of metric descriptors per page. Used for pagination. If not specified, count = 100.",
// "format": "int32",
// "location": "query",
// "maximum": "1000",
// "minimum": "1",
// "type": "integer"
// },
// "pageToken": {
// "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.",
// "location": "query",
// "type": "string"
// },
// "project": {
// "description": "The project id. The value can be the numeric project ID or string-based project name.",
// "location": "path",
// "required": true,
// "type": "string"
// }
// },
// "path": "{project}/metricDescriptors",
// "request": {
// "$ref": "ListMetricRequest"
// },
// "response": {
// "$ref": "ListMetricResponse"
// },
// "scopes": [
// "https://www.googleapis.com/auth/getwithoutbody.readonly"
// ]
// }
}