Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Nov 18, 2024
1 parent a5c133f commit c2b786c
Show file tree
Hide file tree
Showing 1,752 changed files with 277 additions and 353,779 deletions.
Binary file modified AiPlatform/metadata/V1/Endpoint.php
Binary file not shown.
14 changes: 10 additions & 4 deletions AiPlatform/metadata/V1/EndpointService.php

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

31 changes: 31 additions & 0 deletions AiPlatform/src/V1/Client/EndpointServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use Google\Cloud\AIPlatform\V1\ListEndpointsRequest;
use Google\Cloud\AIPlatform\V1\MutateDeployedModelRequest;
use Google\Cloud\AIPlatform\V1\UndeployModelRequest;
use Google\Cloud\AIPlatform\V1\UpdateEndpointLongRunningRequest;
use Google\Cloud\AIPlatform\V1\UpdateEndpointRequest;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;
Expand Down Expand Up @@ -74,6 +75,7 @@
* @method PromiseInterface<OperationResponse> mutateDeployedModelAsync(MutateDeployedModelRequest $request, array $optionalArgs = [])
* @method PromiseInterface<OperationResponse> undeployModelAsync(UndeployModelRequest $request, array $optionalArgs = [])
* @method PromiseInterface<Endpoint> updateEndpointAsync(UpdateEndpointRequest $request, array $optionalArgs = [])
* @method PromiseInterface<OperationResponse> updateEndpointLongRunningAsync(UpdateEndpointLongRunningRequest $request, array $optionalArgs = [])
* @method PromiseInterface<Location> getLocationAsync(GetLocationRequest $request, array $optionalArgs = [])
* @method PromiseInterface<PagedListResponse> listLocationsAsync(ListLocationsRequest $request, array $optionalArgs = [])
* @method PromiseInterface<Policy> getIamPolicyAsync(GetIamPolicyRequest $request, array $optionalArgs = [])
Expand Down Expand Up @@ -673,6 +675,35 @@ public function updateEndpoint(UpdateEndpointRequest $request, array $callOption
return $this->startApiCall('UpdateEndpoint', $request, $callOptions)->wait();
}

/**
* Updates an Endpoint with a long running operation.
*
* The async variant is
* {@see EndpointServiceClient::updateEndpointLongRunningAsync()} .
*
* @example samples/V1/EndpointServiceClient/update_endpoint_long_running.php
*
* @param UpdateEndpointLongRunningRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return OperationResponse
*
* @throws ApiException Thrown if the API call fails.
*/
public function updateEndpointLongRunning(
UpdateEndpointLongRunningRequest $request,
array $callOptions = []
): OperationResponse {
return $this->startApiCall('UpdateEndpointLongRunning', $request, $callOptions)->wait();
}

