...

Source file src/google.golang.org/api/cloudtrace/v2beta1/cloudtrace-gen.go

Documentation: google.golang.org/api/cloudtrace/v2beta1

     1  // Copyright 2024 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 cloudtrace provides access to the Cloud Trace API.
     8  //
     9  // For product documentation, see: https://cloud.google.com/trace
    10  //
    11  // # Library status
    12  //
    13  // These client libraries are officially supported by Google. However, this
    14  // library is considered complete and is in maintenance mode. This means
    15  // that we will address critical bugs and security issues but will not add
    16  // any new features.
    17  //
    18  // When possible, we recommend using our newer
    19  // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
    20  // that are still actively being worked and iterated on.
    21  //
    22  // # Creating a client
    23  //
    24  // Usage example:
    25  //
    26  //	import "google.golang.org/api/cloudtrace/v2beta1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	cloudtraceService, err := cloudtrace.NewService(ctx)
    30  //
    31  // In this example, Google Application Default Credentials are used for
    32  // authentication. For information on how to create and obtain Application
    33  // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
    34  //
    35  // # Other authentication options
    36  //
    37  // By default, all available scopes (see "Constants") are used to authenticate.
    38  // To restrict scopes, use [google.golang.org/api/option.WithScopes]:
    39  //
    40  //	cloudtraceService, err := cloudtrace.NewService(ctx, option.WithScopes(cloudtrace.TraceReadonlyScope))
    41  //
    42  // To use an API key for authentication (note: some APIs do not support API
    43  // keys), use [google.golang.org/api/option.WithAPIKey]:
    44  //
    45  //	cloudtraceService, err := cloudtrace.NewService(ctx, option.WithAPIKey("AIza..."))
    46  //
    47  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    48  // flow, use [google.golang.org/api/option.WithTokenSource]:
    49  //
    50  //	config := &oauth2.Config{...}
    51  //	// ...
    52  //	token, err := config.Exchange(ctx, ...)
    53  //	cloudtraceService, err := cloudtrace.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package cloudtrace // import "google.golang.org/api/cloudtrace/v2beta1"
    57  
    58  import (
    59  	"bytes"
    60  	"context"
    61  	"encoding/json"
    62  	"errors"
    63  	"fmt"
    64  	"io"
    65  	"net/http"
    66  	"net/url"
    67  	"strconv"
    68  	"strings"
    69  
    70  	googleapi "google.golang.org/api/googleapi"
    71  	internal "google.golang.org/api/internal"
    72  	gensupport "google.golang.org/api/internal/gensupport"
    73  	option "google.golang.org/api/option"
    74  	internaloption "google.golang.org/api/option/internaloption"
    75  	htransport "google.golang.org/api/transport/http"
    76  )
    77  
    78  // Always reference these packages, just in case the auto-generated code
    79  // below doesn't.
    80  var _ = bytes.NewBuffer
    81  var _ = strconv.Itoa
    82  var _ = fmt.Sprintf
    83  var _ = json.NewDecoder
    84  var _ = io.Copy
    85  var _ = url.Parse
    86  var _ = gensupport.MarshalJSON
    87  var _ = googleapi.Version
    88  var _ = errors.New
    89  var _ = strings.Replace
    90  var _ = context.Canceled
    91  var _ = internaloption.WithDefaultEndpoint
    92  var _ = internal.Version
    93  
    94  const apiId = "cloudtrace:v2beta1"
    95  const apiName = "cloudtrace"
    96  const apiVersion = "v2beta1"
    97  const basePath = "https://cloudtrace.googleapis.com/"
    98  const basePathTemplate = "https://cloudtrace.UNIVERSE_DOMAIN/"
    99  const mtlsBasePath = "https://cloudtrace.mtls.googleapis.com/"
   100  
   101  // OAuth2 scopes used by this API.
   102  const (
   103  	// See, edit, configure, and delete your Google Cloud data and see the email
   104  	// address for your Google Account.
   105  	CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
   106  
   107  	// Write Trace data for a project or application
   108  	TraceAppendScope = "https://www.googleapis.com/auth/trace.append"
   109  
   110  	// Read Trace data for a project or application
   111  	TraceReadonlyScope = "https://www.googleapis.com/auth/trace.readonly"
   112  )
   113  
   114  // NewService creates a new Service.
   115  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   116  	scopesOption := internaloption.WithDefaultScopes(
   117  		"https://www.googleapis.com/auth/cloud-platform",
   118  		"https://www.googleapis.com/auth/trace.append",
   119  		"https://www.googleapis.com/auth/trace.readonly",
   120  	)
   121  	// NOTE: prepend, so we don't override user-specified scopes.
   122  	opts = append([]option.ClientOption{scopesOption}, opts...)
   123  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   124  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   125  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   126  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   127  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   128  	if err != nil {
   129  		return nil, err
   130  	}
   131  	s, err := New(client)
   132  	if err != nil {
   133  		return nil, err
   134  	}
   135  	if endpoint != "" {
   136  		s.BasePath = endpoint
   137  	}
   138  	return s, nil
   139  }
   140  
   141  // New creates a new Service. It uses the provided http.Client for requests.
   142  //
   143  // Deprecated: please use NewService instead.
   144  // To provide a custom HTTP client, use option.WithHTTPClient.
   145  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   146  func New(client *http.Client) (*Service, error) {
   147  	if client == nil {
   148  		return nil, errors.New("client is nil")
   149  	}
   150  	s := &Service{client: client, BasePath: basePath}
   151  	s.Projects = NewProjectsService(s)
   152  	return s, nil
   153  }
   154  
   155  type Service struct {
   156  	client    *http.Client
   157  	BasePath  string // API endpoint base URL
   158  	UserAgent string // optional additional User-Agent fragment
   159  
   160  	Projects *ProjectsService
   161  }
   162  
   163  func (s *Service) userAgent() string {
   164  	if s.UserAgent == "" {
   165  		return googleapi.UserAgent
   166  	}
   167  	return googleapi.UserAgent + " " + s.UserAgent
   168  }
   169  
   170  func NewProjectsService(s *Service) *ProjectsService {
   171  	rs := &ProjectsService{s: s}
   172  	rs.TraceSinks = NewProjectsTraceSinksService(s)
   173  	return rs
   174  }
   175  
   176  type ProjectsService struct {
   177  	s *Service
   178  
   179  	TraceSinks *ProjectsTraceSinksService
   180  }
   181  
   182  func NewProjectsTraceSinksService(s *Service) *ProjectsTraceSinksService {
   183  	rs := &ProjectsTraceSinksService{s: s}
   184  	return rs
   185  }
   186  
   187  type ProjectsTraceSinksService struct {
   188  	s *Service
   189  }
   190  
   191  // Empty: A generic empty message that you can re-use to avoid defining
   192  // duplicated empty messages in your APIs. A typical example is to use it as
   193  // the request or the response type of an API method. For instance: service Foo
   194  // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
   195  type Empty struct {
   196  	// ServerResponse contains the HTTP response code and headers from the server.
   197  	googleapi.ServerResponse `json:"-"`
   198  }
   199  
   200  // ListTraceSinksResponse: Result returned from `ListTraceSinks`.
   201  type ListTraceSinksResponse struct {
   202  	// NextPageToken: A paginated response where more pages might be available has
   203  	// `next_page_token` set. To get the next set of results, call the same method
   204  	// again using the value of `next_page_token` as `page_token`.
   205  	NextPageToken string `json:"nextPageToken,omitempty"`
   206  	// Sinks: A list of sinks.
   207  	Sinks []*TraceSink `json:"sinks,omitempty"`
   208  
   209  	// ServerResponse contains the HTTP response code and headers from the server.
   210  	googleapi.ServerResponse `json:"-"`
   211  	// ForceSendFields is a list of field names (e.g. "NextPageToken") to
   212  	// unconditionally include in API requests. By default, fields with empty or
   213  	// default values are omitted from API requests. See
   214  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   215  	// details.
   216  	ForceSendFields []string `json:"-"`
   217  	// NullFields is a list of field names (e.g. "NextPageToken") to include in API
   218  	// requests with the JSON null value. By default, fields with empty values are
   219  	// omitted from API requests. See
   220  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   221  	NullFields []string `json:"-"`
   222  }
   223  
   224  func (s *ListTraceSinksResponse) MarshalJSON() ([]byte, error) {
   225  	type NoMethod ListTraceSinksResponse
   226  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   227  }
   228  
   229  // OutputConfig: OutputConfig contains a destination for writing trace data.
   230  type OutputConfig struct {
   231  	// Destination: The destination for writing trace data. Supported formats
   232  	// include: "bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]"
   233  	Destination string `json:"destination,omitempty"`
   234  	// ForceSendFields is a list of field names (e.g. "Destination") to
   235  	// unconditionally include in API requests. By default, fields with empty or
   236  	// default values are omitted from API requests. See
   237  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   238  	// details.
   239  	ForceSendFields []string `json:"-"`
   240  	// NullFields is a list of field names (e.g. "Destination") to include in API
   241  	// requests with the JSON null value. By default, fields with empty values are
   242  	// omitted from API requests. See
   243  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   244  	NullFields []string `json:"-"`
   245  }
   246  
   247  func (s *OutputConfig) MarshalJSON() ([]byte, error) {
   248  	type NoMethod OutputConfig
   249  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   250  }
   251  
   252  // TraceSink: Describes a sink used to export traces to a BigQuery dataset. The
   253  // sink must be created within a project.
   254  type TraceSink struct {
   255  	// Name: Required. The canonical sink resource name, unique within the project.
   256  	// Must be of the form: projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]. E.g.:
   257  	// "projects/12345/traceSinks/my-project-trace-sink". Sink identifiers are
   258  	// limited to 256 characters and can include only the following characters:
   259  	// upper and lower-case alphanumeric characters, underscores, hyphens, and
   260  	// periods.
   261  	Name string `json:"name,omitempty"`
   262  	// OutputConfig: Required. The export destination.
   263  	OutputConfig *OutputConfig `json:"outputConfig,omitempty"`
   264  	// WriterIdentity: Output only. A service account name for exporting the data.
   265  	// This field is set by sinks.create and sinks.update. The service account will
   266  	// need to be granted write access to the destination specified in the output
   267  	// configuration, see Granting access for a resource
   268  	// (/iam/docs/granting-roles-to-service-accounts#granting_access_to_a_service_ac
   269  	// count_for_a_resource). To create tables and to write data, this account
   270  	// needs the `dataEditor` role. Read more about roles in the BigQuery
   271  	// documentation (https://cloud.google.com/bigquery/docs/access-control). E.g.:
   272  	// "service-00000001@00000002.iam.gserviceaccount.com"
   273  	WriterIdentity string `json:"writerIdentity,omitempty"`
   274  
   275  	// ServerResponse contains the HTTP response code and headers from the server.
   276  	googleapi.ServerResponse `json:"-"`
   277  	// ForceSendFields is a list of field names (e.g. "Name") to unconditionally
   278  	// include in API requests. By default, fields with empty or default values are
   279  	// omitted from API requests. See
   280  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   281  	// details.
   282  	ForceSendFields []string `json:"-"`
   283  	// NullFields is a list of field names (e.g. "Name") to include in API requests
   284  	// with the JSON null value. By default, fields with empty values are omitted
   285  	// from API requests. See
   286  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   287  	NullFields []string `json:"-"`
   288  }
   289  
   290  func (s *TraceSink) MarshalJSON() ([]byte, error) {
   291  	type NoMethod TraceSink
   292  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   293  }
   294  
   295  type ProjectsTraceSinksCreateCall struct {
   296  	s          *Service
   297  	parent     string
   298  	tracesink  *TraceSink
   299  	urlParams_ gensupport.URLParams
   300  	ctx_       context.Context
   301  	header_    http.Header
   302  }
   303  
   304  // Create: Creates a sink that exports trace spans to a destination. The export
   305  // of newly-ingested traces begins immediately, unless the sink's
   306  // `writer_identity` is not permitted to write to the destination. A sink can
   307  // export traces only from the resource owning the sink (the 'parent').
   308  //
   309  //   - parent: The resource in which to create the sink (currently only project
   310  //     sinks are supported): "projects/[PROJECT_ID]" Examples:
   311  //     "projects/my-trace-project", "projects/123456789".
   312  func (r *ProjectsTraceSinksService) Create(parent string, tracesink *TraceSink) *ProjectsTraceSinksCreateCall {
   313  	c := &ProjectsTraceSinksCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   314  	c.parent = parent
   315  	c.tracesink = tracesink
   316  	return c
   317  }
   318  
   319  // Fields allows partial responses to be retrieved. See
   320  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   321  // details.
   322  func (c *ProjectsTraceSinksCreateCall) Fields(s ...googleapi.Field) *ProjectsTraceSinksCreateCall {
   323  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   324  	return c
   325  }
   326  
   327  // Context sets the context to be used in this call's Do method.
   328  func (c *ProjectsTraceSinksCreateCall) Context(ctx context.Context) *ProjectsTraceSinksCreateCall {
   329  	c.ctx_ = ctx
   330  	return c
   331  }
   332  
   333  // Header returns a http.Header that can be modified by the caller to add
   334  // headers to the request.
   335  func (c *ProjectsTraceSinksCreateCall) Header() http.Header {
   336  	if c.header_ == nil {
   337  		c.header_ = make(http.Header)
   338  	}
   339  	return c.header_
   340  }
   341  
   342  func (c *ProjectsTraceSinksCreateCall) doRequest(alt string) (*http.Response, error) {
   343  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   344  	var body io.Reader = nil
   345  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.tracesink)
   346  	if err != nil {
   347  		return nil, err
   348  	}
   349  	c.urlParams_.Set("alt", alt)
   350  	c.urlParams_.Set("prettyPrint", "false")
   351  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+parent}/traceSinks")
   352  	urls += "?" + c.urlParams_.Encode()
   353  	req, err := http.NewRequest("POST", urls, body)
   354  	if err != nil {
   355  		return nil, err
   356  	}
   357  	req.Header = reqHeaders
   358  	googleapi.Expand(req.URL, map[string]string{
   359  		"parent": c.parent,
   360  	})
   361  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   362  }
   363  
   364  // Do executes the "cloudtrace.projects.traceSinks.create" call.
   365  // Any non-2xx status code is an error. Response headers are in either
   366  // *TraceSink.ServerResponse.Header or (if a response was returned at all) in
   367  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   368  // whether the returned error was because http.StatusNotModified was returned.
   369  func (c *ProjectsTraceSinksCreateCall) Do(opts ...googleapi.CallOption) (*TraceSink, error) {
   370  	gensupport.SetOptions(c.urlParams_, opts...)
   371  	res, err := c.doRequest("json")
   372  	if res != nil && res.StatusCode == http.StatusNotModified {
   373  		if res.Body != nil {
   374  			res.Body.Close()
   375  		}
   376  		return nil, gensupport.WrapError(&googleapi.Error{
   377  			Code:   res.StatusCode,
   378  			Header: res.Header,
   379  		})
   380  	}
   381  	if err != nil {
   382  		return nil, err
   383  	}
   384  	defer googleapi.CloseBody(res)
   385  	if err := googleapi.CheckResponse(res); err != nil {
   386  		return nil, gensupport.WrapError(err)
   387  	}
   388  	ret := &TraceSink{
   389  		ServerResponse: googleapi.ServerResponse{
   390  			Header:         res.Header,
   391  			HTTPStatusCode: res.StatusCode,
   392  		},
   393  	}
   394  	target := &ret
   395  	if err := gensupport.DecodeResponse(target, res); err != nil {
   396  		return nil, err
   397  	}
   398  	return ret, nil
   399  }
   400  
   401  type ProjectsTraceSinksDeleteCall struct {
   402  	s          *Service
   403  	nameid     string
   404  	urlParams_ gensupport.URLParams
   405  	ctx_       context.Context
   406  	header_    http.Header
   407  }
   408  
   409  // Delete: Deletes a sink.
   410  //
   411  //   - name: The full resource name of the sink to delete, including the parent
   412  //     resource and the sink identifier:
   413  //     "projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]" Example:
   414  //     "projects/12345/traceSinks/my-sink-id".
   415  func (r *ProjectsTraceSinksService) Delete(nameid string) *ProjectsTraceSinksDeleteCall {
   416  	c := &ProjectsTraceSinksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   417  	c.nameid = nameid
   418  	return c
   419  }
   420  
   421  // Fields allows partial responses to be retrieved. See
   422  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   423  // details.
   424  func (c *ProjectsTraceSinksDeleteCall) Fields(s ...googleapi.Field) *ProjectsTraceSinksDeleteCall {
   425  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   426  	return c
   427  }
   428  
   429  // Context sets the context to be used in this call's Do method.
   430  func (c *ProjectsTraceSinksDeleteCall) Context(ctx context.Context) *ProjectsTraceSinksDeleteCall {
   431  	c.ctx_ = ctx
   432  	return c
   433  }
   434  
   435  // Header returns a http.Header that can be modified by the caller to add
   436  // headers to the request.
   437  func (c *ProjectsTraceSinksDeleteCall) Header() http.Header {
   438  	if c.header_ == nil {
   439  		c.header_ = make(http.Header)
   440  	}
   441  	return c.header_
   442  }
   443  
   444  func (c *ProjectsTraceSinksDeleteCall) doRequest(alt string) (*http.Response, error) {
   445  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   446  	var body io.Reader = nil
   447  	c.urlParams_.Set("alt", alt)
   448  	c.urlParams_.Set("prettyPrint", "false")
   449  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+name}")
   450  	urls += "?" + c.urlParams_.Encode()
   451  	req, err := http.NewRequest("DELETE", urls, body)
   452  	if err != nil {
   453  		return nil, err
   454  	}
   455  	req.Header = reqHeaders
   456  	googleapi.Expand(req.URL, map[string]string{
   457  		"name": c.nameid,
   458  	})
   459  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   460  }
   461  
   462  // Do executes the "cloudtrace.projects.traceSinks.delete" call.
   463  // Any non-2xx status code is an error. Response headers are in either
   464  // *Empty.ServerResponse.Header or (if a response was returned at all) in
   465  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   466  // whether the returned error was because http.StatusNotModified was returned.
   467  func (c *ProjectsTraceSinksDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
   468  	gensupport.SetOptions(c.urlParams_, opts...)
   469  	res, err := c.doRequest("json")
   470  	if res != nil && res.StatusCode == http.StatusNotModified {
   471  		if res.Body != nil {
   472  			res.Body.Close()
   473  		}
   474  		return nil, gensupport.WrapError(&googleapi.Error{
   475  			Code:   res.StatusCode,
   476  			Header: res.Header,
   477  		})
   478  	}
   479  	if err != nil {
   480  		return nil, err
   481  	}
   482  	defer googleapi.CloseBody(res)
   483  	if err := googleapi.CheckResponse(res); err != nil {
   484  		return nil, gensupport.WrapError(err)
   485  	}
   486  	ret := &Empty{
   487  		ServerResponse: googleapi.ServerResponse{
   488  			Header:         res.Header,
   489  			HTTPStatusCode: res.StatusCode,
   490  		},
   491  	}
   492  	target := &ret
   493  	if err := gensupport.DecodeResponse(target, res); err != nil {
   494  		return nil, err
   495  	}
   496  	return ret, nil
   497  }
   498  
   499  type ProjectsTraceSinksGetCall struct {
   500  	s            *Service
   501  	name         string
   502  	urlParams_   gensupport.URLParams
   503  	ifNoneMatch_ string
   504  	ctx_         context.Context
   505  	header_      http.Header
   506  }
   507  
   508  // Get: Get a trace sink by name under the parent resource (GCP project).
   509  //
   510  //   - name: The resource name of the sink:
   511  //     "projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]" Example:
   512  //     "projects/12345/traceSinks/my-sink-id".
   513  func (r *ProjectsTraceSinksService) Get(name string) *ProjectsTraceSinksGetCall {
   514  	c := &ProjectsTraceSinksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   515  	c.name = name
   516  	return c
   517  }
   518  
   519  // Fields allows partial responses to be retrieved. See
   520  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   521  // details.
   522  func (c *ProjectsTraceSinksGetCall) Fields(s ...googleapi.Field) *ProjectsTraceSinksGetCall {
   523  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   524  	return c
   525  }
   526  
   527  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   528  // object's ETag matches the given value. This is useful for getting updates
   529  // only after the object has changed since the last request.
   530  func (c *ProjectsTraceSinksGetCall) IfNoneMatch(entityTag string) *ProjectsTraceSinksGetCall {
   531  	c.ifNoneMatch_ = entityTag
   532  	return c
   533  }
   534  
   535  // Context sets the context to be used in this call's Do method.
   536  func (c *ProjectsTraceSinksGetCall) Context(ctx context.Context) *ProjectsTraceSinksGetCall {
   537  	c.ctx_ = ctx
   538  	return c
   539  }
   540  
   541  // Header returns a http.Header that can be modified by the caller to add
   542  // headers to the request.
   543  func (c *ProjectsTraceSinksGetCall) Header() http.Header {
   544  	if c.header_ == nil {
   545  		c.header_ = make(http.Header)
   546  	}
   547  	return c.header_
   548  }
   549  
   550  func (c *ProjectsTraceSinksGetCall) doRequest(alt string) (*http.Response, error) {
   551  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   552  	if c.ifNoneMatch_ != "" {
   553  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   554  	}
   555  	var body io.Reader = nil
   556  	c.urlParams_.Set("alt", alt)
   557  	c.urlParams_.Set("prettyPrint", "false")
   558  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+name}")
   559  	urls += "?" + c.urlParams_.Encode()
   560  	req, err := http.NewRequest("GET", urls, body)
   561  	if err != nil {
   562  		return nil, err
   563  	}
   564  	req.Header = reqHeaders
   565  	googleapi.Expand(req.URL, map[string]string{
   566  		"name": c.name,
   567  	})
   568  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   569  }
   570  
   571  // Do executes the "cloudtrace.projects.traceSinks.get" call.
   572  // Any non-2xx status code is an error. Response headers are in either
   573  // *TraceSink.ServerResponse.Header or (if a response was returned at all) in
   574  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   575  // whether the returned error was because http.StatusNotModified was returned.
   576  func (c *ProjectsTraceSinksGetCall) Do(opts ...googleapi.CallOption) (*TraceSink, error) {
   577  	gensupport.SetOptions(c.urlParams_, opts...)
   578  	res, err := c.doRequest("json")
   579  	if res != nil && res.StatusCode == http.StatusNotModified {
   580  		if res.Body != nil {
   581  			res.Body.Close()
   582  		}
   583  		return nil, gensupport.WrapError(&googleapi.Error{
   584  			Code:   res.StatusCode,
   585  			Header: res.Header,
   586  		})
   587  	}
   588  	if err != nil {
   589  		return nil, err
   590  	}
   591  	defer googleapi.CloseBody(res)
   592  	if err := googleapi.CheckResponse(res); err != nil {
   593  		return nil, gensupport.WrapError(err)
   594  	}
   595  	ret := &TraceSink{
   596  		ServerResponse: googleapi.ServerResponse{
   597  			Header:         res.Header,
   598  			HTTPStatusCode: res.StatusCode,
   599  		},
   600  	}
   601  	target := &ret
   602  	if err := gensupport.DecodeResponse(target, res); err != nil {
   603  		return nil, err
   604  	}
   605  	return ret, nil
   606  }
   607  
   608  type ProjectsTraceSinksListCall struct {
   609  	s            *Service
   610  	parent       string
   611  	urlParams_   gensupport.URLParams
   612  	ifNoneMatch_ string
   613  	ctx_         context.Context
   614  	header_      http.Header
   615  }
   616  
   617  // List: List all sinks for the parent resource (GCP project).
   618  //
   619  //   - parent: The parent resource whose sinks are to be listed (currently only
   620  //     project parent resources are supported): "projects/[PROJECT_ID]".
   621  func (r *ProjectsTraceSinksService) List(parent string) *ProjectsTraceSinksListCall {
   622  	c := &ProjectsTraceSinksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   623  	c.parent = parent
   624  	return c
   625  }
   626  
   627  // PageSize sets the optional parameter "pageSize": The maximum number of
   628  // results to return from this request. Non-positive values are ignored. The
   629  // presence of `next_page_token` in the response indicates that more results
   630  // might be available.
   631  func (c *ProjectsTraceSinksListCall) PageSize(pageSize int64) *ProjectsTraceSinksListCall {
   632  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
   633  	return c
   634  }
   635  
   636  // PageToken sets the optional parameter "pageToken": If present, then retrieve
   637  // the next batch of results from the preceding call to this method.
   638  // `page_token` must be the value of `next_page_token` from the previous
   639  // response. The values of other method parameters should be identical to those
   640  // in the previous call.
   641  func (c *ProjectsTraceSinksListCall) PageToken(pageToken string) *ProjectsTraceSinksListCall {
   642  	c.urlParams_.Set("pageToken", pageToken)
   643  	return c
   644  }
   645  
   646  // Fields allows partial responses to be retrieved. See
   647  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   648  // details.
   649  func (c *ProjectsTraceSinksListCall) Fields(s ...googleapi.Field) *ProjectsTraceSinksListCall {
   650  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   651  	return c
   652  }
   653  
   654  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   655  // object's ETag matches the given value. This is useful for getting updates
   656  // only after the object has changed since the last request.
   657  func (c *ProjectsTraceSinksListCall) IfNoneMatch(entityTag string) *ProjectsTraceSinksListCall {
   658  	c.ifNoneMatch_ = entityTag
   659  	return c
   660  }
   661  
   662  // Context sets the context to be used in this call's Do method.
   663  func (c *ProjectsTraceSinksListCall) Context(ctx context.Context) *ProjectsTraceSinksListCall {
   664  	c.ctx_ = ctx
   665  	return c
   666  }
   667  
   668  // Header returns a http.Header that can be modified by the caller to add
   669  // headers to the request.
   670  func (c *ProjectsTraceSinksListCall) Header() http.Header {
   671  	if c.header_ == nil {
   672  		c.header_ = make(http.Header)
   673  	}
   674  	return c.header_
   675  }
   676  
   677  func (c *ProjectsTraceSinksListCall) doRequest(alt string) (*http.Response, error) {
   678  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   679  	if c.ifNoneMatch_ != "" {
   680  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   681  	}
   682  	var body io.Reader = nil
   683  	c.urlParams_.Set("alt", alt)
   684  	c.urlParams_.Set("prettyPrint", "false")
   685  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+parent}/traceSinks")
   686  	urls += "?" + c.urlParams_.Encode()
   687  	req, err := http.NewRequest("GET", urls, body)
   688  	if err != nil {
   689  		return nil, err
   690  	}
   691  	req.Header = reqHeaders
   692  	googleapi.Expand(req.URL, map[string]string{
   693  		"parent": c.parent,
   694  	})
   695  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   696  }
   697  
   698  // Do executes the "cloudtrace.projects.traceSinks.list" call.
   699  // Any non-2xx status code is an error. Response headers are in either
   700  // *ListTraceSinksResponse.ServerResponse.Header or (if a response was returned
   701  // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   702  // check whether the returned error was because http.StatusNotModified was
   703  // returned.
   704  func (c *ProjectsTraceSinksListCall) Do(opts ...googleapi.CallOption) (*ListTraceSinksResponse, error) {
   705  	gensupport.SetOptions(c.urlParams_, opts...)
   706  	res, err := c.doRequest("json")
   707  	if res != nil && res.StatusCode == http.StatusNotModified {
   708  		if res.Body != nil {
   709  			res.Body.Close()
   710  		}
   711  		return nil, gensupport.WrapError(&googleapi.Error{
   712  			Code:   res.StatusCode,
   713  			Header: res.Header,
   714  		})
   715  	}
   716  	if err != nil {
   717  		return nil, err
   718  	}
   719  	defer googleapi.CloseBody(res)
   720  	if err := googleapi.CheckResponse(res); err != nil {
   721  		return nil, gensupport.WrapError(err)
   722  	}
   723  	ret := &ListTraceSinksResponse{
   724  		ServerResponse: googleapi.ServerResponse{
   725  			Header:         res.Header,
   726  			HTTPStatusCode: res.StatusCode,
   727  		},
   728  	}
   729  	target := &ret
   730  	if err := gensupport.DecodeResponse(target, res); err != nil {
   731  		return nil, err
   732  	}
   733  	return ret, nil
   734  }
   735  
   736  // Pages invokes f for each page of results.
   737  // A non-nil error returned from f will halt the iteration.
   738  // The provided context supersedes any context provided to the Context method.
   739  func (c *ProjectsTraceSinksListCall) Pages(ctx context.Context, f func(*ListTraceSinksResponse) error) error {
   740  	c.ctx_ = ctx
   741  	defer c.PageToken(c.urlParams_.Get("pageToken"))
   742  	for {
   743  		x, err := c.Do()
   744  		if err != nil {
   745  			return err
   746  		}
   747  		if err := f(x); err != nil {
   748  			return err
   749  		}
   750  		if x.NextPageToken == "" {
   751  			return nil
   752  		}
   753  		c.PageToken(x.NextPageToken)
   754  	}
   755  }
   756  
   757  type ProjectsTraceSinksPatchCall struct {
   758  	s          *Service
   759  	nameid     string
   760  	tracesink  *TraceSink
   761  	urlParams_ gensupport.URLParams
   762  	ctx_       context.Context
   763  	header_    http.Header
   764  }
   765  
   766  // Patch: Updates a sink. This method updates fields in the existing sink
   767  // according to the provided update mask. The sink's name cannot be changed nor
   768  // any output-only fields (e.g. the writer_identity).
   769  //
   770  //   - name: The full resource name of the sink to update, including the parent
   771  //     resource and the sink identifier:
   772  //     "projects/[PROJECT_NUMBER]/traceSinks/[SINK_ID]" Example:
   773  //     "projects/12345/traceSinks/my-sink-id".
   774  func (r *ProjectsTraceSinksService) Patch(nameid string, tracesink *TraceSink) *ProjectsTraceSinksPatchCall {
   775  	c := &ProjectsTraceSinksPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   776  	c.nameid = nameid
   777  	c.tracesink = tracesink
   778  	return c
   779  }
   780  
   781  // UpdateMask sets the optional parameter "updateMask": Required. Field mask
   782  // that specifies the fields in `trace_sink` that are to be updated. A sink
   783  // field is overwritten if, and only if, it is in the update mask. `name` and
   784  // `writer_identity` fields cannot be updated. An empty `update_mask` is
   785  // considered an error. For a detailed `FieldMask` definition, see
   786  // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
   787  // Example: `updateMask=output_config`.
   788  func (c *ProjectsTraceSinksPatchCall) UpdateMask(updateMask string) *ProjectsTraceSinksPatchCall {
   789  	c.urlParams_.Set("updateMask", updateMask)
   790  	return c
   791  }
   792  
   793  // Fields allows partial responses to be retrieved. See
   794  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   795  // details.
   796  func (c *ProjectsTraceSinksPatchCall) Fields(s ...googleapi.Field) *ProjectsTraceSinksPatchCall {
   797  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   798  	return c
   799  }
   800  
   801  // Context sets the context to be used in this call's Do method.
   802  func (c *ProjectsTraceSinksPatchCall) Context(ctx context.Context) *ProjectsTraceSinksPatchCall {
   803  	c.ctx_ = ctx
   804  	return c
   805  }
   806  
   807  // Header returns a http.Header that can be modified by the caller to add
   808  // headers to the request.
   809  func (c *ProjectsTraceSinksPatchCall) Header() http.Header {
   810  	if c.header_ == nil {
   811  		c.header_ = make(http.Header)
   812  	}
   813  	return c.header_
   814  }
   815  
   816  func (c *ProjectsTraceSinksPatchCall) doRequest(alt string) (*http.Response, error) {
   817  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   818  	var body io.Reader = nil
   819  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.tracesink)
   820  	if err != nil {
   821  		return nil, err
   822  	}
   823  	c.urlParams_.Set("alt", alt)
   824  	c.urlParams_.Set("prettyPrint", "false")
   825  	urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+name}")
   826  	urls += "?" + c.urlParams_.Encode()
   827  	req, err := http.NewRequest("PATCH", urls, body)
   828  	if err != nil {
   829  		return nil, err
   830  	}
   831  	req.Header = reqHeaders
   832  	googleapi.Expand(req.URL, map[string]string{
   833  		"name": c.nameid,
   834  	})
   835  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   836  }
   837  
   838  // Do executes the "cloudtrace.projects.traceSinks.patch" call.
   839  // Any non-2xx status code is an error. Response headers are in either
   840  // *TraceSink.ServerResponse.Header or (if a response was returned at all) in
   841  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   842  // whether the returned error was because http.StatusNotModified was returned.
   843  func (c *ProjectsTraceSinksPatchCall) Do(opts ...googleapi.CallOption) (*TraceSink, error) {
   844  	gensupport.SetOptions(c.urlParams_, opts...)
   845  	res, err := c.doRequest("json")
   846  	if res != nil && res.StatusCode == http.StatusNotModified {
   847  		if res.Body != nil {
   848  			res.Body.Close()
   849  		}
   850  		return nil, gensupport.WrapError(&googleapi.Error{
   851  			Code:   res.StatusCode,
   852  			Header: res.Header,
   853  		})
   854  	}
   855  	if err != nil {
   856  		return nil, err
   857  	}
   858  	defer googleapi.CloseBody(res)
   859  	if err := googleapi.CheckResponse(res); err != nil {
   860  		return nil, gensupport.WrapError(err)
   861  	}
   862  	ret := &TraceSink{
   863  		ServerResponse: googleapi.ServerResponse{
   864  			Header:         res.Header,
   865  			HTTPStatusCode: res.StatusCode,
   866  		},
   867  	}
   868  	target := &ret
   869  	if err := gensupport.DecodeResponse(target, res); err != nil {
   870  		return nil, err
   871  	}
   872  	return ret, nil
   873  }
   874  

View as plain text