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: [AiPlatform] Allow v1 api calls for some dataset_service, llm_utility_service, and prediction_service apis without project and location #7584

Merged
merged 6 commits into from
Aug 9, 2024
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 AiPlatform/metadata/V1/CustomJob.php
Binary file not shown.
Binary file modified AiPlatform/metadata/V1/DatasetService.php
Binary file not shown.
Binary file added AiPlatform/metadata/V1/EvaluationService.php
Binary file not shown.
10 changes: 5 additions & 5 deletions AiPlatform/metadata/V1/LlmUtilityService.php

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

12 changes: 7 additions & 5 deletions AiPlatform/metadata/V1/MachineResources.php

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

Binary file modified AiPlatform/metadata/V1/PredictionService.php
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2024 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 aiplatform_v1_generated_EvaluationService_EvaluateInstances_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\EvaluationServiceClient;
use Google\Cloud\AIPlatform\V1\EvaluateInstancesRequest;
use Google\Cloud\AIPlatform\V1\EvaluateInstancesResponse;

/**
* Evaluates instances based on a given metric.
*
* @param string $formattedLocation The resource name of the Location to evaluate the instances.
* Format: `projects/{project}/locations/{location}`
* Please see {@see EvaluationServiceClient::locationName()} for help formatting this field.
*/
function evaluate_instances_sample(string $formattedLocation): void
{
// Create a client.
$evaluationServiceClient = new EvaluationServiceClient();

// Prepare the request message.
$request = (new EvaluateInstancesRequest())
->setLocation($formattedLocation);

// Call the API and handle any network failures.
try {
/** @var EvaluateInstancesResponse $response */
$response = $evaluationServiceClient->evaluateInstances($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
{
$formattedLocation = EvaluationServiceClient::locationName('[PROJECT]', '[LOCATION]');

evaluate_instances_sample($formattedLocation);
}
// [END aiplatform_v1_generated_EvaluationService_EvaluateInstances_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2024 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 aiplatform_v1_generated_EvaluationService_GetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\EvaluationServiceClient;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;

/**
* Gets the access control policy for a resource. Returns an empty policy
if the resource exists and does not have a policy set.
*
* @param string $resource REQUIRED: The resource for which the policy is being requested.
* See the operation documentation for the appropriate value for this field.
*/
function get_iam_policy_sample(string $resource): void
{
// Create a client.
$evaluationServiceClient = new EvaluationServiceClient();

// Prepare the request message.
$request = (new GetIamPolicyRequest())
->setResource($resource);

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $evaluationServiceClient->getIamPolicy($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
{
$resource = '[RESOURCE]';

get_iam_policy_sample($resource);
}
// [END aiplatform_v1_generated_EvaluationService_GetIamPolicy_sync]
57 changes: 57 additions & 0 deletions AiPlatform/samples/V1/EvaluationServiceClient/get_location.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/*
* Copyright 2024 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 aiplatform_v1_generated_EvaluationService_GetLocation_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\EvaluationServiceClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;

/**
* Gets information about a location.
*
* 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 get_location_sample(): void
{
// Create a client.
$evaluationServiceClient = new EvaluationServiceClient();

// Prepare the request message.
$request = new GetLocationRequest();

// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $evaluationServiceClient->getLocation($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END aiplatform_v1_generated_EvaluationService_GetLocation_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/*
* Copyright 2024 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 aiplatform_v1_generated_EvaluationService_ListLocations_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AIPlatform\V1\Client\EvaluationServiceClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
* Lists information about the supported locations for this service.
*
* 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 list_locations_sample(): void
{
// Create a client.
$evaluationServiceClient = new EvaluationServiceClient();

// Prepare the request message.
$request = new ListLocationsRequest();

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $evaluationServiceClient->listLocations($request);

/** @var Location $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END aiplatform_v1_generated_EvaluationService_ListLocations_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2024 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 aiplatform_v1_generated_EvaluationService_SetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\EvaluationServiceClient;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;

/**
* Sets the access control policy on the specified resource. Replaces
any existing policy.

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
errors.
*
* @param string $resource REQUIRED: The resource for which the policy is being specified.
* See the operation documentation for the appropriate value for this field.
*/
function set_iam_policy_sample(string $resource): void
{
// Create a client.
$evaluationServiceClient = new EvaluationServiceClient();

// Prepare the request message.
$policy = new Policy();
$request = (new SetIamPolicyRequest())
->setResource($resource)
->setPolicy($policy);

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $evaluationServiceClient->setIamPolicy($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
{
$resource = '[RESOURCE]';

set_iam_policy_sample($resource);
}
// [END aiplatform_v1_generated_EvaluationService_SetIamPolicy_sync]
Loading
Loading