הגדרת השימוש בשירות בסביבת פיתוח
באמצעות Service Usage API אפשר לנהל ממשקי API ושירותים בפרויקט ב-Cloud de Confiance . במדריך למתחילים הזה תגדירו את סביבת הפיתוח כך שתתקשר עם Service Usage API למטרות בדיקה.
- ברוב התרחישים האופרטיביים לדוגמה, הדרך הפשוטה ביותר להפעיל ולהשבית שירותים היא באמצעות מסוף Cloud de Confiance .
- אם אתם צריכים ליצור סקריפטים, אתם יכולים להשתמש ב-Google Cloud CLI.
- אם אתם צריכים לכתוב קוד שמשתמש ב-Service Usage API, השתמשו באחת מספריות הלקוח.
- כדי להתנסות ב-API בלי להגדיר סביבת פיתוח מלאה לאפליקציות, תוכלו לבצע את ההוראות להגדרה שמפורטות במדריך הזה ולהשתמש בפקודה
curl.
הגדרה לקריאה ישירה ל-API
בקטע הזה מתוארים השלבים הבסיסיים להגדרת הסביבה המקומית שלכם כדי להתנסות ב-Service Usage API באמצעות הפקודה curl. הממשק מיועד למפתחים שצריכים לכתוב קוד שמשתמש ב-Service Usage API.
הפעלת Service Usage API
כדי להשתמש ב-Service Usage API, קודם צריך להפעיל אותו בפרויקט ב-Cloud de Confiance .
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Service Usage API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.- מוודאים שלחשבון המשתמש שלכם הוקצה התפקיד אדמין של שימוש בשירות.
בדיקה באמצעות curl
מגדירים משתנה סביבה
PROJECT_IDעם מזהה הפרויקט:PROJECT_ID=PROJECT_IDמחליפים את PROJECT_ID במספר או במזהה הפרויקט ב- Cloud de Confiance .
מוודאים שאתם מחוברים ל-gcloud:
gcloud auth loginמציגים את ממשקי ה-API והשירותים שמופעלים בפרויקט:
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://serviceusage.googleapis.com/v1/projects/${PROJECT_ID}/services?filter=state:ENABLED&fields=services.config.title,services.config.name"אם מופיע פלט כמו זה, סימן שההגדרה הושלמה בלי שגיאות:
{ "services": [ { "config": { "name": "bigquery.googleapis.com", "title": "BigQuery API" } }, { "config": { "name": "bigquerystorage.googleapis.com", "title": "BigQuery Storage API" } }, ...
השלבים הבאים
כדי להציג את רשימת ממשקי ה-API והשירותים שמופעלים או זמינים בפרויקטים שלכם ב-Cloud de Confiance , קראו את המאמר הצגת רשימת השירותים.