• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Runtime.AWSCredentials类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Amazon.Runtime.AWSCredentials的典型用法代码示例。如果您正苦于以下问题:C# AWSCredentials类的具体用法?C# AWSCredentials怎么用?C# AWSCredentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AWSCredentials类属于Amazon.Runtime命名空间,在下文中一共展示了AWSCredentials类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GeneratePresignedUrl

        /// <summary>
        /// Generate a presigned URL based on a <see cref="SynthesizeSpeechRequest"/>.
        /// </summary>
        /// <param name="credentials">The credentials to use in the presigned URL.</param>
        /// <param name="region">The region for the URL.</param>
        /// <param name="request">The request to base the presigned URL on.</param>
        /// <returns></returns>
        public static string GeneratePresignedUrl(AWSCredentials credentials, RegionEndpoint region, SynthesizeSpeechRequest request)
        {
            if (credentials == null)
                throw new ArgumentNullException("credentials");

            if (region == null)
                throw new ArgumentNullException("region");

            if (request == null)
                throw new ArgumentNullException("request");

            // Marshall this request and prepare it to be signed
            var marshaller = new SynthesizeSpeechRequestMarshaller();
            var iRequest = marshaller.Marshall(request);
            iRequest.UseQueryString = true;
            iRequest.HttpMethod = HTTPGet;
            iRequest.Endpoint = new UriBuilder(HTTPS, region.GetEndpointForService(PollyServiceName).Hostname).Uri;
            iRequest.Parameters[XAmzExpires] = ((int)FifteenMinutes.TotalSeconds).ToString(CultureInfo.InvariantCulture);

            if (request.IsSetLexiconNames())
            {
                var sortedLexiconNames = new List<string>(request.LexiconNames);
                sortedLexiconNames.Sort(StringComparer.Ordinal);
                iRequest.Parameters[LexiconNamesParameter] = JsonMapper.ToJson(sortedLexiconNames);
            }

            if (request.IsSetOutputFormat())
                iRequest.Parameters["OutputFormat"] = request.OutputFormat.ToString();

            if (request.IsSetSampleRate())
                iRequest.Parameters["SampleRate"] = request.SampleRate.ToString();

            if (request.IsSetText())
                iRequest.Parameters["Text"] = request.Text;

            if (request.IsSetTextType())
                iRequest.Parameters["TextType"] = request.TextType.ToString();

            if (request.IsSetVoiceId())
                iRequest.Parameters["VoiceId"] = request.VoiceId;

            var immutableCredentials = credentials.GetCredentials();
            if (immutableCredentials.UseToken)
            {
                // Don't use HeaderKeys.XAmzSecurityTokenHeader because Polly treats this as case-sensitive
                iRequest.Parameters["X-Amz-Security-Token"] = immutableCredentials.Token;
            }

            // Only the host header should be signed, and the signer adds that.
            // So clear out headers.
            iRequest.Headers.Clear();

            // Create presigned URL and assign it
            var signingResult = SynthesizeSpeechPresignedUrlSigner.SignSynthesizeSpeechRequest(iRequest, new RequestMetrics(),
                immutableCredentials.AccessKey, immutableCredentials.SecretKey, PollyServiceName, region.SystemName);

            var authorization = "&" + signingResult.ForQueryParameters;

            return ComposeUrl(iRequest).AbsoluteUri + authorization;
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:67,代码来源:SynthesizeSpeechUtil.cs


示例2: DeliveryClient

        /// <summary>
        /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.DeliveryClient"/> class.
        /// </summary>
        /// <param name="policyFactory">An instance of IDeliveryPolicyFactory. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IDeliveryPolicyFactory"/></param>
        /// <param name="maConfig">Mobile Analytics Manager configuration. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManagerConfig"/></param>
        /// <param name="clientContext">An instance of ClientContext. <see cref="Amazon.Runtime.Internal.ClientContext"/></param>
        /// <param name="credentials">An instance of Credentials. <see cref="Amazon.Runtime.AWSCredentials"/></param>
        /// <param name="regionEndPoint">Region endpoint. <see cref="Amazon.RegionEndpoint"/></param>
        public DeliveryClient(IDeliveryPolicyFactory policyFactory, MobileAnalyticsManagerConfig maConfig, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint)
        {
            _policyFactory = policyFactory;
            _deliveryPolicies = new List<IDeliveryPolicy>();
            _deliveryPolicies.Add(_policyFactory.NewConnectivityPolicy());

            _clientContext = clientContext;
            _appID = clientContext.AppID;
            _maConfig = maConfig;
            _eventStore = new SQLiteEventStore(maConfig);

#if PCL
            _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint);
#elif BCL
            if (null == credentials && null == regionEndPoint)
            {
                _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient();
            }
            else if (null == credentials)
            {
                _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(regionEndPoint);
            }
            else if (null == regionEndPoint)
            {
                _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials);
            }
            else
            {
                _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint);
            }
