...

Source file src/google.golang.org/api/playgrouping/v1alpha1/playgrouping-gen.go

Documentation: google.golang.org/api/playgrouping/v1alpha1

     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 playgrouping provides access to the Google Play Grouping API.
     8  //
     9  // For product documentation, see: https://cloud.google.com/playgrouping/
    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/playgrouping/v1alpha1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	playgroupingService, err := playgrouping.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  // To use an API key for authentication (note: some APIs do not support API
    38  // keys), use [google.golang.org/api/option.WithAPIKey]:
    39  //
    40  //	playgroupingService, err := playgrouping.NewService(ctx, option.WithAPIKey("AIza..."))
    41  //
    42  // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
    43  // flow, use [google.golang.org/api/option.WithTokenSource]:
    44  //
    45  //	config := &oauth2.Config{...}
    46  //	// ...
    47  //	token, err := config.Exchange(ctx, ...)
    48  //	playgroupingService, err := playgrouping.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    49  //
    50  // See [google.golang.org/api/option.ClientOption] for details on options.
    51  package playgrouping // import "google.golang.org/api/playgrouping/v1alpha1"
    52  
    53  import (
    54  	"bytes"
    55  	"context"
    56  	"encoding/json"
    57  	"errors"
    58  	"fmt"
    59  	"io"
    60  	"net/http"
    61  	"net/url"
    62  	"strconv"
    63  	"strings"
    64  
    65  	googleapi "google.golang.org/api/googleapi"
    66  	internal "google.golang.org/api/internal"
    67  	gensupport "google.golang.org/api/internal/gensupport"
    68  	option "google.golang.org/api/option"
    69  	internaloption "google.golang.org/api/option/internaloption"
    70  	htransport "google.golang.org/api/transport/http"
    71  )
    72  
    73  // Always reference these packages, just in case the auto-generated code
    74  // below doesn't.
    75  var _ = bytes.NewBuffer
    76  var _ = strconv.Itoa
    77  var _ = fmt.Sprintf
    78  var _ = json.NewDecoder
    79  var _ = io.Copy
    80  var _ = url.Parse
    81  var _ = gensupport.MarshalJSON
    82  var _ = googleapi.Version
    83  var _ = errors.New
    84  var _ = strings.Replace
    85  var _ = context.Canceled
    86  var _ = internaloption.WithDefaultEndpoint
    87  var _ = internal.Version
    88  
    89  const apiId = "playgrouping:v1alpha1"
    90  const apiName = "playgrouping"
    91  const apiVersion = "v1alpha1"
    92  const basePath = "https://playgrouping.googleapis.com/"
    93  const basePathTemplate = "https://playgrouping.UNIVERSE_DOMAIN/"
    94  const mtlsBasePath = "https://playgrouping.mtls.googleapis.com/"
    95  
    96  // NewService creates a new Service.
    97  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
    98  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
    99  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   100  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   101  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   102  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   103  	if err != nil {
   104  		return nil, err
   105  	}
   106  	s, err := New(client)
   107  	if err != nil {
   108  		return nil, err
   109  	}
   110  	if endpoint != "" {
   111  		s.BasePath = endpoint
   112  	}
   113  	return s, nil
   114  }
   115  
   116  // New creates a new Service. It uses the provided http.Client for requests.
   117  //
   118  // Deprecated: please use NewService instead.
   119  // To provide a custom HTTP client, use option.WithHTTPClient.
   120  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   121  func New(client *http.Client) (*Service, error) {
   122  	if client == nil {
   123  		return nil, errors.New("client is nil")
   124  	}
   125  	s := &Service{client: client, BasePath: basePath}
   126  	s.Apps = NewAppsService(s)
   127  	return s, nil
   128  }
   129  
   130  type Service struct {
   131  	client    *http.Client
   132  	BasePath  string // API endpoint base URL
   133  	UserAgent string // optional additional User-Agent fragment
   134  
   135  	Apps *AppsService
   136  }
   137  
   138  func (s *Service) userAgent() string {
   139  	if s.UserAgent == "" {
   140  		return googleapi.UserAgent
   141  	}
   142  	return googleapi.UserAgent + " " + s.UserAgent
   143  }
   144  
   145  func NewAppsService(s *Service) *AppsService {
   146  	rs := &AppsService{s: s}
   147  	rs.Tokens = NewAppsTokensService(s)
   148  	return rs
   149  }
   150  
   151  type AppsService struct {
   152  	s *Service
   153  
   154  	Tokens *AppsTokensService
   155  }
   156  
   157  func NewAppsTokensService(s *Service) *AppsTokensService {
   158  	rs := &AppsTokensService{s: s}
   159  	rs.Tags = NewAppsTokensTagsService(s)
   160  	return rs
   161  }
   162  
   163  type AppsTokensService struct {
   164  	s *Service
   165  
   166  	Tags *AppsTokensTagsService
   167  }
   168  
   169  func NewAppsTokensTagsService(s *Service) *AppsTokensTagsService {
   170  	rs := &AppsTokensTagsService{s: s}
   171  	return rs
   172  }
   173  
   174  type AppsTokensTagsService struct {
   175  	s *Service
   176  }
   177  
   178  // CreateOrUpdateTagsRequest: Request message for CreateOrUpdateTags.
   179  // VerifyToken.
   180  type CreateOrUpdateTagsRequest struct {
   181  	// Tags: Tags to be inserted or updated.
   182  	Tags []*Tag `json:"tags,omitempty"`
   183  	// ForceSendFields is a list of field names (e.g. "Tags") to unconditionally
   184  	// include in API requests. By default, fields with empty or default values are
   185  	// omitted from API requests. See
   186  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   187  	// details.
   188  	ForceSendFields []string `json:"-"`
   189  	// NullFields is a list of field names (e.g. "Tags") to include in API requests
   190  	// with the JSON null value. By default, fields with empty values are omitted
   191  	// from API requests. See
   192  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   193  	NullFields []string `json:"-"`
   194  }
   195  
   196  func (s *CreateOrUpdateTagsRequest) MarshalJSON() ([]byte, error) {
   197  	type NoMethod CreateOrUpdateTagsRequest
   198  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   199  }
   200  
   201  // CreateOrUpdateTagsResponse: Response message for CreateOrUpdateTags.
   202  type CreateOrUpdateTagsResponse struct {
   203  	// Tags: All requested tags are returned, including pre-existing ones.
   204  	Tags []*Tag `json:"tags,omitempty"`
   205  
   206  	// ServerResponse contains the HTTP response code and headers from the server.
   207  	googleapi.ServerResponse `json:"-"`
   208  	// ForceSendFields is a list of field names (e.g. "Tags") to unconditionally
   209  	// include in API requests. By default, fields with empty or default values are
   210  	// omitted from API requests. See
   211  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   212  	// details.
   213  	ForceSendFields []string `json:"-"`
   214  	// NullFields is a list of field names (e.g. "Tags") to include in API requests
   215  	// with the JSON null value. By default, fields with empty values are omitted
   216  	// from API requests. See
   217  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   218  	NullFields []string `json:"-"`
   219  }
   220  
   221  func (s *CreateOrUpdateTagsResponse) MarshalJSON() ([]byte, error) {
   222  	type NoMethod CreateOrUpdateTagsResponse
   223  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   224  }
   225  
   226  // Tag: A tag is associated with exactly one package name and user.
   227  type Tag struct {
   228  	// BooleanValue: A boolean value of the tag.
   229  	BooleanValue bool `json:"booleanValue,omitempty"`
   230  	// Int64Value: A signed 64-bit integer value of the tag.
   231  	Int64Value int64 `json:"int64Value,omitempty,string"`
   232  	// Key: Required. Key for the tag.
   233  	Key string `json:"key,omitempty"`
   234  	// StringValue: A string value of the tag.
   235  	StringValue string `json:"stringValue,omitempty"`
   236  	// TimeValue: A time value of the tag.
   237  	TimeValue string `json:"timeValue,omitempty"`
   238  	// ForceSendFields is a list of field names (e.g. "BooleanValue") to
   239  	// unconditionally include in API requests. By default, fields with empty or
   240  	// default values are omitted from API requests. See
   241  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   242  	// details.
   243  	ForceSendFields []string `json:"-"`
   244  	// NullFields is a list of field names (e.g. "BooleanValue") to include in API
   245  	// requests with the JSON null value. By default, fields with empty values are
   246  	// omitted from API requests. See
   247  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   248  	NullFields []string `json:"-"`
   249  }
   250  
   251  func (s *Tag) MarshalJSON() ([]byte, error) {
   252  	type NoMethod Tag
   253  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   254  }
   255  
   256  // VerifyTokenRequest: Request message for VerifyToken.
   257  type VerifyTokenRequest struct {
   258  	// Persona: Required. Persona represented by the token. Format:
   259  	// personas/{persona}
   260  	Persona string `json:"persona,omitempty"`
   261  	// ForceSendFields is a list of field names (e.g. "Persona") to unconditionally
   262  	// include in API requests. By default, fields with empty or default values are
   263  	// omitted from API requests. See
   264  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   265  	// details.
   266  	ForceSendFields []string `json:"-"`
   267  	// NullFields is a list of field names (e.g. "Persona") to include in API
   268  	// requests with the JSON null value. By default, fields with empty values are
   269  	// omitted from API requests. See
   270  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   271  	NullFields []string `json:"-"`
   272  }
   273  
   274  func (s *VerifyTokenRequest) MarshalJSON() ([]byte, error) {
   275  	type NoMethod VerifyTokenRequest
   276  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   277  }
   278  
   279  // VerifyTokenResponse: Response message for VerifyToken.
   280  type VerifyTokenResponse struct {
   281  	// ServerResponse contains the HTTP response code and headers from the server.
   282  	googleapi.ServerResponse `json:"-"`
   283  }
   284  
   285  type AppsTokensVerifyCall struct {
   286  	s                  *Service
   287  	appPackage         string
   288  	token              string
   289  	verifytokenrequest *VerifyTokenRequest
   290  	urlParams_         gensupport.URLParams
   291  	ctx_               context.Context
   292  	header_            http.Header
   293  }
   294  
   295  // Verify: Verify an API token by asserting the app and persona it belongs to.
   296  // The verification is a protection against client-side attacks and will fail
   297  // if the contents of the token don't match the provided values. A token must
   298  // be verified before it can be used to manipulate user tags.
   299  //
   300  // - appPackage: App the token belongs to. Format: apps/{package_name}.
   301  // - token: The token to be verified. Format: tokens/{token}.
   302  func (r *AppsTokensService) Verify(appPackage string, token string, verifytokenrequest *VerifyTokenRequest) *AppsTokensVerifyCall {
   303  	c := &AppsTokensVerifyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   304  	c.appPackage = appPackage
   305  	c.token = token
   306  	c.verifytokenrequest = verifytokenrequest
   307  	return c
   308  }
   309  
   310  // Fields allows partial responses to be retrieved. See
   311  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   312  // details.
   313  func (c *AppsTokensVerifyCall) Fields(s ...googleapi.Field) *AppsTokensVerifyCall {
   314  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   315  	return c
   316  }
   317  
   318  // Context sets the context to be used in this call's Do method.
   319  func (c *AppsTokensVerifyCall) Context(ctx context.Context) *AppsTokensVerifyCall {
   320  	c.ctx_ = ctx
   321  	return c
   322  }
   323  
   324  // Header returns a http.Header that can be modified by the caller to add
   325  // headers to the request.
   326  func (c *AppsTokensVerifyCall) Header() http.Header {
   327  	if c.header_ == nil {
   328  		c.header_ = make(http.Header)
   329  	}
   330  	return c.header_
   331  }
   332  
   333  func (c *AppsTokensVerifyCall) doRequest(alt string) (*http.Response, error) {
   334  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   335  	var body io.Reader = nil
   336  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.verifytokenrequest)
   337  	if err != nil {
   338  		return nil, err
   339  	}
   340  	c.urlParams_.Set("alt", alt)
   341  	c.urlParams_.Set("prettyPrint", "false")
   342  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha1/{+appPackage}/{+token}:verify")
   343  	urls += "?" + c.urlParams_.Encode()
   344  	req, err := http.NewRequest("POST", urls, body)
   345  	if err != nil {
   346  		return nil, err
   347  	}
   348  	req.Header = reqHeaders
   349  	googleapi.Expand(req.URL, map[string]string{
   350  		"appPackage": c.appPackage,
   351  		"token":      c.token,
   352  	})
   353  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   354  }
   355  
   356  // Do executes the "playgrouping.apps.tokens.verify" call.
   357  // Any non-2xx status code is an error. Response headers are in either
   358  // *VerifyTokenResponse.ServerResponse.Header or (if a response was returned at
   359  // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
   360  // check whether the returned error was because http.StatusNotModified was
   361  // returned.
   362  func (c *AppsTokensVerifyCall) Do(opts ...googleapi.CallOption) (*VerifyTokenResponse, error) {
   363  	gensupport.SetOptions(c.urlParams_, opts...)
   364  	res, err := c.doRequest("json")
   365  	if res != nil && res.StatusCode == http.StatusNotModified {
   366  		if res.Body != nil {
   367  			res.Body.Close()
   368  		}
   369  		return nil, gensupport.WrapError(&googleapi.Error{
   370  			Code:   res.StatusCode,
   371  			Header: res.Header,
   372  		})
   373  	}
   374  	if err != nil {
   375  		return nil, err
   376  	}
   377  	defer googleapi.CloseBody(res)
   378  	if err := googleapi.CheckResponse(res); err != nil {
   379  		return nil, gensupport.WrapError(err)
   380  	}
   381  	ret := &VerifyTokenResponse{
   382  		ServerResponse: googleapi.ServerResponse{
   383  			Header:         res.Header,
   384  			HTTPStatusCode: res.StatusCode,
   385  		},
   386  	}
   387  	target := &ret
   388  	if err := gensupport.DecodeResponse(target, res); err != nil {
   389  		return nil, err
   390  	}
   391  	return ret, nil
   392  }
   393  
   394  type AppsTokensTagsCreateOrUpdateCall struct {
   395  	s                         *Service
   396  	appPackage                string
   397  	token                     string
   398  	createorupdatetagsrequest *CreateOrUpdateTagsRequest
   399  	urlParams_                gensupport.URLParams
   400  	ctx_                      context.Context
   401  	header_                   http.Header
   402  }
   403  
   404  // CreateOrUpdate: Create or update tags for the user and app that are
   405  // represented by the given token.
   406  //
   407  //   - appPackage: App whose tags are being manipulated. Format:
   408  //     apps/{package_name}.
   409  //   - token: Token for which the tags are being inserted or updated. Format:
   410  //     tokens/{token}.
   411  func (r *AppsTokensTagsService) CreateOrUpdate(appPackage string, token string, createorupdatetagsrequest *CreateOrUpdateTagsRequest) *AppsTokensTagsCreateOrUpdateCall {
   412  	c := &AppsTokensTagsCreateOrUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   413  	c.appPackage = appPackage
   414  	c.token = token
   415  	c.createorupdatetagsrequest = createorupdatetagsrequest
   416  	return c
   417  }
   418  
   419  // Fields allows partial responses to be retrieved. See
   420  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   421  // details.
   422  func (c *AppsTokensTagsCreateOrUpdateCall) Fields(s ...googleapi.Field) *AppsTokensTagsCreateOrUpdateCall {
   423  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   424  	return c
   425  }
   426  
   427  // Context sets the context to be used in this call's Do method.
   428  func (c *AppsTokensTagsCreateOrUpdateCall) Context(ctx context.Context) *AppsTokensTagsCreateOrUpdateCall {
   429  	c.ctx_ = ctx
   430  	return c
   431  }
   432  
   433  // Header returns a http.Header that can be modified by the caller to add
   434  // headers to the request.
   435  func (c *AppsTokensTagsCreateOrUpdateCall) Header() http.Header {
   436  	if c.header_ == nil {
   437  		c.header_ = make(http.Header)
   438  	}
   439  	return c.header_
   440  }
   441  
   442  func (c *AppsTokensTagsCreateOrUpdateCall) doRequest(alt string) (*http.Response, error) {
   443  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   444  	var body io.Reader = nil
   445  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.createorupdatetagsrequest)
   446  	if err != nil {
   447  		return nil, err
   448  	}
   449  	c.urlParams_.Set("alt", alt)
   450  	c.urlParams_.Set("prettyPrint", "false")
   451  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1alpha1/{+appPackage}/{+token}/tags:createOrUpdate")
   452  	urls += "?" + c.urlParams_.Encode()
   453  	req, err := http.NewRequest("POST", urls, body)
   454  	if err != nil {
   455  		return nil, err
   456  	}
   457  	req.Header = reqHeaders
   458  	googleapi.Expand(req.URL, map[string]string{
   459  		"appPackage": c.appPackage,
   460  		"token":      c.token,
   461  	})
   462  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   463  }
   464  
   465  // Do executes the "playgrouping.apps.tokens.tags.createOrUpdate" call.
   466  // Any non-2xx status code is an error. Response headers are in either
   467  // *CreateOrUpdateTagsResponse.ServerResponse.Header or (if a response was
   468  // returned at all) in error.(*googleapi.Error).Header. Use
   469  // googleapi.IsNotModified to check whether the returned error was because
   470  // http.StatusNotModified was returned.
   471  func (c *AppsTokensTagsCreateOrUpdateCall) Do(opts ...googleapi.CallOption) (*CreateOrUpdateTagsResponse, error) {
   472  	gensupport.SetOptions(c.urlParams_, opts...)
   473  	res, err := c.doRequest("json")
   474  	if res != nil && res.StatusCode == http.StatusNotModified {
   475  		if res.Body != nil {
   476  			res.Body.Close()
   477  		}
   478  		return nil, gensupport.WrapError(&googleapi.Error{
   479  			Code:   res.StatusCode,
   480  			Header: res.Header,
   481  		})
   482  	}
   483  	if err != nil {
   484  		return nil, err
   485  	}
   486  	defer googleapi.CloseBody(res)
   487  	if err := googleapi.CheckResponse(res); err != nil {
   488  		return nil, gensupport.WrapError(err)
   489  	}
   490  	ret := &CreateOrUpdateTagsResponse{
   491  		ServerResponse: googleapi.ServerResponse{
   492  			Header:         res.Header,
   493  			HTTPStatusCode: res.StatusCode,
   494  		},
   495  	}
   496  	target := &ret
   497  	if err := gensupport.DecodeResponse(target, res); err != nil {
   498  		return nil, err
   499  	}
   500  	return ret, nil
   501  }
   502  

View as plain text