public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.CloudTrail.Model.AddTagsRequest(); if (cmdletContext.ResourceId != null) { request.ResourceId = cmdletContext.ResourceId; } if (cmdletContext.TagsList != null) { request.TagsList = cmdletContext.TagsList; } 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); }
/// <summary> /// Initiates the asynchronous execution of the AddTags operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddTags operation on AmazonCloudTrailClient.</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 EndAddTags /// operation.</returns> public IAsyncResult BeginAddTags(AddTagsRequest request, AsyncCallback callback, object state) { var marshaller = new AddTagsRequestMarshaller(); var unmarshaller = AddTagsResponseUnmarshaller.Instance; return BeginInvoke<AddTagsRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Adds one or more tags to a trail, up to a limit of 10. Tags must be unique per trail. /// Overwrites an existing tag's value when a new value is specified for an existing tag /// key. If you specify a key without a value, the tag will be created with the specified /// key and a value of null. /// </summary> /// <param name="request">Container for the necessary parameters to execute the AddTags service method.</param> /// /// <returns>The response from the AddTags service method, as returned by CloudTrail.</returns> /// <exception cref="Amazon.CloudTrail.Model.CloudTrailARNInvalidException"> /// This exception is thrown when an operation is called with an invalid trail ARN. The /// format of a trail ARN is <code>arn:aws:cloudtrail:us-east-1:123456789012:trail/MyTrail</code>. /// </exception> /// <exception cref="Amazon.CloudTrail.Model.InvalidTagParameterException"> /// This exception is thrown when the key or value specified for the tag does not match /// the regular expression <code>^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$</code>. /// </exception> /// <exception cref="Amazon.CloudTrail.Model.InvalidTrailNameException"> /// This exception is thrown when the provided trail name is not valid. Trail names must /// meet the following requirements: /// /// <ul> <li>Contain only ASCII letters (a-z, A-Z), numbers (0-9), periods (.), underscores /// (_), or dashes (-)</li> <li>Start with a letter or number, and end with a letter or /// number</li> <li>Be between 3 and 128 characters</li> <li>Have no adjacent periods, /// underscores or dashes. Names like <code>my-_namespace</code> and <code>my--namespace</code> /// are invalid.</li> <li>Not be in IP address format (for example, 192.168.5.4)</li> /// </ul> /// </exception> /// <exception cref="Amazon.CloudTrail.Model.OperationNotPermittedException"> /// This exception is thrown when the requested operation is not permitted. /// </exception> /// <exception cref="Amazon.CloudTrail.Model.ResourceNotFoundException"> /// This exception is thrown when the specified resource is not found. /// </exception> /// <exception cref="Amazon.CloudTrail.Model.ResourceTypeNotSupportedException"> /// This exception is thrown when the specified resource type is not supported by CloudTrail. /// </exception> /// <exception cref="Amazon.CloudTrail.Model.TagsLimitExceededException"> /// The number of tags per trail has exceeded the permitted amount. Currently, the limit /// is 10. /// </exception> /// <exception cref="Amazon.CloudTrail.Model.UnsupportedOperationException"> /// This exception is thrown when the requested operation is not supported. For example, /// this exception will occur if an attempt is made to tag a trail and tagging is not /// supported in the current region. /// </exception> public AddTagsResponse AddTags(AddTagsRequest request) { var marshaller = new AddTagsRequestMarshaller(); var unmarshaller = AddTagsResponseUnmarshaller.Instance; return Invoke<AddTagsRequest,AddTagsResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the AddTags operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddTags 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<AddTagsResponse> AddTagsAsync(AddTagsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new AddTagsRequestMarshaller(); var unmarshaller = AddTagsResponseUnmarshaller.Instance; return InvokeAsync<AddTagsRequest,AddTagsResponse>(request, marshaller, unmarshaller, cancellationToken); }
private Amazon.CloudTrail.Model.AddTagsResponse CallAWSServiceOperation(IAmazonCloudTrail client, Amazon.CloudTrail.Model.AddTagsRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS CloudTrail", "AddTags"); try { #if DESKTOP return(client.AddTags(request)); #elif CORECLR return(client.AddTagsAsync(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; } }