Container for the parameters to the PutObjectTagging operation.
Inheritance: Amazon.Runtime.AmazonWebServiceRequest
コード例 #1
0
        public async Task <PutObjectTaggingResponse> SetObjectTagsAsync(string bucket,
                                                                        string key,
                                                                        IEnumerable <Tag> tags,
                                                                        CancellationToken cancellationToken = default)
        {
            this.Logger.LogDebug($"[{nameof(this.SetObjectTagAsync)}]");

            this.Logger.LogTrace(JsonConvert.SerializeObject(new { bucket, key, tags }));

            if (string.IsNullOrWhiteSpace(bucket))
            {
                throw new ArgumentNullException(nameof(bucket));
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (tags == null)
            {
                throw new ArgumentNullException(nameof(tags));
            }

            var request = new Amazon.S3.Model.PutObjectTaggingRequest
            {
                BucketName = bucket,
                Key        = key,
                Tagging    = new Tagging()
                {
                    TagSet = tags.ToList()
                }
            };

            this.Logger.LogTrace(JsonConvert.SerializeObject(value: request));

            var response = await this.Repository.PutObjectTaggingAsync(request : request,
                                                                       cancellationToken : cancellationToken == default?this.CancellationToken.Token : cancellationToken);

            this.Logger.LogTrace(JsonConvert.SerializeObject(value: response));

            return(response);
        }
コード例 #2
0
 private Amazon.S3.Model.PutObjectTaggingResponse CallAWSServiceOperation(IAmazonS3 client, Amazon.S3.Model.PutObjectTaggingRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Storage Service (S3)", "PutObjectTagging");
     try
     {
         #if DESKTOP
         return(client.PutObjectTagging(request));
         #elif CORECLR
         return(client.PutObjectTaggingAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
コード例 #3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.S3.Model.PutObjectTaggingRequest();

            if (cmdletContext.BucketName != null)
            {
                request.BucketName = cmdletContext.BucketName;
            }
            if (cmdletContext.ExpectedBucketOwner != null)
            {
                request.ExpectedBucketOwner = cmdletContext.ExpectedBucketOwner;
            }
            if (cmdletContext.Key != null)
            {
                request.Key = cmdletContext.Key;
            }
            if (cmdletContext.RequestPayer != null)
            {
                request.RequestPayer = cmdletContext.RequestPayer;
            }

            // populate Tagging
            var requestTaggingIsNull = true;

            request.Tagging = new Amazon.S3.Model.Tagging();
            List <Amazon.S3.Model.Tag> requestTagging_tagging_TagSet = null;

            if (cmdletContext.Tagging_TagSet != null)
            {
                requestTagging_tagging_TagSet = cmdletContext.Tagging_TagSet;
            }
            if (requestTagging_tagging_TagSet != null)
            {
                request.Tagging.TagSet = requestTagging_tagging_TagSet;
                requestTaggingIsNull   = false;
            }
            // determine if request.Tagging should be set to null
            if (requestTaggingIsNull)
            {
                request.Tagging = null;
            }
            if (cmdletContext.VersionId != null)
            {
                request.VersionId = cmdletContext.VersionId;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
コード例 #4
0
ファイル: AmazonS3Client.cs プロジェクト: aws/aws-sdk-net
 /// <summary>
 /// Initiates the asynchronous execution of the PutObjectTagging operation.
 /// This API is supported only when AWSConfigs.HttpClient is set to AWSConfigs.HttpClientOption.UnityWebRequest, the default value for this configuration option is AWSConfigs.HttpClientOption.UnityWWW
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the PutObjectTagging operation on AmazonS3Client.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void PutObjectTaggingAsync(PutObjectTaggingRequest request, AmazonServiceCallback<PutObjectTaggingRequest, PutObjectTaggingResponse> callback, AsyncOptions options = null)
 {
     if (AWSConfigs.HttpClient == AWSConfigs.HttpClientOption.UnityWWW)
     {
         throw new InvalidOperationException("PutObjectTagging is only allowed with AWSConfigs.HttpClientOption.UnityWebRequest API option");
     }
     options = options == null?new AsyncOptions():options;
     var marshaller = new PutObjectTaggingRequestMarshaller();
     var unmarshaller = PutObjectTaggingResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<PutObjectTaggingRequest,PutObjectTaggingResponse> responseObject 
                     = new AmazonServiceResult<PutObjectTaggingRequest,PutObjectTaggingResponse>((PutObjectTaggingRequest)req, (PutObjectTaggingResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<PutObjectTaggingRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
コード例 #5
0
ファイル: AmazonS3Client.cs プロジェクト: aws/aws-sdk-net
        /// <summary>
        /// Initiates the asynchronous execution of the PutObjectTagging operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutObjectTagging operation on AmazonS3Client.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPutObjectTagging
        ///         operation.</returns>
        public IAsyncResult BeginPutObjectTagging(PutObjectTaggingRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new PutObjectTaggingRequestMarshaller();
            var unmarshaller = PutObjectTaggingResponseUnmarshaller.Instance;

            return BeginInvoke<PutObjectTaggingRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
コード例 #6
0
ファイル: AmazonS3Client.cs プロジェクト: aws/aws-sdk-net
        /// <summary>
        /// Sets the supplied tag-set to an object that already exists in a bucket
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the PutObjectTagging service method.</param>
        /// 
        /// <returns>The response from the PutObjectTagging service method, as returned by S3.</returns>
        public PutObjectTaggingResponse PutObjectTagging(PutObjectTaggingRequest request)
        {
            var marshaller = new PutObjectTaggingRequestMarshaller();
            var unmarshaller = PutObjectTaggingResponseUnmarshaller.Instance;

            return Invoke<PutObjectTaggingRequest,PutObjectTaggingResponse>(request, marshaller, unmarshaller);
        }
コード例 #7
0
ファイル: AmazonS3Client.cs プロジェクト: aws/aws-sdk-net
        /// <summary>
        /// Initiates the asynchronous execution of the PutObjectTagging operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the PutObjectTagging operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<PutObjectTaggingResponse> PutObjectTaggingAsync(PutObjectTaggingRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PutObjectTaggingRequestMarshaller();
            var unmarshaller = PutObjectTaggingResponseUnmarshaller.Instance;

            return InvokeAsync<PutObjectTaggingRequest,PutObjectTaggingResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }