// Copyright 2024 Google LLC. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Code generated file. DO NOT EDIT. // Package workspaceevents provides access to the Google Workspace Events API. // // For product documentation, see: https://developers.google.com/workspace/events // // # Library status // // These client libraries are officially supported by Google. However, this // library is considered complete and is in maintenance mode. This means // that we will address critical bugs and security issues but will not add // any new features. // // When possible, we recommend using our newer // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) // that are still actively being worked and iterated on. // // # Creating a client // // Usage example: // // import "google.golang.org/api/workspaceevents/v1" // ... // ctx := context.Background() // workspaceeventsService, err := workspaceevents.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 // // By default, all available scopes (see "Constants") are used to authenticate. // To restrict scopes, use [google.golang.org/api/option.WithScopes]: // // workspaceeventsService, err := workspaceevents.NewService(ctx, option.WithScopes(workspaceevents.MeetingsSpaceReadonlyScope)) // // To use an API key for authentication (note: some APIs do not support API // keys), use [google.golang.org/api/option.WithAPIKey]: // // workspaceeventsService, err := workspaceevents.NewService(ctx, option.WithAPIKey("AIza...")) // // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth // flow, use [google.golang.org/api/option.WithTokenSource]: // // config := &oauth2.Config{...} // // ... // token, err := config.Exchange(ctx, ...) // workspaceeventsService, err := workspaceevents.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) // // See [google.golang.org/api/option.ClientOption] for details on options. package workspaceevents // import "google.golang.org/api/workspaceevents/v1" import ( "bytes" "context" "encoding/json" "errors" "fmt" "io" "net/http" "net/url" "strconv" "strings" googleapi "google.golang.org/api/googleapi" internal "google.golang.org/api/internal" gensupport "google.golang.org/api/internal/gensupport" option "google.golang.org/api/option" internaloption "google.golang.org/api/option/internaloption" htransport "google.golang.org/api/transport/http" ) // Always reference these packages, just in case the auto-generated code // below doesn't. var _ = bytes.NewBuffer var _ = strconv.Itoa var _ = fmt.Sprintf var _ = json.NewDecoder var _ = io.Copy var _ = url.Parse var _ = gensupport.MarshalJSON var _ = googleapi.Version var _ = errors.New var _ = strings.Replace var _ = context.Canceled var _ = internaloption.WithDefaultEndpoint var _ = internal.Version const apiId = "workspaceevents:v1" const apiName = "workspaceevents" const apiVersion = "v1" const basePath = "https://workspaceevents.googleapis.com/" const basePathTemplate = "https://workspaceevents.UNIVERSE_DOMAIN/" const mtlsBasePath = "https://workspaceevents.mtls.googleapis.com/" // OAuth2 scopes used by this API. const ( // Private Service: https://www.googleapis.com/auth/chat.bot ChatBotScope = "https://www.googleapis.com/auth/chat.bot" // View, add, update, and remove members from conversations in Google Chat ChatMembershipsScope = "https://www.googleapis.com/auth/chat.memberships" // View members in Google Chat conversations. ChatMembershipsReadonlyScope = "https://www.googleapis.com/auth/chat.memberships.readonly" // View, compose, send, update, and delete messages, and add, view, and delete // reactions to messages. ChatMessagesScope = "https://www.googleapis.com/auth/chat.messages" // View, add, and delete reactions to messages in Google Chat ChatMessagesReactionsScope = "https://www.googleapis.com/auth/chat.messages.reactions" // View reactions to messages in Google Chat ChatMessagesReactionsReadonlyScope = "https://www.googleapis.com/auth/chat.messages.reactions.readonly" // View messages and reactions in Google Chat ChatMessagesReadonlyScope = "https://www.googleapis.com/auth/chat.messages.readonly" // Create conversations and spaces and see or edit metadata (including history // settings and access settings) in Google Chat ChatSpacesScope = "https://www.googleapis.com/auth/chat.spaces" // View chat and spaces in Google Chat ChatSpacesReadonlyScope = "https://www.googleapis.com/auth/chat.spaces.readonly" // Create, edit, and see information about your Google Meet conferences created // by the app. MeetingsSpaceCreatedScope = "https://www.googleapis.com/auth/meetings.space.created" // Read information about any of your Google Meet conferences MeetingsSpaceReadonlyScope = "https://www.googleapis.com/auth/meetings.space.readonly" ) // NewService creates a new Service. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { scopesOption := internaloption.WithDefaultScopes( "https://www.googleapis.com/auth/chat.bot", "https://www.googleapis.com/auth/chat.memberships", "https://www.googleapis.com/auth/chat.memberships.readonly", "https://www.googleapis.com/auth/chat.messages", "https://www.googleapis.com/auth/chat.messages.reactions", "https://www.googleapis.com/auth/chat.messages.reactions.readonly", "https://www.googleapis.com/auth/chat.messages.readonly", "https://www.googleapis.com/auth/chat.spaces", "https://www.googleapis.com/auth/chat.spaces.readonly", "https://www.googleapis.com/auth/meetings.space.created", "https://www.googleapis.com/auth/meetings.space.readonly", ) // NOTE: prepend, so we don't override user-specified scopes. opts = append([]option.ClientOption{scopesOption}, opts...) opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) opts = append(opts, internaloption.EnableNewAuthLibrary()) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err } s, err := New(client) if err != nil { return nil, err } if endpoint != "" { s.BasePath = endpoint } return s, nil } // 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 New(client *http.Client) (*Service, error) { if client == nil { return nil, errors.New("client is nil") } s := &Service{client: client, BasePath: basePath} s.Operations = NewOperationsService(s) s.Subscriptions = NewSubscriptionsService(s) return s, nil } type Service struct { client *http.Client BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment Operations *OperationsService Subscriptions *SubscriptionsService } func (s *Service) userAgent() string { if s.UserAgent == "" { return googleapi.UserAgent } return googleapi.UserAgent + " " + s.UserAgent } func NewOperationsService(s *Service) *OperationsService { rs := &OperationsService{s: s} return rs } type OperationsService struct { s *Service } func NewSubscriptionsService(s *Service) *SubscriptionsService { rs := &SubscriptionsService{s: s} return rs } type SubscriptionsService struct { s *Service } // ListSubscriptionsResponse: The response message for // SubscriptionsService.ListSubscriptions. type ListSubscriptionsResponse struct { // NextPageToken: A token, which can be sent as `page_token` to retrieve the // next page. If this field is omitted, there are no subsequent pages. NextPageToken string `json:"nextPageToken,omitempty"` // Subscriptions: List of subscriptions. Subscriptions []*Subscription `json:"subscriptions,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "NextPageToken") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "NextPageToken") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *ListSubscriptionsResponse) MarshalJSON() ([]byte, error) { type NoMethod ListSubscriptionsResponse return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // NotificationEndpoint: The endpoint where the subscription delivers events. type NotificationEndpoint struct { // PubsubTopic: Immutable. The Cloud Pub/Sub topic that receives events for the // subscription. Format: `projects/{project}/topics/{topic}` You must create // the topic in the same Google Cloud project where you create this // subscription. When the topic receives events, the events are encoded as // Cloud Pub/Sub messages. For details, see the Google Cloud Pub/Sub Protocol // Binding for CloudEvents // (https://github.com/googleapis/google-cloudevents/blob/main/docs/spec/pubsub.md). PubsubTopic string `json:"pubsubTopic,omitempty"` // ForceSendFields is a list of field names (e.g. "PubsubTopic") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "PubsubTopic") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *NotificationEndpoint) MarshalJSON() ([]byte, error) { type NoMethod NotificationEndpoint return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // Operation: This resource represents a long-running operation that is the // result of a network API call. type Operation struct { // Done: If the value is `false`, it means the operation is still in progress. // If `true`, the operation is completed, and either `error` or `response` is // available. Done bool `json:"done,omitempty"` // Error: The error result of the operation in case of failure or cancellation. Error *Status `json:"error,omitempty"` // Metadata: Service-specific metadata associated with the operation. It // typically contains progress information and common metadata such as create // time. Some services might not provide such metadata. Any method that returns // a long-running operation should document the metadata type, if any. Metadata googleapi.RawMessage `json:"metadata,omitempty"` // Name: The server-assigned name, which is only unique within the same service // that originally returns it. If you use the default HTTP mapping, the `name` // should be a resource name ending with `operations/{unique_id}`. Name string `json:"name,omitempty"` // Response: The normal, successful response of the operation. If the original // method returns no data on success, such as `Delete`, the response is // `google.protobuf.Empty`. If the original method is standard // `Get`/`Create`/`Update`, the response should be the resource. For other // methods, the response should have the type `XxxResponse`, where `Xxx` is the // original method name. For example, if the original method name is // `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. Response googleapi.RawMessage `json:"response,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "Done") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Done") to include in API requests // with the JSON null value. By default, fields with empty values are omitted // from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Operation) MarshalJSON() ([]byte, error) { type NoMethod Operation return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // PayloadOptions: Options about what data to include in the event payload. // Only supported for Google Chat events. type PayloadOptions struct { // FieldMask: Optional. If `include_resource` is set to `true`, the list of // fields to include in the event payload. Separate fields with a comma. For // example, to include a Google Chat message's sender and create time, enter // `message.sender,message.createTime`. If omitted, the payload includes all // fields for the resource. If you specify a field that doesn't exist for the // resource, the system ignores the field. FieldMask string `json:"fieldMask,omitempty"` // IncludeResource: Optional. Whether the event payload includes data about the // resource that changed. For example, for an event where a Google Chat message // was created, whether the payload contains data about the `Message` // (https://developers.google.com/chat/api/reference/rest/v1/spaces.messages) // resource. If false, the event payload only includes the name of the changed // resource. IncludeResource bool `json:"includeResource,omitempty"` // ForceSendFields is a list of field names (e.g. "FieldMask") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "FieldMask") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *PayloadOptions) MarshalJSON() ([]byte, error) { type NoMethod PayloadOptions return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // ReactivateSubscriptionRequest: The request message for // SubscriptionsService.ReactivateSubscription. type ReactivateSubscriptionRequest struct { } // Status: The `Status` type defines a logical error model that is suitable for // different programming environments, including REST APIs and RPC APIs. It is // used by gRPC (https://github.com/grpc). Each `Status` message contains three // pieces of data: error code, error message, and error details. You can find // out more about this error model and how to work with it in the API Design // Guide (https://cloud.google.com/apis/design/errors). type Status struct { // Code: The status code, which should be an enum value of google.rpc.Code. Code int64 `json:"code,omitempty"` // Details: A list of messages that carry the error details. There is a common // set of message types for APIs to use. Details []googleapi.RawMessage `json:"details,omitempty"` // Message: A developer-facing error message, which should be in English. Any // user-facing error message should be localized and sent in the // google.rpc.Status.details field, or localized by the client. Message string `json:"message,omitempty"` // ForceSendFields is a list of field names (e.g. "Code") to unconditionally // include in API requests. By default, fields with empty or default values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Code") to include in API requests // with the JSON null value. By default, fields with empty values are omitted // from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Status) MarshalJSON() ([]byte, error) { type NoMethod Status return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } // Subscription: Developer Preview // (https://developers.google.com/workspace/preview). A subscription to receive // events about a Google Workspace resource. To learn more about subscriptions, // see the Google Workspace Events API overview // (https://developers.google.com/workspace/events). type Subscription struct { // Authority: Output only. The user who authorized the creation of the // subscription. Format: `users/{user}` For Google Workspace users, the // `{user}` value is the `user.id` // (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users#User.FIELDS.ids) // field from the Directory API. Authority string `json:"authority,omitempty"` // CreateTime: Output only. The time when the subscription is created. CreateTime string `json:"createTime,omitempty"` // Etag: Optional. This checksum is computed by the server based on the value // of other fields, and might be sent on update requests to ensure the client // has an up-to-date value before proceeding. Etag string `json:"etag,omitempty"` // EventTypes: Required. Immutable. Unordered list. Input for creating a // subscription. Otherwise, output only. One or more types of events to receive // about the target resource. Formatted according to the CloudEvents // specification. The supported event types depend on the target resource of // your subscription. For details, see Supported Google Workspace events // (https://developers.google.com/workspace/events/guides#supported-events). By // default, you also receive events about the lifecycle of your subscription // (https://developers.google.com/workspace/events/guides/events-lifecycle). // You don't need to specify lifecycle events for this field. If you specify an // event type that doesn't exist for the target resource, the request returns // an HTTP `400 Bad Request` status code. EventTypes []string `json:"eventTypes,omitempty"` // ExpireTime: Non-empty default. The timestamp in UTC when the subscription // expires. Always displayed on output, regardless of what was used on input. ExpireTime string `json:"expireTime,omitempty"` // Name: Optional. Immutable. Identifier. Resource name of the subscription. // Format: `subscriptions/{subscription}` Name string `json:"name,omitempty"` // NotificationEndpoint: Required. Immutable. The endpoint where the // subscription delivers events, such as a Pub/Sub topic. NotificationEndpoint *NotificationEndpoint `json:"notificationEndpoint,omitempty"` // PayloadOptions: Optional. Options about what data to include in the event // payload. Only supported for Google Chat events. PayloadOptions *PayloadOptions `json:"payloadOptions,omitempty"` // Reconciling: Output only. If `true`, the subscription is in the process of // being updated. Reconciling bool `json:"reconciling,omitempty"` // State: Output only. The state of the subscription. Determines whether the // subscription can receive events and deliver them to the notification // endpoint. // // Possible values: // "STATE_UNSPECIFIED" - Default value. This value is unused. // "ACTIVE" - The subscription is active and can receive and deliver events // to its notification endpoint. // "SUSPENDED" - The subscription is unable to receive events due to an // error. To identify the error, see the `suspension_reason` field. // "DELETED" - The subscription is deleted. State string `json:"state,omitempty"` // SuspensionReason: Output only. The error that suspended the subscription. To // reactivate the subscription, resolve the error and call the // `ReactivateSubscription` method. // // Possible values: // "ERROR_TYPE_UNSPECIFIED" - Default value. This value is unused. // "USER_SCOPE_REVOKED" - The authorizing user has revoked the grant of one // or more OAuth scopes. To learn more about authorization for Google // Workspace, see [Configure the OAuth consent // screen](https://developers.google.com/workspace/guides/configure-oauth-consen // t#choose-scopes). // "RESOURCE_DELETED" - The target resource for the subscription no longer // exists. // "USER_AUTHORIZATION_FAILURE" - The user that authorized the creation of // the subscription no longer has access to the subscription's target resource. // "ENDPOINT_PERMISSION_DENIED" - The Google Workspace application doesn't // have access to deliver events to your subscription's notification endpoint. // "ENDPOINT_NOT_FOUND" - The subscription's notification endpoint doesn't // exist, or the endpoint can't be found in the Google Cloud project where you // created the subscription. // "ENDPOINT_RESOURCE_EXHAUSTED" - The subscription's notification endpoint // failed to receive events due to insufficient quota or reaching rate // limiting. // "OTHER" - An unidentified error has occurred. SuspensionReason string `json:"suspensionReason,omitempty"` // TargetResource: Required. Immutable. The Google Workspace resource that's // monitored for events, formatted as the full resource name // (https://google.aip.dev/122#full-resource-names). To learn about target // resources and the events that they support, see Supported Google Workspace // events (https://developers.google.com/workspace/events#supported-events). A // user can only authorize your app to create one subscription for a given // target resource. If your app tries to create another subscription with the // same user credentials, the request returns an `ALREADY_EXISTS` error. TargetResource string `json:"targetResource,omitempty"` // Ttl: Input only. The time-to-live (TTL) or duration for the subscription. If // unspecified or set to `0`, uses the maximum possible duration. Ttl string `json:"ttl,omitempty"` // Uid: Output only. System-assigned unique identifier for the subscription. Uid string `json:"uid,omitempty"` // UpdateTime: Output only. The last time that the subscription is updated. UpdateTime string `json:"updateTime,omitempty"` // ServerResponse contains the HTTP response code and headers from the server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "Authority") to // unconditionally include in API requests. By default, fields with empty or // default values are omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more // details. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Authority") to include in API // requests with the JSON null value. By default, fields with empty values are // omitted from API requests. See // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. NullFields []string `json:"-"` } func (s *Subscription) MarshalJSON() ([]byte, error) { type NoMethod Subscription return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) } type OperationsGetCall struct { s *Service name string urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // Get: Gets the latest state of a long-running operation. Clients can use this // method to poll the operation result at intervals as recommended by the API // service. // // - name: The name of the operation resource. func (r *OperationsService) Get(name string) *OperationsGetCall { c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets an 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. func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do method. func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *OperationsGetCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "workspaceevents.operations.get" call. // Any non-2xx status code is an error. Response headers are in either // *Operation.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 (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Operation{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type SubscriptionsCreateCall struct { s *Service subscription *Subscription urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // Create: Developer Preview (https://developers.google.com/workspace/preview): // Creates a Google Workspace subscription. To learn how to use this method, // see Create a Google Workspace subscription // (https://developers.google.com/workspace/events/guides/create-subscription). func (r *SubscriptionsService) Create(subscription *Subscription) *SubscriptionsCreateCall { c := &SubscriptionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.subscription = subscription return c } // ValidateOnly sets the optional parameter "validateOnly": If set to `true`, // validates and previews the request, but doesn't create the subscription. func (c *SubscriptionsCreateCall) ValidateOnly(validateOnly bool) *SubscriptionsCreateCall { c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly)) return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *SubscriptionsCreateCall) Fields(s ...googleapi.Field) *SubscriptionsCreateCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *SubscriptionsCreateCall) Context(ctx context.Context) *SubscriptionsCreateCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *SubscriptionsCreateCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *SubscriptionsCreateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription) if err != nil { return nil, err } c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/subscriptions") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { return nil, err } req.Header = reqHeaders return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "workspaceevents.subscriptions.create" call. // Any non-2xx status code is an error. Response headers are in either // *Operation.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 (c *SubscriptionsCreateCall) Do(opts ...googleapi.CallOption) (*Operation, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Operation{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type SubscriptionsDeleteCall struct { s *Service name string urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // Delete: Developer Preview (https://developers.google.com/workspace/preview): // Deletes a Google Workspace subscription. To learn how to use this method, // see Delete a Google Workspace subscription // (https://developers.google.com/workspace/events/guides/delete-subscription). // // - name: Resource name of the subscription to delete. Format: // `subscriptions/{subscription}`. func (r *SubscriptionsService) Delete(name string) *SubscriptionsDeleteCall { c := &SubscriptionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name return c } // AllowMissing sets the optional parameter "allowMissing": If set to `true` // and the subscription isn't found, the request succeeds but doesn't delete // the subscription. func (c *SubscriptionsDeleteCall) AllowMissing(allowMissing bool) *SubscriptionsDeleteCall { c.urlParams_.Set("allowMissing", fmt.Sprint(allowMissing)) return c } // Etag sets the optional parameter "etag": Etag of the subscription. If // present, it must match with the server's etag. Otherwise, request fails with // the status `ABORTED`. func (c *SubscriptionsDeleteCall) Etag(etag string) *SubscriptionsDeleteCall { c.urlParams_.Set("etag", etag) return c } // ValidateOnly sets the optional parameter "validateOnly": If set to `true`, // validates and previews the request, but doesn't delete the subscription. func (c *SubscriptionsDeleteCall) ValidateOnly(validateOnly bool) *SubscriptionsDeleteCall { c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly)) return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *SubscriptionsDeleteCall) Fields(s ...googleapi.Field) *SubscriptionsDeleteCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *SubscriptionsDeleteCall) Context(ctx context.Context) *SubscriptionsDeleteCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *SubscriptionsDeleteCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *SubscriptionsDeleteCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("DELETE", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "workspaceevents.subscriptions.delete" call. // Any non-2xx status code is an error. Response headers are in either // *Operation.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 (c *SubscriptionsDeleteCall) Do(opts ...googleapi.CallOption) (*Operation, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Operation{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type SubscriptionsGetCall struct { s *Service name string urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // Get: Developer Preview (https://developers.google.com/workspace/preview): // Gets details about a Google Workspace subscription. To learn how to use this // method, see Get details about a Google Workspace subscription // (https://developers.google.com/workspace/events/guides/get-subscription). // // - name: Resource name of the subscription. Format: // `subscriptions/{subscription}`. func (r *SubscriptionsService) Get(name string) *SubscriptionsGetCall { c := &SubscriptionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *SubscriptionsGetCall) Fields(s ...googleapi.Field) *SubscriptionsGetCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets an 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. func (c *SubscriptionsGetCall) IfNoneMatch(entityTag string) *SubscriptionsGetCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do method. func (c *SubscriptionsGetCall) Context(ctx context.Context) *SubscriptionsGetCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *SubscriptionsGetCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *SubscriptionsGetCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "workspaceevents.subscriptions.get" call. // Any non-2xx status code is an error. Response headers are in either // *Subscription.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 (c *SubscriptionsGetCall) Do(opts ...googleapi.CallOption) (*Subscription, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Subscription{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type SubscriptionsListCall struct { s *Service urlParams_ gensupport.URLParams ifNoneMatch_ string ctx_ context.Context header_ http.Header } // List: Developer Preview (https://developers.google.com/workspace/preview): // Lists Google Workspace subscriptions. To learn how to use this method, see // List Google Workspace subscriptions // (https://developers.google.com/workspace/events/guides/list-subscriptions). func (r *SubscriptionsService) List() *SubscriptionsListCall { c := &SubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} return c } // Filter sets the optional parameter "filter": Required. A query filter. You // can filter subscriptions by event type (`event_types`) and target resource // (`target_resource`). You must specify at least one event type in your query. // To filter for multiple event types, use the `OR` operator. To filter by both // event type and target resource, use the `AND` operator and specify the full // resource name, such as `//chat.googleapis.com/spaces/{space}`. For example, // the following queries are valid: ``` // event_types:"google.workspace.chat.membership.v1.updated" OR // event_types:"google.workspace.chat.message.v1.created" // event_types:"google.workspace.chat.message.v1.created" AND // target_resource="//chat.googleapis.com/spaces/{space}" ( // event_types:"google.workspace.chat.membership.v1.updated" OR // event_types:"google.workspace.chat.message.v1.created" ) AND // target_resource="//chat.googleapis.com/spaces/{space}" ``` The server // rejects invalid queries with an `INVALID_ARGUMENT` error. func (c *SubscriptionsListCall) Filter(filter string) *SubscriptionsListCall { c.urlParams_.Set("filter", filter) return c } // PageSize sets the optional parameter "pageSize": The maximum number of // subscriptions to return. The service might return fewer than this value. If // unspecified or set to `0`, up to 50 subscriptions are returned. The maximum // value is 100. If you specify a value more than 100, the system only returns // 100 subscriptions. func (c *SubscriptionsListCall) PageSize(pageSize int64) *SubscriptionsListCall { c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) return c } // PageToken sets the optional parameter "pageToken": A page token, received // from a previous list subscriptions call. Provide this parameter to retrieve // the subsequent page. When paginating, the filter value should match the call // that provided the page token. Passing a different value might lead to // unexpected results. func (c *SubscriptionsListCall) PageToken(pageToken string) *SubscriptionsListCall { c.urlParams_.Set("pageToken", pageToken) return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *SubscriptionsListCall) Fields(s ...googleapi.Field) *SubscriptionsListCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // IfNoneMatch sets an 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. func (c *SubscriptionsListCall) IfNoneMatch(entityTag string) *SubscriptionsListCall { c.ifNoneMatch_ = entityTag return c } // Context sets the context to be used in this call's Do method. func (c *SubscriptionsListCall) Context(ctx context.Context) *SubscriptionsListCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *SubscriptionsListCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *SubscriptionsListCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) if c.ifNoneMatch_ != "" { reqHeaders.Set("If-None-Match", c.ifNoneMatch_) } var body io.Reader = nil c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/subscriptions") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("GET", urls, body) if err != nil { return nil, err } req.Header = reqHeaders return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "workspaceevents.subscriptions.list" call. // Any non-2xx status code is an error. Response headers are in either // *ListSubscriptionsResponse.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 (c *SubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListSubscriptionsResponse, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &ListSubscriptionsResponse{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } // Pages invokes f for each page of results. // A non-nil error returned from f will halt the iteration. // The provided context supersedes any context provided to the Context method. func (c *SubscriptionsListCall) Pages(ctx context.Context, f func(*ListSubscriptionsResponse) error) error { c.ctx_ = ctx defer c.PageToken(c.urlParams_.Get("pageToken")) for { x, err := c.Do() if err != nil { return err } if err := f(x); err != nil { return err } if x.NextPageToken == "" { return nil } c.PageToken(x.NextPageToken) } } type SubscriptionsPatchCall struct { s *Service name string subscription *Subscription urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // Patch: Developer Preview (https://developers.google.com/workspace/preview): // Updates or renews a Google Workspace subscription. To learn how to use this // method, see Update or renew a Google Workspace subscription // (https://developers.google.com/workspace/events/guides/update-subscription). // // - name: Optional. Immutable. Identifier. Resource name of the subscription. // Format: `subscriptions/{subscription}`. func (r *SubscriptionsService) Patch(name string, subscription *Subscription) *SubscriptionsPatchCall { c := &SubscriptionsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name c.subscription = subscription return c } // UpdateMask sets the optional parameter "updateMask": The field to update. If // omitted, updates any fields included in the request. You can update one of // the following fields in a subscription: * `expire_time`: The timestamp when // the subscription expires. * `ttl`: The time-to-live (TTL) or duration of the // subscription. To fully replace the subscription (the equivalent of `PUT`), // use `*`. Any omitted fields are updated with empty values. func (c *SubscriptionsPatchCall) UpdateMask(updateMask string) *SubscriptionsPatchCall { c.urlParams_.Set("updateMask", updateMask) return c } // ValidateOnly sets the optional parameter "validateOnly": If set to `true`, // validates and previews the request, but doesn't update the subscription. func (c *SubscriptionsPatchCall) ValidateOnly(validateOnly bool) *SubscriptionsPatchCall { c.urlParams_.Set("validateOnly", fmt.Sprint(validateOnly)) return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *SubscriptionsPatchCall) Fields(s ...googleapi.Field) *SubscriptionsPatchCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *SubscriptionsPatchCall) Context(ctx context.Context) *SubscriptionsPatchCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *SubscriptionsPatchCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *SubscriptionsPatchCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription) if err != nil { return nil, err } c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("PATCH", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "workspaceevents.subscriptions.patch" call. // Any non-2xx status code is an error. Response headers are in either // *Operation.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 (c *SubscriptionsPatchCall) Do(opts ...googleapi.CallOption) (*Operation, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Operation{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil } type SubscriptionsReactivateCall struct { s *Service name string reactivatesubscriptionrequest *ReactivateSubscriptionRequest urlParams_ gensupport.URLParams ctx_ context.Context header_ http.Header } // Reactivate: Developer Preview // (https://developers.google.com/workspace/preview): Reactivates a suspended // Google Workspace subscription. This method resets your subscription's // `State` field to `ACTIVE`. Before you use this method, you must fix the // error that suspended the subscription. To learn how to use this method, see // Reactivate a Google Workspace subscription // (https://developers.google.com/workspace/events/guides/reactivate-subscription). // // - name: Resource name of the subscription. Format: // `subscriptions/{subscription}`. func (r *SubscriptionsService) Reactivate(name string, reactivatesubscriptionrequest *ReactivateSubscriptionRequest) *SubscriptionsReactivateCall { c := &SubscriptionsReactivateCall{s: r.s, urlParams_: make(gensupport.URLParams)} c.name = name c.reactivatesubscriptionrequest = reactivatesubscriptionrequest return c } // Fields allows partial responses to be retrieved. See // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more // details. func (c *SubscriptionsReactivateCall) Fields(s ...googleapi.Field) *SubscriptionsReactivateCall { c.urlParams_.Set("fields", googleapi.CombineFields(s)) return c } // Context sets the context to be used in this call's Do method. func (c *SubscriptionsReactivateCall) Context(ctx context.Context) *SubscriptionsReactivateCall { c.ctx_ = ctx return c } // Header returns a http.Header that can be modified by the caller to add // headers to the request. func (c *SubscriptionsReactivateCall) Header() http.Header { if c.header_ == nil { c.header_ = make(http.Header) } return c.header_ } func (c *SubscriptionsReactivateCall) doRequest(alt string) (*http.Response, error) { reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) var body io.Reader = nil body, err := googleapi.WithoutDataWrapper.JSONReader(c.reactivatesubscriptionrequest) if err != nil { return nil, err } c.urlParams_.Set("alt", alt) c.urlParams_.Set("prettyPrint", "false") urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:reactivate") urls += "?" + c.urlParams_.Encode() req, err := http.NewRequest("POST", urls, body) if err != nil { return nil, err } req.Header = reqHeaders googleapi.Expand(req.URL, map[string]string{ "name": c.name, }) return gensupport.SendRequest(c.ctx_, c.s.client, req) } // Do executes the "workspaceevents.subscriptions.reactivate" call. // Any non-2xx status code is an error. Response headers are in either // *Operation.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 (c *SubscriptionsReactivateCall) Do(opts ...googleapi.CallOption) (*Operation, error) { gensupport.SetOptions(c.urlParams_, opts...) res, err := c.doRequest("json") if res != nil && res.StatusCode == http.StatusNotModified { if res.Body != nil { res.Body.Close() } return nil, gensupport.WrapError(&googleapi.Error{ Code: res.StatusCode, Header: res.Header, }) } if err != nil { return nil, err } defer googleapi.CloseBody(res) if err := googleapi.CheckResponse(res); err != nil { return nil, gensupport.WrapError(err) } ret := &Operation{ ServerResponse: googleapi.ServerResponse{ Header: res.Header, HTTPStatusCode: res.StatusCode, }, } target := &ret if err := gensupport.DecodeResponse(target, res); err != nil { return nil, err } return ret, nil }