

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

# Exemples d'API de capture d'écran améliorées

Utilisez les exemples suivants pour appeler les actions de l'API Enhanced Snapshot. Chaque exemple d'action instantanée montre l'intégralité de la demande et de la réponse. Le `CreateApplication` et `UpdateApplication` les exemples montrent uniquement la demande. Pour obtenir des informations sur l’utilisation d’un fichier JSON comme entrée pour une action d’API, consultez [Exemple de code de l'API Managed Service for Apache Flink](api-examples.md).

Les exemples utilisent le compte `111122223333`, la Région `aa-example-1`, l'application `MyApplication`, et la capture d'écran améliorée `MyApplication-snapshot-1`. Les horodatages sont exprimés en secondes d'époque.

## Exemples de demandes
<a name="snapshots-api-examples-request-examples"></a>

Chacune des sections suivantes présente une action d'API.

### Création d'un instantané amélioré
<a name="snapshots-api-examples-createsnapshot"></a>

L'exemple de demande suivant pour [`CreateSnapshot`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_CreateSnapshot.html) l'action crée un instantané amélioré d'une application en cours d'exécution :

```json
{
    "ApplicationName": "MyApplication",
    "SnapshotName": "MyApplication-snapshot-1",
    "SnapshotDescription": "Before code update",
    "Tags": [ { "Key": "Environment", "Value": "prod" } ]
}
```

L'exemple suivant montre la réponse :

```json
{
    "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1",
    "SnapshotStatus": "CREATING",
    "SnapshotOperationId": "a1B2c3D4e5F6",
    "SnapshotOperationStatus": "IN_PROGRESS"
}
```

### Décrire un instantané amélioré
<a name="snapshots-api-examples-describesnapshot"></a>

L'exemple de demande suivant pour [`DescribeSnapshot`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_DescribeSnapshot.html) action renvoie les détails d'un instantané amélioré :

```json
{
    "SnapshotName": "MyApplication-snapshot-1"
}
```

L'exemple suivant montre la réponse :

```json
{
    "SnapshotInfoDetails": {
        "SnapshotName": "MyApplication-snapshot-1",
        "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1",
        "SnapshotDescription": "Before code update",
        "SnapshotStatus": "READY",
        "SnapshotCreationTimestamp": 1767225600,
        "RuntimeEnvironment": "FLINK-1_20",
        "SnapshotSizeInBytes": 104857600,
        "SnapshotEncryptionConfigurationDescription": {
            "KeyType": "AWS_OWNED_KEY"
        },
        "SnapshotInitiator": "USER",
        "SnapshotInitiatorOperation": "CreateSnapshot",
        "SnapshotSourceDescription": {
            "SourceApplicationDescription": {
                "ApplicationName": "MyApplication",
                "ApplicationCreationTimestamp": 1764547200,
                "ApplicationVersionId": 3
            }
        },
        "SnapshotFormat": "CANONICAL"
    }
}
```

### Répertorier les instantanés améliorés d'un compte
<a name="snapshots-api-examples-listsnapshots"></a>

L'exemple de demande suivant pour [`ListSnapshots`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_ListSnapshots.html) action répertorie les instantanés améliorés du compte et de la région.

Tous les champs de filtre sont facultatifs. La demande accepte au plus l'un des champs de filtre suivants : `SourceApplicationName`, `SnapshotInitiator`, `SnapshotInitiatorOperation`, ou `SnapshotStatus`.

```json
{
    "Limit": 50
}
```

L'exemple suivant montre la réponse. Le dernier instantané amélioré vient en premier.

