Пример #1
0
        public static ListCommandsResponse Unmarshall(UnmarshallerContext context)
        {
            ListCommandsResponse listCommandsResponse = new ListCommandsResponse();

            listCommandsResponse.HttpResponse = context.HttpResponse;
            listCommandsResponse.RequestId    = context.StringValue("ListCommands.RequestId");
            listCommandsResponse.TotalCount   = context.IntegerValue("ListCommands.TotalCount");
            listCommandsResponse.PageNumber   = context.IntegerValue("ListCommands.PageNumber");
            listCommandsResponse.PageSize     = context.IntegerValue("ListCommands.PageSize");

            List <ListCommandsResponse.ListCommands_Command> listCommandsResponse_commands = new List <ListCommandsResponse.ListCommands_Command>();

            for (int i = 0; i < context.Length("ListCommands.Commands.Length"); i++)
            {
                ListCommandsResponse.ListCommands_Command command = new ListCommandsResponse.ListCommands_Command();
                command.CommandId      = context.StringValue("ListCommands.Commands[" + i + "].CommandId");
                command.CommandContent = context.StringValue("ListCommands.Commands[" + i + "].CommandContent");
                command.WorkingDir     = context.StringValue("ListCommands.Commands[" + i + "].WorkingDir");
                command.Timeout        = context.StringValue("ListCommands.Commands[" + i + "].Timeout");

                listCommandsResponse_commands.Add(command);
            }
            listCommandsResponse.Commands = listCommandsResponse_commands;

            return(listCommandsResponse);
        }
Пример #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)
        {
            ListCommandsResponse response = new ListCommandsResponse();

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

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

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

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

            ListCommandsResponse resp = new ListCommandsResponse();

            do
            {
                ListCommandsRequest req = new ListCommandsRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

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

                foreach (var obj in resp.Commands)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }