Anda sedang melihat dokumentasi Apigee Edge.
  Buka
     Dokumentasi Apigee X. info

Apa
Mengambil profil entity yang Anda tentukan dari penyimpanan data Apigee Edge. Kebijakan ini menempatkan
  profil dalam variabel yang namanya mengikuti format AccessEntity.{policy_name}. Anda
  dapat menggunakan AccessEntity untuk mengakses profil entitas berikut:
- Aplikasi
- Produk API
- Perusahaan
- Developer perusahaan
- Kunci konsumen
- Developer
Kebijakan AccessEntity berfungsi sebagai pencarian database runtime berbasis kebijakan. Anda
  dapat menggunakan informasi profil yang ditampilkan oleh kebijakan ini untuk mengaktifkan perilaku dinamis, seperti
  perutean endpoint bersyarat, eksekusi alur, penerapan kebijakan.
Anda menggunakan kebijakan AccessEntity untuk mendapatkan data profil entitas sebagai
  XML, lalu masukkan ke dalam variabel. Anda mengidentifikasi entity yang akan didapatkan dengan menentukan entity
  dan satu atau beberapa pengenal yang menentukan
entitas mana dari jenis itu yang Anda inginkan. Nanti, di
  kebijakan lain, Anda dapat mengambil data profil entitas dengan kebijakan lain, seperti
  Kebijakan ExtractVariables atau kebijakan MenetapkanMessage.
Contoh
Contoh berikut menunjukkan AccessEntity yang digunakan bersama dengan
  Kebijakan ExtractVariables dan AssignMessage untuk mengekstrak kebijakan
  dan menambahkannya ke header HTTP.
Mendapatkan email developer untuk digunakan dalam kebijakan lain
Menyiapkan kebijakan AccessEntity untuk menentukan profil entitas yang akan diambil
      Edge, serta tempat untuk meletakkan data profil.
Pada contoh berikut, kebijakan mendapatkan profil entity developer, menggunakan
      Kunci API diteruskan sebagai parameter kueri untuk mengidentifikasi developer. Profil ditempatkan dalam
      variabel yang namanya mengikuti bentuk AccessEntity.{policy_name}. Jadi variabel
      yang disetel oleh kebijakan ini adalah AccessEntity.GetDeveloperProfile.
<AccessEntity name="GetDeveloperProfile"> <!-- This is the type entity whose profile we need to pull from the Edge datastore. --> <EntityType value="developer"/> <!-- We tell the policy to use the API key (presented as query parameter) to identify the developer. --> <EntityIdentifier ref="request.queryparam.apikey" type="consumerkey"/> </AccessEntity>
Gunakan kebijakan lain untuk mengambil nilai profil entitas dari variabel yang ditetapkan oleh
      AccessEntity.
Dalam contoh berikut, kebijakan ExtractVariables mengambil nilai dari
      variabel AccessEntity.GetDeveloperProfile yang ditetapkan sebelumnya dengan
      AccessEntity.
Perhatikan bahwa nilai yang diambil ditetapkan sebagai ekspresi XPath dalam
      Elemen XMLPayload. Nilai yang diekstrak ditempatkan dalam kolom
      Variabel developer.email.
<ExtractVariables name="SetDeveloperProfile"> <!-- The source element points to the variable populated by AccessEntity policy. The format is <policy-type>.<policy-name>. In this case, the variable contains the whole developer profile. --> <Source>AccessEntity.GetDeveloperProfile</Source> <VariablePrefix>developer</VariablePrefix> <XMLPayload> <Variable name="email" type="string"> <!-- You parse elements from the developer profile using XPath. --> <XPath>/Developer/Email</XPath> </Variable> </XMLPayload> </ExtractVariables>
Kebijakan TetapkanMessage berikut mengambil email developer yang ditetapkan oleh Kebijakan ExtractVariables.
<!-- We'll use this policy to return the variables set in the developer profile, just so that we can easily see them in the response. --> <AssignMessage name="EchoVariables"> <AssignTo createNew="false" type="response"></AssignTo> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <Set> <Headers> <Header name="X-Developer-email">{developer.email}</Header> </Headers> </Set> </AssignMessage>
Referensi elemen
Dasar struktur kebijakan AccessEntity adalah:
<AccessEntity name="policy_name"> <EntityType value="entity_type"/> <EntityIdentifier ref="entity_identifier" type="identifier_type"/> <SecondaryIdentifier ref="secondary_identifier" type="identifier_type"/> </AccessEntity>
Anda dapat mengakses beberapa entitas yang jenisnya sama dengan mengelompokkannya dalam
  Elemen Identifiers:
<AccessEntity name="name_of_the_policy"> <EntityType value="type_of_entity"/> <Identifiers> <Identifier> <EntityIdentifier ref="reference_to_entity_identifier" type*="identifier_type"/> <SecondaryIdentifier ref="reference_to_secondary_entity_identifier" type="identifier_type"/><!-- optional --> </Identifier > <Identifier> <EntityIdentifier ref="reference_to_entity_identifier" type*="identifier_type"/> <SecondaryIdentifier ref="reference_to_secondary_entity_identifier" type="identifier_type"/><!-- optional --> </Identifier > </Identifiers> </AccessEntity>
<AccessEntity> atribut
<AccessEntity async="false" continueOnError="false" enabled="true" name="policy_name">
Tabel berikut menjelaskan atribut yang umum untuk semua elemen induk kebijakan:
| Atribut | Deskripsi | Default | Ketersediaan | 
|---|---|---|---|
| name | Nama internal kebijakan. Nilai atribut  Secara opsional, gunakan elemen  | T/A | Wajib | 
| continueOnError | Tetapkan ke  Setel ke  | salah | Opsional | 
| enabled | Setel ke  Setel ke  | true | Opsional | 
| async | Atribut ini tidak digunakan lagi. | salah | Tidak digunakan lagi | 
<DisplayName> elemen
Gunakan selain atribut name untuk memberi label kebijakan di
  editor proxy UI dengan nama natural language yang berbeda.
<DisplayName>Policy Display Name</DisplayName>
| Default | T/A Jika Anda menghapus elemen ini, nilai atribut  | 
|---|---|
| Ketersediaan | Opsional | 
| Jenis | String | 
<EntityIdentifier> elemen
Menentukan entity tertentu -- dari jenis yang diberikan dalam EntityType -- yang akan didapatkan.
<EntityIdentifier ref="value_variable" type="identifier_type"/>
| Default | T/A | 
| Kehadiran | Wajib | 
| Jenis | String | 
Atribut
| Atribut | Deskripsi | Default | Ketersediaan | Jenis | 
|---|---|---|---|---|
| referensi | Variabel yang menyediakan sumber ID, seperti
           | T/A | Wajib. | String | 
| jenis | Jenis yang diisi oleh variabel dalam atribut ref. seperti consumerkey. Lihat ID dan jenis entitas untuk
        sebuah daftar nilai. | Wajib. | String | 
Contoh
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AccessEntity async="false" continueOnError="false" enabled="true" name="GetCompany"> <DisplayName>GetCompanyProfile</DisplayName> <EntityType value="company"></EntityType> <EntityIdentifier ref="request.queryparam.apikey" type="consumerkey"/> </AccessEntity>
<EntityType> elemen
Menentukan jenis entity yang akan diambil dari penyimpanan data.
<EntityType value="entity_type"/>
| Default | T/A | 
| Kehadiran | Wajib | 
| Jenis | String | 
Gunakan elemen EntityIdentifier untuk menentukan
  entitas mana dari jenis 
yang diberikan yang Anda inginkan. Untuk referensi tentang jenis entitas, lihat Jenis dan ID entitas.
Atribut
| Atribut | Deskripsi | Default | Ketersediaan | Jenis | 
|---|---|---|---|---|
| nilai | Salah satu jenis entity yang didukung. Lihat Jenis entitas dan ID untuk sebuah daftar. | Tidak ada. | Wajib. | String | 
<SecondaryIdentifier> elemen
Bersamaan dengan EntityIdentifier, tentukan nilai untuk mengidentifikasi nilai yang diinginkan
  instance dari EntityType yang diberikan.
