/// <summary> /// Gets the information for the specified VNIC attachment. /// </summary> /// <param name="getRequest"></param> /// <returns></returns> public async Task <GetVnicAttachmentResponse> GetVnicAttachment(GetVnicAttachmentRequest getRequest) { var uri = new Uri($"{GetEndPoint(CoreServices.VNICAttachment, this.Region)}/{getRequest.VnicAttachmentId}"); using (var webResponse = await this.RestClientAsync.Get(uri)) using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = await reader.ReadToEndAsync(); return(new GetVnicAttachmentResponse() { Attachment = this.JsonSerializer.Deserialize <VnicAttachment>(response), ETag = webResponse.Headers.Get("ETag"), OpcRequestId = webResponse.Headers.Get("opc-request-id") }); } }
private void HandleOutput(GetVnicAttachmentRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForVnicAttachment(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetVnicAttachment(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.VnicAttachment); }
protected override void ProcessRecord() { base.ProcessRecord(); GetVnicAttachmentRequest request; try { request = new GetVnicAttachmentRequest { VnicAttachmentId = VnicAttachmentId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetVnicAttachmentRequest, GetVnicAttachmentResponse> ForVnicAttachment(GetVnicAttachmentRequest request, WaiterConfiguration config, params VnicAttachment.LifecycleStateEnum[] targetStates) { var agent = new WaiterAgent <GetVnicAttachmentRequest, GetVnicAttachmentResponse>( request, request => client.GetVnicAttachment(request), response => targetStates.Contains(response.VnicAttachment.LifecycleState.Value) ); return(new Waiter <GetVnicAttachmentRequest, GetVnicAttachmentResponse>(config, agent)); }
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetVnicAttachmentRequest, GetVnicAttachmentResponse> ForVnicAttachment(GetVnicAttachmentRequest request, params VnicAttachment.LifecycleStateEnum[] targetStates) { return(this.ForVnicAttachment(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }