...

Text file src/google.golang.org/api/google-api-go-generator/testdata/mapofarrayofobjects.want

Documentation: google.golang.org/api/google-api-go-generator/testdata

     1// Copyright YEAR Google LLC.
     2// Use of this source code is governed by a BSD-style
     3// license that can be found in the LICENSE file.
     4
     5// Code generated file. DO NOT EDIT.
     6
     7// Package additionalprops provides access to the Example API.
     8//
     9// # Library status
    10//
    11// These client libraries are officially supported by Google. However, this
    12// library is considered complete and is in maintenance mode. This means
    13// that we will address critical bugs and security issues but will not add
    14// any new features.
    15//
    16// When possible, we recommend using our newer
    17// [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    18// that are still actively being worked and iterated on.
    19//
    20// # Creating a client
    21//
    22// Usage example:
    23//
    24//	import "google.golang.org/api/additionalprops/v1"
    25//	...
    26//	ctx := context.Background()
    27//	additionalpropsService, err := additionalprops.NewService(ctx)
    28//
    29// In this example, Google Application Default Credentials are used for
    30// authentication. For information on how to create and obtain Application
    31// Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    32//
    33// # Other authentication options
    34//
    35// To use an API key for authentication (note: some APIs do not support API
    36// keys), use [google.golang.org/api/option.WithAPIKey]:
    37//
    38//	additionalpropsService, err := additionalprops.NewService(ctx, option.WithAPIKey("AIza..."))
    39//
    40// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    41// flow, use [google.golang.org/api/option.WithTokenSource]:
    42//
    43//	config := &oauth2.Config{...}
    44//	// ...
    45//	token, err := config.Exchange(ctx, ...)
    46//	additionalpropsService, err := additionalprops.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    47//
    48// See [google.golang.org/api/option.ClientOption] for details on options.
    49package additionalprops // import "google.golang.org/api/additionalprops/v1"
    50
    51import (
    52	"bytes"
    53	"context"
    54	"encoding/json"
    55	"errors"
    56	"fmt"
    57	"io"
    58	"net/http"
    59	"net/url"
    60	"strconv"
    61	"strings"
    62
    63	googleapi "google.golang.org/api/googleapi"
    64	internal "google.golang.org/api/internal"
    65	gensupport "google.golang.org/api/internal/gensupport"
    66	option "google.golang.org/api/option"
    67	internaloption "google.golang.org/api/option/internaloption"
    68	htransport "google.golang.org/api/transport/http"
    69)
    70
    71// Always reference these packages, just in case the auto-generated code
    72// below doesn't.
    73var _ = bytes.NewBuffer
    74var _ = strconv.Itoa
    75var _ = fmt.Sprintf
    76var _ = json.NewDecoder
    77var _ = io.Copy
    78var _ = url.Parse
    79var _ = gensupport.MarshalJSON
    80var _ = googleapi.Version
    81var _ = errors.New
    82var _ = strings.Replace
    83var _ = context.Canceled
    84var _ = internaloption.WithDefaultEndpoint
    85var _ = internal.Version
    86
    87const apiId = "additionalprops:v1"
    88const apiName = "additionalprops"
    89const apiVersion = "v1"
    90const basePath = "https://www.googleapis.com/discovery/v1/apis"
    91const basePathTemplate = "https://www.UNIVERSE_DOMAIN/discovery/v1/apis"
    92
    93// NewService creates a new Service.
    94func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    95	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
    96	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
    97	opts = append(opts, internaloption.EnableNewAuthLibrary())
    98	client, endpoint, err := htransport.NewClient(ctx, opts...)
    99	if err != nil {
   100		return nil, err
   101	}
   102	s, err := New(client)
   103	if err != nil {
   104		return nil, err
   105	}
   106	if endpoint != "" {
   107		s.BasePath = endpoint
   108	}
   109	return s, nil
   110}
   111
   112// New creates a new Service. It uses the provided http.Client for requests.
   113//
   114// Deprecated: please use NewService instead.
   115// To provide a custom HTTP client, use option.WithHTTPClient.
   116// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   117func New(client *http.Client) (*Service, error) {
   118	if client == nil {
   119		return nil, errors.New("client is nil")
   120	}
   121	s := &Service{client: client, BasePath: basePath}
   122	s.Atlas = NewAtlasService(s)
   123	return s, nil
   124}
   125
   126type Service struct {
   127	client    *http.Client
   128	BasePath  string // API endpoint base URL
   129	UserAgent string // optional additional User-Agent fragment
   130
   131	Atlas *AtlasService
   132}
   133
   134func (s *Service) userAgent() string {
   135	if s.UserAgent == "" {
   136		return googleapi.UserAgent
   137	}
   138	return googleapi.UserAgent + " " + s.UserAgent
   139}
   140
   141func NewAtlasService(s *Service) *AtlasService {
   142	rs := &AtlasService{s: s}
   143	return rs
   144}
   145
   146type AtlasService struct {
   147	s *Service
   148}
   149
   150type Property struct {
   151}
   152
   153// TimeseriesDescriptor: The descriptions of a time series.
   154type TimeseriesDescriptor struct {
   155	// Labels: The set of key-value pairs that describe this time series, including
   156	// target-specific labels and metric-specific labels.
   157	Labels map[string]string `json:"labels,omitempty"`
   158	// Metric: The name of the metric.
   159	Metric string `json:"metric,omitempty"`
   160	// Project: The project ID to which this time series belongs.
   161	Project string `json:"project,omitempty"`
   162	// Tags: A map of additional information.
   163	Tags map[string][]Property `json:"tags,omitempty"`
   164	// ForceSendFields is a list of field names (e.g. "Labels") to unconditionally
   165	// include in API requests. By default, fields with empty or default values are
   166	// omitted from API requests. See
   167	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   168	// details.
   169	ForceSendFields []string `json:"-"`
   170	// NullFields is a list of field names (e.g. "Labels") to include in API
   171	// requests with the JSON null value. By default, fields with empty values are
   172	// omitted from API requests. See
   173	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   174	NullFields []string `json:"-"`
   175}
   176
   177func (s *TimeseriesDescriptor) MarshalJSON() ([]byte, error) {
   178	type NoMethod TimeseriesDescriptor
   179	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   180}
   181
   182type AtlasGetMapCall struct {
   183	s            *Service
   184	urlParams_   gensupport.URLParams
   185	ifNoneMatch_ string
   186	ctx_         context.Context
   187	header_      http.Header
   188}
   189
   190// GetMap: Get a map.
   191func (r *AtlasService) GetMap() *AtlasGetMapCall {
   192	c := &AtlasGetMapCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   193	return c
   194}
   195
   196// Fields allows partial responses to be retrieved. See
   197// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   198// details.
   199func (c *AtlasGetMapCall) Fields(s ...googleapi.Field) *AtlasGetMapCall {
   200	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   201	return c
   202}
   203
   204// IfNoneMatch sets an optional parameter which makes the operation fail if the
   205// object's ETag matches the given value. This is useful for getting updates
   206// only after the object has changed since the last request.
   207func (c *AtlasGetMapCall) IfNoneMatch(entityTag string) *AtlasGetMapCall {
   208	c.ifNoneMatch_ = entityTag
   209	return c
   210}
   211
   212// Context sets the context to be used in this call's Do method.
   213func (c *AtlasGetMapCall) Context(ctx context.Context) *AtlasGetMapCall {
   214	c.ctx_ = ctx
   215	return c
   216}
   217
   218// Header returns a http.Header that can be modified by the caller to add
   219// headers to the request.
   220func (c *AtlasGetMapCall) Header() http.Header {
   221	if c.header_ == nil {
   222		c.header_ = make(http.Header)
   223	}
   224	return c.header_
   225}
   226
   227func (c *AtlasGetMapCall) doRequest(alt string) (*http.Response, error) {
   228	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   229	if c.ifNoneMatch_ != "" {
   230		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   231	}
   232	var body io.Reader = nil
   233	c.urlParams_.Set("alt", alt)
   234	c.urlParams_.Set("prettyPrint", "false")
   235	urls := googleapi.ResolveRelative(c.s.BasePath, "map")
   236	urls += "?" + c.urlParams_.Encode()
   237	req, err := http.NewRequest("GET", urls, body)
   238	if err != nil {
   239		return nil, err
   240	}
   241	req.Header = reqHeaders
   242	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   243}
   244
   245// Do executes the "mapofstrings.getMap" call.
   246func (c *AtlasGetMapCall) Do(opts ...googleapi.CallOption) (map[string]string, error) {
   247	gensupport.SetOptions(c.urlParams_, opts...)
   248	res, err := c.doRequest("json")
   249	if err != nil {
   250		return nil, err
   251	}
   252	defer googleapi.CloseBody(res)
   253	if err := googleapi.CheckResponse(res); err != nil {
   254		return nil, gensupport.WrapError(err)
   255	}
   256	var ret map[string]string
   257	target := &ret
   258	if err := gensupport.DecodeResponse(target, res); err != nil {
   259		return nil, err
   260	}
   261	return ret, nil
   262}

View as plain text