<SecondaryIdentifier ref="value_variable" type="identifier_type"/>
| Default | T/A | 
| Kehadiran | Opsional | 
| Jenis | String | 
Gunakan SecondaryIdentifier saat menentukan EntityIdentifier saja
  tidak akan menjamin bahwa Anda mendapatkan satu entitas. Lihat Penyempitan
  hasil dengan ID sekunder untuk mengetahui informasi selengkapnya.
Penggunaan beberapa elemen SecondaryIdentifier tidak didukung.
Atribut
| Atribut | Deskripsi | Default | Ketersediaan | Jenis | 
|---|---|---|---|---|
| referensi | Variabel yang menyediakan sumber ID, seperti
           | T/A | Wajib. | String | 
| jenis | Jenis yang diisi oleh variabel dalam atribut ref. seperti consumerkey. Lihat ID dan jenis entitas untuk
        sebuah daftar nilai. | Wajib. | String | 
Contoh
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AccessEntity async="false" continueOnError="false" enabled="true" name="GetAPIProduct"> <DisplayName>GetAPIProduct</DisplayName> <EntityType value="apiproduct"></EntityType> <EntityIdentifier ref="developer.app.name" type="appname"/> <SecondaryIdentifier ref="developer.id" type="developerid"/> </AccessEntity>
Catatan penggunaan
Mempersempit hasil dengan ID sekunder
Untuk beberapa entitas, memberikan satu ID mungkin tidak cukup spesifik untuk mendapatkan entitas kita inginkan. Dalam kasus tersebut, Anda dapat menggunakan ID sekunder untuk mempersempit hasil.
Konfigurasi kebijakan pertama Anda yang mungkin luas mungkin terlihat seperti ini:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AccessEntity async="false" continueOnError="false" enabled="true" name="GetApp"> <DisplayName>GetAppProfile</DisplayName> <EntityType value="apiproduct"></EntityType> <EntityIdentifier ref="request.queryparam.apikey" type="consumerkey"/> </AccessEntity>
Karena aplikasi dapat dikaitkan dengan beberapa produk API, menggunakan ID aplikasi saja mungkin tidak mengembalikan produk API yang Anda inginkan (Anda bisa mendapatkan yang pertama dari beberapa produk yang cocok).
Sebagai gantinya, untuk mendapatkan hasil yang lebih tepat, Anda dapat menggunakan SecondaryIdentifier. Sebagai
  Misalnya, Anda mungkin memiliki variabel appname dan developerid dalam flow
  karena ini diisi secara {i>default<i} 
selama pertukaran OAuth 2.0. Anda bisa menggunakan nilai-nilai
  variabel tersebut dalam kebijakan AccessEntity untuk mendapatkan detail profil tentang permintaan
  .
Konfigurasi kebijakan Anda yang lebih spesifik mungkin terlihat seperti ini:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AccessEntity async="false" continueOnError="false" enabled="true" name="GetApp"> <DisplayName>GetAppProfile</DisplayName> <EntityType value="apiproduct"></EntityType> <EntityIdentifier ref="developer.app.name" type="appname"/> <SecondaryIdentifier ref="developer.id" type="developerid"/> </AccessEntity>
Jenis dan ID entity yang didukung
AccessEntity mendukung jenis dan ID entity berikut.
| Nilai EntityType | Jenis EntityIdentifier | Jenis SecondaryIdentifier | 
|---|---|---|
| apiproduct | appid | apiresource | 
| apiproductname | ||
| appname | apiresourcedeveloperemaildeveloperidcompanyname | |
| consumerkey | apiresource | |
| app | appid | |
| appname | developeremaildeveloperidcompanyname | |
| consumerkey | ||
| authorizationcode | authorizationcode | |
| company | appid | |
| company | ||
| consumerkey | ||
| companydeveloper | companyname | |
| consumerkey | consumerkey | |
| consumerkey_scope | consumerkey | |
| developer | appid | |
| consumerkey | ||
| developeremail | ||
| developerid | ||
| requesttoken | requesttoken | consumerkey | 
| verifier | verifier | 
Contoh XML profil entity
Untuk mengambil nilai profil entitas yang Anda inginkan dengan XPath, Anda harus mengetahui struktur XML profil. Untuk contoh struktur, gunakan panggilan API pengelolaan untuk mendapatkan XML untuk entitas yang Anda inginkan. Untuk mengetahui detailnya, lihat management API .
Bagian berikut menyertakan kode untuk panggilan API, beserta contoh XML dari panggilan tersebut.
Aplikasi
$ curl -H "Accept:text/xml" -X GET \ https://api.enterprise.apigee.com/v1/o/{org_name}/apps/{app_id} \ -u email:password
Lihat juga Mendapatkan Aplikasi di Pengaturan berdasarkan ID Aplikasi dalam referensi API pengelolaan Edge.
Atau:
$ curl -H "Accept:text/xml" -X GET \ https://api.enterprise.apigee.com/v1/o/{org_name}/developers/{developer_email}/apps/{app_name} \ -u email:password
Lihat juga Mendapatkan Detail Aplikasi Developer dalam referensi API pengelolaan Edge.
Contoh profil:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <App name="thomas-app"> <AccessType>read</AccessType> <ApiProducts/> <Credentials> <Credential> <Attributes/> <ConsumerKey>wrqOOOiPArFI0WRoB1gAJMRbOguekJ5w</ConsumerKey> <ConsumerSecret>WvOhDrJ8m6kzz7Ni</ConsumerSecret> <ApiProducts> <ApiProduct> <Name>FreeProduct</Name> <Status>approved</Status> </ApiProduct> </ApiProducts> <Scopes/> <Status>approved</Status> </Credential> </Credentials> <AppFamily>default</AppFamily> <AppId>ab308c13-bc99-4c50-8434-0e0ed1b86075</AppId> <Attributes> <Attribute> <Name>DisplayName</Name> <Value>Tom's Weather App</Value> </Attribute> </Attributes> <CallbackUrl>http://tom.app/login</CallbackUrl> <CreatedAt>1362502872727</CreatedAt> <CreatedBy>admin@apigee.com</CreatedBy> <DeveloperId>PFK8IwOeAOW01JKA</DeveloperId> <LastModifiedAt>1362502872727</LastModifiedAt> <LastModifiedBy>admin@apigee.com</LastModifiedBy> <Scopes/> <Status>approved</Status> </App>
Produk API
$ curl -H "Accept:text/xml" -X GET \ https://api.enterprise.apigee.com/v1/o/{org_name}/apiproducts/{apiproduct_name} \ -u email:password
Lihat juga Mendapatkan API Produk dalam referensi API pengelolaan Edge.
Contoh XPath, mengambil resource API (URI) kedua dari produk API bernama
  weather_free:
/ApiProduct['@name=weather_free']/ApiResources/ApiResource[1]/text()
Profil contoh yang ditampilkan dalam bentuk XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ApiProduct name="weather_free"> <ApiResources> <ApiResource>/forecastrss, /reports</ApiResource> </ApiResources> <ApprovalType>auto</ApprovalType> <Attributes> <Attribute> <Name>description</Name> <Value>Introductory API Product</Value> </Attribute> <Attribute> <Name>developer.quota.interval</Name> <Value>1</Value> </Attribute> <Attribute> <Name>developer.quota.limit</Name> <Value>1</Value> </Attribute> <Attribute> <Name>developer.quota.timeunit</Name> <Value>minute</Value> </Attribute> <Attribute> <Name>servicePlan</Name> <Value>Introductory</Value> </Attribute> </Attributes> <CreatedAt>1355847839224</CreatedAt> <CreatedBy>andrew@apigee.com</CreatedBy> <Description>Free API Product</Description> <DisplayName>Free API Product</DisplayName> <Environments/> <LastModifiedAt>1355847839224</LastModifiedAt> <LastModifiedBy>andrew@apigee.com</LastModifiedBy> <Proxies/> <Scopes/> </ApiProduct>
Perusahaan
$ curl -H "Accept:text/xml" -X GET \ https://api.enterprise.apigee.com/v1/o/{org_name}/companies/{company_name} \ -u email:password
Lihat juga Mendapatkan Detail Perusahaan dalam referensi API pengelolaan Edge.
Contoh profil:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Company name="theramin"> <Apps/> <DisplayName>Theramin Corporation</DisplayName> <Organization>apigee-pm</Organization> <Status>active</Status> <Attributes> <Attribute> <Name>billing_code</Name> <Value>13648765</Value> </Attribute> </Attributes> <CreatedAt>1349208631291</CreatedAt> <CreatedBy>andrew@apigee.com</CreatedBy> <LastModifiedAt>1349208631291</LastModifiedAt> <LastModifiedBy>andrew@apigee.com</LastModifiedBy> </Company>
Developer perusahaan
$ curl -H "Accept:text/xml" -X GET \ https://api.enterprise.apigee.com/v1/o/{org_name}/companies/{company_name}/developers/{developer_name} \ -u email:password
Contoh profil:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Developers> <Developer> <Email>ntesla@theramin.com</Email> <Role>developer</Role> </Developer> </Developers>
Kunci konsumen
$ curl -H "Accept:text/xml" -X GET \ https://api.enterprise.apigee.com/v1/o/{org_name}/developers/{developer_email}/apps/{app_name}/keys/{consumer_key} \ -u email:password
Lihat juga Mendapatkan Detail Kunci untuk Aplikasi Developer dalam referensi API pengelolaan Edge.
Contoh XPath:
/Credential/ApiProducts/ApiProduct[Name='weather_free']/Status/text()
Contoh profil:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Credential>
    <Attributes/>
    <ConsumerKey>XLotL3PRxNkUGXhGAFDPOr6fqtvAhuZe</ConsumerKey>
    <ConsumerSecret>iNUyEaOOh96KR3YL</ConsumerSecret>
    <ApiProducts>
        <ApiProduct>
            <Name>weather_free</Name>
            <Status>approved</Status>
        </ApiProduct>
    </ApiProducts>
    <Scopes/>
    <Status>approved</Status>