```json
{
    "SnapshotInfoList": [
        {
            "SnapshotName": "SYSTEMSNAPSHOT-STOP-MyApplication-1767312000000",
            "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/SYSTEMSNAPSHOT-STOP-MyApplication-1767312000000",
            "SnapshotStatus": "READY",
            "SnapshotCreationTimestamp": 1767312000,
            "SnapshotInitiator": "SYSTEM",
            "SnapshotInitiatorOperation": "SystemCreateSnapshot",
            "SourceApplicationName": "MyApplication",
            "SnapshotFormat": "CANONICAL"
        },
        {
            "SnapshotName": "MyApplication-snapshot-1",
            "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1",
            "SnapshotStatus": "READY",
            "SnapshotCreationTimestamp": 1767225600,
            "SnapshotInitiator": "USER",
            "SnapshotInitiatorOperation": "CreateSnapshot",
            "SourceApplicationName": "MyApplication",
            "SnapshotFormat": "CANONICAL"
        }
    ]
}
```

### Supprimer un instantané amélioré
<a name="snapshots-api-examples-deletesnapshot"></a>

L'exemple de demande suivant pour [`DeleteSnapshot`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_DeleteSnapshot.html) l'action supprime un instantané amélioré. Copiez le `SnapshotCreationTimestamp` valeur provenant de `DescribeSnapshot` réponse.

```json
{
    "SnapshotName": "MyApplication-snapshot-1",
    "SnapshotCreationTimestamp": 1767225600
}
```

L'exemple suivant montre la réponse :

```json
{
    "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1",
    "SnapshotStatus": "DELETING",
    "SnapshotOperationId": "g7H8i9J0k1L2",
    "SnapshotOperationStatus": "IN_PROGRESS"
}
```

### Importer un instantané amélioré
<a name="snapshots-api-examples-importsnapshot"></a>

L'exemple de demande suivant pour [`ImportSnapshot`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_ImportSnapshot.html) action importe un point de sauvegarde Apache Flink depuis Amazon S3 en tant que nouvel instantané amélioré :

```json
{
    "SnapshotName": "MyApplication-snapshot-imported",
    "ImportSourceConfiguration": {
        "SourceType": "S3",
        "ImportRoleArn": "arn:aws:iam::111122223333:role/MSFSnapshotImportRole",
        "SourceS3PrefixLocation": {
            "BucketARN": "arn:aws:s3:::amzn-s3-demo-bucket",
            "KeyPrefix": "imports/my-app/"
        }
    },
    "DestinationEncryptionConfiguration": {
        "KeyId": "arn:aws:kms:aa-example-1:111122223333:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "KeyType": "CUSTOMER_MANAGED_KEY"
    },
    "SnapshotDescription": "Imported from self-managed Apache Flink",
    "Tags": [ { "Key": "Environment", "Value": "prod" } ]
}
```

L'exemple suivant montre la réponse :

```json
{
    "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-imported",
    "SnapshotStatus": "CREATING",
    "SnapshotOperationId": "m3N4o5P6q7R8",
    "SnapshotOperationStatus": "IN_PROGRESS"
}
```

### Exporter un instantané amélioré
<a name="snapshots-api-examples-exportsnapshot"></a>

L'exemple de demande suivant pour [`ExportSnapshot`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_ExportSnapshot.html) action exporte un instantané amélioré vers un compartiment Amazon S3. `DestinationEncryptionConfiguration` est facultatif. Si vous l'omettez, Managed Service for Apache Flink utilise `AWS_OWNED_KEY`.

```json
{
    "SnapshotName": "MyApplication-snapshot-1",
    "ExportDestinationConfiguration": {
        "DestinationType": "S3",
        "ExportRoleArn": "arn:aws:iam::111122223333:role/MSFSnapshotExportRole",
        "DestinationEncryptionConfiguration": {
            "KeyType": "AWS_OWNED_KEY"
        },
        "DestinationS3PrefixLocation": {
            "BucketARN": "arn:aws:s3:::amzn-s3-demo-bucket",
            "KeyPrefix": "exports/my-app/"
        }
    }
}
```

L'exemple suivant montre la réponse. La réponse n'a pas d'ARN instantané ni d'état de cliché.

```json
{
    "SnapshotOperationId": "s9T0u1V2w3X4",
    "SnapshotOperationStatus": "IN_PROGRESS"
}
```

