appstate

package
v0.174.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package appstate provides access to the Google App State API.

For product documentation, see: https://developers.google.com/games/services/web/api/states

Creating a client

Usage example:

import "google.golang.org/api/appstate/v1"
...
ctx := context.Background()
appstateService, err := appstate.NewService(ctx)

In this example, Google Application Default Credentials are used for authentication.

For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.

Other authentication options

To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:

appstateService, err := appstate.NewService(ctx, option.WithAPIKey("AIza..."))

To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:

config := &oauth2.Config{...}
// ...
token, err := config.Exchange(ctx, ...)
appstateService, err := appstate.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))

See https://godoc.org/google.golang.org/api/option/ for details on options.

Index

Constants

View Source
const (
	// View and manage your data for this application
	AppstateScope = "https://www.googleapis.com/auth/appstate"
)

OAuth2 scopes used by this API.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetResponse

type GetResponse struct {
	// CurrentStateVersion: The current app state version.
	CurrentStateVersion string `json:"currentStateVersion,omitempty"`

	// Data: The requested data.
	Data string `json:"data,omitempty"`

	// Kind: Uniquely identifies the type of this resource. Value is always
	// the fixed string appstate#getResponse.
	Kind string `json:"kind,omitempty"`

	// StateKey: The key for the data.
	StateKey int64 `json:"stateKey,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the
	// server.
	googleapi.ServerResponse `json:"-"`

	// ForceSendFields is a list of field names (e.g. "CurrentStateVersion")
	// to unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`

	// NullFields is a list of field names (e.g. "CurrentStateVersion") to
	// include in API requests with the JSON null value. By default, fields
	// with empty values are omitted from API requests. However, any field
	// with an empty value appearing in NullFields will be sent to the
	// server as null. It is an error if a field in this list has a
	// non-empty value. This may be used to include null fields in Patch
	// requests.
	NullFields []string `json:"-"`
}

GetResponse: This is a JSON template for an app state resource.

func (*GetResponse) MarshalJSON

func (s *GetResponse) MarshalJSON() ([]byte, error)

type ListResponse

type ListResponse struct {
	// Items: The app state data.
	Items []*GetResponse `json:"items,omitempty"`

	// Kind: Uniquely identifies the type of this resource. Value is always
	// the fixed string appstate#listResponse.
	Kind string `json:"kind,omitempty"`

	// MaximumKeyCount: The maximum number of keys allowed for this user.
	MaximumKeyCount int64 `json:"maximumKeyCount,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the
	// server.
	googleapi.ServerResponse `json:"-"`

	// ForceSendFields is a list of field names (e.g. "Items") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`

	// NullFields is a list of field names (e.g. "Items") to include in API
	// requests with the JSON null value. By default, fields with empty
	// values are omitted from API requests. However, any field with an
	// empty value appearing in NullFields will be sent to the server as
	// null. It is an error if a field in this list has a non-empty value.
	// This may be used to include null fields in Patch requests.
	NullFields []string `json:"-"`
}

ListResponse: This is a JSON template to convert a list-response for app state.

func (*ListResponse) MarshalJSON

func (s *ListResponse) MarshalJSON() ([]byte, error)

type Service

type Service struct {
	BasePath  string // API endpoint base URL
	UserAgent string // optional additional User-Agent fragment

	States *StatesService
	// contains filtered or unexported fields
}

func New deprecated

func New(client *http.Client) (*Service, error)

New creates a new Service. It uses the provided http.Client for requests.

Deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.

func NewService added in v0.3.0

func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error)

NewService creates a new Service.

type StatesClearCall

type StatesClearCall struct {
	// contains filtered or unexported fields
}

func (*StatesClearCall) Context

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*StatesClearCall) CurrentDataVersion

func (c *StatesClearCall) CurrentDataVersion(currentDataVersion string) *StatesClearCall

CurrentDataVersion sets the optional parameter "currentDataVersion": The version of the data to be cleared. Version strings are returned by the server.

func (*StatesClearCall) Do

Do executes the "appstate.states.clear" call. Exactly one of *WriteResult or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *WriteResult.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*StatesClearCall) Fields

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*StatesClearCall) Header

func (c *StatesClearCall) Header() http.Header

Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.

type StatesDeleteCall

type StatesDeleteCall struct {
	// contains filtered or unexported fields
}

func (*StatesDeleteCall) Context

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*StatesDeleteCall) Do

func (c *StatesDeleteCall) Do(opts ...googleapi.CallOption) error

Do executes the "appstate.states.delete" call.

func (*StatesDeleteCall) Fields

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*StatesDeleteCall) Header

func (c *StatesDeleteCall) Header() http.Header

Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.

type StatesGetCall

type StatesGetCall struct {
	// contains filtered or unexported fields
}

func (*StatesGetCall) Context

func (c *StatesGetCall) Context(ctx context.Context) *StatesGetCall

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*StatesGetCall) Do

func (c *StatesGetCall) Do(opts ...googleapi.CallOption) (*GetResponse, error)

Do executes the "appstate.states.get" call. Exactly one of *GetResponse or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *GetResponse.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*StatesGetCall) Fields

func (c *StatesGetCall) Fields(s ...googleapi.Field) *StatesGetCall

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*StatesGetCall) Header

func (c *StatesGetCall) Header() http.Header

Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.

func (*StatesGetCall) IfNoneMatch

func (c *StatesGetCall) IfNoneMatch(entityTag string) *StatesGetCall

IfNoneMatch sets the optional parameter which makes the operation fail if the object's ETag matches the given value. This is useful for getting updates only after the object has changed since the last request. Use googleapi.IsNotModified to check whether the response error from Do is the result of In-None-Match.

