Пример #1
0
        public static bool checkVault(string vaultName)
        {
            bool result = false;

            try
            {
                client = new AmazonGlacierClient(Amazon.RegionEndpoint.USEast1);

                DescribeVaultRequest describeVaultRequest = new DescribeVaultRequest()
                {
                    VaultName = vaultName
                };
                DescribeVaultResponse describeVaultResponse = client.DescribeVault(describeVaultRequest);
                DescribeVaultResult   describeVaultResult   = describeVaultResponse.DescribeVaultResult;
                Console.WriteLine("\nVault description...");
                Console.WriteLine(
                    "\nVaultName: " + describeVaultResult.VaultName +
                    "\nVaultARN: " + describeVaultResult.VaultARN +
                    "\nVaultCreationDate: " + describeVaultResult.CreationDate +
                    "\nNumberOfArchives: " + describeVaultResult.NumberOfArchives +
                    "\nSizeInBytes: " + describeVaultResult.SizeInBytes +
                    "\nLastInventoryDate: " + describeVaultResult.LastInventoryDate
                    );
                result = true;
            }
            catch (AmazonGlacierException e)
            { Console.WriteLine(e.Message); result = false; }
            catch (AmazonServiceException e)
            { Console.WriteLine(e.Message); result = false; }
            catch (Exception e)
            { Console.WriteLine(e.Message); result = false; }

            return(result);
        }
Пример #2
0
        private static void UnmarshallResult(JsonUnmarshallerContext context, DescribeVaultResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("VaultARN", targetDepth))
                {
                    context.Read();
                    response.VaultARN = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("VaultName", targetDepth))
                {
                    context.Read();
                    response.VaultName = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("CreationDate", targetDepth))
                {
                    context.Read();
                    response.CreationDate = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("LastInventoryDate", targetDepth))
                {
                    context.Read();
                    response.LastInventoryDate = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("NumberOfArchives", targetDepth))
                {
                    context.Read();
                    response.NumberOfArchives = LongUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("SizeInBytes", targetDepth))
                {
                    context.Read();
                    response.SizeInBytes = LongUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }
Пример #3
0
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeVaultResponse response = new DescribeVaultResponse();

            context.Read();

            UnmarshallResult(context, response);
            return(response);
        }
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeVaultResponse response = new DescribeVaultResponse();

            context.Read();

            response.DescribeVaultResult = DescribeVaultResultUnmarshaller.GetInstance().Unmarshall(context);

            return(response);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeVaultResponse response = new DescribeVaultResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("CreationDate", targetDepth))
                {
                    var unmarshaller = Amazon.Runtime.Internal.Transform.DateTimeUnmarshaller.Instance;
                    response.CreationDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastInventoryDate", targetDepth))
                {
                    var unmarshaller = Amazon.Runtime.Internal.Transform.DateTimeUnmarshaller.Instance;
                    response.LastInventoryDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NumberOfArchives", targetDepth))
                {
                    var unmarshaller = LongUnmarshaller.Instance;
                    response.NumberOfArchives = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("SizeInBytes", targetDepth))
                {
                    var unmarshaller = LongUnmarshaller.Instance;
                    response.SizeInBytes = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("VaultARN", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.VaultARN = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("VaultName", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.VaultName = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Пример #6
0
        public void DescribeVault()
        {
            var settings = SettingsManager.GetSettings();
            DescribeVaultRequest describeVaultRequest = new DescribeVaultRequest()
            {
                VaultName = settings.AWSGlacierVault
            };
            var client = new AmazonGlacierClient(
                settings.AWSAccessKeyID,
                settings.AWSSecretAccessKey,
                RegionEndpoint.GetBySystemName(settings.AWSS3Region.SystemName));

            DescribeVaultResponse describeVaultResponse = client.DescribeVault(describeVaultRequest);

            Debug.WriteLine("\nVault description...");
            Debug.WriteLine(
                "\nVaultName: " + describeVaultResponse.VaultName +
                "\nVaultARN: " + describeVaultResponse.VaultARN +
                "\nVaultCreationDate: " + describeVaultResponse.CreationDate +
                "\nNumberOfArchives: " + describeVaultResponse.NumberOfArchives +
                "\nSizeInBytes: " + describeVaultResponse.SizeInBytes +
                "\nLastInventoryDate: " + describeVaultResponse.LastInventoryDate
                );
        }