#endif
        }
开发者ID:yeurch,项目名称:aws-sdk-net,代码行数:40,代码来源:DeliveryClient.cs


示例3: IntegrationAwsClientFactory

 public IntegrationAwsClientFactory()
 {
     var ci = System.Environment.GetEnvironmentVariable(_ci);
     if (string.IsNullOrWhiteSpace(ci))
         this._credentials = new StoredProfileAWSCredentials(IntegrationTestConfig.AwsProfileName);
     else
         _credentials = CredentialsFromEnvironment();
 }
开发者ID:denizkocak,项目名称:JustSaying,代码行数:8,代码来源:IntegrationAwsClientFactory.cs


示例4: S3ClientCache

        internal S3ClientCache(AWSCredentials credentials, AmazonS3Config config)
        {
            this.credentials = credentials;
            this.config = config;

            this.clientsByRegion = new Dictionary<string,AmazonS3Client>(StringComparer.OrdinalIgnoreCase);
            this.transferUtilitiesByRegion = new Dictionary<string,TransferUtility>(StringComparer.OrdinalIgnoreCase);
        }
开发者ID:rossmas,项目名称:aws-sdk-net,代码行数:8,代码来源:S3ClientCache.cs


示例5: GetOrCreateInstance

        /// <summary>
        /// Gets or creates Mobile Analytics Manager instance. If the instance already exists, returns the instance; otherwise
        /// creates new instance and returns it.
        /// </summary>
        /// <param name="appID">Amazon Mobile Analytics Application ID.</param>
        /// <param name="credentials">AWS Credentials.</param>
        /// <returns>Mobile Analytics Manager instance. </returns>
        public static MobileAnalyticsManager GetOrCreateInstance(string appID, AWSCredentials credentials)
        {
            if (string.IsNullOrEmpty(appID))
                throw new ArgumentNullException("appID");
            if (null == credentials)
                throw new ArgumentNullException("credentials");

            return GetOrCreateInstanceHelper(appID, credentials, null, null);
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:16,代码来源:MobileAnalyticsManager.bcl.cs


示例6: WriteToQueue

        static void WriteToQueue(AWSCredentials credentials)
        {
            AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);

            string message = "my message";
            string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk";

            SendMessageResponse sendMessageResponse = client.SendMessage(queueUrl, message);
        }
开发者ID:modulexcite,项目名称:2015-Slides-and-Demos,代码行数:9,代码来源:Program.cs


示例7: GetOrCreateInstance

        public static MobileAnalyticsManager GetOrCreateInstance(AWSCredentials credential,
                                                                 string appId)
        {
            if (credential == null)
                throw new ArgumentNullException("credential");
            if (string.IsNullOrEmpty(appId))
                throw new ArgumentNullException("appId");

            return MobileAnalyticsManager.GetOrCreateInstanceHelper(appId, credential, null);
        }
开发者ID:NathanSDunn,项目名称:aws-sdk-unity-samples,代码行数:10,代码来源:MobileAnalyticsManager.unity.cs


示例8: GetOrCreateInstance

        /// <summary>
        /// Gets the or creates Mobile Analytics Manager instance. If the instance already exists, returns the instance; otherwise
        /// creates new instance and returns it.
        /// </summary>
        /// <returns>Mobile Analytics Manager instance.</returns>
        /// <param name="credentials">AWS Credentials.</param>
        /// <param name="appId">Amazon Mobile Analytics Application ID.</param>
        public static MobileAnalyticsManager GetOrCreateInstance(AWSCredentials credential,
                                                                         string appId)
        {
            if (credential == null)
                throw new ArgumentNullException("credential");
            if (string.IsNullOrEmpty(appId))
                throw new ArgumentNullException("appId");

            ClientContextConfig config = new ClientContextConfig(appId);
            return MobileAnalyticsManager.GetOrCreateInstance(credential, null, config);
        }
