יצירת לקוח עם העברה ב-HTTP/JSON

מאתחלים לקוח Admin שמוגדר להשתמש בפרוטוקול התעבורה HTTP/JSON במקום ב-gRPC שמוגדר כברירת מחדל. האפשרות הזו שימושית בסביבות שבהן gRPC לא נתמך או חסום, כמו בחלק מחומות האש או שרתי ה-proxy באינטרנט.

דוגמת קוד

Java

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

import com.google.cloud.alloydb.v1.AlloyDBCSQLAdminClient;
import com.google.cloud.alloydb.v1.AlloyDBCSQLAdminSettings;

public class SyncCreateUseHttpJsonTransport {

  public static void main(String[] args) throws Exception {
    syncCreateUseHttpJsonTransport();
  }

  public static void syncCreateUseHttpJsonTransport() throws Exception {
    // 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/java/docs/setup#configure_endpoints_for_the_client_library
    AlloyDBCSQLAdminSettings alloyDBCSQLAdminSettings =
        AlloyDBCSQLAdminSettings.newHttpJsonBuilder().build();
    AlloyDBCSQLAdminClient alloyDBCSQLAdminClient =
        AlloyDBCSQLAdminClient.create(alloyDBCSQLAdminSettings);
  }
}

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

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