Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Tutorial: Membuat REST API ConnectionType dan Koneksi
Menghubungkan ke Foo REST API
Kami akan membuat AWS Glue REST API ConnectionType dan AWS Glue koneksi yang sesuai untuk Foo REST API. API ini memiliki properti berikut (yang dapat diambil dari dokumentasi REST API).
-
URL instans: https://foo.cloud.com/rest/v1.
-
Jenis otentikasi: OAuth2 (KredenSIAL Klien).
-
Metode REST: DAPATKAN.
-
Jenis paginasi: Offset dengan properti “limit” dan “offset” ditempatkan dalam parameter kueri permintaan.
-
Entitas yang didukung:
-
Bilah: jalur relatif [/bar.json].
-
Baz: jalur relatif [/baz.json].
-
Setelah semua detail diperoleh, kita dapat mulai membuat AWS Glue koneksi ke Foo REST API.
Untuk membuat koneksi REST API:
-
Buat jenis koneksi REST API AWS Glue dengan memanggil RegisterConnectionType API menggunakan AWS API, CLI, atau SDK. Ini akan membuat sumber ConnectionType daya baru di AWS Glue.
{ "ConnectionType": "REST-FOO-CONNECTOR", "IntegrationType": "REST", "Description": "AWS Glue Connection Type for the FOO REST API", "ConnectionProperties": { "Url": { "Name": "Url", "Required": true, "DefaultValue": "https://foo.cloud.com/rest/v1", "PropertyType": "USER_INPUT" } }, "ConnectorAuthenticationConfiguration": { "AuthenticationTypes": ["OAUTH2"], "OAuth2Properties": { "OAuth2GrantType": "CLIENT_CREDENTIALS" } }, "RestConfiguration": { "GlobalSourceConfiguration": { "RequestMethod": "GET", "ResponseConfiguration": { "ResultPath": "$.result", "ErrorPath": "$.error.message" }, "PaginationConfiguration": { "OffsetConfiguration": { "OffsetParameter": { "Key": "offset", "PropertyLocation": "QUERY_PARAM" }, "LimitParameter": { "Key": "limit", "PropertyLocation": "QUERY_PARAM", "DefaultValue": "50" } } } }, "ValidationEndpointConfiguration": { "RequestMethod": "GET", "RequestPath": "/bar.json?offset=1&limit=10" }, "EntityConfigurations": { "bar": { "SourceConfiguration": { "RequestMethod": "GET", "RequestPath": "/bar.json", "ResponseConfiguration": { "ResultPath": "$.result", "ErrorPath": "$.error.message" } }, "Schema": { "name": { "Name": "name", "FieldDataType": "STRING" }, "description": { "Name": "description", "FieldDataType": "STRING" }, "id": { "Name": "id", "FieldDataType": "STRING" }, "status": { "Name": "status", "FieldDataType": "STRING" } } } } } } -
Di Manajer AWS Rahasia, buat rahasia. Rahasia harus berisi aplikasi Consumer Secret yang terhubung
USER_MANAGED_CLIENT_APPLICATION_CLIENT_SECRETdengan kunci.catatan
Anda harus membuat rahasia per koneksi di AWS Glue
-
Buat AWS Glue koneksi dengan memanggil CreateConnection API menggunakan AWS API, CLI, atau SDK.
-
Referensikan nama tipe koneksi REST dari Langkah 1 sebagai "ConnectionType”.
-
Berikan InstanceUrl dan ConnectionProperties yang lainnya yang ditentukan selama proses AWS Glue ConnectionType pendaftaran.
-
Pilih dari Jenis Otentikasi yang dikonfigurasi. REST API Foo menggunakan OAuth2 dengan jenis hibah. ClientCredentials
-
Berikan SecretArn dan lainnya AuthenticationProperties yang dikonfigurasi. Karena contoh ini
OAUTH2digunakan sebagai AuthenticationType, atur "OAuth2Properties" di CreateConnectionInput. Ini membutuhkan properti seperti "OAuth2GrantType“," TokenUrl “, dan"OAuth2ClientApplication”.
-
-
Buat CreateConnection permintaan yang akan membuat AWS Glue koneksi.
{ "ConnectionInput": { "Name": "ConnectionFooREST", "ConnectionType": "REST-FOO-CONNECTOR", "ConnectionProperties": {}, "ValidateCredentials": true, "AuthenticationConfiguration": { "AuthenticationType": "OAUTH2", "SecretArn": "arn:aws:secretsmanager:<region>:<accountId>:secret:<secretId>", "OAuth2Properties": { "OAuth2GrantType": "CLIENT_CREDENTIALS", "TokenUrl": "https://foo.cloud.com/oauth/token", "OAuth2ClientApplication": { "UserManagedClientApplicationClientId": "your-managed-client-id" } } } } }