Beispiel #1
0
        private async Task <bool> CheckIfLedgerExistsAsync()
        {
            Console.WriteLine("Checking if ledger exists.");
            ListLedgersResponse response = await qldbClient.ListLedgersAsync(new ListLedgersRequest());

            return(response.Ledgers != null && response.Ledgers.Any(x => x.Name == LedgerName));
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListLedgersResponse response = new ListLedgersResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Ledgers", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <LedgerSummary, LedgerSummaryUnmarshaller>(LedgerSummaryUnmarshaller.Instance);
                    response.Ledgers = 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)
        {
            AmazonQLDBConfig config = new AmazonQLDBConfig();

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

            ListLedgersResponse resp = new ListLedgersResponse();

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

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

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