开发者ID:paveltimofeev,项目名称:aws-sdk-unity,代码行数:18,代码来源:MobileAnalyticsManager.cs


示例9: DeliveryClient

 /// <summary>
 /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.DeliveryClient"/> class.
 /// </summary>
 /// <param name="isDataAllowed">An instance of IDeliveryPolicyFactory <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IDeliveryPolicyFactory"/></param>
 /// <param name="clientContext">An instance of ClientContext <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.ClientContext"/></param>
 /// <param name="credentials">An instance of Credentials <see cref="Amazon.Runtime.AWSCredentials"/></param>
 /// <param name="regionEndPoint">Region end point <see cref="Amazon.RegionEndpoint"/></param>
 public DeliveryClient(IDeliveryPolicyFactory policyFactory, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint)
 {
     _policyFactory = policyFactory;
     _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint);
     _clientContext = clientContext;
     _appId = clientContext.Config.AppId;
     _eventStore = new SQLiteEventStore(AWSConfigsMobileAnalytics.MaxDBSize, AWSConfigsMobileAnalytics.DBWarningThreshold);
     _deliveryPolicies = new List<IDeliveryPolicy>();
     _deliveryPolicies.Add(_policyFactory.NewConnectivityPolicy());
     _deliveryPolicies.Add(_policyFactory.NewBackgroundSubmissionPolicy());
 }
开发者ID:johnryork,项目名称:aws-sdk-unity,代码行数:18,代码来源:DeliveryClient.cs


示例10: DeleteImageArtifacts

 /// <summary>
 /// Deletes the image file artifacts associated with the specified conversion task.
 /// If the task is still active, ignoreActiveTask must be set true to enable artifact
 /// deletion, which will cause the task to fail. Use this option at your own risk.
 /// </summary>
 /// <param name="awsCredentials">
 /// Credentials to use to instantiate the Amazon EC2 and Amazon S3 clients needed to
 /// complete the operation.
 /// </param>
 /// <param name="region">
 /// The region containing the bucket where the image file artifacts were stored
 /// </param>
 /// <param name="conversionTaskId">
 /// The ID of the conversion task that used the image file
 /// </param>
 /// <param name="ignoreActiveTask">
 /// If true the artifacts are deleted even if the conversion task is still in progress
 /// </param>
 /// <param name="progressCallback">Optional progress callback</param>
 public static void DeleteImageArtifacts(AWSCredentials awsCredentials, 
                                         RegionEndpoint region, 
                                         string conversionTaskId, 
                                         bool ignoreActiveTask,
                                         CleanupProgressCallback progressCallback)
 {
     DeleteImageArtifacts(new AmazonEC2Client(awsCredentials, region), 
                          new AmazonS3Client(awsCredentials, region), 
                          conversionTaskId, 
                          ignoreActiveTask,
                          progressCallback);                        
 }
开发者ID:wmatveyenko,项目名称:aws-sdk-net,代码行数:31,代码来源:ImportCleanup.cs


示例11: AwsClient

        public AwsClient(AWSCredentials credentials, IStackItConfiguration configuration)
        {
            _credentials = credentials;

            _cloudFormationClient = new Lazy<IAmazonCloudFormation>(() => AWSClientFactory.CreateAmazonCloudFormationClient(_credentials));
            _ec2Client = new Lazy<IAmazonEC2>(() => AWSClientFactory.CreateAmazonEC2Client(_credentials));
            _route53Client = new Lazy<IAmazonRoute53>(() => AWSClientFactory.CreateAmazonRoute53Client(_credentials));
            _s3Client = new Lazy<IAmazonS3>(() => AWSClientFactory.CreateAmazonS3Client(_credentials));
            _iamClient = new Lazy<IAmazonIdentityManagementService>(() => AWSClientFactory.CreateAmazonIdentityManagementServiceClient(_credentials));

            _configuration = configuration;
        }
开发者ID:nelsonwellswku,项目名称:stack-it-net,代码行数:12,代码来源:AwsClient.cs