type StatesListCall

type StatesListCall struct {
	// contains filtered or unexported fields
}

func (*StatesListCall) Context

func (c *StatesListCall) Context(ctx context.Context) *StatesListCall

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*StatesListCall) Do

Do executes the "appstate.states.list" call. Exactly one of *ListResponse or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *ListResponse.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*StatesListCall) Fields

func (c *StatesListCall) Fields(s ...googleapi.Field) *StatesListCall

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*StatesListCall) Header

func (c *StatesListCall) Header() http.Header

Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.

func (*StatesListCall) IfNoneMatch

func (c *StatesListCall) IfNoneMatch(entityTag string) *StatesListCall

IfNoneMatch sets the optional parameter which makes the operation fail if the object's ETag matches the given value. This is useful for getting updates only after the object has changed since the last request. Use googleapi.IsNotModified to check whether the response error from Do is the result of In-None-Match.

func (*StatesListCall) IncludeData

func (c *StatesListCall) IncludeData(includeData bool) *StatesListCall

IncludeData sets the optional parameter "includeData": Whether to include the full data in addition to the version number

type StatesService

type StatesService struct {
	// contains filtered or unexported fields
}

func NewStatesService

func NewStatesService(s *Service) *StatesService

func (*StatesService) Clear

func (r *StatesService) Clear(stateKey int64) *StatesClearCall

Clear: Clears (sets to empty) the data for the passed key if and only if the passed version matches the currently stored version. This method results in a conflict error on version mismatch.

func (*StatesService) Delete

func (r *StatesService) Delete(stateKey int64) *StatesDeleteCall

Delete: Deletes a key and the data associated with it. The key is removed and no longer counts against the key quota. Note that since this method is not safe in the face of concurrent modifications, it should only be used for development and testing purposes. Invoking this method in shipping code can result in data loss and data corruption.

func (*StatesService) Get

func (r *StatesService) Get(stateKey int64) *StatesGetCall

Get: Retrieves the data corresponding to the passed key. If the key does not exist on the server, an HTTP 404 will be returned.

func (*StatesService) List

func (r *StatesService) List() *StatesListCall

List: Lists all the states keys, and optionally the state data.

func (*StatesService) Update

func (r *StatesService) Update(stateKey int64, updaterequest *UpdateRequest) *StatesUpdateCall

Update: Update the data associated with the input key if and only if the passed version matches the currently stored version. This method is safe in the face of concurrent writes. Maximum per-key size is 128KB.

type StatesUpdateCall

type StatesUpdateCall struct {
	// contains filtered or unexported fields
}

func (*StatesUpdateCall) Context

Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.

func (*StatesUpdateCall) CurrentStateVersion

func (c *StatesUpdateCall) CurrentStateVersion(currentStateVersion string) *StatesUpdateCall

CurrentStateVersion sets the optional parameter "currentStateVersion": The version of the app state your application is attempting to update. If this does not match the current version, this method will return a conflict error. If there is no data stored on the server for this key, the update will succeed irrespective of the value of this parameter.

func (*StatesUpdateCall) Do

Do executes the "appstate.states.update" call. Exactly one of *WriteResult or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *WriteResult.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*StatesUpdateCall) Fields

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.

func (*StatesUpdateCall) Header

func (c *StatesUpdateCall) Header() http.Header

Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.

type UpdateRequest

type UpdateRequest struct {
	// Data: The new app state data that your application is trying to
	// update with.
	Data string `json:"data,omitempty"`

	// Kind: Uniquely identifies the type of this resource. Value is always
	// the fixed string appstate#updateRequest.
	Kind string `json:"kind,omitempty"`

	// ForceSendFields is a list of field names (e.g. "Data") to
	// unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`

	// NullFields is a list of field names (e.g. "Data") to include in API
	// requests with the JSON null value. By default, fields with empty
	// values are omitted from API requests. However, any field with an
	// empty value appearing in NullFields will be sent to the server as
	// null. It is an error if a field in this list has a non-empty value.
	// This may be used to include null fields in Patch requests.
	NullFields []string `json:"-"`
}

UpdateRequest: This is a JSON template for a requests which update app state

func (*UpdateRequest) MarshalJSON

func (s *UpdateRequest) MarshalJSON() ([]byte, error)

type WriteResult

type WriteResult struct {
	// CurrentStateVersion: The version of the data for this key on the
	// server.
	CurrentStateVersion string `json:"currentStateVersion,omitempty"`

	// Kind: Uniquely identifies the type of this resource. Value is always
	// the fixed string appstate#writeResult.
	Kind string `json:"kind,omitempty"`

	// StateKey: The written key.
	StateKey int64 `json:"stateKey,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the
	// server.
	googleapi.ServerResponse `json:"-"`

	// ForceSendFields is a list of field names (e.g. "CurrentStateVersion")
	// to unconditionally include in API requests. By default, fields with
	// empty values are omitted from API requests. However, any non-pointer,
	// non-interface field appearing in ForceSendFields will be sent to the
	// server regardless of whether the field is empty or not. This may be
	// used to include empty fields in Patch requests.
	ForceSendFields []string `json:"-"`

	// NullFields is a list of field names (e.g. "CurrentStateVersion") to
	// include in API requests with the JSON null value. By default, fields
	// with empty values are omitted from API requests. However, any field
	// with an empty value appearing in NullFields will be sent to the
	// server as null. It is an error if a field in this list has a
	// non-empty value. This may be used to include null fields in Patch
	// requests.
	NullFields []string `json:"-"`
}

WriteResult: This is a JSON template for an app state write result.

func (*WriteResult) MarshalJSON

func (s *WriteResult) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL