Skip to content

Commit

Permalink
Add the beta 1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
Hectorhammett committed Dec 12, 2024
1 parent da58088 commit 51c2982
Show file tree
Hide file tree
Showing 51 changed files with 7,833 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Memorystore/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
deep-copy-regex:
- source: /google/cloud/memorystore/(v1)/.*-php/(.*)
- source: /google/cloud/memorystore/(v1|v1beta)/.*-php/(.*)
dest: /owl-bot-staging/Memorystore/$1/$2
api-name: Memorystore
Binary file added Memorystore/metadata/V1Beta/Memorystore.php
Binary file not shown.
123 changes: 123 additions & 0 deletions Memorystore/samples/V1beta/MemorystoreClient/create_instance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START memorystore_v1beta_generated_Memorystore_CreateInstance_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Memorystore\V1beta\Client\MemorystoreClient;
use Google\Cloud\Memorystore\V1beta\CreateInstanceRequest;
use Google\Cloud\Memorystore\V1beta\Instance;
use Google\Cloud\Memorystore\V1beta\PscAutoConnection;
use Google\Rpc\Status;

/**
* Creates a new Instance in a given project and location.
*
* @param string $formattedParent The parent resource where this instance will be created.
* Format: projects/{project}/locations/{location}
* Please see {@see MemorystoreClient::locationName()} for help formatting this field.
* @param string $instanceId The ID to use for the instance, which will become the final
* component of the instance's resource name.
*
* This value is subject to the following restrictions:
*
* * Must be 4-63 characters in length
* * Must begin with a letter or digit
* * Must contain only lowercase letters, digits, and hyphens
* * Must not end with a hyphen
* * Must be unique within a location
* @param string $instancePscAutoConnectionsProjectId The consumer project_id where PSC connections are established.
* This should be the same project_id that the instance is being created in.
* @param string $formattedInstancePscAutoConnectionsNetwork The network where the PSC endpoints are created, in the form of
* projects/{project_id}/global/networks/{network_id}. Please see
* {@see MemorystoreClient::networkName()} for help formatting this field.
*/
function create_instance_sample(
string $formattedParent,
string $instanceId,
string $instancePscAutoConnectionsProjectId,
string $formattedInstancePscAutoConnectionsNetwork
): void {
// Create a client.
$memorystoreClient = new MemorystoreClient();

// Prepare the request message.
$pscAutoConnection = (new PscAutoConnection())
->setProjectId($instancePscAutoConnectionsProjectId)
->setNetwork($formattedInstancePscAutoConnectionsNetwork);
$instancePscAutoConnections = [$pscAutoConnection,];
$instance = (new Instance())
->setPscAutoConnections($instancePscAutoConnections);
$request = (new CreateInstanceRequest())
->setParent($formattedParent)
->setInstanceId($instanceId)
->setInstance($instance);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $memorystoreClient->createInstance($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
/** @var Instance $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = MemorystoreClient::locationName('[PROJECT]', '[LOCATION]');
$instanceId = '[INSTANCE_ID]';
$instancePscAutoConnectionsProjectId = '[PROJECT_ID]';
$formattedInstancePscAutoConnectionsNetwork = MemorystoreClient::networkName(
'[PROJECT]',
'[NETWORK]'
);

create_instance_sample(
$formattedParent,
$instanceId,
$instancePscAutoConnectionsProjectId,
$formattedInstancePscAutoConnectionsNetwork
);
}
// [END memorystore_v1beta_generated_Memorystore_CreateInstance_sync]
81 changes: 81 additions & 0 deletions Memorystore/samples/V1beta/MemorystoreClient/delete_instance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START memorystore_v1beta_generated_Memorystore_DeleteInstance_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Memorystore\V1beta\Client\MemorystoreClient;
use Google\Cloud\Memorystore\V1beta\DeleteInstanceRequest;
use Google\Rpc\Status;

/**
* Deletes a single Instance.
*
* @param string $formattedName The name of the instance to delete.
* Format: projects/{project}/locations/{location}/instances/{instance}
* Please see {@see MemorystoreClient::instanceName()} for help formatting this field.
*/
function delete_instance_sample(string $formattedName): void
{
// Create a client.
$memorystoreClient = new MemorystoreClient();

// Prepare the request message.
$request = (new DeleteInstanceRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $memorystoreClient->deleteInstance($request);
$response->pollUntilComplete();

if ($response->operationSucceeded()) {
printf('Operation completed successfully.' . PHP_EOL);
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = MemorystoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

delete_instance_sample($formattedName);
}
// [END memorystore_v1beta_generated_Memorystore_DeleteInstance_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START memorystore_v1beta_generated_Memorystore_GetCertificateAuthority_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Memorystore\V1beta\CertificateAuthority;
use Google\Cloud\Memorystore\V1beta\Client\MemorystoreClient;
use Google\Cloud\Memorystore\V1beta\GetCertificateAuthorityRequest;

/**
* Gets details about the certificate authority for an Instance.
*
* @param string $formattedName The name of the certificate authority.
* Format:
* projects/{project}/locations/{location}/instances/{instance}/certificateAuthority
* Please see {@see MemorystoreClient::instanceName()} for help formatting this field.
*/
function get_certificate_authority_sample(string $formattedName): void
{
// Create a client.
$memorystoreClient = new MemorystoreClient();

// Prepare the request message.
$request = (new GetCertificateAuthorityRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var CertificateAuthority $response */
$response = $memorystoreClient->getCertificateAuthority($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = MemorystoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

get_certificate_authority_sample($formattedName);
}
// [END memorystore_v1beta_generated_Memorystore_GetCertificateAuthority_sync]
72 changes: 72 additions & 0 deletions Memorystore/samples/V1beta/MemorystoreClient/get_instance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START memorystore_v1beta_generated_Memorystore_GetInstance_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Memorystore\V1beta\Client\MemorystoreClient;
use Google\Cloud\Memorystore\V1beta\GetInstanceRequest;
use Google\Cloud\Memorystore\V1beta\Instance;

/**
* Gets details of a single Instance.
*
* @param string $formattedName The name of the instance to retrieve.
* Format: projects/{project}/locations/{location}/instances/{instance}
* Please see {@see MemorystoreClient::instanceName()} for help formatting this field.
*/
function get_instance_sample(string $formattedName): void
{
// Create a client.
$memorystoreClient = new MemorystoreClient();

// Prepare the request message.
$request = (new GetInstanceRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var Instance $response */
$response = $memorystoreClient->getInstance($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = MemorystoreClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

get_instance_sample($formattedName);
}
// [END memorystore_v1beta_generated_Memorystore_GetInstance_sync]
Loading

0 comments on commit 51c2982

Please sign in to comment.