示例12: GetOrCreateInstance

        /// <summary>
        /// Gets or creates Mobile Analytics Manager instance. If the instance already exists, returns the instance; otherwise
        /// creates new instance and returns it.
        /// </summary>
        /// <param name="appID">Amazon Mobile Analytics Application ID.</param>
        /// <param name="credentials">AWS Credentials.</param>
        /// <param name="regionEndpoint">Region endpoint.</param>
        /// <returns>Mobile Analytics Manager instance.</returns>
        public static MobileAnalyticsManager GetOrCreateInstance(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint)
        {
            if (string.IsNullOrEmpty(appID))
                throw new ArgumentNullException("appID");
            if (null == credentials)
                throw new ArgumentNullException("credentials");
            if (null == regionEndpoint)
                throw new ArgumentNullException("regionEndpoint");

            MobileAnalyticsManagerConfig maConfig = new MobileAnalyticsManagerConfig();
            return GetOrCreateInstanceHelper(appID, credentials, regionEndpoint, maConfig);
        }
开发者ID:praveenpadamati,项目名称:aws-sdk-net,代码行数:20,代码来源:MobileAnalyticsManager.cs


示例13: DeleteImageArtifacts

 /// <summary>
 /// Deletes the image file artifacts associated with the specified conversion task.
 /// If the task is still active, ignoreActiveTask must be set true to enable artifact
 /// deletion, which will cause the task to fail. Use this option at your own risk.
 /// </summary>
 /// <param name="awsCredentials">
 /// Credentials to use to instantiate the Amazon EC2 and Amazon S3 clients needed to
 /// complete the operation.
 /// </param>
 /// <param name="region">
 /// The region containing the bucket where the image file artifacts were stored
 /// </param>
 /// <param name="conversionTaskId">
 /// The ID of the conversion task that used the image file
 /// </param>
 /// <param name="ignoreActiveTask">
 /// If true the artifacts are deleted even if the conversion task is still in progress
 /// </param>
 /// <param name="progressCallback">Optional progress callback</param>
 public static void DeleteImageArtifacts(AWSCredentials awsCredentials, 
                                         RegionEndpoint region, 
                                         string conversionTaskId, 
                                         bool ignoreActiveTask,
                                         CleanupProgressCallback progressCallback)
 {
     DeleteImageArtifacts(new AmazonEC2Client(awsCredentials, region),
                          ServiceClientHelpers.CreateServiceFromAssembly<ICoreAmazonS3>(ServiceClientHelpers.S3_ASSEMBLY_NAME, ServiceClientHelpers.S3_SERVICE_CLASS_NAME, awsCredentials, region),
                          conversionTaskId, 
                          ignoreActiveTask,
                          progressCallback);                        
 }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:31,代码来源:ImportCleanup.cs


示例14: DeliveryClient

 /// <summary>
 /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.DeliveryClient"/> class.
 /// </summary>
 /// <param name="policyFactory">An instance of IDeliveryPolicyFactory <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IDeliveryPolicyFactory"/></param>
 /// <param name="maConfig"></param>
 /// <param name="maManager"></param>
 /// <param name="clientContext">An instance of ClientContext <see cref="Amazon.Runtime.Internal.ClientContext"/></param>
 /// <param name="credentials">An instance of Credentials <see cref="Amazon.Runtime.AWSCredentials"/></param>
 /// <param name="regionEndPoint">Region end point <see cref="Amazon.RegionEndpoint"/></param>
 public DeliveryClient(IDeliveryPolicyFactory policyFactory, MobileAnalyticsManagerConfig maConfig, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint, MobileAnalyticsManager maManager)
 {
     _policyFactory = policyFactory;
     _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint);
     _clientContext = clientContext;
     _appID = clientContext.AppID;
     _maConfig = maConfig;
     _maManager = maManager;
     _eventStore = new SQLiteEventStore(maConfig);
     _deliveryPolicies = new List<IDeliveryPolicy>();
     _deliveryPolicies.Add(_policyFactory.NewConnectivityPolicy());
 }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:21,代码来源:DeliveryClient.unity.cs


示例15: AwsClient

        public AwsClient()
        {
            this.key = ConfigurationManager.AppSettings["AWSKey"];
            this.secret = ConfigurationManager.AppSettings["AWSSecret"];

            if (string.IsNullOrEmpty(this.key))
                throw new ArgumentNullException("key", "Missing AWSKey appSettings entry.");

            if (string.IsNullOrEmpty(this.secret))
                throw new ArgumentNullException("secret", "Missing AWSSecret appSettings entry.");

            this.credentials = new BasicAWSCredentials(this.key, this.secret);
        }