/**
* Gets information about a location.
*
Expand Down
44 changes: 44 additions & 0 deletions AiPlatform/src/V1/Endpoint.php

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

5 changes: 5 additions & 0 deletions AiPlatform/src/V1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@
"updateEndpoint"
]
},
"UpdateEndpointLongRunning": {
"methods": [
"updateEndpointLongRunning"
]
},
"GetLocation": {
"methods": [
"getLocation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"retry_codes_name": "no_retry_codes",
"retry_params_name": "no_retry_params"
},
"UpdateEndpointLongRunning": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_codes",
"retry_params_name": "no_retry_params"
},
"GetLocation": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_codes",
Expand Down
20 changes: 20 additions & 0 deletions AiPlatform/src/V1/resources/endpoint_service_descriptor_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@
],
],
],
'UpdateEndpointLongRunning' => [
'longRunning' => [
'operationReturnType' => '\Google\Cloud\AIPlatform\V1\Endpoint',
'metadataReturnType' => '\Google\Cloud\AIPlatform\V1\UpdateEndpointOperationMetadata',
'initialPollDelayMillis' => '500',
'pollDelayMultiplier' => '1.5',
'maxPollDelayMillis' => '5000',
'totalPollTimeoutMillis' => '300000',
],
'callType' => \Google\ApiCore\Call::LONGRUNNING_CALL,
'headerParams' => [
[
'keyName' => 'endpoint.name',
'fieldAccessors' => [
'getEndpoint',
'getName',
],
],
],
],
'GetEndpoint' => [
'callType' => \Google\ApiCore\Call::UNARY_CALL,
'responseType' => 'Google\Cloud\AIPlatform\V1\Endpoint',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@
'update_mask',
],
],
'UpdateEndpointLongRunning' => [
'method' => 'post',
'uriTemplate' => '/v1/{endpoint.name=projects/*/locations/*/endpoints/*}:update',
'body' => '*',
'placeholders' => [
'endpoint.name' => [
'getters' => [
'getEndpoint',
'getName',
],
],
],
],
],
'google.cloud.location.Locations' => [
'GetLocation' => [
Expand Down
149 changes: 149 additions & 0 deletions AiPlatform/tests/Unit/V1/Client/EndpointServiceClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Google\Cloud\AIPlatform\V1\MutateDeployedModelResponse;
use Google\Cloud\AIPlatform\V1\UndeployModelRequest;
use Google\Cloud\AIPlatform\V1\UndeployModelResponse;
use Google\Cloud\AIPlatform\V1\UpdateEndpointLongRunningRequest;
use Google\Cloud\AIPlatform\V1\UpdateEndpointRequest;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;
Expand Down Expand Up @@ -1008,6 +1009,154 @@ public function updateEndpointExceptionTest()
$this->assertTrue($transport->isExhausted());
}

/** @test */
public function updateEndpointLongRunningTest()
{
$operationsTransport = $this->createTransport();
$operationsClient = new OperationsClient([
'apiEndpoint' => '',
'transport' => $operationsTransport,
'credentials' => $this->createCredentials(),
]);
$transport = $this->createTransport();
$gapicClient = $this->createClient([
'transport' => $transport,
'operationsClient' => $operationsClient,
]);
$this->assertTrue($transport->isExhausted());
$this->assertTrue($operationsTransport->isExhausted());
// Mock response
$incompleteOperation = new Operation();
$incompleteOperation->setName('operations/updateEndpointLongRunningTest');
$incompleteOperation->setDone(false);
$transport->addResponse($incompleteOperation);
$name = 'name3373707';
$displayName = 'displayName1615086568';
$description = 'description-1724546052';
$etag = 'etag3123477';
$network = 'network1843485230';
$enablePrivateServiceConnect = true;
$modelDeploymentMonitoringJob = 'modelDeploymentMonitoringJob1797127786';
$dedicatedEndpointEnabled = false;
$dedicatedEndpointDns = 'dedicatedEndpointDns598984655';
$satisfiesPzs = false;
$satisfiesPzi = false;
$expectedResponse = new Endpoint();
$expectedResponse->setName($name);
$expectedResponse->setDisplayName($displayName);
$expectedResponse->setDescription($description);
$expectedResponse->setEtag($etag);
$expectedResponse->setNetwork($network);
$expectedResponse->setEnablePrivateServiceConnect($enablePrivateServiceConnect);
$expectedResponse->setModelDeploymentMonitoringJob($modelDeploymentMonitoringJob);
$expectedResponse->setDedicatedEndpointEnabled($dedicatedEndpointEnabled);
$expectedResponse->setDedicatedEndpointDns($dedicatedEndpointDns);
$expectedResponse->setSatisfiesPzs($satisfiesPzs);
$expectedResponse->setSatisfiesPzi($satisfiesPzi);
$anyResponse = new Any();
$anyResponse->setValue($expectedResponse->serializeToString());
$completeOperation = new Operation();
$completeOperation->setName('operations/updateEndpointLongRunningTest');
$completeOperation->setDone(true);
$completeOperation->setResponse($anyResponse);
$operationsTransport->addResponse($completeOperation);
// Mock request
$endpoint = new Endpoint();
$endpointDisplayName = 'endpointDisplayName697270680';
$endpoint->setDisplayName($endpointDisplayName);
$request = (new UpdateEndpointLongRunningRequest())->setEndpoint($endpoint);
$response = $gapicClient->updateEndpointLongRunning($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
$apiRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($apiRequests));
$operationsRequestsEmpty = $operationsTransport->popReceivedCalls();
$this->assertSame(0, count($operationsRequestsEmpty));
$actualApiFuncCall = $apiRequests[0]->getFuncCall();
$actualApiRequestObject = $apiRequests[0]->getRequestObject();
$this->assertSame('/google.cloud.aiplatform.v1.EndpointService/UpdateEndpointLongRunning', $actualApiFuncCall);
$actualValue = $actualApiRequestObject->getEndpoint();
$this->assertProtobufEquals($endpoint, $actualValue);
$expectedOperationsRequestObject = new GetOperationRequest();
$expectedOperationsRequestObject->setName('operations/updateEndpointLongRunningTest');
$response->pollUntilComplete([
'initialPollDelayMillis' => 1,
]);
$this->assertTrue($response->isDone());
$this->assertEquals($expectedResponse, $response->getResult());
$apiRequestsEmpty = $transport->popReceivedCalls();
$this->assertSame(0, count($apiRequestsEmpty));
$operationsRequests = $operationsTransport->popReceivedCalls();
$this->assertSame(1, count($operationsRequests));
$actualOperationsFuncCall = $operationsRequests[0]->getFuncCall();
$actualOperationsRequestObject = $operationsRequests[0]->getRequestObject();
$this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall);
$this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject);
$this->assertTrue($transport->isExhausted());
$this->assertTrue($operationsTransport->isExhausted());
}