</Credential>Developer
$ curl -H "Accept:text/xml" -X GET \ https://api.enterprise.apigee.com/v1/o/{org_name}/developers/{developer_email} \ -u email:password
Lihat juga Dapatkan Developer di referensi API pengelolaan Edge.
Contoh XPath:
/Developer/Attributes/Attribute[Name='my_custom_attribute']/Value/text()
/Developer/Email/text()
Contoh profil:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Developer> <Apps> <App>weatherappx</App> <App>weatherapp</App> </Apps> <Email>ntesla@theramin.com</Email> <DeveloperId>4Y4xd0KRZ1wmHJqu</DeveloperId> <FirstName>Nikola</FirstName> <LastName>Tesla</LastName> <UserName>theramin</UserName> <OrganizationName>apigee-pm</OrganizationName> <Status>active</Status> <Attributes> <Attribute> <Name>project_type</Name> <Value>public</Value> </Attribute> </Attributes> <CreatedAt>1349797040634</CreatedAt> <CreatedBy>rsaha@apigee.com</CreatedBy> <LastModifiedAt>1349797040634</LastModifiedAt> <LastModifiedBy>rsaha@apigee.com</LastModifiedBy> </Developer>
Variabel flow
Saat profil entity yang ditentukan dalam kebijakan AccessEntity diambil, file berformat XML objek profil ditambahkan ke konteks pesan sebagai variabel. Data ini dapat diakses seperti variabel, dengan referensi ke nama variabel. Nama kebijakan AccessEntity yang diberikan pengguna ditetapkan sebagai awalan variabel dari nama variabel.
Misalnya, jika kebijakan AccessEntity dengan nama GetDeveloper dijalankan,
  maka profil berformat XML disimpan dalam variabel bernama
  AccessEntity.GetDeveloper. Profil berformat XML kemudian 
dapat diurai menggunakan atribut
  XPath yang ditentukan dalam kebijakan ExtractVariables yang menentukan AccessEntity.GetDeveloper
  sebagai sumbernya.
Referensi error
Untuk informasi terkait, lihat Yang perlu Anda ketahui tentang error kebijakan dan Menangani error.
Error runtime
Tidak ada.
Error saat deployment
| Nama error | String error | Status HTTP | Terjadi saat | 
|---|---|---|---|
| InvalidEntityType | Invalid type [entity_type] in ACCESSENTITYStepDefinition
        [policy_name] | T/A | Jenis entitas yang digunakan harus berupa salah satu jenis yang didukung. | 
Topik terkait
- ExtractVariables: Kebijakan ExtractVariables
- AssignMessage: Kebijakan Menetapkan Pesan