Cloud Scheduler のリージョン エンドポイントを使用すると、API トラフィックを単一のGoogle Cloud リージョン内に保持して、データ所在地とデータ主権の要件を満たすことができます。リージョン エンドポイントにリクエストを送信すると、TLS が終了し、Cloud Scheduler は指定されたリージョン内でリクエストを完全に処理します。
Cloud Scheduler のリージョン エンドポイントの形式は https://cloudscheduler.REGION.rep.googleapis.com です。ここで、REGION はサポート対象の地域(https://cloudscheduler.us-central1.rep.googleapis.com など)です。
Private Service Connect を使用して Virtual Private Cloud(VPC)ネットワーク内から Cloud Scheduler リージョン エンドポイントにプライベートにアクセスする方法については、エンドポイントを介したリージョンおよびマルチリージョンの Google API へのアクセスについてをご覧ください。
制限事項
Cloud Scheduler リージョン エンドポイントを使用する場合は、次の制限事項が適用されます。
- リージョン エンドポイントは、独自のリージョン内のリソースのみを処理します。リソース名のロケーションは、エンドポイントのリージョンと一致する必要があります。たとえば、
projects/PROJECT_ID/locations/us-central1のリソースのリクエストをcloudscheduler.us-central1.rep.googleapis.comに送信できます。他のリージョンのリソースに対するリクエストは失敗します。 - リージョン エンドポイントは、Cloud Scheduler API に送信されるリクエストに適用されます。Cloud Scheduler がジョブ ターゲットにリクエストを送信する方法は変更されません。ジョブが VPC Service Controls の境界内で実行される場合は、VPC Service Controls で cron ジョブを保護するでジョブ ターゲットの要件をご覧ください。
リージョン エンドポイントにリクエストを送信する
リージョン エンドポイントにリクエストを送信するには、Google Cloud CLI、REST API、または Cloud Scheduler クライアント ライブラリを使用します。
gcloud
api_endpoint_overrides/cloudscheduler プロパティをリージョン エンドポイントに設定し、そのリージョンのリソースに対して gcloud scheduler コマンドを実行します。
gcloud config set api_endpoint_overrides/cloudscheduler \ https://cloudscheduler.REGION.rep.googleapis.com/ gcloud scheduler jobs list --location=REGION
REGION は、リージョン エンドポイントを提供するリージョン(例: us-central1)に置き換えます。
デフォルトのグローバル エンドポイントを再度使用するには、プロパティの設定を解除します。
gcloud config unset api_endpoint_overrides/cloudscheduler
REST
リージョン エンドポイントをリクエスト URL のホストとして使用します。たとえば、次のコマンドはリージョン内のジョブを一覧表示します。
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://cloudscheduler.REGION.rep.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/jobs"
次のように置き換えます。
REGION: リージョン エンドポイントを提供するリージョン(例:us-central1)。PROJECT_ID: 実際の Google Cloud プロジェクト ID。
クライアント ライブラリ
クライアントの作成時に API エンドポイントを設定します。次の例では、us-central1 のクライアントを作成します。
Go
import ( scheduler "cloud.google.com/go/scheduler/apiv1" "google.golang.org/api/option" ) client, err := scheduler.NewCloudSchedulerClient(ctx, option.WithEndpoint("cloudscheduler.us-central1.rep.googleapis.com:443"))
Java
import com.google.cloud.scheduler.v1.CloudSchedulerClient; import com.google.cloud.scheduler.v1.CloudSchedulerSettings; CloudSchedulerSettings settings = CloudSchedulerSettings.newBuilder() .setEndpoint("cloudscheduler.us-central1.rep.googleapis.com:443") .build(); try (CloudSchedulerClient client = CloudSchedulerClient.create(settings)) { // Send requests for resources in us-central1. }
Python
from google.api_core.client_options import ClientOptions from google.cloud import scheduler_v1 client = scheduler_v1.CloudSchedulerClient( client_options=ClientOptions( api_endpoint="cloudscheduler.us-central1.rep.googleapis.com" ) )