开发者ID:koushikajay,项目名称:Alfred,代码行数:13,代码来源:AwsClient.cs


示例16: GetApi

        public static AmazonS3Client GetApi(AWSCredentials credentials, RegionEndpoint region)
        {
            if (credentials == null) throw new ArgumentNullException("credentials");
            if (region == null) throw new ArgumentNullException("region");

            var config = new AmazonS3Config
            {
                RegionEndpoint = region,
            };

            ApplyProxy(config);

            var api = new AmazonS3Client(credentials, config);
            return api;
        }
开发者ID:Kyrodan,项目名称:KeeAnywhere,代码行数:15,代码来源:AmazonS3Helper.cs


示例17: WriteToSimpleDb

        static void WriteToSimpleDb(AWSCredentials credentials)
        {
            var client = new AmazonSimpleDBClient(credentials, RegionEndpoint.USEast1);

            var request = new CreateDomainRequest("aws-talk");
            var response = client.CreateDomain(request);

            var putData = new PutAttributesRequest("aws-talk", "products/" + Guid.NewGuid().ToString(),
                new List<ReplaceableAttribute>()
                {
                    new ReplaceableAttribute("Name", "Couch", true),
                    new ReplaceableAttribute("Price", "20", true)
                });
            client.PutAttributes(putData);
        }
开发者ID:modulexcite,项目名称:2015-Slides-and-Demos,代码行数:15,代码来源:Program.cs


示例18: ReadFromQueue

        static void ReadFromQueue(AWSCredentials credentials)
        {
            AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);

            string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk";

            ReceiveMessageRequest request = new ReceiveMessageRequest(queueUrl);
            request.MaxNumberOfMessages = 1;
            ReceiveMessageResponse response = client.ReceiveMessage(request);

            foreach (var message in response.Messages)
            {
                // Do something with the message
            }
        }
开发者ID:modulexcite,项目名称:2015-Slides-and-Demos,代码行数:15,代码来源:Program.cs


示例19: GetInstances

        static void GetInstances(AWSCredentials credentials)
        {
            IAmazonEC2 client = AWSClientFactory.CreateAmazonEC2Client(credentials, RegionEndpoint.USEast1);

            DescribeInstancesRequest request = new DescribeInstancesRequest();
            request.Filters.Add(new Filter("instance-state-code", new List<string>() { "0", "16" }));

            DescribeInstancesResponse describeInstancesResponse = client.DescribeInstances();
            List<Reservation> reservations = describeInstancesResponse.Reservations;

            foreach (Instance instance in reservations.SelectMany(x => x.Instances))
            {
                Console.WriteLine("Instance with ID {0} is currently {1}", instance.InstanceId, instance.State.Name);
            }
        }
开发者ID:modulexcite,项目名称:2015-Slides-and-Demos,代码行数:15,代码来源:Program.cs


示例20: GetSignedPolicy

        /// <summary>
        ///  Given a policy and AWS credentials, produce a S3PostUploadSignedPolicy.
        /// </summary>
        /// <param name="policy">JSON string representing the policy to sign</param>
        /// <param name="credentials">Credentials to sign the policy with</param>
        /// <returns></returns>
        public static S3PostUploadSignedPolicy GetSignedPolicy(string policy, AWSCredentials credentials)
        {
            var policyBytes = Encoding.UTF8.GetBytes(policy.Trim());
            var base64Policy = Convert.ToBase64String(policyBytes);
            
            string signature = null;

            signature = CryptoUtilFactory.CryptoInstance.HMACSign(Encoding.UTF8.GetBytes(base64Policy), credentials.GetCredentials().SecretKey, SigningAlgorithm.HmacSHA1);

            return new S3PostUploadSignedPolicy
            {
                Policy = base64Policy,
                Signature = signature,
                AccessKeyId = credentials.GetCredentials().AccessKey
            };
        }
开发者ID:scopely,项目名称:aws-sdk-net,代码行数:22,代码来源:S3PostUploadSignedPolicy.cs



注:本文中的Amazon.Runtime.AWSCredentials类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Runtime.AsyncOptions类代码示例发布时间:2022-05-24
下一篇:
C# Route53.AmazonRoute53Config类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap