

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Tutorial: creazione di un'API REST ConnectionType e di una connessione
<a name="rest-api-example"></a>

**Connessione all'API REST Foo **

 Creeremo un'API AWS Glue REST ConnectionType e una AWS Glue connessione corrispondente per l'API REST Foo. Questa API ha le seguenti proprietà (che possono essere recuperate dalla documentazione dell'API REST). 
+  **URL dell'istanza: ** https://foo.cloud.com/rest/v1. 
+  **Tipo di autenticazione**: OAuth2 (credenziali del cliente). 
+  **Metodo ** REST: GET. 
+  **Tipo di impaginazione**: Offset con proprietà «limit» e «offset» inserite nel parametro di interrogazione della richiesta. 
+ **Entità supportate: **
  +  **Barra**: percorso relativo [/bar.json]. 
  +  **Baz**: percorso relativo [/baz.json]. 

 Una volta ottenuti tutti i dettagli, possiamo iniziare a creare la AWS Glue connessione all'API REST di Foo. 

**Per creare una connessione ** API REST:

1.  Crea il tipo di connessione API REST AWS Glue chiamando l' RegisterConnectionType API utilizzando AWS API, CLI o SDK. Questo creerà una nuova ConnectionType risorsa in. 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"
                   }
               }
           }
       }
   }
   }
   ```

1.  In AWS Secrets Manager, crea un segreto. The Secret deve contenere l'app connessa Consumer Secret con `USER_MANAGED_CLIENT_APPLICATION_CLIENT_SECRET` una chiave. 
**Nota**  
È necessario creare un segreto per connessione in AWS Glue

1.  Crea la AWS Glue connessione chiamando l' CreateConnection API utilizzando l' AWS API, la CLI o l'SDK. 

   1.  Fai riferimento al nome del tipo di connessione REST indicato nella Fase 1 come "». ConnectionType 

   1.  Fornisci il InstanceUrl e qualsiasi altro ConnectionProperties che sia stato definito durante il processo AWS Glue ConnectionType di registrazione. 

   1.  Scegli tra i tipi di autenticazione configurati. L'API REST Foo utilizza OAuth2 con il ClientCredentials tipo di concessione. 

   1.  Fornisci il ** SecretArn ** e gli altri ** AuthenticationProperties ** configurati. Poiché in questo esempio viene utilizzato `OAUTH2` come AuthenticationType, imposta OAuth2Properties "in CreateConnectionInput. Ciò richiede proprietà come "OAuth2GrantType«," TokenUrl «e"OAuth2ClientApplication». 

1.  Effettua la CreateConnection richiesta che creerà la AWS Glue connessione. 

   ```
   {
       "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"
                   }
               }
           }
       }
   }
   ```