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

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

            ListDirectoriesResponse resp = new ListDirectoriesResponse();

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

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

                foreach (var obj in resp.Directories)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Ejemplo n.º 2
0
        public void TestAttributes()
        {
            using (var servlet = new ResponseTestServlet())
            {
                servlet.Response = ListObjectAttributesResponse;

                var config = new AmazonCloudDirectoryConfig {
                    ServiceURL = servlet.ServiceURL
                };
                using (var client = new AmazonCloudDirectoryClient(config))
                {
                    var response = client.ListObjectAttributes(new ListObjectAttributesRequest());

                    var attribute = response.Attributes.SingleOrDefault();
                    Assert.IsNotNull(attribute);

                    var key = attribute.Key;
                    Assert.IsNotNull(key);

                    Assert.AreEqual("Person", key.FacetName);
                    Assert.AreEqual("username", key.Name);
                    Assert.AreEqual("arn:aws:clouddirectory:us-east-1:123456789012:directory/AQPCHP0oaUPOoPHKMr1kMTs/schema/person/1", key.SchemaArn);

                    var value = attribute.Value;
                    Assert.IsNotNull(value);

                    Assert.IsNull(value.BinaryValue);
                    Assert.IsFalse(value.BooleanValue);
                    Assert.AreEqual(default(DateTime), value.DatetimeValue);
                    Assert.IsNull(value.NumberValue);
                    Assert.AreEqual("bob", value.StringValue);
                }
            }
        }
Ejemplo n.º 3
0
        public void Test()
        {
            var cdc = new AmazonCloudDirectoryConfig()
            {
                RegionEndpoint = RegionEndpoint.APSoutheast2
            };
            AmazonCloudDirectoryClient c = new AmazonCloudDirectoryClient(cred, cdc);



            //Enumerable.Range(0, 10000)
            //    .ToList().AsParallel()
            //    .ForAll(s =>
            //    {
            //        try
            //        {
            //            CloudDirectoryAPI.Delete(c, directoryARN, ItemName + s.ToString()).Wait();
            //        }
            //        catch (Exception e)
            //        {
            //        }

            //    });

            Console.WriteLine("starting 10k write test");
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            CloudDirectoryAPI.CreateBatch(c, schemaARN, directoryARN, facetName).Wait();
            stopwatch.Stop();
            Console.WriteLine($"write 10k in {stopwatch.Elapsed.TotalMilliseconds} MS");

            CloudDirectoryAPI.Delete(c, directoryARN, ItemName).Wait();

            var p1 = CloudDirectoryAPI.Create(c, schemaARN, directoryARN, facetName, ItemName).Result;

            stopwatch = new Stopwatch();

            stopwatch.Start();
            var p2 = CloudDirectoryAPI.Read(c, schemaARN, directoryARN, facetName, ItemName).Result;

            stopwatch.Stop();

            Console.WriteLine($"read 1 in {stopwatch.Elapsed.TotalMilliseconds} MS");

            stopwatch = new Stopwatch();
            stopwatch.Start();
            p2 = CloudDirectoryAPI.Read(c, schemaARN, directoryARN, facetName, ItemName).Result;
            stopwatch.Stop();

            Console.WriteLine($"read 2 in {stopwatch.Elapsed.TotalMilliseconds} MS");

            Assert.AreEqual(p1.username, p2.username);
            Assert.AreEqual(p1.website, p2.website);
        }
        protected IAmazonCloudDirectory CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonCloudDirectoryConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonCloudDirectoryClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }