קבלת פרטי מכונה

בקטע הקוד הבא אפשר לראות איך מאחזרים את הפרטים של מופע ספציפי. אפשר להשתמש בפקודה הזו כדי לקבל מידע על מכונה, כמו ההגדרה שלה, המצב הנוכחי או כתובת ה-IP.

דוגמת קוד

C#

כדי לבצע אימות ב-AlloyDB, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

using Google.Cloud.AlloyDb.V1;

public sealed partial class GeneratedAlloyDBAdminClientSnippets
{
    /// <summary>Snippet for GetInstance</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 GetInstance()
    {
        // Create client
        AlloyDBAdminClient alloyDBAdminClient = AlloyDBAdminClient.Create();
        // Initialize request argument(s)
        string name = "projects/[PROJECT]/locations/[LOCATION]/clusters/[CLUSTER]/instances/[INSTANCE]";
        // Make the request
        Instance response = alloyDBAdminClient.GetInstance(name);
    }
}

המאמרים הבאים

כדי לחפש ולסנן דוגמאות קוד למוצרים אחרים של Google Cloud , אפשר להיעזר בGoogle Cloud דפדפן לדוגמה.