データベース ユーザーを更新する

このサンプルは、既存のデータベース ユーザーのプロパティを更新する方法を示しています。これを使用して、フィールド マスクで更新するフィールドを指定することで、ユーザーのパスワードを変更したり、割り当てられたデータベース ロールを変更したりできます。

コードサンプル

C#

AlloyDB に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。

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

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

次のステップ

他の Google Cloud プロダクトのコードサンプルを検索およびフィルタするには、Google Cloud サンプル ブラウザをご覧ください。