-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [Dataproc] added node groups API protos (#5698)
* feat: added node groups API protos PiperOrigin-RevId: 494840237 Source-Link: googleapis/googleapis@28449ec Source-Link: googleapis/googleapis-gen@786b188 Copy-Tag: eyJwIjoiRGF0YXByb2MvLk93bEJvdC55YW1sIiwiaCI6Ijc4NmIxODg5YzA3YzRlYWQxNjA5M2QzNzVjNTk0NTVhMDU3NmVlMjUifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
- Loading branch information
1 parent
3b2e1b5
commit 4afaf33
Showing
52 changed files
with
3,545 additions
and
239 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
Dataproc/samples/V1/NodeGroupControllerClient/create_node_group.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 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 dataproc_v1_generated_NodeGroupController_CreateNodeGroup_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Dataproc\V1\NodeGroup; | ||
use Google\Cloud\Dataproc\V1\NodeGroupControllerClient; | ||
use Google\Cloud\Dataproc\V1\NodeGroup\Role; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Creates a node group in a cluster. The returned | ||
* [Operation.metadata][google.longrunning.Operation.metadata] is | ||
* [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata). | ||
* | ||
* @param string $formattedParent The parent resource where this node group will be created. | ||
* Format: `projects/{project}/regions/{region}/clusters/{cluster}` | ||
* Please see {@see NodeGroupControllerClient::clusterRegionName()} for help formatting this field. | ||
* @param int $nodeGroupRolesElement Node group roles. | ||
*/ | ||
function create_node_group_sample(string $formattedParent, int $nodeGroupRolesElement): void | ||
{ | ||
// Create a client. | ||
$nodeGroupControllerClient = new NodeGroupControllerClient(); | ||
|
||
// Prepare any non-scalar elements to be passed along with the request. | ||
$nodeGroupRoles = [$nodeGroupRolesElement,]; | ||
$nodeGroup = (new NodeGroup()) | ||
->setRoles($nodeGroupRoles); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $nodeGroupControllerClient->createNodeGroup($formattedParent, $nodeGroup); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var NodeGroup $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 = NodeGroupControllerClient::clusterRegionName( | ||
'[PROJECT]', | ||
'[REGION]', | ||
'[CLUSTER]' | ||
); | ||
$nodeGroupRolesElement = Role::ROLE_UNSPECIFIED; | ||
|
||
create_node_group_sample($formattedParent, $nodeGroupRolesElement); | ||
} | ||
// [END dataproc_v1_generated_NodeGroupController_CreateNodeGroup_sync] |
74 changes: 74 additions & 0 deletions
74
Dataproc/samples/V1/NodeGroupControllerClient/get_node_group.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 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 dataproc_v1_generated_NodeGroupController_GetNodeGroup_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\Cloud\Dataproc\V1\NodeGroup; | ||
use Google\Cloud\Dataproc\V1\NodeGroupControllerClient; | ||
|
||
/** | ||
* Gets the resource representation for a node group in a | ||
* cluster. | ||
* | ||
* @param string $formattedName The name of the node group to retrieve. | ||
* Format: | ||
* `projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{nodeGroup}` | ||
* Please see {@see NodeGroupControllerClient::nodeGroupName()} for help formatting this field. | ||
*/ | ||
function get_node_group_sample(string $formattedName): void | ||
{ | ||
// Create a client. | ||
$nodeGroupControllerClient = new NodeGroupControllerClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var NodeGroup $response */ | ||
$response = $nodeGroupControllerClient->getNodeGroup($formattedName); | ||
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 = NodeGroupControllerClient::nodeGroupName( | ||
'[PROJECT]', | ||
'[REGION]', | ||
'[CLUSTER]', | ||
'[NODE_GROUP]' | ||
); | ||
|
||
get_node_group_sample($formattedName); | ||
} | ||
// [END dataproc_v1_generated_NodeGroupController_GetNodeGroup_sync] |
85 changes: 85 additions & 0 deletions
85
Dataproc/samples/V1/NodeGroupControllerClient/resize_node_group.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/* | ||
* Copyright 2022 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 dataproc_v1_generated_NodeGroupController_ResizeNodeGroup_sync] | ||
use Google\ApiCore\ApiException; | ||
use Google\ApiCore\OperationResponse; | ||
use Google\Cloud\Dataproc\V1\NodeGroup; | ||
use Google\Cloud\Dataproc\V1\NodeGroupControllerClient; | ||
use Google\Rpc\Status; | ||
|
||
/** | ||
* Resizes a node group in a cluster. The returned | ||
* [Operation.metadata][google.longrunning.Operation.metadata] is | ||
* [NodeGroupOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#nodegroupoperationmetadata). | ||
* | ||
* @param string $name The name of the node group to resize. | ||
* Format: | ||
* `projects/{project}/regions/{region}/clusters/{cluster}/nodeGroups/{nodeGroup}` | ||
* @param int $size The number of running instances for the node group to maintain. | ||
* The group adds or removes instances to maintain the number of instances | ||
* specified by this parameter. | ||
*/ | ||
function resize_node_group_sample(string $name, int $size): void | ||
{ | ||
// Create a client. | ||
$nodeGroupControllerClient = new NodeGroupControllerClient(); | ||
|
||
// Call the API and handle any network failures. | ||
try { | ||
/** @var OperationResponse $response */ | ||
$response = $nodeGroupControllerClient->resizeNodeGroup($name, $size); | ||
$response->pollUntilComplete(); | ||
|
||
if ($response->operationSucceeded()) { | ||
/** @var NodeGroup $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 | ||
{ | ||
$name = '[NAME]'; | ||
$size = 0; | ||
|
||
resize_node_group_sample($name, $size); | ||
} | ||
// [END dataproc_v1_generated_NodeGroupController_ResizeNodeGroup_sync] |
Oops, something went wrong.