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

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

            ListPhoneNumbersResponse resp = new ListPhoneNumbersResponse();

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

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

                foreach (var obj in resp.PhoneNumbers)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Example #2
0
        public void BearerTokenAccessTest()
        {
            var provider = new BearerTokenCredentialProvider(FeatureTest.BearerToken);

            var profile = DefaultProfile.GetProfile("cn-hangzhou");
            var client  = new DefaultAcsClient(profile, provider);

            var request = new ListPhoneNumbersRequest();

            var exception = Assert.Throws <ClientException>(() =>
            {
                var response = client.GetAcsResponse(request);
            });

            Assert.Equal("InvalidBearerToken.Inactive", exception.ErrorCode);
        }
        public void BearerTokenAccessTest()
        {
            BearerTokenCredential bearerTokenCredential = new BearerTokenCredential(GetBearerToken());

            base.profile = DefaultProfile.GetProfile("cn-hangzhou");
            client       = new Acs.Core.DefaultAcsClient(base.profile, bearerTokenCredential);

            ListPhoneNumbersRequest request = new ListPhoneNumbersRequest();

            var exception = Assert.Throws <ClientException>(() =>
            {
                var response = client.GetAcsResponse(request);
            });

            Assert.Equal("InvalidBearerToken.Inactive", exception.ErrorCode);
        }