Skip to content

Commit fac9667

Browse files
feat: Add the AppsEventSubscriptions beta component (#8405)
1 parent 6b4dcca commit fac9667

32 files changed

Lines changed: 5035 additions & 1 deletion
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
deep-copy-regex:
2-
- source: /google/apps/events/subscriptions/(v1)/.*-php/(.*)
2+
- source: /google/apps/events/subscriptions/(v1beta|v1)/.*-php/(.*)
33
dest: /owl-bot-staging/AppsEventsSubscriptions/$1/$2
44
api-name: AppsEventsSubscriptions
3.17 KB
Binary file not shown.

AppsEventsSubscriptions/metadata/V1Beta/SubscriptionsService.php

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START workspaceevents_v1beta_generated_SubscriptionsService_CreateSubscription_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Apps\Events\Subscriptions\V1beta\Client\SubscriptionsServiceClient;
29+
use Google\Apps\Events\Subscriptions\V1beta\CreateSubscriptionRequest;
30+
use Google\Apps\Events\Subscriptions\V1beta\NotificationEndpoint;
31+
use Google\Apps\Events\Subscriptions\V1beta\Subscription;
32+
use Google\Rpc\Status;
33+
34+
/**
35+
* Creates a Google Workspace subscription. To learn how to use this
36+
* method, see [Create a Google Workspace
37+
* subscription](https://developers.google.com/workspace/events/guides/create-subscription).
38+
*
39+
*
40+
* @param string $subscriptionTargetResource Immutable. The Google Workspace resource that's monitored for
41+
* events, formatted as the [full resource
42+
* name](https://google.aip.dev/122#full-resource-names). To learn about
43+
* target resources and the events that they support, see [Supported Google
44+
* Workspace
45+
* events](https://developers.google.com/workspace/events#supported-events).
46+
*
47+
* A user can only authorize your app to create one subscription for a given
48+
* target resource. If your app tries to create another subscription with the
49+
* same user credentials, the request returns an `ALREADY_EXISTS` error.
50+
* @param string $subscriptionEventTypesElement Unordered list. Input for creating a subscription. Otherwise,
51+
* output only. One or more types of events to receive about the target
52+
* resource. Formatted according to the CloudEvents specification.
53+
*
54+
* The supported event types depend on the target resource of your
55+
* subscription. For details, see [Supported Google Workspace
56+
* events](https://developers.google.com/workspace/events/guides#supported-events).
57+
*
58+
* By default, you also receive events about the [lifecycle of your
59+
* subscription](https://developers.google.com/workspace/events/guides/events-lifecycle).
60+
* You don't need to specify lifecycle events for this field.
61+
*
62+
* If you specify an event type that doesn't exist for the target resource,
63+
* the request returns an HTTP `400 Bad Request` status code.
64+
*/
65+
function create_subscription_sample(
66+
string $subscriptionTargetResource,
67+
string $subscriptionEventTypesElement
68+
): void {
69+
// Create a client.
70+
$subscriptionsServiceClient = new SubscriptionsServiceClient();
71+
72+
// Prepare the request message.
73+
$subscriptionEventTypes = [$subscriptionEventTypesElement,];
74+
$subscriptionNotificationEndpoint = new NotificationEndpoint();
75+
$subscription = (new Subscription())
76+
->setTargetResource($subscriptionTargetResource)
77+
->setEventTypes($subscriptionEventTypes)
78+
->setNotificationEndpoint($subscriptionNotificationEndpoint);
79+
$request = (new CreateSubscriptionRequest())
80+
->setSubscription($subscription);
81+
82+
// Call the API and handle any network failures.
83+
try {
84+
/** @var OperationResponse $response */
85+
$response = $subscriptionsServiceClient->createSubscription($request);
86+
$response->pollUntilComplete();
87+
88+
if ($response->operationSucceeded()) {
89+
/** @var Subscription $result */
90+
$result = $response->getResult();
91+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
92+
} else {
93+
/** @var Status $error */
94+
$error = $response->getError();
95+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
96+
}
97+
} catch (ApiException $ex) {
98+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
99+
}
100+
}
101+
102+
/**
103+
* Helper to execute the sample.
104+
*
105+
* This sample has been automatically generated and should be regarded as a code
106+
* template only. It will require modifications to work:
107+
* - It may require correct/in-range values for request initialization.
108+
* - It may require specifying regional endpoints when creating the service client,
109+
* please see the apiEndpoint client configuration option for more details.
110+
*/
111+
function callSample(): void
112+
{
113+
$subscriptionTargetResource = '[TARGET_RESOURCE]';
114+
$subscriptionEventTypesElement = '[EVENT_TYPES]';
115+
116+
create_subscription_sample($subscriptionTargetResource, $subscriptionEventTypesElement);
117+
}
118+
// [END workspaceevents_v1beta_generated_SubscriptionsService_CreateSubscription_sync]
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START workspaceevents_v1beta_generated_SubscriptionsService_DeleteSubscription_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Apps\Events\Subscriptions\V1beta\Client\SubscriptionsServiceClient;
29+
use Google\Apps\Events\Subscriptions\V1beta\DeleteSubscriptionRequest;
30+
use Google\Rpc\Status;
31+
32+
/**
33+
* Deletes a Google Workspace subscription.
34+
* To learn how to use this method, see [Delete a Google Workspace
35+
* subscription](https://developers.google.com/workspace/events/guides/delete-subscription).
36+
*
37+
* @param string $formattedName Resource name of the subscription to delete.
38+
*
39+
* Format: `subscriptions/{subscription}`
40+
* Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
41+
*/
42+
function delete_subscription_sample(string $formattedName): void
43+
{
44+
// Create a client.
45+
$subscriptionsServiceClient = new SubscriptionsServiceClient();
46+
47+
// Prepare the request message.
48+
$request = (new DeleteSubscriptionRequest())
49+
->setName($formattedName);
50+
51+
// Call the API and handle any network failures.
52+
try {
53+
/** @var OperationResponse $response */
54+
$response = $subscriptionsServiceClient->deleteSubscription($request);
55+
$response->pollUntilComplete();
56+
57+
if ($response->operationSucceeded()) {
58+
printf('Operation completed successfully.' . PHP_EOL);
59+
} else {
60+
/** @var Status $error */
61+
$error = $response->getError();
62+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
63+
}
64+
} catch (ApiException $ex) {
65+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
66+
}
67+
}
68+
69+
/**
70+
* Helper to execute the sample.
71+
*
72+
* This sample has been automatically generated and should be regarded as a code
73+
* template only. It will require modifications to work:
74+
* - It may require correct/in-range values for request initialization.
75+
* - It may require specifying regional endpoints when creating the service client,
76+
* please see the apiEndpoint client configuration option for more details.
77+
*/
78+
function callSample(): void
79+
{
80+
$formattedName = SubscriptionsServiceClient::subscriptionName('[SUBSCRIPTION]');
81+
82+
delete_subscription_sample($formattedName);
83+
}
84+
// [END workspaceevents_v1beta_generated_SubscriptionsService_DeleteSubscription_sync]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/*
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START workspaceevents_v1beta_generated_SubscriptionsService_GetSubscription_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Apps\Events\Subscriptions\V1beta\Client\SubscriptionsServiceClient;
28+
use Google\Apps\Events\Subscriptions\V1beta\GetSubscriptionRequest;
29+
use Google\Apps\Events\Subscriptions\V1beta\Subscription;
30+
31+
/**
32+
* Gets details about a Google Workspace subscription. To learn how to use
33+
* this method, see [Get details about a Google Workspace
34+
* subscription](https://developers.google.com/workspace/events/guides/get-subscription).
35+
*
36+
* @param string $formattedName Resource name of the subscription.
37+
*
38+
* Format: `subscriptions/{subscription}`
39+
* Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
40+
*/
41+
function get_subscription_sample(string $formattedName): void
42+
{
43+
// Create a client.
44+
$subscriptionsServiceClient = new SubscriptionsServiceClient();
45+
46+
// Prepare the request message.
47+
$request = (new GetSubscriptionRequest())
48+
->setName($formattedName);
49+
50+
// Call the API and handle any network failures.
51+
try {
52+
/** @var Subscription $response */
53+
$response = $subscriptionsServiceClient->getSubscription($request);
54+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
55+
} catch (ApiException $ex) {
56+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
57+
}
58+
}
59+
60+
/**
61+
* Helper to execute the sample.
62+
*
63+
* This sample has been automatically generated and should be regarded as a code
64+
* template only. It will require modifications to work:
65+
* - It may require correct/in-range values for request initialization.
66+
* - It may require specifying regional endpoints when creating the service client,
67+
* please see the apiEndpoint client configuration option for more details.
68+
*/
69+
function callSample(): void
70+
{
71+
$formattedName = SubscriptionsServiceClient::subscriptionName('[SUBSCRIPTION]');
72+
73+
get_subscription_sample($formattedName);
74+
}
75+
// [END workspaceevents_v1beta_generated_SubscriptionsService_GetSubscription_sync]

0 commit comments

Comments
 (0)