### Décrire une opération de capture d'écran améliorée
<a name="snapshots-api-examples-describesnapshotoperation"></a>

L'exemple de demande suivant pour [`DescribeSnapshotOperation`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_DescribeSnapshotOperation.html) action renvoie les détails d'une opération d'exportation :

```json
{
    "SnapshotName": "MyApplication-snapshot-1",
    "SnapshotOperationId": "s9T0u1V2w3X4"
}
```

L'exemple suivant montre la réponse à une exportation réussie. Le `ExportedPrefix` Ce champ contient le chemin complet des fichiers exportés.

```json
{
    "SnapshotOperationInfoDetails": {
        "SnapshotOperationId": "s9T0u1V2w3X4",
        "SnapshotOperation": "ExportSnapshot",
        "SnapshotOperationStatus": "SUCCESSFUL",
        "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1",
        "DestinationEncryptionConfigurationDescription": {
            "KeyType": "AWS_OWNED_KEY"
        },
        "SnapshotDestinationLocationDescription": {
            "LocationType": "S3",
            "S3PrefixLocation": {
                "BucketARN": "arn:aws:s3:::amzn-s3-demo-bucket",
                "KeyPrefix": "exports/my-app/",
                "ExportedPrefix": "exports/my-app/s9T0u1V2w3X4/data/"
            }
        },
        "StartTime": 1767229200,
        "EndTime": 1767229800
    }
}
```

L'exemple suivant montre la réponse à un échec d'exportation. La réponse ajoute `SnapshotOperationFailureDetails`. `S3PrefixLocation` comprend également `ExportedPrefix` en cas d'échec de l'exportation.

```json
{
    "SnapshotOperationInfoDetails": {
        "SnapshotOperationId": "y5Z6a7B8c9D0",
        "SnapshotOperation": "ExportSnapshot",
        "SnapshotOperationStatus": "FAILED",
        "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1",
        "DestinationEncryptionConfigurationDescription": {
            "KeyType": "AWS_OWNED_KEY"
        },
        "SnapshotDestinationLocationDescription": {
            "LocationType": "S3",
            "S3PrefixLocation": {
                "BucketARN": "arn:aws:s3:::amzn-s3-demo-bucket",
                "KeyPrefix": "exports/my-app/",
                "ExportedPrefix": "exports/my-app/y5Z6a7B8c9D0/data/"
            }
        },
        "StartTime": 1767232800,
        "EndTime": 1767233100,
        "SnapshotOperationFailureDetails": {
            "ErrorInfo": {
                "ErrorCode": "S3AccessDenied",
                "ErrorString": "..."
            }
        }
    }
}
```

### Répertorier les opérations d'un instantané amélioré
<a name="snapshots-api-examples-listsnapshotoperations"></a>

L'exemple de demande suivant pour [`ListSnapshotOperations`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_ListSnapshotOperations.html) action répertorie les opérations échouées d'un instantané amélioré. La demande accepte au plus l'un des champs de filtre suivants : `SnapshotOperation` ou `SnapshotOperationStatus`.

```json
{
    "SnapshotName": "MyApplication-snapshot-1",
    "SnapshotOperationStatus": "FAILED",
    "Limit": 50
}
```

L'exemple suivant montre la réponse :

```json
{
    "SnapshotOperationInfoList": [
        {
            "SnapshotOperationId": "y5Z6a7B8c9D0",
            "SnapshotOperation": "ExportSnapshot",
            "SnapshotOperationStatus": "FAILED",
            "StartTime": 1767232800,
            "EndTime": 1767233100
        }
    ]
}
```

### Création d'une application en mode instantané amélioré
<a name="snapshots-api-examples-createapplication"></a>

L'exemple de demande suivant pour [`CreateApplication`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_CreateApplication.html) l'action crée une application en mode instantané amélioré. Définissez `SnapshotMode` sur `ENHANCED_SNAPSHOTS`. La demande doit inclure `SnapshotsEnabled`. Set `SnapshotsEnabled` pour `true` pour activer les captures d'écran du système.

