dex/vendor/google.golang.org/api/google-api-go-generator/testdata/getwithoutbody.want
2016-04-08 11:56:29 -07:00

202 lines
6.2 KiB
Text

// 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"
"google.golang.org/api/googleapi"
"encoding/json"
"errors"
"fmt"
"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
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
MetricDescriptors *MetricDescriptorsService
}
func NewMetricDescriptorsService(s *Service) *MetricDescriptorsService {
rs := &MetricDescriptorsService{s: s}
return rs
}
type MetricDescriptorsService struct {
s *Service
}
type ListMetricRequest struct {
// Kind: Identifies what kind of resource this is. Value: the fixed
// string "getwithoutbody#listMetricRequest".
Kind string `json:"kind,omitempty"`
}
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"`
}
// method id "getwithoutbody.metricDescriptors.list":
type MetricDescriptorsListCall struct {
s *Service
project string
listmetricrequest *ListMetricRequest
opt_ map[string]interface{}
}
// 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
}
func (c *MetricDescriptorsListCall) Do() (*ListMetricResponse, error) {
var body io.Reader = nil
params := make(url.Values)
params.Set("alt", "json")
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", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
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"
// ]
// }
}