...

Source file src/google.golang.org/api/workspaceevents/v1/workspaceevents-gen.go

Documentation: google.golang.org/api/workspaceevents/v1

     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 workspaceevents provides access to the Google Workspace Events API.
     8  //
     9  // For product documentation, see: https://developers.google.com/workspace/events
    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/workspaceevents/v1"
    27  //	...
    28  //	ctx := context.Background()
    29  //	workspaceeventsService, err := workspaceevents.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  //	workspaceeventsService, err := workspaceevents.NewService(ctx, option.WithScopes(workspaceevents.MeetingsSpaceReadonlyScope))
    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  //	workspaceeventsService, err := workspaceevents.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  //	workspaceeventsService, err := workspaceevents.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
    54  //
    55  // See [google.golang.org/api/option.ClientOption] for details on options.
    56  package workspaceevents // import "google.golang.org/api/workspaceevents/v1"
    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 = "workspaceevents:v1"
    95  const apiName = "workspaceevents"
    96  const apiVersion = "v1"
    97  const basePath = "https://workspaceevents.googleapis.com/"
    98  const basePathTemplate = "https://workspaceevents.UNIVERSE_DOMAIN/"
    99  const mtlsBasePath = "https://workspaceevents.mtls.googleapis.com/"
   100  
   101  // OAuth2 scopes used by this API.
   102  const (
   103  	// Private Service: https://www.googleapis.com/auth/chat.bot
   104  	ChatBotScope = "https://www.googleapis.com/auth/chat.bot"
   105  
   106  	// View, add, update, and remove members from conversations in Google Chat
   107  	ChatMembershipsScope = "https://www.googleapis.com/auth/chat.memberships"
   108  
   109  	// View members in Google Chat conversations.
   110  	ChatMembershipsReadonlyScope = "https://www.googleapis.com/auth/chat.memberships.readonly"
   111  
   112  	// View, compose, send, update, and delete messages, and add, view, and delete
   113  	// reactions to messages.
   114  	ChatMessagesScope = "https://www.googleapis.com/auth/chat.messages"
   115  
   116  	// View, add, and delete reactions to messages in Google Chat
   117  	ChatMessagesReactionsScope = "https://www.googleapis.com/auth/chat.messages.reactions"
   118  
   119  	// View reactions to messages in Google Chat
   120  	ChatMessagesReactionsReadonlyScope = "https://www.googleapis.com/auth/chat.messages.reactions.readonly"
   121  
   122  	// View messages and reactions in Google Chat
   123  	ChatMessagesReadonlyScope = "https://www.googleapis.com/auth/chat.messages.readonly"
   124  
   125  	// Create conversations and spaces and see or edit metadata (including history
   126  	// settings and access settings) in Google Chat
   127  	ChatSpacesScope = "https://www.googleapis.com/auth/chat.spaces"
   128  
   129  	// View chat and spaces in Google Chat
   130  	ChatSpacesReadonlyScope = "https://www.googleapis.com/auth/chat.spaces.readonly"
   131  
   132  	// Create, edit, and see information about your Google Meet conferences created
   133  	// by the app.
   134  	MeetingsSpaceCreatedScope = "https://www.googleapis.com/auth/meetings.space.created"
   135  
   136  	// Read information about any of your Google Meet conferences
   137  	MeetingsSpaceReadonlyScope = "https://www.googleapis.com/auth/meetings.space.readonly"
   138  )
   139  
   140  // NewService creates a new Service.
   141  func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
   142  	scopesOption := internaloption.WithDefaultScopes(
   143  		"https://www.googleapis.com/auth/chat.bot",
   144  		"https://www.googleapis.com/auth/chat.memberships",
   145  		"https://www.googleapis.com/auth/chat.memberships.readonly",
   146  		"https://www.googleapis.com/auth/chat.messages",
   147  		"https://www.googleapis.com/auth/chat.messages.reactions",
   148  		"https://www.googleapis.com/auth/chat.messages.reactions.readonly",
   149  		"https://www.googleapis.com/auth/chat.messages.readonly",
   150  		"https://www.googleapis.com/auth/chat.spaces",
   151  		"https://www.googleapis.com/auth/chat.spaces.readonly",
   152  		"https://www.googleapis.com/auth/meetings.space.created",
   153  		"https://www.googleapis.com/auth/meetings.space.readonly",
   154  	)
   155  	// NOTE: prepend, so we don't override user-specified scopes.
   156  	opts = append([]option.ClientOption{scopesOption}, opts...)
   157  	opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
   158  	opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
   159  	opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
   160  	opts = append(opts, internaloption.EnableNewAuthLibrary())
   161  	client, endpoint, err := htransport.NewClient(ctx, opts...)
   162  	if err != nil {
   163  		return nil, err
   164  	}
   165  	s, err := New(client)
   166  	if err != nil {
   167  		return nil, err
   168  	}
   169  	if endpoint != "" {
   170  		s.BasePath = endpoint
   171  	}
   172  	return s, nil
   173  }
   174  
   175  // New creates a new Service. It uses the provided http.Client for requests.
   176  //
   177  // Deprecated: please use NewService instead.
   178  // To provide a custom HTTP client, use option.WithHTTPClient.
   179  // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
   180  func New(client *http.Client) (*Service, error) {
   181  	if client == nil {
   182  		return nil, errors.New("client is nil")
   183  	}
   184  	s := &Service{client: client, BasePath: basePath}
   185  	s.Operations = NewOperationsService(s)
   186  	s.Subscriptions = NewSubscriptionsService(s)
   187  	return s, nil
   188  }
   189  
   190  type Service struct {
   191  	client    *http.Client
   192  	BasePath  string // API endpoint base URL
   193  	UserAgent string // optional additional User-Agent fragment
   194  
   195  	Operations *OperationsService
   196  
   197  	Subscriptions *SubscriptionsService
   198  }
   199  
   200  func (s *Service) userAgent() string {
   201  	if s.UserAgent == "" {
   202  		return googleapi.UserAgent
   203  	}
   204  	return googleapi.UserAgent + " " + s.UserAgent
   205  }
   206  
   207  func NewOperationsService(s *Service) *OperationsService {
   208  	rs := &OperationsService{s: s}
   209  	return rs
   210  }
   211  
   212  type OperationsService struct {
   213  	s *Service
   214  }
   215  
   216  func NewSubscriptionsService(s *Service) *SubscriptionsService {
   217  	rs := &SubscriptionsService{s: s}
   218  	return rs
   219  }
   220  
   221  type SubscriptionsService struct {
   222  	s *Service
   223  }
   224  
   225  // ListSubscriptionsResponse: The response message for
   226  // SubscriptionsService.ListSubscriptions.
   227  type ListSubscriptionsResponse struct {
   228  	// NextPageToken: A token, which can be sent as `page_token` to retrieve the
   229  	// next page. If this field is omitted, there are no subsequent pages.
   230  	NextPageToken string `json:"nextPageToken,omitempty"`
   231  	// Subscriptions: List of subscriptions.
   232  	Subscriptions []*Subscription `json:"subscriptions,omitempty"`
   233  
   234  	// ServerResponse contains the HTTP response code and headers from the server.
   235  	googleapi.ServerResponse `json:"-"`
   236  	// ForceSendFields is a list of field names (e.g. "NextPageToken") to
   237  	// unconditionally include in API requests. By default, fields with empty or
   238  	// default values are omitted from API requests. See
   239  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   240  	// details.
   241  	ForceSendFields []string `json:"-"`
   242  	// NullFields is a list of field names (e.g. "NextPageToken") to include in API
   243  	// requests with the JSON null value. By default, fields with empty values are
   244  	// omitted from API requests. See
   245  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   246  	NullFields []string `json:"-"`
   247  }
   248  
   249  func (s *ListSubscriptionsResponse) MarshalJSON() ([]byte, error) {
   250  	type NoMethod ListSubscriptionsResponse
   251  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   252  }
   253  
   254  // NotificationEndpoint: The endpoint where the subscription delivers events.
   255  type NotificationEndpoint struct {
   256  	// PubsubTopic: Immutable. The Cloud Pub/Sub topic that receives events for the
   257  	// subscription. Format: `projects/{project}/topics/{topic}` You must create
   258  	// the topic in the same Google Cloud project where you create this
   259  	// subscription. When the topic receives events, the events are encoded as
   260  	// Cloud Pub/Sub messages. For details, see the Google Cloud Pub/Sub Protocol
   261  	// Binding for CloudEvents
   262  	// (https://github.com/googleapis/google-cloudevents/blob/main/docs/spec/pubsub.md).
   263  	PubsubTopic string `json:"pubsubTopic,omitempty"`
   264  	// ForceSendFields is a list of field names (e.g. "PubsubTopic") to
   265  	// unconditionally include in API requests. By default, fields with empty or
   266  	// default values are omitted from API requests. See
   267  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   268  	// details.
   269  	ForceSendFields []string `json:"-"`
   270  	// NullFields is a list of field names (e.g. "PubsubTopic") to include in API
   271  	// requests with the JSON null value. By default, fields with empty values are
   272  	// omitted from API requests. See
   273  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   274  	NullFields []string `json:"-"`
   275  }
   276  
   277  func (s *NotificationEndpoint) MarshalJSON() ([]byte, error) {
   278  	type NoMethod NotificationEndpoint
   279  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   280  }
   281  
   282  // Operation: This resource represents a long-running operation that is the
   283  // result of a network API call.
   284  type Operation struct {
   285  	// Done: If the value is `false`, it means the operation is still in progress.
   286  	// If `true`, the operation is completed, and either `error` or `response` is
   287  	// available.
   288  	Done bool `json:"done,omitempty"`
   289  	// Error: The error result of the operation in case of failure or cancellation.
   290  	Error *Status `json:"error,omitempty"`
   291  	// Metadata: Service-specific metadata associated with the operation. It
   292  	// typically contains progress information and common metadata such as create
   293  	// time. Some services might not provide such metadata. Any method that returns
   294  	// a long-running operation should document the metadata type, if any.
   295  	Metadata googleapi.RawMessage `json:"metadata,omitempty"`
   296  	// Name: The server-assigned name, which is only unique within the same service
   297  	// that originally returns it. If you use the default HTTP mapping, the `name`
   298  	// should be a resource name ending with `operations/{unique_id}`.
   299  	Name string `json:"name,omitempty"`
   300  	// Response: The normal, successful response of the operation. If the original
   301  	// method returns no data on success, such as `Delete`, the response is
   302  	// `google.protobuf.Empty`. If the original method is standard
   303  	// `Get`/`Create`/`Update`, the response should be the resource. For other
   304  	// methods, the response should have the type `XxxResponse`, where `Xxx` is the
   305  	// original method name. For example, if the original method name is
   306  	// `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
   307  	Response googleapi.RawMessage `json:"response,omitempty"`
   308  
   309  	// ServerResponse contains the HTTP response code and headers from the server.
   310  	googleapi.ServerResponse `json:"-"`
   311  	// ForceSendFields is a list of field names (e.g. "Done") to unconditionally
   312  	// include in API requests. By default, fields with empty or default values are
   313  	// omitted from API requests. See
   314  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   315  	// details.
   316  	ForceSendFields []string `json:"-"`
   317  	// NullFields is a list of field names (e.g. "Done") to include in API requests
   318  	// with the JSON null value. By default, fields with empty values are omitted
   319  	// from API requests. See
   320  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   321  	NullFields []string `json:"-"`
   322  }
   323  
   324  func (s *Operation) MarshalJSON() ([]byte, error) {
   325  	type NoMethod Operation
   326  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   327  }
   328  
   329  // PayloadOptions: Options about what data to include in the event payload.
   330  // Only supported for Google Chat events.
   331  type PayloadOptions struct {
   332  	// FieldMask: Optional. If `include_resource` is set to `true`, the list of
   333  	// fields to include in the event payload. Separate fields with a comma. For
   334  	// example, to include a Google Chat message's sender and create time, enter
   335  	// `message.sender,message.createTime`. If omitted, the payload includes all
   336  	// fields for the resource. If you specify a field that doesn't exist for the
   337  	// resource, the system ignores the field.
   338  	FieldMask string `json:"fieldMask,omitempty"`
   339  	// IncludeResource: Optional. Whether the event payload includes data about the
   340  	// resource that changed. For example, for an event where a Google Chat message
   341  	// was created, whether the payload contains data about the `Message`
   342  	// (https://developers.google.com/chat/api/reference/rest/v1/spaces.messages)
   343  	// resource. If false, the event payload only includes the name of the changed
   344  	// resource.
   345  	IncludeResource bool `json:"includeResource,omitempty"`
   346  	// ForceSendFields is a list of field names (e.g. "FieldMask") to
   347  	// unconditionally include in API requests. By default, fields with empty or
   348  	// default values are omitted from API requests. See
   349  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   350  	// details.
   351  	ForceSendFields []string `json:"-"`
   352  	// NullFields is a list of field names (e.g. "FieldMask") to include in API
   353  	// requests with the JSON null value. By default, fields with empty values are
   354  	// omitted from API requests. See
   355  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   356  	NullFields []string `json:"-"`
   357  }
   358  
   359  func (s *PayloadOptions) MarshalJSON() ([]byte, error) {
   360  	type NoMethod PayloadOptions
   361  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   362  }
   363  
   364  // ReactivateSubscriptionRequest: The request message for
   365  // SubscriptionsService.ReactivateSubscription.
   366  type ReactivateSubscriptionRequest struct {
   367  }
   368  
   369  // Status: The `Status` type defines a logical error model that is suitable for
   370  // different programming environments, including REST APIs and RPC APIs. It is
   371  // used by gRPC (https://github.com/grpc). Each `Status` message contains three
   372  // pieces of data: error code, error message, and error details. You can find
   373  // out more about this error model and how to work with it in the API Design
   374  // Guide (https://cloud.google.com/apis/design/errors).
   375  type Status struct {
   376  	// Code: The status code, which should be an enum value of google.rpc.Code.
   377  	Code int64 `json:"code,omitempty"`
   378  	// Details: A list of messages that carry the error details. There is a common
   379  	// set of message types for APIs to use.
   380  	Details []googleapi.RawMessage `json:"details,omitempty"`
   381  	// Message: A developer-facing error message, which should be in English. Any
   382  	// user-facing error message should be localized and sent in the
   383  	// google.rpc.Status.details field, or localized by the client.
   384  	Message string `json:"message,omitempty"`
   385  	// ForceSendFields is a list of field names (e.g. "Code") to unconditionally
   386  	// include in API requests. By default, fields with empty or default values are
   387  	// omitted from API requests. See
   388  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   389  	// details.
   390  	ForceSendFields []string `json:"-"`
   391  	// NullFields is a list of field names (e.g. "Code") to include in API requests
   392  	// with the JSON null value. By default, fields with empty values are omitted
   393  	// from API requests. See
   394  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   395  	NullFields []string `json:"-"`
   396  }
   397  
   398  func (s *Status) MarshalJSON() ([]byte, error) {
   399  	type NoMethod Status
   400  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   401  }
   402  
   403  // Subscription: Developer Preview
   404  // (https://developers.google.com/workspace/preview). A subscription to receive
   405  // events about a Google Workspace resource. To learn more about subscriptions,
   406  // see the Google Workspace Events API overview
   407  // (https://developers.google.com/workspace/events).
   408  type Subscription struct {
   409  	// Authority: Output only. The user who authorized the creation of the
   410  	// subscription. Format: `users/{user}` For Google Workspace users, the
   411  	// `{user}` value is the `user.id`
   412  	// (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users#User.FIELDS.ids)
   413  	// field from the Directory API.
   414  	Authority string `json:"authority,omitempty"`
   415  	// CreateTime: Output only. The time when the subscription is created.
   416  	CreateTime string `json:"createTime,omitempty"`
   417  	// Etag: Optional. This checksum is computed by the server based on the value
   418  	// of other fields, and might be sent on update requests to ensure the client
   419  	// has an up-to-date value before proceeding.
   420  	Etag string `json:"etag,omitempty"`
   421  	// EventTypes: Required. Immutable. Unordered list. Input for creating a
   422  	// subscription. Otherwise, output only. One or more types of events to receive
   423  	// about the target resource. Formatted according to the CloudEvents
   424  	// specification. The supported event types depend on the target resource of
   425  	// your subscription. For details, see Supported Google Workspace events
   426  	// (https://developers.google.com/workspace/events/guides#supported-events). By
   427  	// default, you also receive events about the lifecycle of your subscription
   428  	// (https://developers.google.com/workspace/events/guides/events-lifecycle).
   429  	// You don't need to specify lifecycle events for this field. If you specify an
   430  	// event type that doesn't exist for the target resource, the request returns
   431  	// an HTTP `400 Bad Request` status code.
   432  	EventTypes []string `json:"eventTypes,omitempty"`
   433  	// ExpireTime: Non-empty default. The timestamp in UTC when the subscription
   434  	// expires. Always displayed on output, regardless of what was used on input.
   435  	ExpireTime string `json:"expireTime,omitempty"`
   436  	// Name: Optional. Immutable. Identifier. Resource name of the subscription.
   437  	// Format: `subscriptions/{subscription}`
   438  	Name string `json:"name,omitempty"`
   439  	// NotificationEndpoint: Required. Immutable. The endpoint where the
   440  	// subscription delivers events, such as a Pub/Sub topic.
   441  	NotificationEndpoint *NotificationEndpoint `json:"notificationEndpoint,omitempty"`
   442  	// PayloadOptions: Optional. Options about what data to include in the event
   443  	// payload. Only supported for Google Chat events.
   444  	PayloadOptions *PayloadOptions `json:"payloadOptions,omitempty"`
   445  	// Reconciling: Output only. If `true`, the subscription is in the process of
   446  	// being updated.
   447  	Reconciling bool `json:"reconciling,omitempty"`
   448  	// State: Output only. The state of the subscription. Determines whether the
   449  	// subscription can receive events and deliver them to the notification
   450  	// endpoint.
   451  	//
   452  	// Possible values:
   453  	//   "STATE_UNSPECIFIED" - Default value. This value is unused.
   454  	//   "ACTIVE" - The subscription is active and can receive and deliver events
   455  	// to its notification endpoint.
   456  	//   "SUSPENDED" - The subscription is unable to receive events due to an
   457  	// error. To identify the error, see the `suspension_reason` field.
   458  	//   "DELETED" - The subscription is deleted.
   459  	State string `json:"state,omitempty"`
   460  	// SuspensionReason: Output only. The error that suspended the subscription. To
   461  	// reactivate the subscription, resolve the error and call the
   462  	// `ReactivateSubscription` method.
   463  	//
   464  	// Possible values:
   465  	//   "ERROR_TYPE_UNSPECIFIED" - Default value. This value is unused.
   466  	//   "USER_SCOPE_REVOKED" - The authorizing user has revoked the grant of one
   467  	// or more OAuth scopes. To learn more about authorization for Google
   468  	// Workspace, see [Configure the OAuth consent
   469  	// screen](https://developers.google.com/workspace/guides/configure-oauth-consen
   470  	// t#choose-scopes).
   471  	//   "RESOURCE_DELETED" - The target resource for the subscription no longer
   472  	// exists.
   473  	//   "USER_AUTHORIZATION_FAILURE" - The user that authorized the creation of
   474  	// the subscription no longer has access to the subscription's target resource.
   475  	//   "ENDPOINT_PERMISSION_DENIED" - The Google Workspace application doesn't
   476  	// have access to deliver events to your subscription's notification endpoint.
   477  	//   "ENDPOINT_NOT_FOUND" - The subscription's notification endpoint doesn't
   478  	// exist, or the endpoint can't be found in the Google Cloud project where you
   479  	// created the subscription.
   480  	//   "ENDPOINT_RESOURCE_EXHAUSTED" - The subscription's notification endpoint
   481  	// failed to receive events due to insufficient quota or reaching rate
   482  	// limiting.
   483  	//   "OTHER" - An unidentified error has occurred.
   484  	SuspensionReason string `json:"suspensionReason,omitempty"`
   485  	// TargetResource: Required. Immutable. The Google Workspace resource that's
   486  	// monitored for events, formatted as the full resource name
   487  	// (https://google.aip.dev/122#full-resource-names). To learn about target
   488  	// resources and the events that they support, see Supported Google Workspace
   489  	// events (https://developers.google.com/workspace/events#supported-events). A
   490  	// user can only authorize your app to create one subscription for a given
   491  	// target resource. If your app tries to create another subscription with the
   492  	// same user credentials, the request returns an `ALREADY_EXISTS` error.
   493  	TargetResource string `json:"targetResource,omitempty"`
   494  	// Ttl: Input only. The time-to-live (TTL) or duration for the subscription. If
   495  	// unspecified or set to `0`, uses the maximum possible duration.
   496  	Ttl string `json:"ttl,omitempty"`
   497  	// Uid: Output only. System-assigned unique identifier for the subscription.
   498  	Uid string `json:"uid,omitempty"`
   499  	// UpdateTime: Output only. The last time that the subscription is updated.
   500  	UpdateTime string `json:"updateTime,omitempty"`
   501  
   502  	// ServerResponse contains the HTTP response code and headers from the server.
   503  	googleapi.ServerResponse `json:"-"`
   504  	// ForceSendFields is a list of field names (e.g. "Authority") to
   505  	// unconditionally include in API requests. By default, fields with empty or
   506  	// default values are omitted from API requests. See
   507  	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
   508  	// details.
   509  	ForceSendFields []string `json:"-"`
   510  	// NullFields is a list of field names (e.g. "Authority") to include in API
   511  	// requests with the JSON null value. By default, fields with empty values are
   512  	// omitted from API requests. See
   513  	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
   514  	NullFields []string `json:"-"`
   515  }
   516  
   517  func (s *Subscription) MarshalJSON() ([]byte, error) {
   518  	type NoMethod Subscription
   519  	return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
   520  }
   521  
   522  type OperationsGetCall struct {
   523  	s            *Service
   524  	name         string
   525  	urlParams_   gensupport.URLParams
   526  	ifNoneMatch_ string
   527  	ctx_         context.Context
   528  	header_      http.Header
   529  }
   530  
   531  // Get: Gets the latest state of a long-running operation. Clients can use this
   532  // method to poll the operation result at intervals as recommended by the API
   533  // service.
   534  //
   535  // - name: The name of the operation resource.
   536  func (r *OperationsService) Get(name string) *OperationsGetCall {
   537  	c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   538  	c.name = name
   539  	return c
   540  }
   541  
   542  // Fields allows partial responses to be retrieved. See
   543  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   544  // details.
   545  func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall {
   546  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   547  	return c
   548  }
   549  
   550  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   551  // object's ETag matches the given value. This is useful for getting updates
   552  // only after the object has changed since the last request.
   553  func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall {
   554  	c.ifNoneMatch_ = entityTag
   555  	return c
   556  }
   557  
   558  // Context sets the context to be used in this call's Do method.
   559  func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall {
   560  	c.ctx_ = ctx
   561  	return c
   562  }
   563  
   564  // Header returns a http.Header that can be modified by the caller to add
   565  // headers to the request.
   566  func (c *OperationsGetCall) Header() http.Header {
   567  	if c.header_ == nil {
   568  		c.header_ = make(http.Header)
   569  	}
   570  	return c.header_
   571  }
   572  
   573  func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) {
   574  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   575  	if c.ifNoneMatch_ != "" {
   576  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   577  	}
   578  	var body io.Reader = nil
   579  	c.urlParams_.Set("alt", alt)
   580  	c.urlParams_.Set("prettyPrint", "false")
   581  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   582  	urls += "?" + c.urlParams_.Encode()
   583  	req, err := http.NewRequest("GET", urls, body)
   584  	if err != nil {
   585  		return nil, err
   586  	}
   587  	req.Header = reqHeaders
   588  	googleapi.Expand(req.URL, map[string]string{
   589  		"name": c.name,
   590  	})
   591  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   592  }
   593  
   594  // Do executes the "workspaceevents.operations.get" call.
   595  // Any non-2xx status code is an error. Response headers are in either
   596  // *Operation.ServerResponse.Header or (if a response was returned at all) in
   597  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   598  // whether the returned error was because http.StatusNotModified was returned.
   599  func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   600  	gensupport.SetOptions(c.urlParams_, opts...)
   601  	res, err := c.doRequest("json")
   602  	if res != nil && res.StatusCode == http.StatusNotModified {
   603  		if res.Body != nil {
   604  			res.Body.Close()
   605  		}
   606  		return nil, gensupport.WrapError(&googleapi.Error{
   607  			Code:   res.StatusCode,
   608  			Header: res.Header,
   609  		})
   610  	}
   611  	if err != nil {
   612  		return nil, err
   613  	}
   614  	defer googleapi.CloseBody(res)
   615  	if err := googleapi.CheckResponse(res); err != nil {
   616  		return nil, gensupport.WrapError(err)
   617  	}
   618  	ret := &Operation{
   619  		ServerResponse: googleapi.ServerResponse{
   620  			Header:         res.Header,
   621  			HTTPStatusCode: res.StatusCode,
   622  		},
   623  	}
   624  	target := &ret
   625  	if err := gensupport.DecodeResponse(target, res); err != nil {
   626  		return nil, err
   627  	}
   628  	return ret, nil
   629  }
   630  
   631  type SubscriptionsCreateCall struct {
   632  	s            *Service
   633  	subscription *Subscription
   634  	urlParams_   gensupport.URLParams
   635  	ctx_         context.Context
   636  	header_      http.Header
   637  }
   638  
   639  // Create: Developer Preview (https://developers.google.com/workspace/preview):
   640  // Creates a Google Workspace subscription. To learn how to use this method,
   641  // see Create a Google Workspace subscription
   642  // (https://developers.google.com/workspace/events/guides/create-subscription).
   643  func (r *SubscriptionsService) Create(subscription *Subscription) *SubscriptionsCreateCall {
   644  	c := &SubscriptionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   645  	c.subscription = subscription
   646  	return c
   647  }
   648  
   649  // ValidateOnly sets the optional parameter "validateOnly": If set to `true`,
   650  // validates and previews the request, but doesn't create the subscription.
   651  func (c *SubscriptionsCreateCall) ValidateOnly(validateOnly bool) *SubscriptionsCreateCall {
   652  	c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly))
   653  	return c
   654  }
   655  
   656  // Fields allows partial responses to be retrieved. See
   657  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   658  // details.
   659  func (c *SubscriptionsCreateCall) Fields(s ...googleapi.Field) *SubscriptionsCreateCall {
   660  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   661  	return c
   662  }
   663  
   664  // Context sets the context to be used in this call's Do method.
   665  func (c *SubscriptionsCreateCall) Context(ctx context.Context) *SubscriptionsCreateCall {
   666  	c.ctx_ = ctx
   667  	return c
   668  }
   669  
   670  // Header returns a http.Header that can be modified by the caller to add
   671  // headers to the request.
   672  func (c *SubscriptionsCreateCall) Header() http.Header {
   673  	if c.header_ == nil {
   674  		c.header_ = make(http.Header)
   675  	}
   676  	return c.header_
   677  }
   678  
   679  func (c *SubscriptionsCreateCall) doRequest(alt string) (*http.Response, error) {
   680  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
   681  	var body io.Reader = nil
   682  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription)
   683  	if err != nil {
   684  		return nil, err
   685  	}
   686  	c.urlParams_.Set("alt", alt)
   687  	c.urlParams_.Set("prettyPrint", "false")
   688  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/subscriptions")
   689  	urls += "?" + c.urlParams_.Encode()
   690  	req, err := http.NewRequest("POST", urls, body)
   691  	if err != nil {
   692  		return nil, err
   693  	}
   694  	req.Header = reqHeaders
   695  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   696  }
   697  
   698  // Do executes the "workspaceevents.subscriptions.create" call.
   699  // Any non-2xx status code is an error. Response headers are in either
   700  // *Operation.ServerResponse.Header or (if a response was returned at all) in
   701  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   702  // whether the returned error was because http.StatusNotModified was returned.
   703  func (c *SubscriptionsCreateCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   704  	gensupport.SetOptions(c.urlParams_, opts...)
   705  	res, err := c.doRequest("json")
   706  	if res != nil && res.StatusCode == http.StatusNotModified {
   707  		if res.Body != nil {
   708  			res.Body.Close()
   709  		}
   710  		return nil, gensupport.WrapError(&googleapi.Error{
   711  			Code:   res.StatusCode,
   712  			Header: res.Header,
   713  		})
   714  	}
   715  	if err != nil {
   716  		return nil, err
   717  	}
   718  	defer googleapi.CloseBody(res)
   719  	if err := googleapi.CheckResponse(res); err != nil {
   720  		return nil, gensupport.WrapError(err)
   721  	}
   722  	ret := &Operation{
   723  		ServerResponse: googleapi.ServerResponse{
   724  			Header:         res.Header,
   725  			HTTPStatusCode: res.StatusCode,
   726  		},
   727  	}
   728  	target := &ret
   729  	if err := gensupport.DecodeResponse(target, res); err != nil {
   730  		return nil, err
   731  	}
   732  	return ret, nil
   733  }
   734  
   735  type SubscriptionsDeleteCall struct {
   736  	s          *Service
   737  	name       string
   738  	urlParams_ gensupport.URLParams
   739  	ctx_       context.Context
   740  	header_    http.Header
   741  }
   742  
   743  // Delete: Developer Preview (https://developers.google.com/workspace/preview):
   744  // Deletes a Google Workspace subscription. To learn how to use this method,
   745  // see Delete a Google Workspace subscription
   746  // (https://developers.google.com/workspace/events/guides/delete-subscription).
   747  //
   748  //   - name: Resource name of the subscription to delete. Format:
   749  //     `subscriptions/{subscription}`.
   750  func (r *SubscriptionsService) Delete(name string) *SubscriptionsDeleteCall {
   751  	c := &SubscriptionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   752  	c.name = name
   753  	return c
   754  }
   755  
   756  // AllowMissing sets the optional parameter "allowMissing": If set to `true`
   757  // and the subscription isn't found, the request succeeds but doesn't delete
   758  // the subscription.
   759  func (c *SubscriptionsDeleteCall) AllowMissing(allowMissing bool) *SubscriptionsDeleteCall {
   760  	c.urlParams_.Set("allowMissing", fmt.Sprint(allowMissing))
   761  	return c
   762  }
   763  
   764  // Etag sets the optional parameter "etag": Etag of the subscription. If
   765  // present, it must match with the server's etag. Otherwise, request fails with
   766  // the status `ABORTED`.
   767  func (c *SubscriptionsDeleteCall) Etag(etag string) *SubscriptionsDeleteCall {
   768  	c.urlParams_.Set("etag", etag)
   769  	return c
   770  }
   771  
   772  // ValidateOnly sets the optional parameter "validateOnly": If set to `true`,
   773  // validates and previews the request, but doesn't delete the subscription.
   774  func (c *SubscriptionsDeleteCall) ValidateOnly(validateOnly bool) *SubscriptionsDeleteCall {
   775  	c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly))
   776  	return c
   777  }
   778  
   779  // Fields allows partial responses to be retrieved. See
   780  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   781  // details.
   782  func (c *SubscriptionsDeleteCall) Fields(s ...googleapi.Field) *SubscriptionsDeleteCall {
   783  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   784  	return c
   785  }
   786  
   787  // Context sets the context to be used in this call's Do method.
   788  func (c *SubscriptionsDeleteCall) Context(ctx context.Context) *SubscriptionsDeleteCall {
   789  	c.ctx_ = ctx
   790  	return c
   791  }
   792  
   793  // Header returns a http.Header that can be modified by the caller to add
   794  // headers to the request.
   795  func (c *SubscriptionsDeleteCall) Header() http.Header {
   796  	if c.header_ == nil {
   797  		c.header_ = make(http.Header)
   798  	}
   799  	return c.header_
   800  }
   801  
   802  func (c *SubscriptionsDeleteCall) doRequest(alt string) (*http.Response, error) {
   803  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   804  	var body io.Reader = nil
   805  	c.urlParams_.Set("alt", alt)
   806  	c.urlParams_.Set("prettyPrint", "false")
   807  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   808  	urls += "?" + c.urlParams_.Encode()
   809  	req, err := http.NewRequest("DELETE", urls, body)
   810  	if err != nil {
   811  		return nil, err
   812  	}
   813  	req.Header = reqHeaders
   814  	googleapi.Expand(req.URL, map[string]string{
   815  		"name": c.name,
   816  	})
   817  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   818  }
   819  
   820  // Do executes the "workspaceevents.subscriptions.delete" call.
   821  // Any non-2xx status code is an error. Response headers are in either
   822  // *Operation.ServerResponse.Header or (if a response was returned at all) in
   823  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   824  // whether the returned error was because http.StatusNotModified was returned.
   825  func (c *SubscriptionsDeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
   826  	gensupport.SetOptions(c.urlParams_, opts...)
   827  	res, err := c.doRequest("json")
   828  	if res != nil && res.StatusCode == http.StatusNotModified {
   829  		if res.Body != nil {
   830  			res.Body.Close()
   831  		}
   832  		return nil, gensupport.WrapError(&googleapi.Error{
   833  			Code:   res.StatusCode,
   834  			Header: res.Header,
   835  		})
   836  	}
   837  	if err != nil {
   838  		return nil, err
   839  	}
   840  	defer googleapi.CloseBody(res)
   841  	if err := googleapi.CheckResponse(res); err != nil {
   842  		return nil, gensupport.WrapError(err)
   843  	}
   844  	ret := &Operation{
   845  		ServerResponse: googleapi.ServerResponse{
   846  			Header:         res.Header,
   847  			HTTPStatusCode: res.StatusCode,
   848  		},
   849  	}
   850  	target := &ret
   851  	if err := gensupport.DecodeResponse(target, res); err != nil {
   852  		return nil, err
   853  	}
   854  	return ret, nil
   855  }
   856  
   857  type SubscriptionsGetCall struct {
   858  	s            *Service
   859  	name         string
   860  	urlParams_   gensupport.URLParams
   861  	ifNoneMatch_ string
   862  	ctx_         context.Context
   863  	header_      http.Header
   864  }
   865  
   866  // Get: Developer Preview (https://developers.google.com/workspace/preview):
   867  // Gets details about a Google Workspace subscription. To learn how to use this
   868  // method, see Get details about a Google Workspace subscription
   869  // (https://developers.google.com/workspace/events/guides/get-subscription).
   870  //
   871  //   - name: Resource name of the subscription. Format:
   872  //     `subscriptions/{subscription}`.
   873  func (r *SubscriptionsService) Get(name string) *SubscriptionsGetCall {
   874  	c := &SubscriptionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   875  	c.name = name
   876  	return c
   877  }
   878  
   879  // Fields allows partial responses to be retrieved. See
   880  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
   881  // details.
   882  func (c *SubscriptionsGetCall) Fields(s ...googleapi.Field) *SubscriptionsGetCall {
   883  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
   884  	return c
   885  }
   886  
   887  // IfNoneMatch sets an optional parameter which makes the operation fail if the
   888  // object's ETag matches the given value. This is useful for getting updates
   889  // only after the object has changed since the last request.
   890  func (c *SubscriptionsGetCall) IfNoneMatch(entityTag string) *SubscriptionsGetCall {
   891  	c.ifNoneMatch_ = entityTag
   892  	return c
   893  }
   894  
   895  // Context sets the context to be used in this call's Do method.
   896  func (c *SubscriptionsGetCall) Context(ctx context.Context) *SubscriptionsGetCall {
   897  	c.ctx_ = ctx
   898  	return c
   899  }
   900  
   901  // Header returns a http.Header that can be modified by the caller to add
   902  // headers to the request.
   903  func (c *SubscriptionsGetCall) Header() http.Header {
   904  	if c.header_ == nil {
   905  		c.header_ = make(http.Header)
   906  	}
   907  	return c.header_
   908  }
   909  
   910  func (c *SubscriptionsGetCall) doRequest(alt string) (*http.Response, error) {
   911  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
   912  	if c.ifNoneMatch_ != "" {
   913  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
   914  	}
   915  	var body io.Reader = nil
   916  	c.urlParams_.Set("alt", alt)
   917  	c.urlParams_.Set("prettyPrint", "false")
   918  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
   919  	urls += "?" + c.urlParams_.Encode()
   920  	req, err := http.NewRequest("GET", urls, body)
   921  	if err != nil {
   922  		return nil, err
   923  	}
   924  	req.Header = reqHeaders
   925  	googleapi.Expand(req.URL, map[string]string{
   926  		"name": c.name,
   927  	})
   928  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
   929  }
   930  
   931  // Do executes the "workspaceevents.subscriptions.get" call.
   932  // Any non-2xx status code is an error. Response headers are in either
   933  // *Subscription.ServerResponse.Header or (if a response was returned at all)
   934  // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
   935  // whether the returned error was because http.StatusNotModified was returned.
   936  func (c *SubscriptionsGetCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
   937  	gensupport.SetOptions(c.urlParams_, opts...)
   938  	res, err := c.doRequest("json")
   939  	if res != nil && res.StatusCode == http.StatusNotModified {
   940  		if res.Body != nil {
   941  			res.Body.Close()
   942  		}
   943  		return nil, gensupport.WrapError(&googleapi.Error{
   944  			Code:   res.StatusCode,
   945  			Header: res.Header,
   946  		})
   947  	}
   948  	if err != nil {
   949  		return nil, err
   950  	}
   951  	defer googleapi.CloseBody(res)
   952  	if err := googleapi.CheckResponse(res); err != nil {
   953  		return nil, gensupport.WrapError(err)
   954  	}
   955  	ret := &Subscription{
   956  		ServerResponse: googleapi.ServerResponse{
   957  			Header:         res.Header,
   958  			HTTPStatusCode: res.StatusCode,
   959  		},
   960  	}
   961  	target := &ret
   962  	if err := gensupport.DecodeResponse(target, res); err != nil {
   963  		return nil, err
   964  	}
   965  	return ret, nil
   966  }
   967  
   968  type SubscriptionsListCall struct {
   969  	s            *Service
   970  	urlParams_   gensupport.URLParams
   971  	ifNoneMatch_ string
   972  	ctx_         context.Context
   973  	header_      http.Header
   974  }
   975  
   976  // List: Developer Preview (https://developers.google.com/workspace/preview):
   977  // Lists Google Workspace subscriptions. To learn how to use this method, see
   978  // List Google Workspace subscriptions
   979  // (https://developers.google.com/workspace/events/guides/list-subscriptions).
   980  func (r *SubscriptionsService) List() *SubscriptionsListCall {
   981  	c := &SubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
   982  	return c
   983  }
   984  
   985  // Filter sets the optional parameter "filter": Required. A query filter. You
   986  // can filter subscriptions by event type (`event_types`) and target resource
   987  // (`target_resource`). You must specify at least one event type in your query.
   988  // To filter for multiple event types, use the `OR` operator. To filter by both
   989  // event type and target resource, use the `AND` operator and specify the full
   990  // resource name, such as `//chat.googleapis.com/spaces/{space}`. For example,
   991  // the following queries are valid: ```
   992  // event_types:"google.workspace.chat.membership.v1.updated" OR
   993  // event_types:"google.workspace.chat.message.v1.created"
   994  // event_types:"google.workspace.chat.message.v1.created" AND
   995  // target_resource="//chat.googleapis.com/spaces/{space}" (
   996  // event_types:"google.workspace.chat.membership.v1.updated" OR
   997  // event_types:"google.workspace.chat.message.v1.created" ) AND
   998  // target_resource="//chat.googleapis.com/spaces/{space}" ``` The server
   999  // rejects invalid queries with an `INVALID_ARGUMENT` error.
  1000  func (c *SubscriptionsListCall) Filter(filter string) *SubscriptionsListCall {
  1001  	c.urlParams_.Set("filter", filter)
  1002  	return c
  1003  }
  1004  
  1005  // PageSize sets the optional parameter "pageSize": The maximum number of
  1006  // subscriptions to return. The service might return fewer than this value. If
  1007  // unspecified or set to `0`, up to 50 subscriptions are returned. The maximum
  1008  // value is 100. If you specify a value more than 100, the system only returns
  1009  // 100 subscriptions.
  1010  func (c *SubscriptionsListCall) PageSize(pageSize int64) *SubscriptionsListCall {
  1011  	c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1012  	return c
  1013  }
  1014  
  1015  // PageToken sets the optional parameter "pageToken": A page token, received
  1016  // from a previous list subscriptions call. Provide this parameter to retrieve
  1017  // the subsequent page. When paginating, the filter value should match the call
  1018  // that provided the page token. Passing a different value might lead to
  1019  // unexpected results.
  1020  func (c *SubscriptionsListCall) PageToken(pageToken string) *SubscriptionsListCall {
  1021  	c.urlParams_.Set("pageToken", pageToken)
  1022  	return c
  1023  }
  1024  
  1025  // Fields allows partial responses to be retrieved. See
  1026  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1027  // details.
  1028  func (c *SubscriptionsListCall) Fields(s ...googleapi.Field) *SubscriptionsListCall {
  1029  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1030  	return c
  1031  }
  1032  
  1033  // IfNoneMatch sets an optional parameter which makes the operation fail if the
  1034  // object's ETag matches the given value. This is useful for getting updates
  1035  // only after the object has changed since the last request.
  1036  func (c *SubscriptionsListCall) IfNoneMatch(entityTag string) *SubscriptionsListCall {
  1037  	c.ifNoneMatch_ = entityTag
  1038  	return c
  1039  }
  1040  
  1041  // Context sets the context to be used in this call's Do method.
  1042  func (c *SubscriptionsListCall) Context(ctx context.Context) *SubscriptionsListCall {
  1043  	c.ctx_ = ctx
  1044  	return c
  1045  }
  1046  
  1047  // Header returns a http.Header that can be modified by the caller to add
  1048  // headers to the request.
  1049  func (c *SubscriptionsListCall) Header() http.Header {
  1050  	if c.header_ == nil {
  1051  		c.header_ = make(http.Header)
  1052  	}
  1053  	return c.header_
  1054  }
  1055  
  1056  func (c *SubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  1057  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
  1058  	if c.ifNoneMatch_ != "" {
  1059  		reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1060  	}
  1061  	var body io.Reader = nil
  1062  	c.urlParams_.Set("alt", alt)
  1063  	c.urlParams_.Set("prettyPrint", "false")
  1064  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/subscriptions")
  1065  	urls += "?" + c.urlParams_.Encode()
  1066  	req, err := http.NewRequest("GET", urls, body)
  1067  	if err != nil {
  1068  		return nil, err
  1069  	}
  1070  	req.Header = reqHeaders
  1071  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1072  }
  1073  
  1074  // Do executes the "workspaceevents.subscriptions.list" call.
  1075  // Any non-2xx status code is an error. Response headers are in either
  1076  // *ListSubscriptionsResponse.ServerResponse.Header or (if a response was
  1077  // returned at all) in error.(*googleapi.Error).Header. Use
  1078  // googleapi.IsNotModified to check whether the returned error was because
  1079  // http.StatusNotModified was returned.
  1080  func (c *SubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListSubscriptionsResponse, error) {
  1081  	gensupport.SetOptions(c.urlParams_, opts...)
  1082  	res, err := c.doRequest("json")
  1083  	if res != nil && res.StatusCode == http.StatusNotModified {
  1084  		if res.Body != nil {
  1085  			res.Body.Close()
  1086  		}
  1087  		return nil, gensupport.WrapError(&googleapi.Error{
  1088  			Code:   res.StatusCode,
  1089  			Header: res.Header,
  1090  		})
  1091  	}
  1092  	if err != nil {
  1093  		return nil, err
  1094  	}
  1095  	defer googleapi.CloseBody(res)
  1096  	if err := googleapi.CheckResponse(res); err != nil {
  1097  		return nil, gensupport.WrapError(err)
  1098  	}
  1099  	ret := &ListSubscriptionsResponse{
  1100  		ServerResponse: googleapi.ServerResponse{
  1101  			Header:         res.Header,
  1102  			HTTPStatusCode: res.StatusCode,
  1103  		},
  1104  	}
  1105  	target := &ret
  1106  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1107  		return nil, err
  1108  	}
  1109  	return ret, nil
  1110  }
  1111  
  1112  // Pages invokes f for each page of results.
  1113  // A non-nil error returned from f will halt the iteration.
  1114  // The provided context supersedes any context provided to the Context method.
  1115  func (c *SubscriptionsListCall) Pages(ctx context.Context, f func(*ListSubscriptionsResponse) error) error {
  1116  	c.ctx_ = ctx
  1117  	defer c.PageToken(c.urlParams_.Get("pageToken"))
  1118  	for {
  1119  		x, err := c.Do()
  1120  		if err != nil {
  1121  			return err
  1122  		}
  1123  		if err := f(x); err != nil {
  1124  			return err
  1125  		}
  1126  		if x.NextPageToken == "" {
  1127  			return nil
  1128  		}
  1129  		c.PageToken(x.NextPageToken)
  1130  	}
  1131  }
  1132  
  1133  type SubscriptionsPatchCall struct {
  1134  	s            *Service
  1135  	name         string
  1136  	subscription *Subscription
  1137  	urlParams_   gensupport.URLParams
  1138  	ctx_         context.Context
  1139  	header_      http.Header
  1140  }
  1141  
  1142  // Patch: Developer Preview (https://developers.google.com/workspace/preview):
  1143  // Updates or renews a Google Workspace subscription. To learn how to use this
  1144  // method, see Update or renew a Google Workspace subscription
  1145  // (https://developers.google.com/workspace/events/guides/update-subscription).
  1146  //
  1147  //   - name: Optional. Immutable. Identifier. Resource name of the subscription.
  1148  //     Format: `subscriptions/{subscription}`.
  1149  func (r *SubscriptionsService) Patch(name string, subscription *Subscription) *SubscriptionsPatchCall {
  1150  	c := &SubscriptionsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1151  	c.name = name
  1152  	c.subscription = subscription
  1153  	return c
  1154  }
  1155  
  1156  // UpdateMask sets the optional parameter "updateMask": The field to update. If
  1157  // omitted, updates any fields included in the request. You can update one of
  1158  // the following fields in a subscription: * `expire_time`: The timestamp when
  1159  // the subscription expires. * `ttl`: The time-to-live (TTL) or duration of the
  1160  // subscription. To fully replace the subscription (the equivalent of `PUT`),
  1161  // use `*`. Any omitted fields are updated with empty values.
  1162  func (c *SubscriptionsPatchCall) UpdateMask(updateMask string) *SubscriptionsPatchCall {
  1163  	c.urlParams_.Set("updateMask", updateMask)
  1164  	return c
  1165  }
  1166  
  1167  // ValidateOnly sets the optional parameter "validateOnly": If set to `true`,
  1168  // validates and previews the request, but doesn't update the subscription.
  1169  func (c *SubscriptionsPatchCall) ValidateOnly(validateOnly bool) *SubscriptionsPatchCall {
  1170  	c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly))
  1171  	return c
  1172  }
  1173  
  1174  // Fields allows partial responses to be retrieved. See
  1175  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1176  // details.
  1177  func (c *SubscriptionsPatchCall) Fields(s ...googleapi.Field) *SubscriptionsPatchCall {
  1178  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1179  	return c
  1180  }
  1181  
  1182  // Context sets the context to be used in this call's Do method.
  1183  func (c *SubscriptionsPatchCall) Context(ctx context.Context) *SubscriptionsPatchCall {
  1184  	c.ctx_ = ctx
  1185  	return c
  1186  }
  1187  
  1188  // Header returns a http.Header that can be modified by the caller to add
  1189  // headers to the request.
  1190  func (c *SubscriptionsPatchCall) Header() http.Header {
  1191  	if c.header_ == nil {
  1192  		c.header_ = make(http.Header)
  1193  	}
  1194  	return c.header_
  1195  }
  1196  
  1197  func (c *SubscriptionsPatchCall) doRequest(alt string) (*http.Response, error) {
  1198  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
  1199  	var body io.Reader = nil
  1200  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription)
  1201  	if err != nil {
  1202  		return nil, err
  1203  	}
  1204  	c.urlParams_.Set("alt", alt)
  1205  	c.urlParams_.Set("prettyPrint", "false")
  1206  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  1207  	urls += "?" + c.urlParams_.Encode()
  1208  	req, err := http.NewRequest("PATCH", urls, body)
  1209  	if err != nil {
  1210  		return nil, err
  1211  	}
  1212  	req.Header = reqHeaders
  1213  	googleapi.Expand(req.URL, map[string]string{
  1214  		"name": c.name,
  1215  	})
  1216  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1217  }
  1218  
  1219  // Do executes the "workspaceevents.subscriptions.patch" call.
  1220  // Any non-2xx status code is an error. Response headers are in either
  1221  // *Operation.ServerResponse.Header or (if a response was returned at all) in
  1222  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1223  // whether the returned error was because http.StatusNotModified was returned.
  1224  func (c *SubscriptionsPatchCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1225  	gensupport.SetOptions(c.urlParams_, opts...)
  1226  	res, err := c.doRequest("json")
  1227  	if res != nil && res.StatusCode == http.StatusNotModified {
  1228  		if res.Body != nil {
  1229  			res.Body.Close()
  1230  		}
  1231  		return nil, gensupport.WrapError(&googleapi.Error{
  1232  			Code:   res.StatusCode,
  1233  			Header: res.Header,
  1234  		})
  1235  	}
  1236  	if err != nil {
  1237  		return nil, err
  1238  	}
  1239  	defer googleapi.CloseBody(res)
  1240  	if err := googleapi.CheckResponse(res); err != nil {
  1241  		return nil, gensupport.WrapError(err)
  1242  	}
  1243  	ret := &Operation{
  1244  		ServerResponse: googleapi.ServerResponse{
  1245  			Header:         res.Header,
  1246  			HTTPStatusCode: res.StatusCode,
  1247  		},
  1248  	}
  1249  	target := &ret
  1250  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1251  		return nil, err
  1252  	}
  1253  	return ret, nil
  1254  }
  1255  
  1256  type SubscriptionsReactivateCall struct {
  1257  	s                             *Service
  1258  	name                          string
  1259  	reactivatesubscriptionrequest *ReactivateSubscriptionRequest
  1260  	urlParams_                    gensupport.URLParams
  1261  	ctx_                          context.Context
  1262  	header_                       http.Header
  1263  }
  1264  
  1265  // Reactivate: Developer Preview
  1266  // (https://developers.google.com/workspace/preview): Reactivates a suspended
  1267  // Google Workspace subscription. This method resets your subscription's
  1268  // `State` field to `ACTIVE`. Before you use this method, you must fix the
  1269  // error that suspended the subscription. To learn how to use this method, see
  1270  // Reactivate a Google Workspace subscription
  1271  // (https://developers.google.com/workspace/events/guides/reactivate-subscription).
  1272  //
  1273  //   - name: Resource name of the subscription. Format:
  1274  //     `subscriptions/{subscription}`.
  1275  func (r *SubscriptionsService) Reactivate(name string, reactivatesubscriptionrequest *ReactivateSubscriptionRequest) *SubscriptionsReactivateCall {
  1276  	c := &SubscriptionsReactivateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1277  	c.name = name
  1278  	c.reactivatesubscriptionrequest = reactivatesubscriptionrequest
  1279  	return c
  1280  }
  1281  
  1282  // Fields allows partial responses to be retrieved. See
  1283  // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
  1284  // details.
  1285  func (c *SubscriptionsReactivateCall) Fields(s ...googleapi.Field) *SubscriptionsReactivateCall {
  1286  	c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1287  	return c
  1288  }
  1289  
  1290  // Context sets the context to be used in this call's Do method.
  1291  func (c *SubscriptionsReactivateCall) Context(ctx context.Context) *SubscriptionsReactivateCall {
  1292  	c.ctx_ = ctx
  1293  	return c
  1294  }
  1295  
  1296  // Header returns a http.Header that can be modified by the caller to add
  1297  // headers to the request.
  1298  func (c *SubscriptionsReactivateCall) Header() http.Header {
  1299  	if c.header_ == nil {
  1300  		c.header_ = make(http.Header)
  1301  	}
  1302  	return c.header_
  1303  }
  1304  
  1305  func (c *SubscriptionsReactivateCall) doRequest(alt string) (*http.Response, error) {
  1306  	reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
  1307  	var body io.Reader = nil
  1308  	body, err := googleapi.WithoutDataWrapper.JSONReader(c.reactivatesubscriptionrequest)
  1309  	if err != nil {
  1310  		return nil, err
  1311  	}
  1312  	c.urlParams_.Set("alt", alt)
  1313  	c.urlParams_.Set("prettyPrint", "false")
  1314  	urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:reactivate")
  1315  	urls += "?" + c.urlParams_.Encode()
  1316  	req, err := http.NewRequest("POST", urls, body)
  1317  	if err != nil {
  1318  		return nil, err
  1319  	}
  1320  	req.Header = reqHeaders
  1321  	googleapi.Expand(req.URL, map[string]string{
  1322  		"name": c.name,
  1323  	})
  1324  	return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1325  }
  1326  
  1327  // Do executes the "workspaceevents.subscriptions.reactivate" call.
  1328  // Any non-2xx status code is an error. Response headers are in either
  1329  // *Operation.ServerResponse.Header or (if a response was returned at all) in
  1330  // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1331  // whether the returned error was because http.StatusNotModified was returned.
  1332  func (c *SubscriptionsReactivateCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1333  	gensupport.SetOptions(c.urlParams_, opts...)
  1334  	res, err := c.doRequest("json")
  1335  	if res != nil && res.StatusCode == http.StatusNotModified {
  1336  		if res.Body != nil {
  1337  			res.Body.Close()
  1338  		}
  1339  		return nil, gensupport.WrapError(&googleapi.Error{
  1340  			Code:   res.StatusCode,
  1341  			Header: res.Header,
  1342  		})
  1343  	}
  1344  	if err != nil {
  1345  		return nil, err
  1346  	}
  1347  	defer googleapi.CloseBody(res)
  1348  	if err := googleapi.CheckResponse(res); err != nil {
  1349  		return nil, gensupport.WrapError(err)
  1350  	}
  1351  	ret := &Operation{
  1352  		ServerResponse: googleapi.ServerResponse{
  1353  			Header:         res.Header,
  1354  			HTTPStatusCode: res.StatusCode,
  1355  		},
  1356  	}
  1357  	target := &ret
  1358  	if err := gensupport.DecodeResponse(target, res); err != nil {
  1359  		return nil, err
  1360  	}
  1361  	return ret, nil
  1362  }
  1363  

View as plain text