public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.DirectConnect.Model.TagResourceRequest(); if (cmdletContext.ResourceArn != null) { request.ResourceArn = cmdletContext.ResourceArn; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } 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); }
private Amazon.DirectConnect.Model.TagResourceResponse CallAWSServiceOperation(IAmazonDirectConnect client, Amazon.DirectConnect.Model.TagResourceRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Direct Connect", "TagResource"); try { #if DESKTOP return(client.TagResource(request)); #elif CORECLR return(client.TagResourceAsync(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; } }
/// <summary> /// Adds the specified tags to the specified Direct Connect resource. Each Direct Connect /// resource can have a maximum of 50 tags. /// /// /// <para> /// Each tag consists of a key and an optional value. If a tag with the same key is already /// associated with the Direct Connect resource, this action updates its value. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the TagResource service method.</param> /// /// <returns>The response from the TagResource service method, as returned by DirectConnect.</returns> /// <exception cref="Amazon.DirectConnect.Model.DirectConnectClientException"> /// The API was called with invalid parameters. The error message will contain additional /// details about the cause. /// </exception> /// <exception cref="Amazon.DirectConnect.Model.DirectConnectServerException"> /// A server-side error occurred during the API call. The error message will contain additional /// details about the cause. /// </exception> /// <exception cref="Amazon.DirectConnect.Model.DuplicateTagKeysException"> /// A tag key was specified more than once. /// </exception> /// <exception cref="Amazon.DirectConnect.Model.TooManyTagsException"> /// You have reached the limit on the number of tags that can be assigned to a Direct /// Connect resource. /// </exception> public TagResourceResponse TagResource(TagResourceRequest request) { var marshaller = new TagResourceRequestMarshaller(); var unmarshaller = TagResourceResponseUnmarshaller.Instance; return Invoke<TagResourceRequest,TagResourceResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the TagResource operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the TagResource 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<TagResourceResponse> TagResourceAsync(TagResourceRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new TagResourceRequestMarshaller(); var unmarshaller = TagResourceResponseUnmarshaller.Instance; return InvokeAsync<TagResourceRequest,TagResourceResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the TagResource operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the TagResource operation on AmazonDirectConnectClient.</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 EndTagResource /// operation.</returns> public IAsyncResult BeginTagResource(TagResourceRequest request, AsyncCallback callback, object state) { var marshaller = new TagResourceRequestMarshaller(); var unmarshaller = TagResourceResponseUnmarshaller.Instance; return BeginInvoke<TagResourceRequest>(request, marshaller, unmarshaller, callback, state); }