public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonSimpleWorkflowConfig config = new AmazonSimpleWorkflowConfig();

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

            DomainInfos resp = new DomainInfos();

            do
            {
                ListDomainsRequest req = new ListDomainsRequest
                {
                    NextPageToken = resp.NextPageToken
                    ,
                    MaximumPageSize = maxItems
                };

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

                foreach (var obj in resp.DomainInfos)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextPageToken));
        }
Esempio n. 2
0
        public static string GetServiceOutput()
        {
            var sb = new StringBuilder(1024);

            using (var sr = new StringWriter(sb))
            {
                sr.WriteLine("===============================");
                sr.WriteLine("| AWS Simple Workflow Service |");
                sr.WriteLine("===============================");

                try
                {
                    // Print the available domains, workflows and activities. Region endpoint depends on where
                    // you chose to set up your workflow domain
                    var swfClient = new AmazonSimpleWorkflowClient(RegionEndpoint.USWest2);

                    sr.WriteLine();
                    var listDomainRequest = new ListDomainsRequest
                    {
                        RegistrationStatus = "REGISTERED"
                    };

                    var listDomainResponse = swfClient.ListDomains(listDomainRequest);
                    foreach (var domain in listDomainResponse.DomainInfos.Infos)
                    {
                        sr.WriteLine("[" + domain.Name + "]");
                        sr.WriteLine("status: " + domain.Status);
                        sr.WriteLine("description: " + domain.Description);

                        sr.WriteLine("\n  WORKFLOWS");
                        var listWorkflowRequest = new ListWorkflowTypesRequest
                        {
                            Domain             = domain.Name,
                            RegistrationStatus = "REGISTERED"
                        };
                        var listWorkflowTypesResponse = swfClient.ListWorkflowTypes(listWorkflowRequest);
                        foreach (
                            var workflow in
                            listWorkflowTypesResponse.WorkflowTypeInfos.TypeInfos)
                        {
                            sr.WriteLine("  [" + workflow.WorkflowType.Name + "] (" + workflow.WorkflowType.Version + ") " + workflow.Status);
                            sr.WriteLine("  creation: " + workflow.CreationDate);
                            sr.WriteLine("  deprecation: " + workflow.DeprecationDate);
                            sr.WriteLine("  description:" + TrimStringToLength(workflow.Description, 60, "", "              "));
                            sr.WriteLine();
                        }

                        sr.WriteLine("\n  ACTIVITIES");
                        var listActivityRequest = new ListActivityTypesRequest
                        {
                            Domain             = domain.Name,
                            RegistrationStatus = "REGISTERED"
                        };
                        var listActivityResponse = swfClient.ListActivityTypes(listActivityRequest);
                        foreach (
                            var activity in listActivityResponse.ActivityTypeInfos.TypeInfos)
                        {
                            sr.WriteLine("  [" + activity.ActivityType.Name + "] (" + activity.ActivityType.Version + ") " + activity.Status);
                            sr.WriteLine("  creation: " + activity.CreationDate);
                            sr.WriteLine("  deprecation: " + activity.DeprecationDate);
                            sr.WriteLine("  description:" + TrimStringToLength(activity.Description, 60, "", "              "));
                            sr.WriteLine();
                        }
                    }
                }
                catch (AmazonSimpleWorkflowException ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon SWF.");
                        sr.WriteLine("You can sign up for Amazon SWF at http://aws.amazon.com/swf");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("Data: " + ex.Data);
                        sr.WriteLine("Stacktrace: " + ex.StackTrace);
                    }
                }
                sr.WriteLine();
            }
            return(sb.ToString());
        }