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: [OrchestrationAirflow] added RPCs StopAirflowCommand, ExecuteAirflowCommand, PollAirflowCommand, DatabaseFailover, FetchDatabaseProperties #6360

Merged
merged 2 commits into from
Jun 13, 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 OrchestrationAirflow/metadata/V1/Environments.php
Binary file not shown.
Binary file modified OrchestrationAirflow/metadata/V1/Operations.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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 composer_v1_generated_Environments_DatabaseFailover_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Orchestration\Airflow\Service\V1\DatabaseFailoverResponse;
use Google\Cloud\Orchestration\Airflow\Service\V1\EnvironmentsClient;
use Google\Rpc\Status;

/**
* Triggers database failover (only for highly resilient environments).
*
* 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 database_failover_sample(): void
{
// Create a client.
$environmentsClient = new EnvironmentsClient();

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

if ($response->operationSucceeded()) {
/** @var DatabaseFailoverResponse $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());
}
}
// [END composer_v1_generated_Environments_DatabaseFailover_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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 composer_v1_generated_Environments_ExecuteAirflowCommand_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Orchestration\Airflow\Service\V1\EnvironmentsClient;
use Google\Cloud\Orchestration\Airflow\Service\V1\ExecuteAirflowCommandResponse;

/**
* Executes Airflow CLI command.
*
* 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 execute_airflow_command_sample(): void
{
// Create a client.
$environmentsClient = new EnvironmentsClient();

// Call the API and handle any network failures.
try {
/** @var ExecuteAirflowCommandResponse $response */
$response = $environmentsClient->executeAirflowCommand();
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END composer_v1_generated_Environments_ExecuteAirflowCommand_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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 composer_v1_generated_Environments_FetchDatabaseProperties_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Orchestration\Airflow\Service\V1\EnvironmentsClient;
use Google\Cloud\Orchestration\Airflow\Service\V1\FetchDatabasePropertiesResponse;

/**
* Fetches database properties.
*
* @param string $formattedEnvironment The resource name of the environment, in the form:
* "projects/{projectId}/locations/{locationId}/environments/{environmentId}"
* Please see {@see EnvironmentsClient::environmentName()} for help formatting this field.
*/
function fetch_database_properties_sample(string $formattedEnvironment): void
{
// Create a client.
$environmentsClient = new EnvironmentsClient();

// Call the API and handle any network failures.
try {
/** @var FetchDatabasePropertiesResponse $response */
$response = $environmentsClient->fetchDatabaseProperties($formattedEnvironment);
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
{
$formattedEnvironment = EnvironmentsClient::environmentName(
'[PROJECT]',
'[LOCATION]',
'[ENVIRONMENT]'
);

fetch_database_properties_sample($formattedEnvironment);
}
// [END composer_v1_generated_Environments_FetchDatabaseProperties_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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 composer_v1_generated_Environments_PollAirflowCommand_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Orchestration\Airflow\Service\V1\EnvironmentsClient;
use Google\Cloud\Orchestration\Airflow\Service\V1\PollAirflowCommandResponse;

/**
* Polls Airflow CLI command execution and fetches logs.
*
* 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 poll_airflow_command_sample(): void
{
// Create a client.
$environmentsClient = new EnvironmentsClient();

// Call the API and handle any network failures.
try {
/** @var PollAirflowCommandResponse $response */
$response = $environmentsClient->pollAirflowCommand();
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END composer_v1_generated_Environments_PollAirflowCommand_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?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 composer_v1_generated_Environments_StopAirflowCommand_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Orchestration\Airflow\Service\V1\EnvironmentsClient;
use Google\Cloud\Orchestration\Airflow\Service\V1\StopAirflowCommandResponse;

/**
* Stops Airflow CLI command execution.
*
* 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 stop_airflow_command_sample(): void
{
// Create a client.
$environmentsClient = new EnvironmentsClient();

// Call the API and handle any network failures.
try {
/** @var StopAirflowCommandResponse $response */
$response = $environmentsClient->stopAirflowCommand();
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END composer_v1_generated_Environments_StopAirflowCommand_sync]
Loading