클러스터 업데이트

이 스니펫은 기존 클러스터의 속성을 업데이트하는 방법을 보여줍니다. 클러스터 객체와 업데이트할 필드를 지정하는 필드 마스크를 제공하여 클러스터의 구성을 변경하는 데 사용합니다.

코드 샘플

C#

AlloyDB에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

using Google.Cloud.AlloyDb.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedAlloyDBAdminClientSnippets
{
    /// <summary>Snippet for UpdateCluster</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 UpdateCluster()
    {
        // Create client
        AlloyDBAdminClient alloyDBAdminClient = AlloyDBAdminClient.Create();
        // Initialize request argument(s)
        Cluster cluster = new Cluster();
        FieldMask updateMask = new FieldMask();
        // Make the request
        Operation<Cluster, OperationMetadata> response = alloyDBAdminClient.UpdateCluster(cluster, updateMask);

        // Poll until the returned long-running operation is complete
        Operation<Cluster, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        Cluster 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<Cluster, OperationMetadata> retrievedResponse = alloyDBAdminClient.PollOnceUpdateCluster(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            Cluster retrievedResult = retrievedResponse.Result;
        }
    }
}

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저 참조하기