更新備份

這個範例說明如何更新特定備份的中繼資料。您可以使用這項功能變更備份的顯示名稱或標籤等屬性。

程式碼範例

C#

如要向 AlloyDB 進行驗證,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證機制」。

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

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

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

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 範例瀏覽工具。