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 Contoh: https://foo.cloud.com/rest/ v1.
-
Jenis otentikasi: OAuth2 (Kredensial Klien).
-
Metode REST: GET.
-
Jenis pagination: Offset dengan properti “limit” dan “offset” ditempatkan dalam parameter permintaan 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 tipe koneksi REST API AWS Glue dengan memanggil RegisterConnectionType API menggunakan AWS API, CLI, atau SDK. Ini akan menciptakan ConnectionType sumber 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 AWS Secrets Manager, buat rahasia. Rahasia harus berisi aplikasi Consumer Secret yang terhubung dengan
USER_MANAGED_CLIENT_APPLICATION_CLIENT_SECRETsebagai 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 jenis 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 tipe ClientCredentials hibah.
-
Berikan SecretArndan lainnya AuthenticationPropertiesyang dikonfigurasi. Sebagai contoh, kita telah mengkonfigurasi
OAUTH2sebagai AuthenticationType sehingga kita akan mengatur “OAuth2Properties” di CreateConnectionInput. Ini akan 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" } } } } }