...

Text file src/google.golang.org/api/google-api-go-generator/testdata/required-query.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 tshealth provides access to the .
     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/tshealth/"
    25//	...
    26//	ctx := context.Background()
    27//	tshealthService, err := tshealth.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//	tshealthService, err := tshealth.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//	tshealthService, err := tshealth.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    47//
    48// See [google.golang.org/api/option.ClientOption] for details on options.
    49package tshealth // import "google.golang.org/api/tshealth/"
    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 = "tshealth:v1"
    88const apiName = "tshealth"
    89const apiVersion = ""
    90const basePath = "https://www.googleapis.com/_ah/api/tshealth/v1/"
    91const basePathTemplate = "https://www.UNIVERSE_DOMAIN/_ah/api/tshealth/v1/"
    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.Techs = NewTechsService(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	Techs *TechsService
   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 NewTechsService(s *Service) *TechsService {
   142	rs := &TechsService{s: s}
   143	return rs
   144}
   145
   146type TechsService struct {
   147	s *Service
   148}
   149
   150// Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse:
   151// Response for a tech count request.
   152type Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse struct {
   153	Count int64 `json:"count,omitempty,string"`
   154
   155	// ServerResponse contains the HTTP response code and headers from the server.
   156	googleapi.ServerResponse `json:"-"`
   157	// ForceSendFields is a list of field names (e.g. "Count") to unconditionally
   158	// include in API requests. By default, fields with empty or default values are
   159	// omitted from API requests. See
   160	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   161	// details.
   162	ForceSendFields []string `json:"-"`
   163	// NullFields is a list of field names (e.g. "Count") to include in API
   164	// requests with the JSON null value. By default, fields with empty values are
   165	// omitted from API requests. See
   166	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   167	NullFields []string `json:"-"`
   168}
   169
   170func (s *Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse) MarshalJSON() ([]byte, error) {
   171	type NoMethod Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse
   172	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   173}
   174
   175type TechsCountCall struct {
   176	s            *Service
   177	urlParams_   gensupport.URLParams
   178	ifNoneMatch_ string
   179	ctx_         context.Context
   180	header_      http.Header
   181}
   182
   183// Count: Counts the number of techs matching the constraints.
   184//
   185// - manager: .
   186func (r *TechsService) Count(manager string) *TechsCountCall {
   187	c := &TechsCountCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   188	c.urlParams_.Set("manager", manager)
   189	return c
   190}
   191
   192// Fields allows partial responses to be retrieved. See
   193// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   194// details.
   195func (c *TechsCountCall) Fields(s ...googleapi.Field) *TechsCountCall {
   196	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   197	return c
   198}
   199
   200// IfNoneMatch sets an optional parameter which makes the operation fail if the
   201// object's ETag matches the given value. This is useful for getting updates
   202// only after the object has changed since the last request.
   203func (c *TechsCountCall) IfNoneMatch(entityTag string) *TechsCountCall {
   204	c.ifNoneMatch_ = entityTag
   205	return c
   206}
   207
   208// Context sets the context to be used in this call's Do method.
   209func (c *TechsCountCall) Context(ctx context.Context) *TechsCountCall {
   210	c.ctx_ = ctx
   211	return c
   212}
   213
   214// Header returns a http.Header that can be modified by the caller to add
   215// headers to the request.
   216func (c *TechsCountCall) Header() http.Header {
   217	if c.header_ == nil {
   218		c.header_ = make(http.Header)
   219	}
   220	return c.header_
   221}
   222
   223func (c *TechsCountCall) doRequest(alt string) (*http.Response, error) {
   224	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   225	if c.ifNoneMatch_ != "" {
   226		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   227	}
   228	var body io.Reader = nil
   229	c.urlParams_.Set("alt", alt)
   230	c.urlParams_.Set("prettyPrint", "false")
   231	urls := googleapi.ResolveRelative(c.s.BasePath, "techs/count")
   232	urls += "?" + c.urlParams_.Encode()
   233	req, err := http.NewRequest("GET", urls, body)
   234	if err != nil {
   235		return nil, err
   236	}
   237	req.Header = reqHeaders
   238	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   239}
   240
   241// Do executes the "tshealth.techs.count" call.
   242// Any non-2xx status code is an error. Response headers are in either
   243// *Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse.S
   244// erverResponse.Header or (if a response was returned at all) in
   245// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   246// whether the returned error was because http.StatusNotModified was returned.
   247func (c *TechsCountCall) Do(opts ...googleapi.CallOption) (*Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse, error) {
   248	gensupport.SetOptions(c.urlParams_, opts...)
   249	res, err := c.doRequest("json")
   250	if res != nil && res.StatusCode == http.StatusNotModified {
   251		if res.Body != nil {
   252			res.Body.Close()
   253		}
   254		return nil, gensupport.WrapError(&googleapi.Error{
   255			Code:   res.StatusCode,
   256			Header: res.Header,
   257		})
   258	}
   259	if err != nil {
   260		return nil, err
   261	}
   262	defer googleapi.CloseBody(res)
   263	if err := googleapi.CheckResponse(res); err != nil {
   264		return nil, gensupport.WrapError(err)
   265	}
   266	ret := &Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse{
   267		ServerResponse: googleapi.ServerResponse{
   268			Header:         res.Header,
   269			HTTPStatusCode: res.StatusCode,
   270		},
   271	}
   272	target := &ret
   273	if err := gensupport.DecodeResponse(target, res); err != nil {
   274		return nil, err
   275	}
   276	return ret, nil
   277}

View as plain text