Пример #1
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)
        {
            ListPublicKeysResponse response = new ListPublicKeysResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("PublicKeyList", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <PublicKey, PublicKeyUnmarshaller>(PublicKeyUnmarshaller.Instance);
                    response.PublicKeyList = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonCloudTrailConfig config = new AmazonCloudTrailConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonCloudTrailClient client = new AmazonCloudTrailClient(creds, config);

            ListPublicKeysResponse resp = new ListPublicKeysResponse();

            do
            {
                ListPublicKeysRequest req = new ListPublicKeysRequest
                {
                    NextToken = resp.NextToken
                };

                resp = client.ListPublicKeys(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.PublicKeyList)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            ListPublicKeysResponse response = new ListPublicKeysResponse();

            UnmarshallResult(context, response);

            return(response);
        }
        public static ListPublicKeysResponse Unmarshall(UnmarshallerContext context)
        {
            ListPublicKeysResponse listPublicKeysResponse = new ListPublicKeysResponse();

            listPublicKeysResponse.HttpResponse = context.HttpResponse;
            listPublicKeysResponse.RequestId    = context.StringValue("ListPublicKeys.RequestId");

            List <ListPublicKeysResponse.ListPublicKeys_PublicKey> listPublicKeysResponse_publicKeys = new List <ListPublicKeysResponse.ListPublicKeys_PublicKey>();

            for (int i = 0; i < context.Length("ListPublicKeys.PublicKeys.Length"); i++)
            {
                ListPublicKeysResponse.ListPublicKeys_PublicKey publicKey = new ListPublicKeysResponse.ListPublicKeys_PublicKey();
                publicKey.PublicKeyId = context.StringValue("ListPublicKeys.PublicKeys[" + i + "].PublicKeyId");
                publicKey.Status      = context.StringValue("ListPublicKeys.PublicKeys[" + i + "].Status");
                publicKey.CreateDate  = context.StringValue("ListPublicKeys.PublicKeys[" + i + "].CreateDate");

                listPublicKeysResponse_publicKeys.Add(publicKey);
            }
            listPublicKeysResponse.PublicKeys = listPublicKeysResponse_publicKeys;

            return(listPublicKeysResponse);
        }
        private static void UnmarshallResult(XmlUnmarshallerContext context, ListPublicKeysResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("PublicKeyList", targetDepth))
                    {
                        var unmarshaller = PublicKeyListUnmarshaller.Instance;
                        response.PublicKeyList = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }

            return;
        }