Skip to content

Commit

Permalink
feat: add Model Garden deploy API
Browse files Browse the repository at this point in the history
docs: A comment for field `labels` in message `.google.cloud.aiplatform.v1beta1.PublisherModel` is changed

PiperOrigin-RevId: 708446642

Source-Link: googleapis/googleapis@960afb3

Source-Link: googleapis/googleapis-gen@736b3d6
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuQUlQbGF0Zm9ybS5WMUJldGExLy5Pd2xCb3QueWFtbCIsImgiOiI3MzZiM2Q2YjY1ZGJiNjkyMjQ1Y2I4NjIxODgxN2YxMzUxOTA3Y2I0In0=
  • Loading branch information
gcf-owl-bot[bot] authored and amanda-tarafa committed Dec 21, 2024
1 parent 76bc3bd commit bc4928d
Show file tree
Hide file tree
Showing 10 changed files with 2,052 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START aiplatform_v1beta1_generated_ModelGardenService_DeployPublisherModel_async]
using Google.Api.Gax.ResourceNames;
using Google.Cloud.AIPlatform.V1Beta1;
using Google.LongRunning;
using System.Threading.Tasks;

public sealed partial class GeneratedModelGardenServiceClientSnippets
{
/// <summary>Snippet for DeployPublisherModelAsync</summary>
/// <remarks>
/// This snippet 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 as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public async Task DeployPublisherModelRequestObjectAsync()
{
// Create client
ModelGardenServiceClient modelGardenServiceClient = await ModelGardenServiceClient.CreateAsync();
// Initialize request argument(s)
DeployPublisherModelRequest request = new DeployPublisherModelRequest
{
Model = "",
DestinationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
EndpointDisplayName = "",
DedicatedResources = new DedicatedResources(),
ModelDisplayName = "",
HuggingFaceAccessToken = "",
AcceptEula = false,
};
// Make the request
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> response = await modelGardenServiceClient.DeployPublisherModelAsync(request);

// Poll until the returned long-running operation is complete
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeployPublisherModelResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> retrievedResponse = await modelGardenServiceClient.PollOnceDeployPublisherModelAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
DeployPublisherModelResponse retrievedResult = retrievedResponse.Result;
}
}
}
// [END aiplatform_v1beta1_generated_ModelGardenService_DeployPublisherModel_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// 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. DO NOT EDIT!

