/**
         * Creates a point in time snapshot of a file system and waits for it to become available. Note that snapshot
         * names are immutable and must be unique amongst all non-DELETED snapshots for a file system.
         *
         * We recommend using a retry token on these requests so that if you receive a timeout or server error
         * and need to retry the request you won't run the risk of creating multiple resources.
         *
         * @param fsClient the service client used to communicate with the File Storage service
         * @param fileSystem the file system to create the snapshot of
         */
        private static async Task <Snapshot> CreateSnapshot(FileStorageClient fsClient, FileSystem fileSystem)
        {
            logger.Info("Creating Snapshot...");

            CreateSnapshotDetails createSnapshotDetails = new CreateSnapshotDetails
            {
                FileSystemId = fileSystem.Id,
                Name         = "example_snapshot"
            };
            CreateSnapshotRequest createRequest = new CreateSnapshotRequest
            {
                CreateSnapshotDetails = createSnapshotDetails
            };
            CreateSnapshotResponse createResponse = await fsClient.CreateSnapshot(createRequest);

            logger.Info($"Created snapshot: {createResponse.Snapshot.Name}");

            logger.Info($"Waiting for snapshot to become available");
            GetSnapshotRequest getRequest = new GetSnapshotRequest
            {
                SnapshotId = createResponse.Snapshot.Id
            };
            GetSnapshotResponse getResponse = fsClient.Waiters.ForSnapshot(getRequest, Snapshot.LifecycleStateEnum.Active).Execute();

            logger.Info($"Snapshot state: {getResponse.Snapshot.LifecycleState}");

            return(getResponse.Snapshot);
        }
Example #2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetSnapshotResponse response = new GetSnapshotResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Snapshot", targetDepth))
                {
                    var unmarshaller = SnapshotDetailsUnmarshaller.Instance;
                    response.Snapshot = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }