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: [Dataform] Support for ReleaseConfigs #6737

Merged
merged 5 commits into from
Oct 31, 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 Dataform/metadata/V1Beta1/Dataform.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?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 dataform_v1beta1_generated_Dataform_CommitRepositoryChanges_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CommitAuthor;
use Google\Cloud\Dataform\V1beta1\CommitMetadata;
use Google\Cloud\Dataform\V1beta1\CommitRepositoryChangesRequest;

/**
* Applies a Git commit to a Repository. The Repository must not have a value
* for `git_remote_settings.url`.
*
* @param string $formattedName The repository's name. Please see
* {@see DataformClient::repositoryName()} for help formatting this field.
* @param string $commitMetadataAuthorName The commit author's name.
* @param string $commitMetadataAuthorEmailAddress The commit author's email address.
*/
function commit_repository_changes_sample(
string $formattedName,
string $commitMetadataAuthorName,
string $commitMetadataAuthorEmailAddress
): void {
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$commitMetadataAuthor = (new CommitAuthor())
->setName($commitMetadataAuthorName)
->setEmailAddress($commitMetadataAuthorEmailAddress);
$commitMetadata = (new CommitMetadata())
->setAuthor($commitMetadataAuthor);
$request = (new CommitRepositoryChangesRequest())
->setName($formattedName)
->setCommitMetadata($commitMetadata);

// Call the API and handle any network failures.
try {
$dataformClient->commitRepositoryChanges($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = DataformClient::repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]');
$commitMetadataAuthorName = '[NAME]';
$commitMetadataAuthorEmailAddress = '[EMAIL_ADDRESS]';

commit_repository_changes_sample(
$formattedName,
$commitMetadataAuthorName,
$commitMetadataAuthorEmailAddress
);
}
// [END dataform_v1beta1_generated_Dataform_CommitRepositoryChanges_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 dataform_v1beta1_generated_Dataform_ComputeRepositoryAccessTokenStatus_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\ComputeRepositoryAccessTokenStatusRequest;
use Google\Cloud\Dataform\V1beta1\ComputeRepositoryAccessTokenStatusResponse;

/**
* Computes a Repository's Git access token status.
*
* @param string $formattedName The repository's name. Please see
* {@see DataformClient::repositoryName()} for help formatting this field.
*/
function compute_repository_access_token_status_sample(string $formattedName): void
{
// Create a client.
$dataformClient = new DataformClient();

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

// Call the API and handle any network failures.
try {
/** @var ComputeRepositoryAccessTokenStatusResponse $response */
$response = $dataformClient->computeRepositoryAccessTokenStatus($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 = DataformClient::repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]');

compute_repository_access_token_status_sample($formattedName);
}
// [END dataform_v1beta1_generated_Dataform_ComputeRepositoryAccessTokenStatus_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
/**
* Creates a new CompilationResult in a given project and location.
*
* @param string $formattedParent The repository in which to create the compilation result. Must be in the
* format `projects/&#42;/locations/&#42;/repositories/*`. Please see
* @param string $formattedParent The repository in which to create the compilation result. Must be
* in the format `projects/&#42;/locations/&#42;/repositories/*`. Please see
* {@see DataformClient::repositoryName()} for help formatting this field.
*/
function create_compilation_result_sample(string $formattedParent): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?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 dataform_v1beta1_generated_Dataform_CreateReleaseConfig_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CreateReleaseConfigRequest;
use Google\Cloud\Dataform\V1beta1\ReleaseConfig;

/**
* Creates a new ReleaseConfig in a given Repository.
*
* @param string $formattedParent The repository in which to create the release config. Must be in
* the format `projects/&#42;/locations/&#42;/repositories/*`. Please see
* {@see DataformClient::repositoryName()} for help formatting this field.
* @param string $releaseConfigGitCommitish Git commit/tag/branch name at which the repository should be
* compiled. Must exist in the remote repository. Examples:
* - a commit SHA: `12ade345`
* - a tag: `tag1`
* - a branch name: `branch1`
* @param string $releaseConfigId The ID to use for the release config, which will become the final
* component of the release config's resource name.
*/
function create_release_config_sample(
string $formattedParent,
string $releaseConfigGitCommitish,
string $releaseConfigId
): void {
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$releaseConfig = (new ReleaseConfig())
->setGitCommitish($releaseConfigGitCommitish);
$request = (new CreateReleaseConfigRequest())
->setParent($formattedParent)
->setReleaseConfig($releaseConfig)
->setReleaseConfigId($releaseConfigId);

// Call the API and handle any network failures.
try {
/** @var ReleaseConfig $response */
$response = $dataformClient->createReleaseConfig($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
{
$formattedParent = DataformClient::repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]');
$releaseConfigGitCommitish = '[GIT_COMMITISH]';
$releaseConfigId = '[RELEASE_CONFIG_ID]';

create_release_config_sample($formattedParent, $releaseConfigGitCommitish, $releaseConfigId);
}
// [END dataform_v1beta1_generated_Dataform_CreateReleaseConfig_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
/**
* Creates a new Repository in a given project and location.
*
* @param string $formattedParent The location in which to create the repository. Must be in the format
* `projects/&#42;/locations/*`. Please see
* @param string $formattedParent The location in which to create the repository. Must be in the
* format `projects/&#42;/locations/*`. Please see
* {@see DataformClient::locationName()} for help formatting this field.
* @param string $repositoryId The ID to use for the repository, which will become the final component of
* the repository's resource name.
* @param string $repositoryId The ID to use for the repository, which will become the final
* component of the repository's resource name.
*/
function create_repository_sample(string $formattedParent, string $repositoryId): void
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?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 dataform_v1beta1_generated_Dataform_CreateWorkflowConfig_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Dataform\V1beta1\Client\DataformClient;
use Google\Cloud\Dataform\V1beta1\CreateWorkflowConfigRequest;
use Google\Cloud\Dataform\V1beta1\WorkflowConfig;

/**
* Creates a new WorkflowConfig in a given Repository.
*
* @param string $formattedParent The repository in which to create the workflow config. Must be in
* the format `projects/&#42;/locations/&#42;/repositories/*`. Please see
* {@see DataformClient::repositoryName()} for help formatting this field.
* @param string $formattedWorkflowConfigReleaseConfig The name of the release config whose release_compilation_result
* should be executed. Must be in the format
* `projects/&#42;/locations/&#42;/repositories/&#42;/releaseConfigs/*`. Please see
* {@see DataformClient::releaseConfigName()} for help formatting this field.
* @param string $workflowConfigId The ID to use for the workflow config, which will become the
* final component of the workflow config's resource name.
*/
function create_workflow_config_sample(
string $formattedParent,
string $formattedWorkflowConfigReleaseConfig,
string $workflowConfigId
): void {
// Create a client.
$dataformClient = new DataformClient();

// Prepare the request message.
$workflowConfig = (new WorkflowConfig())
->setReleaseConfig($formattedWorkflowConfigReleaseConfig);
$request = (new CreateWorkflowConfigRequest())
->setParent($formattedParent)
->setWorkflowConfig($workflowConfig)
->setWorkflowConfigId($workflowConfigId);

// Call the API and handle any network failures.
try {
/** @var WorkflowConfig $response */
$response = $dataformClient->createWorkflowConfig($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
{
$formattedParent = DataformClient::repositoryName('[PROJECT]', '[LOCATION]', '[REPOSITORY]');
$formattedWorkflowConfigReleaseConfig = DataformClient::releaseConfigName(
'[PROJECT]',
'[LOCATION]',
'[REPOSITORY]',
'[RELEASE_CONFIG]'
);
$workflowConfigId = '[WORKFLOW_CONFIG_ID]';

create_workflow_config_sample(
$formattedParent,
$formattedWorkflowConfigReleaseConfig,
$workflowConfigId
);
}
// [END dataform_v1beta1_generated_Dataform_CreateWorkflowConfig_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
/**
* Creates a new WorkflowInvocation in a given Repository.
*
* @param string $formattedParent The repository in which to create the workflow invocation. Must be in the
* format `projects/&#42;/locations/&#42;/repositories/*`. Please see
* @param string $formattedParent The repository in which to create the workflow invocation. Must
* be in the format `projects/&#42;/locations/&#42;/repositories/*`. Please see
* {@see DataformClient::repositoryName()} for help formatting this field.
*/
function create_workflow_invocation_sample(string $formattedParent): void
Expand Down
Loading