namespace GoogleCSharpSnippets
{
// [START aiplatform_v1beta1_generated_ModelGardenService_DeployPublisherModel_sync]
using Google.Api.Gax.ResourceNames;
using Google.Cloud.AIPlatform.V1Beta1;
using Google.LongRunning;

public sealed partial class GeneratedModelGardenServiceClientSnippets
{
/// <summary>Snippet for DeployPublisherModel</summary>
/// <remarks>
/// This snippet 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 as shown in
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
/// </remarks>
public void DeployPublisherModelRequestObject()
{
// Create client
ModelGardenServiceClient modelGardenServiceClient = ModelGardenServiceClient.Create();
// Initialize request argument(s)
DeployPublisherModelRequest request = new DeployPublisherModelRequest
{
Model = "",
DestinationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
EndpointDisplayName = "",
DedicatedResources = new DedicatedResources(),
ModelDisplayName = "",
HuggingFaceAccessToken = "",
AcceptEula = false,
};
// Make the request
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> response = modelGardenServiceClient.DeployPublisherModel(request);

// Poll until the returned long-running operation is complete
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
DeployPublisherModelResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> retrievedResponse = modelGardenServiceClient.PollOnceDeployPublisherModel(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
DeployPublisherModelResponse retrievedResult = retrievedResponse.Result;
}
}
}
// [END aiplatform_v1beta1_generated_ModelGardenService_DeployPublisherModel_sync]
}
Original file line number Diff line number Diff line change
Expand Up @@ -58055,6 +58055,103 @@
}
]
},
{
"regionTag": "aiplatform_v1beta1_generated_ModelGardenService_DeployPublisherModel_sync",
"title": "DeployPublisherModelRequestObject",
"description": "Snippet for DeployPublisherModel",
"file": "ModelGardenServiceClient.DeployPublisherModelRequestObjectSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "DeployPublisherModel",
"fullName": "Google.Cloud.AIPlatform.V1Beta1.ModelGardenServiceClient.DeployPublisherModel",
"parameters": [
{
"type": "Google.Cloud.AIPlatform.V1Beta1.DeployPublisherModelRequest",
"name": "request"
},
{
"type": "Google.Api.Gax.Grpc.CallSettings",
"name": "callSettings"
}
],
"resultType": "Google.LongRunning.Operation<Google.Cloud.AIPlatform.V1Beta1.DeployPublisherModelResponse, Google.Cloud.AIPlatform.V1Beta1.DeployPublisherModelOperationMetadata>",
"client": {
"shortName": "ModelGardenServiceClient",
"fullName": "Google.Cloud.AIPlatform.V1Beta1.ModelGardenServiceClient"
},
"method": {
"shortName": "DeployPublisherModel",
"fullName": "google.cloud.aiplatform.v1beta1.ModelGardenService.DeployPublisherModel",
"service": {
"shortName": "ModelGardenService",
"fullName": "google.cloud.aiplatform.v1beta1.ModelGardenService"
}
}
},
"canonical": true,
"origin": "API_DEFINITION",
"segments": [
{
"start": 20,
"end": 68,
"type": "FULL"
},
{
"start": 36,
"end": 66,
"type": "SHORT"
}
]
},
{
"regionTag": "aiplatform_v1beta1_generated_ModelGardenService_DeployPublisherModel_async",
"title": "DeployPublisherModelRequestObjectAsync",
"description": "Snippet for DeployPublisherModelAsync",
"file": "ModelGardenServiceClient.DeployPublisherModelRequestObjectAsyncSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "DeployPublisherModelAsync",
"fullName": "Google.Cloud.AIPlatform.V1Beta1.ModelGardenServiceClient.DeployPublisherModelAsync",
"async": true,
"parameters": [
{
"type": "Google.Cloud.AIPlatform.V1Beta1.DeployPublisherModelRequest",
"name": "request"
},
{
"type": "Google.Api.Gax.Grpc.CallSettings",
"name": "callSettings"
}
],
"resultType": "System.Threading.Tasks.Task<Google.LongRunning.Operation<Google.Cloud.AIPlatform.V1Beta1.DeployPublisherModelResponse, Google.Cloud.AIPlatform.V1Beta1.DeployPublisherModelOperationMetadata>>",
"client": {
"shortName": "ModelGardenServiceClient",
"fullName": "Google.Cloud.AIPlatform.V1Beta1.ModelGardenServiceClient"
},
"method": {
"shortName": "DeployPublisherModel",
"fullName": "google.cloud.aiplatform.v1beta1.ModelGardenService.DeployPublisherModel",
"service": {
"shortName": "ModelGardenService",
"fullName": "google.cloud.aiplatform.v1beta1.ModelGardenService"
}
}
},
"canonical": true,
"origin": "API_DEFINITION",
"segments": [
{
"start": 20,
"end": 69,
"type": "FULL"
},
{
"start": 37,
"end": 67,
"type": "SHORT"
}
]
},
{
"regionTag": "aiplatform_v1beta1_generated_ModelMonitoringService_CreateModelMonitor_sync",
"title": "CreateModelMonitorRequestObject",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
namespace GoogleCSharpSnippets
{
using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.AIPlatform.V1Beta1;
using Google.LongRunning;
using System;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -315,5 +317,82 @@ await response.AsRawResponses().ForEachAsync((ListPublisherModelsResponse page)
string nextPageToken = singlePage.NextPageToken;
// End snippet
}

/// <summary>Snippet for DeployPublisherModel</summary>
public void DeployPublisherModelRequestObject()
{
// Snippet: DeployPublisherModel(DeployPublisherModelRequest, CallSettings)
// Create client
ModelGardenServiceClient modelGardenServiceClient = ModelGardenServiceClient.Create();
// Initialize request argument(s)
DeployPublisherModelRequest request = new DeployPublisherModelRequest
{
Model = "",
DestinationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
EndpointDisplayName = "",
DedicatedResources = new DedicatedResources(),
ModelDisplayName = "",
HuggingFaceAccessToken = "",
AcceptEula = false,
};
// Make the request
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> response = modelGardenServiceClient.DeployPublisherModel(request);

// Poll until the returned long-running operation is complete
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
DeployPublisherModelResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> retrievedResponse = modelGardenServiceClient.PollOnceDeployPublisherModel(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
DeployPublisherModelResponse retrievedResult = retrievedResponse.Result;
}
// End snippet
}

/// <summary>Snippet for DeployPublisherModelAsync</summary>
public async Task DeployPublisherModelRequestObjectAsync()
{
// Snippet: DeployPublisherModelAsync(DeployPublisherModelRequest, CallSettings)
// Additional: DeployPublisherModelAsync(DeployPublisherModelRequest, CancellationToken)
// Create client
ModelGardenServiceClient modelGardenServiceClient = await ModelGardenServiceClient.CreateAsync();
// Initialize request argument(s)
DeployPublisherModelRequest request = new DeployPublisherModelRequest
{
Model = "",
DestinationAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
EndpointDisplayName = "",
DedicatedResources = new DedicatedResources(),
ModelDisplayName = "",
HuggingFaceAccessToken = "",
AcceptEula = false,
};
// Make the request
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> response = await modelGardenServiceClient.DeployPublisherModelAsync(request);

// Poll until the returned long-running operation is complete
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
DeployPublisherModelResponse result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<DeployPublisherModelResponse, DeployPublisherModelOperationMetadata> retrievedResponse = await modelGardenServiceClient.PollOnceDeployPublisherModelAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
// If it has completed, then access the result
DeployPublisherModelResponse retrievedResult = retrievedResponse.Result;
}
// End snippet
}
}
}
Loading

0 comments on commit bc4928d

Please sign in to comment.