ניהול אוספים באמצעות ה-API

אתם צופים במסמכי התיעוד של Apigee Edge.
כדאי לעיין במסמכי התיעוד של Apigee X.
מידע

אוספים מאפשרים לקבץ שרתי proxy של API, יעדים או אפליקציות למפתחים, ולהגדיר ערכי סף מתאימים לכל החברים בקבוצה כדי לאבחן בעיות מהר יותר.

בקטעים הבאים מוסבר איך לנהל אוספים באמצעות ה-API.

מידע נוסף על Collections API זמין במאמר בנושא Collections API.

יצירת אוספים באמצעות API

כדי ליצור אוסף של שרתי proxy של API, שולחים בקשת POST למשאב הבא: https://apimonitoring.enterprise.apigee.com/collections

בדוגמה הבאה אפשר לראות איך יוצרים אוסף.

curl 'https://apimonitoring.enterprise.apigee.com/collections' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"My Collection",
     "description":"My collection for critical APIs",
     "environment": "prod",
     "type": "proxy",
     "members":["proxy1", "proxy2"]
    }'

מגדירים את $ACCESS_TOKEN לאסימון הגישה מסוג OAuth 2.0, כמו שמתואר במאמר קבלת אסימון גישה מסוג OAuth 2.0.

מידע על האפשרויות של cURL שבהן נעשה שימוש בדוגמה הזו זמין במאמר שימוש ב-cURL.

אפשר לציין את הערך type כ-proxy,‏ target או developerApp. לדוגמה, כדי ליצור אוסף של אפליקציות למפתחים:

curl 'https://apimonitoring.enterprise.apigee.com/collections' \
  -X POST \
  -H 'Accept: application/json, text/plain, */*' -H "Content-Type: application/json"\
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
     "organization":"myorg",
     "name":"My Dev App Collection",
     "description":"My collection for critical apps",
     "environment": "prod",
     "type": "developerApp",
     "members":["app1", "app2"]
    }'

הצגת כל האוספים באמצעות ה-API

כדי לראות את כל ההתראות וההודעות, שולחים בקשת GET למשאב הבא: https://apimonitoring.enterprise.apigee.com/collections

חובה להעביר את שם הארגון באמצעות פרמטר השאילתה org.

לדוגמה:

curl 'https://apimonitoring.enterprise.apigee.com/collections?org=myorg' 
  -X GET
  -H 'Accept: application/json, text/plain, */*' 
  -H "Authorization: Bearer $ACCESS_TOKEN"    

זוהי דוגמה לתגובה:

[{
     "uuid":"1234abcd",
     "organization":"myorg",
     "environment": "prod",
     "name":"My Collection",
     "type": "proxy",
     "members":["proxy1", "proxy2"],
     "description":"My collection for critical APIs",
     "updatedAt":"2018-07-13T16:25:15Z",
     "updatedBy":"joe@acme.com"
}]

מגדירים את $ACCESS_TOKEN לאסימון הגישה מסוג OAuth 2.0, כמו שמתואר במאמר קבלת אסימון גישה מסוג OAuth 2.0.

מידע על האפשרויות של cURL שבהן נעשה שימוש בדוגמה הזו זמין במאמר שימוש ב-cURL.

מוסיפים את uuid של האוסף למשאב /collections כדי לראות את האוסף הספציפי:

curl 'https://apimonitoring.enterprise.apigee.com/collections/1234abcd?org=myorg'
  -X GET
  -H 'Accept: application/json, text/plain, */*' 
  -H "Authorization: Bearer $ACCESS_TOKEN"