Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [VmwareEngine] Adding private connection CRUD, updating management subnets and time-limited PC features #6343

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified VmwareEngine/metadata/V1/Vmwareengine.php
Binary file not shown.
Binary file modified VmwareEngine/metadata/V1/VmwareengineResources.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?php
/*
* Copyright 2023 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 vmwareengine_v1_generated_VmwareEngine_CreatePrivateConnection_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VmwareEngine\V1\Client\VmwareEngineClient;
use Google\Cloud\VmwareEngine\V1\CreatePrivateConnectionRequest;
use Google\Cloud\VmwareEngine\V1\PrivateConnection;
use Google\Cloud\VmwareEngine\V1\PrivateConnection\Type;
use Google\Rpc\Status;

/**
* Creates a new private connection that can be used for accessing private
* Clouds.
*
* @param string $formattedParent The resource name of the location to create the new private
* connection in. Private connection is a regional resource.
* Resource names are schemeless URIs that follow the conventions in
* https://cloud.google.com/apis/design/resource_names. For example:
* `projects/my-project/locations/us-central1`
* Please see {@see VmwareEngineClient::locationName()} for help formatting this field.
* @param string $privateConnectionId The user-provided identifier of the new private connection.
* This identifier must be unique among private connection resources
* within the parent and becomes the final token in the name URI. The
* identifier must meet the following requirements:
*
* * Only contains 1-63 alphanumeric characters and hyphens
* * Begins with an alphabetical character
* * Ends with a non-hyphen character
* * Not formatted as a UUID
* * Complies with [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034)
* (section 3.5)
* @param string $formattedPrivateConnectionVmwareEngineNetwork The relative resource name of Legacy VMware Engine network.
* Specify the name in the following form:
* `projects/{project}/locations/{location}/vmwareEngineNetworks/{vmware_engine_network_id}`
* where `{project}`, `{location}` will be same as specified in private
* connection resource name and `{vmware_engine_network_id}` will be in the
* form of `{location}`-default e.g.
* projects/project/locations/us-central1/vmwareEngineNetworks/us-central1-default. Please see
* {@see VmwareEngineClient::vmwareEngineNetworkName()} for help formatting this field.
* @param int $privateConnectionType Private connection type.
* @param string $formattedPrivateConnectionServiceNetwork Service network to create private connection.
* Specify the name in the following form:
* `projects/{project}/global/networks/{network_id}`
* For type = PRIVATE_SERVICE_ACCESS, this field represents servicenetworking
* VPC, e.g. projects/project-tp/global/networks/servicenetworking.
* For type = NETAPP_CLOUD_VOLUME, this field represents NetApp service VPC,
* e.g. projects/project-tp/global/networks/netapp-tenant-vpc.
* For type = DELL_POWERSCALE, this field represent Dell service VPC, e.g.
* projects/project-tp/global/networks/dell-tenant-vpc.
* For type= THIRD_PARTY_SERVICE, this field could represent a consumer VPC or
* any other producer VPC to which the VMware Engine Network needs to be
* connected, e.g. projects/project/global/networks/vpc. Please see
* {@see VmwareEngineClient::networkName()} for help formatting this field.
*/
function create_private_connection_sample(
string $formattedParent,
string $privateConnectionId,
string $formattedPrivateConnectionVmwareEngineNetwork,
int $privateConnectionType,
string $formattedPrivateConnectionServiceNetwork
): void {
// Create a client.
$vmwareEngineClient = new VmwareEngineClient();

// Prepare the request message.
$privateConnection = (new PrivateConnection())
->setVmwareEngineNetwork($formattedPrivateConnectionVmwareEngineNetwork)
->setType($privateConnectionType)
->setServiceNetwork($formattedPrivateConnectionServiceNetwork);
$request = (new CreatePrivateConnectionRequest())
->setParent($formattedParent)
->setPrivateConnectionId($privateConnectionId)
->setPrivateConnection($privateConnection);

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

if ($response->operationSucceeded()) {
/** @var PrivateConnection $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 = VmwareEngineClient::locationName('[PROJECT]', '[LOCATION]');
$privateConnectionId = '[PRIVATE_CONNECTION_ID]';
$formattedPrivateConnectionVmwareEngineNetwork = VmwareEngineClient::vmwareEngineNetworkName(
'[PROJECT]',
'[LOCATION]',
'[VMWARE_ENGINE_NETWORK]'
);
$privateConnectionType = Type::TYPE_UNSPECIFIED;
$formattedPrivateConnectionServiceNetwork = VmwareEngineClient::networkName(
'[PROJECT]',
'[NETWORK]'
);

create_private_connection_sample(
$formattedParent,
$privateConnectionId,
$formattedPrivateConnectionVmwareEngineNetwork,
$privateConnectionType,
$formattedPrivateConnectionServiceNetwork
);
}
// [END vmwareengine_v1_generated_VmwareEngine_CreatePrivateConnection_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/*
* Copyright 2023 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 vmwareengine_v1_generated_VmwareEngine_DeletePrivateConnection_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\VmwareEngine\V1\Client\VmwareEngineClient;
use Google\Cloud\VmwareEngine\V1\DeletePrivateConnectionRequest;
use Google\Rpc\Status;

/**
* Deletes a `PrivateConnection` resource. When a private connection is
* deleted for a VMware Engine network, the connected network becomes
* inaccessible to that VMware Engine network.
*
* @param string $formattedName The resource name of the private connection to be deleted.
* Resource names are schemeless URIs that follow the conventions in
* https://cloud.google.com/apis/design/resource_names.
* For example:
* `projects/my-project/locations/us-central1/privateConnections/my-connection`
* Please see {@see VmwareEngineClient::privateConnectionName()} for help formatting this field.
*/
function delete_private_connection_sample(string $formattedName): void
{
// Create a client.
$vmwareEngineClient = new VmwareEngineClient();

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

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $vmwareEngineClient->deletePrivateConnection($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 = VmwareEngineClient::privateConnectionName(
'[PROJECT]',
'[LOCATION]',
'[PRIVATE_CONNECTION]'
);

delete_private_connection_sample($formattedName);
}
// [END vmwareengine_v1_generated_VmwareEngine_DeletePrivateConnection_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/*
* Copyright 2023 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 vmwareengine_v1_generated_VmwareEngine_GetPrivateConnection_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\VmwareEngine\V1\Client\VmwareEngineClient;
use Google\Cloud\VmwareEngine\V1\GetPrivateConnectionRequest;
use Google\Cloud\VmwareEngine\V1\PrivateConnection;

/**
* Retrieves a `PrivateConnection` resource by its resource name. The resource
* contains details of the private connection, such as connected
* network, routing mode and state.
*
* @param string $formattedName The resource name of the private connection to retrieve.
* Resource names are schemeless URIs that follow the conventions in
* https://cloud.google.com/apis/design/resource_names.
* For example:
* `projects/my-project/locations/us-central1/privateConnections/my-connection`
* Please see {@see VmwareEngineClient::privateConnectionName()} for help formatting this field.
*/
function get_private_connection_sample(string $formattedName): void
{
// Create a client.
$vmwareEngineClient = new VmwareEngineClient();

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

// Call the API and handle any network failures.
try {
/** @var PrivateConnection $response */
$response = $vmwareEngineClient->getPrivateConnection($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 = VmwareEngineClient::privateConnectionName(
'[PROJECT]',
'[LOCATION]',
'[PRIVATE_CONNECTION]'
);

get_private_connection_sample($formattedName);
}
// [END vmwareengine_v1_generated_VmwareEngine_GetPrivateConnection_sync]
Loading