Utilizzare DiscoverInputSchema con un o AWS SDK CLI - Esempi di codice dell'AWS SDK

Ci sono altri AWS SDK esempi disponibili nel repository AWS Doc SDK Examples GitHub .

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à.

Utilizzare DiscoverInputSchema con un o AWS SDK CLI

Il seguente esempio di codice mostra come usareDiscoverInputSchema.

Python
SDKper Python (Boto3)
Nota

C'è di più su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

class KinesisAnalyticsApplicationV2: """Encapsulates Kinesis Data Analytics application functions.""" def __init__(self, analytics_client): """ :param analytics_client: A Boto3 Kinesis Data Analytics v2 client. """ self.analytics_client = analytics_client self.name = None self.arn = None self.version_id = None self.create_timestamp = None def discover_input_schema(self, stream_arn, role_arn): """ Discovers a schema that maps data in a stream to a format that is usable by an application's runtime environment. The stream must be active and have enough data moving through it for the service to sample. The returned schema can be used when you add the stream as an input to the application or you can write your own schema. :param stream_arn: The ARN of the stream to map. :param role_arn: A role that lets Kinesis Data Analytics read from the stream. :return: The discovered schema of the data in the input stream. """ try: response = self.analytics_client.discover_input_schema( ResourceARN=stream_arn, ServiceExecutionRole=role_arn, InputStartingPositionConfiguration={"InputStartingPosition": "NOW"}, ) schema = response["InputSchema"] logger.info("Discovered input schema for stream %s.", stream_arn) except ClientError: logger.exception( "Couldn't discover input schema for stream %s.", stream_arn ) raise else: return schema