Atualizar um backup

Este exemplo mostra como atualizar os metadados de um backup específico. Use isso para mudar propriedades como o nome de exibição ou os rótulos do backup.

Exemplo de código

C#

Para autenticar no AlloyDB, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.

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;
        }
    }
}

A seguir

Para pesquisar e filtrar exemplos de código de outros Google Cloud produtos, consulte a Google Cloud pesquisa de exemplos de código.