```json
{
    "ApplicationName": "MyApplication",
    "RuntimeEnvironment": "FLINK-1_20",
    "ServiceExecutionRole": "arn:aws:iam::111122223333:role/MyApplicationServiceRole",
    "ApplicationConfiguration": {
        "ApplicationCodeConfiguration": {
            "CodeContent": {
                "S3ContentLocation": {
                    "BucketARN": "arn:aws:s3:::amzn-s3-demo-bucket",
                    "FileKey": "my-flink-app.jar"
                }
            },
            "CodeContentType": "ZIPFILE"
        },
        "ApplicationSnapshotConfiguration": {
            "SnapshotsEnabled": true,
            "SnapshotMode": "ENHANCED_SNAPSHOTS"
        }
    }
}
```

### Mettre à niveau une application existante vers le mode instantané amélioré
<a name="snapshots-api-examples-opt-in"></a>

L'exemple de demande suivant pour [`UpdateApplication`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_UpdateApplication.html) action fait passer une application en mode instantané amélioré. La demande doit inclure `SnapshotsEnabledUpdate` conjointement avec `SnapshotModeUpdate`.

**Note**  
Vous ne pouvez pas définir `SnapshotModeUpdate` retour à `APPLICATION_SNAPSHOTS_LEGACY`. Cette demande renvoie `InvalidArgumentException`. Pour revenir aux instantanés de l'application (anciens), appelez `RollbackApplication` lorsque la mise à niveau est toujours la mise à jour la plus récente. Pour plus d’informations, consultez [Mettre à niveau une application existante vers des instantanés améliorés](snapshots-upgrade.md).

```json
{
    "ApplicationName": "MyApplication",
    "CurrentApplicationVersionId": 3,
    "ApplicationConfigurationUpdate": {
        "ApplicationSnapshotConfigurationUpdate": {
            "SnapshotsEnabledUpdate": true,
            "SnapshotModeUpdate": "ENHANCED_SNAPSHOTS"
        }
    }
}
```

### Démarrez une application à partir d'un instantané amélioré
<a name="snapshots-api-examples-startapplication"></a>

L'exemple de demande suivant pour [`StartApplication`](https://docs.aws.amazon.com/managed-service-for-apache-flink/latest/apiv2/API_StartApplication.html) action démarre une application à partir d'un instantané amélioré. Définissez `ApplicationRestoreType` sur `RESTORE_FROM_CUSTOM_SNAPSHOT`. Identifiez l'instantané amélioré avec `SnapshotArn`, pas `SnapshotName`.

```json
{
    "ApplicationName": "MyApplication",
    "RunConfiguration": {
        "ApplicationRestoreConfiguration": {
            "ApplicationRestoreType": "RESTORE_FROM_CUSTOM_SNAPSHOT",
            "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1"
        }
    }
}
```

L'exemple suivant montre la réponse :

```json
{
    "OperationId": "Abc123Def456"
}
```

### Mettre à jour une application et effectuer une restauration à partir d'un instantané amélioré
<a name="snapshots-api-examples-updateapplication-restore"></a>

L'exemple de demande suivant pour `UpdateApplication` l'action restaure une application en cours d'exécution à partir d'un instantané amélioré. La demande doit se trouver dans `RUNNING` statut.

```json
{
    "ApplicationName": "MyApplication",
    "CurrentApplicationVersionId": 4,
    "RunConfigurationUpdate": {
        "ApplicationRestoreConfiguration": {
            "ApplicationRestoreType": "RESTORE_FROM_CUSTOM_SNAPSHOT",
            "SnapshotArn": "arn:aws:kinesisanalytics:aa-example-1:111122223333:snapshot/MyApplication-snapshot-1"
        }
    }
}
```

Pour plus d’informations, consultez [Restaurer une application à partir d'un instantané amélioré](snapshots-restore.md).