Skip to content

Commit 0c00daa

Browse files
feat: Memorystore backup (#8275)
* fix: Changed field behavior for an existing field `psc_connection_id` in message `.google.cloud.memorystore.v1.PscConnection` feat: A new resource_definition `cloudkms.googleapis.com/CryptoKey` is added feat: A new method `RescheduleMaintenance` is added to service `Memorystore` feat: A new method `ListBackupCollections` is added to service `Memorystore` feat: A new method `GetBackupCollection` is added to service `Memorystore` feat: A new method `ListBackups` is added to service `Memorystore` feat: A new method `GetBackup` is added to service `Memorystore` feat: A new method `DeleteBackup` is added to service `Memorystore` feat: A new method `ExportBackup` is added to service `Memorystore` feat: A new method `BackupInstance` is added to service `Memorystore` feat: A new field `target_engine_version` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `target_node_type` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new message `GcsBackupSource` is added feat: A new message `ManagedBackupSource` is added feat: A new field `gcs_source` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `managed_backup_source` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `psc_attachment_details` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `ondemand_maintenance` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `maintenance_policy` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `maintenance_schedule` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `cross_instance_replication_config` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `async_instance_endpoints_deletion_enabled` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `backup_collection` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new field `automated_backup_config` is added to message `.google.cloud.memorystore.v1.Instance` feat: A new message `AutomatedBackupConfig` is added feat: A new message `BackupCollection` is added feat: A new resource_definition `memorystore.googleapis.com/BackupCollection` is added feat: A new message `Backup` is added feat: A new resource_definition `memorystore.googleapis.com/Backup` is added feat: A new message `BackupFile` is added feat: A new message `CrossInstanceReplicationConfig` is added feat: A new message `MaintenancePolicy` is added feat: A new message `WeeklyMaintenanceWindow` is added feat: A new message `MaintenanceSchedule` is added feat: A new message `PscAttachmentDetail` is added feat: A new field `port` is added to message `.google.cloud.memorystore.v1.PscConnection` feat: A new message `RescheduleMaintenanceRequest` is added feat: A new message `ListBackupCollectionsRequest` is added feat: A new message `ListBackupCollectionsResponse` is added feat: A new message `GetBackupCollectionRequest` is added feat: A new message `ListBackupsRequest` is added feat: A new message `ListBackupsResponse` is added feat: A new message `GetBackupRequest` is added feat: A new message `DeleteBackupRequest` is added feat: A new message `ExportBackupRequest` is added feat: A new message `BackupInstanceRequest` is added docs: A comment for field `psc_auto_connection` in message `.google.cloud.memorystore.v1.Instance` is changed docs: A comment for field `discovery_endpoints` in message `.google.cloud.memorystore.v1.Instance` is changed docs: A comment for field `node_type` in message `.google.cloud.memorystore.v1.Instance` is changed docs: A comment for field `engine_version` in message `.google.cloud.memorystore.v1.Instance` is changed docs: A comment for field `psc_auto_connections` in message `.google.cloud.memorystore.v1.Instance` is changed docs: A comment for field `port` in message `.google.cloud.memorystore.v1.PscAutoConnection` is changed docs: A comment for field `psc_connection_id` in message `.google.cloud.memorystore.v1.PscConnection` is changed PiperOrigin-RevId: 753627410 Source-Link: googleapis/googleapis@4554091 Source-Link: googleapis/googleapis-gen@a8de37e Copy-Tag: eyJwIjoiTWVtb3J5c3RvcmUvLk93bEJvdC55YW1sIiwiaCI6ImE4ZGUzN2U0ODVlMWY3MDQyMWVmMmVhNDNlMWVmOGM4MzhjODFlNDYifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 25d2285 commit 0c00daa

51 files changed

Lines changed: 7047 additions & 251 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
8.17 KB
Binary file not shown.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 memorystore_v1_generated_Memorystore_BackupInstance_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\Memorystore\V1\BackupInstanceRequest;
29+
use Google\Cloud\Memorystore\V1\Client\MemorystoreClient;
30+
use Google\Cloud\Memorystore\V1\Instance;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Backup Instance.
35+
* If this is the first time a backup is being created, a backup collection
36+
* will be created at the backend, and this backup belongs to this collection.
37+
* Both collection and backup will have a resource name. Backup will be
38+
* executed for each shard. A replica (primary if nonHA) will be selected to
39+
* perform the execution. Backup call will be rejected if there is an ongoing
40+
* backup or update operation. Be aware that during preview, if the instance's
41+
* internal software version is too old, critical update will be performed
42+
* before actual backup. Once the internal software version is updated to the
43+
* minimum version required by the backup feature, subsequent backups will not
44+
* require critical update. After preview, there will be no critical update
45+
* needed for backup.
46+
*
47+
* @param string $formattedName Instance resource name using the form:
48+
* `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
49+
* where `location_id` refers to a Google Cloud region. Please see
50+
* {@see MemorystoreClient::instanceName()} for help formatting this field.
51+
*/
52+
function backup_instance_sample(string $formattedName): void
53+
{
54+
// Create a client.
55+
$memorystoreClient = new MemorystoreClient();
56+
57+
// Prepare the request message.
58+
$request = (new BackupInstanceRequest())
59+
->setName($formattedName);
60+
61+
// Call the API and handle any network failures.
62+
try {
63+
/** @var OperationResponse $response */
64+
$response = $memorystoreClient->backupInstance($request);
65+
$response->pollUntilComplete();
66+
67+
if ($response->operationSucceeded()) {
68+
/** @var Instance $result */
69+
$result = $response->getResult();
70+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
71+
} else {
72+
/** @var Status $error */
73+
$error = $response->getError();
74+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
75+
}
76+
} catch (ApiException $ex) {
77+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
78+
}
79+
}
80+
81+
/**
82+
* Helper to execute the sample.
83+
*
84+
* This sample has been automatically generated and should be regarded as a code
85+
* template only. It will require modifications to work:
86+
* - It may require correct/in-range values for request initialization.
87+
* - It may require specifying regional endpoints when creating the service client,
88+
* please see the apiEndpoint client configuration option for more details.
89+
*/
90+
function callSample(): void
91+
{
92+
$formattedName = MemorystoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
93+
94+
backup_instance_sample($formattedName);
95+
}
96+
// [END memorystore_v1_generated_Memorystore_BackupInstance_sync]

Memorystore/samples/V1/MemorystoreClient/create_instance.php

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,47 +28,32 @@
2828
use Google\Cloud\Memorystore\V1\Client\MemorystoreClient;
2929
use Google\Cloud\Memorystore\V1\CreateInstanceRequest;
3030
use Google\Cloud\Memorystore\V1\Instance;
31-
use Google\Cloud\Memorystore\V1\PscAutoConnection;
3231
use Google\Rpc\Status;
3332

3433
/**
3534
* Creates a new Instance in a given project and location.
3635
*
37-
* @param string $formattedParent The parent resource where this instance will be created.
38-
* Format: projects/{project}/locations/{location}
39-
* Please see {@see MemorystoreClient::locationName()} for help formatting this field.
40-
* @param string $instanceId The ID to use for the instance, which will become the final
41-
* component of the instance's resource name.
36+
* @param string $formattedParent The parent resource where this instance will be created.
37+
* Format: projects/{project}/locations/{location}
38+
* Please see {@see MemorystoreClient::locationName()} for help formatting this field.
39+
* @param string $instanceId The ID to use for the instance, which will become the final
40+
* component of the instance's resource name.
4241
*
43-
* This value is subject to the following restrictions:
42+
* This value is subject to the following restrictions:
4443
*
45-
* * Must be 4-63 characters in length
46-
* * Must begin with a letter or digit
47-
* * Must contain only lowercase letters, digits, and hyphens
48-
* * Must not end with a hyphen
49-
* * Must be unique within a location
50-
* @param string $instancePscAutoConnectionsProjectId The consumer project_id where PSC connections are established.
51-
* This should be the same project_id that the instance is being created in.
52-
* @param string $formattedInstancePscAutoConnectionsNetwork The network where the PSC endpoints are created, in the form of
53-
* projects/{project_id}/global/networks/{network_id}. Please see
54-
* {@see MemorystoreClient::networkName()} for help formatting this field.
44+
* * Must be 4-63 characters in length
45+
* * Must begin with a letter or digit
46+
* * Must contain only lowercase letters, digits, and hyphens
47+
* * Must not end with a hyphen
48+
* * Must be unique within a location
5549
*/
56-
function create_instance_sample(
57-
string $formattedParent,
58-
string $instanceId,
59-
string $instancePscAutoConnectionsProjectId,
60-
string $formattedInstancePscAutoConnectionsNetwork
61-
): void {
50+
function create_instance_sample(string $formattedParent, string $instanceId): void
51+
{
6252
// Create a client.
6353
$memorystoreClient = new MemorystoreClient();
6454

6555
// Prepare the request message.
66-
$pscAutoConnection = (new PscAutoConnection())
67-
->setProjectId($instancePscAutoConnectionsProjectId)
68-
->setNetwork($formattedInstancePscAutoConnectionsNetwork);
69-
$instancePscAutoConnections = [$pscAutoConnection,];
70-
$instance = (new Instance())
71-
->setPscAutoConnections($instancePscAutoConnections);
56+
$instance = new Instance();
7257
$request = (new CreateInstanceRequest())
7358
->setParent($formattedParent)
7459
->setInstanceId($instanceId)
@@ -107,17 +92,7 @@ function callSample(): void
10792
{
10893
$formattedParent = MemorystoreClient::locationName('[PROJECT]', '[LOCATION]');
10994
$instanceId = '[INSTANCE_ID]';
110-
$instancePscAutoConnectionsProjectId = '[PROJECT_ID]';
111-
$formattedInstancePscAutoConnectionsNetwork = MemorystoreClient::networkName(
112-
'[PROJECT]',
113-
'[NETWORK]'
114-
);
11595

116-
create_instance_sample(
117-
$formattedParent,
118-
$instanceId,
119-
$instancePscAutoConnectionsProjectId,
120-
$formattedInstancePscAutoConnectionsNetwork
121-
);
96+
create_instance_sample($formattedParent, $instanceId);
12297
}
12398
// [END memorystore_v1_generated_Memorystore_CreateInstance_sync]
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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 memorystore_v1_generated_Memorystore_DeleteBackup_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\Memorystore\V1\Client\MemorystoreClient;
29+
use Google\Cloud\Memorystore\V1\DeleteBackupRequest;
30+
use Google\Rpc\Status;
31+
32+
/**
33+
* Deletes a specific backup.
34+
*
35+
* @param string $formattedName Instance backup resource name using the form:
36+
* `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}`
37+
* Please see {@see MemorystoreClient::backupName()} for help formatting this field.
38+
*/
39+
function delete_backup_sample(string $formattedName): void
40+
{
41+
// Create a client.
42+
$memorystoreClient = new MemorystoreClient();
43+
44+
// Prepare the request message.
45+
$request = (new DeleteBackupRequest())
46+
->setName($formattedName);
47+
48+
// Call the API and handle any network failures.
49+
try {
50+
/** @var OperationResponse $response */
51+
$response = $memorystoreClient->deleteBackup($request);
52+
$response->pollUntilComplete();
53+
54+
if ($response->operationSucceeded()) {
55+
printf('Operation completed successfully.' . PHP_EOL);
56+
} else {
57+
/** @var Status $error */
58+
$error = $response->getError();
59+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
60+
}
61+
} catch (ApiException $ex) {
62+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
63+
}
64+
}
65+
66+
/**
67+
* Helper to execute the sample.
68+
*
69+
* This sample has been automatically generated and should be regarded as a code
70+
* template only. It will require modifications to work:
71+
* - It may require correct/in-range values for request initialization.
72+
* - It may require specifying regional endpoints when creating the service client,
73+
* please see the apiEndpoint client configuration option for more details.
74+
*/
75+
function callSample(): void
76+
{
77+
$formattedName = MemorystoreClient::backupName(
78+
'[PROJECT]',
79+
'[LOCATION]',
80+
'[BACKUP_COLLECTION]',
81+
'[BACKUP]'
82+
);
83+
84+
delete_backup_sample($formattedName);
85+
}
86+
// [END memorystore_v1_generated_Memorystore_DeleteBackup_sync]
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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 memorystore_v1_generated_Memorystore_ExportBackup_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\Memorystore\V1\Backup;
29+
use Google\Cloud\Memorystore\V1\Client\MemorystoreClient;
30+
use Google\Cloud\Memorystore\V1\ExportBackupRequest;
31+
use Google\Rpc\Status;
32+
33+
/**
34+
* Exports a specific backup to a customer target Cloud Storage URI.
35+
*
36+
* @param string $formattedName Instance backup resource name using the form:
37+
* `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}`
38+
* Please see {@see MemorystoreClient::backupName()} for help formatting this field.
39+
*/
40+
function export_backup_sample(string $formattedName): void
41+
{
42+
// Create a client.
43+
$memorystoreClient = new MemorystoreClient();
44+
45+
// Prepare the request message.
46+
$request = (new ExportBackupRequest())
47+
->setName($formattedName);
48+
49+
// Call the API and handle any network failures.
50+
try {
51+
/** @var OperationResponse $response */
52+
$response = $memorystoreClient->exportBackup($request);
53+
$response->pollUntilComplete();
54+
55+
if ($response->operationSucceeded()) {
56+
/** @var Backup $result */
57+
$result = $response->getResult();
58+
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
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 = MemorystoreClient::backupName(
81+
'[PROJECT]',
82+
'[LOCATION]',
83+
'[BACKUP_COLLECTION]',
84+
'[BACKUP]'
85+
);
86+
87+
export_backup_sample($formattedName);
88+
}
89+
// [END memorystore_v1_generated_Memorystore_ExportBackup_sync]

0 commit comments

Comments
 (0)