/** @test */
public function updateEndpointLongRunningExceptionTest()
{
$operationsTransport = $this->createTransport();
$operationsClient = new OperationsClient([
'apiEndpoint' => '',
'transport' => $operationsTransport,
'credentials' => $this->createCredentials(),
]);
$transport = $this->createTransport();
$gapicClient = $this->createClient([
'transport' => $transport,
'operationsClient' => $operationsClient,
]);
$this->assertTrue($transport->isExhausted());
$this->assertTrue($operationsTransport->isExhausted());
// Mock response
$incompleteOperation = new Operation();
$incompleteOperation->setName('operations/updateEndpointLongRunningTest');
$incompleteOperation->setDone(false);
$transport->addResponse($incompleteOperation);
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
$expectedExceptionMessage = json_encode(
[
'message' => 'internal error',
'code' => Code::DATA_LOSS,
'status' => 'DATA_LOSS',
'details' => [],
],
JSON_PRETTY_PRINT
);
$operationsTransport->addResponse(null, $status);
// Mock request
$endpoint = new Endpoint();
$endpointDisplayName = 'endpointDisplayName697270680';
$endpoint->setDisplayName($endpointDisplayName);
$request = (new UpdateEndpointLongRunningRequest())->setEndpoint($endpoint);
$response = $gapicClient->updateEndpointLongRunning($request);
$this->assertFalse($response->isDone());
$this->assertNull($response->getResult());
$expectedOperationsRequestObject = new GetOperationRequest();
$expectedOperationsRequestObject->setName('operations/updateEndpointLongRunningTest');
try {
$response->pollUntilComplete([
'initialPollDelayMillis' => 1,
]);
// If the pollUntilComplete() method call did not throw, fail the test
$this->fail('Expected an ApiException, but no exception was thrown.');
} catch (ApiException $ex) {
$this->assertEquals($status->code, $ex->getCode());
$this->assertEquals($expectedExceptionMessage, $ex->getMessage());
}
// Call popReceivedCalls to ensure the stubs are exhausted
$transport->popReceivedCalls();
$operationsTransport->popReceivedCalls();
$this->assertTrue($transport->isExhausted());
$this->assertTrue($operationsTransport->isExhausted());
}

/** @test */
public function getLocationTest()
{
Expand Down
Binary file not shown.
Loading

0 comments on commit c2b786c

Please sign in to comment.