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

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

            ListEmailIdentitiesResponse resp = new ListEmailIdentitiesResponse();

            do
            {
                ListEmailIdentitiesRequest req = new ListEmailIdentitiesRequest
                {
                    NextToken = resp.NextToken
                    ,
                    PageSize = maxItems
                };

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

                foreach (var obj in resp.EmailIdentities)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        protected IAmazonSimpleEmailServiceV2 CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonSimpleEmailServiceV2Config {
                RegionEndpoint = region
            };

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

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
Example #3
0
        public void AddAWSSimpleEmailService(IServiceCollection services, AWSConfigs options)
        {
            var config = new AmazonSimpleEmailServiceV2Config();

            if (options.Region != null)
            {
                config.RegionEndpoint = options.Region;
            }
            else
            {
                config.ServiceURL = options.DefaultClientConfig.ServiceURL;
            }

            if (!string.IsNullOrEmpty(options.Profile))
            {
                var chain = new CredentialProfileStoreChain(options.ProfilesLocation);
                chain.TryGetAWSCredentials(options.Profile, out AWSCredentials awsCredential);

                var client = new AmazonSimpleEmailServiceV2Client(awsCredential, config);

                services.AddSingleton <IAmazonSimpleEmailServiceV2>(se =>
                {
                    return(client);
                });
            }
            else
            {
                var client = new AmazonSimpleEmailServiceV2Client(config.AccessKey,
                                                                  config.SerectKey,
                                                                  config);

                services.AddSingleton <IAmazonSimpleEmailServiceV2>(se =>
                {
                    return(client);
                });
            }
        }