Skip to content

Commit

Permalink
feat: [Dataproc] added node groups API protos (#5698)
Browse files Browse the repository at this point in the history
* 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
gcf-owl-bot[bot] authored Jan 4, 2023
1 parent 3b2e1b5 commit 4afaf33
Show file tree
Hide file tree
Showing 52 changed files with 3,545 additions and 239 deletions.
Binary file modified Dataproc/metadata/V1/Clusters.php
Binary file not shown.
Binary file modified Dataproc/metadata/V1/Jobs.php
Binary file not shown.
58 changes: 58 additions & 0 deletions Dataproc/metadata/V1/NodeGroups.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Dataproc/metadata/V1/Operations.php
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
* belongs to.
* @param string $region The Dataproc region in which to handle the request.
* @param string $clusterProjectId The Google Cloud Platform project ID that the cluster belongs to.
* @param string $clusterClusterName The cluster name. Cluster names within a project must be
* unique. Names of deleted clusters can be reused.
* @param string $clusterClusterName The cluster name, which must be unique within a project.
* The name must start with a lowercase letter, and can contain
* up to 51 lowercase letters, numbers, and hyphens. It cannot end
* with a hyphen. The name of a deleted cluster can be reused.
*/
function create_cluster_sample(
string $projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@
* Updates a cluster in a project. The returned
* [Operation.metadata][google.longrunning.Operation.metadata] will be
* [ClusterOperationMetadata](https://cloud.google.com/dataproc/docs/reference/rpc/google.cloud.dataproc.v1#clusteroperationmetadata).
* The cluster must be in a [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error
* The cluster must be in a
* [`RUNNING`][google.cloud.dataproc.v1.ClusterStatus.State] state or an error
* is returned.
*
* @param string $projectId The ID of the Google Cloud Platform project the
* cluster belongs to.
* @param string $region The Dataproc region in which to handle the request.
* @param string $clusterName The cluster name.
* @param string $clusterProjectId The Google Cloud Platform project ID that the cluster belongs to.
* @param string $clusterClusterName The cluster name. Cluster names within a project must be
* unique. Names of deleted clusters can be reused.
* @param string $clusterClusterName The cluster name, which must be unique within a project.
* The name must start with a lowercase letter, and can contain
* up to 51 lowercase letters, numbers, and hyphens. It cannot end
* with a hyphen. The name of a deleted cluster can be reused.
*/
function update_cluster_sample(
string $projectId,
Expand Down
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 Dataproc/samples/V1/NodeGroupControllerClient/get_node_group.php
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]
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]
Loading

0 comments on commit 4afaf33

Please sign in to comment.