/// <summary> /// Gets information about the link. /// </summary> /// <param name="request">The request object containing the details to send. Required.</param> /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param> /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param> /// <returns>A response object containing details about the completed operation</returns> /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/tenantmanagercontrolplane/GetLink.cs.html">here</a> to see an example of how to use GetLink API.</example> public async Task <GetLinkResponse> GetLink(GetLinkRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called getLink"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/links/{linkId}".Trim('/'))); HttpMethod method = new HttpMethod("GET"); HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request); requestMessage.Headers.Add("Accept", "application/json"); GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration); HttpResponseMessage responseMessage; try { if (retryingClient != null) { responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false); } else { responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false); } this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage); return(Converter.FromHttpResponseMessage <GetLinkResponse>(responseMessage)); } catch (Exception e) { logger.Error($"GetLink failed with error: {e.Message}"); throw; } }
public async Task <ActionResult> RedirectFullUrl(string code) { var request = new GetLinkRequest(code); Link link = await _mediator.Send(request); // _logger.LogInformation($"Redirect: {link.ShortCode} -> {link.FullUrl}"); return(Redirect(link.FullUrl)); }
public async Task <ActionResult <LinkDto> > GetLink(string?code) { var request = new GetLinkRequest(code); Link link = await _mediator.Send(request); var linkDto = _mapper.Map <LinkDto>(link); linkDto.ShortCode = code; return(Ok(linkDto)); }
public override async Task <LinkReply> GetLink(GetLinkRequest request, ServerCallContext context) { this.logger.LogInformation($"Getting link for short id: {request.Id}"); var item = await this.repo.GetByShortId(request.Id); return(new LinkReply() { Link = item.Url }); }
/// <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 <GetLinkRequest, GetLinkResponse> ForLink(GetLinkRequest request, WaiterConfiguration config, params LifecycleState[] targetStates) { var agent = new WaiterAgent <GetLinkRequest, GetLinkResponse>( request, request => client.GetLink(request), response => targetStates.Contains(response.Link.LifecycleState.Value), targetStates.Contains(LifecycleState.Terminated) ); return(new Waiter <GetLinkRequest, GetLinkResponse>(config, agent)); }
public object Get(GetLinkRequest request) { var link = _linkRepo.GetByKey(request.Key); if (link == null) { throw HttpError.NotFound($"Link with key '{request.Key}' not found."); } return(_linkRepo.GetLinkResponse(link.Id)); }
public IActionResult Get([FromQuery] GetLinkRequest request) { var(links, count) = repository .Get(request.Search, (request.Page.Value - 1) * itemPerPage); var result = new SearchResult { PageInfo = new PageInfo { CurrentPage = request.Page.Value, MaxPage = count % itemPerPage == 0 ? count / itemPerPage : count / itemPerPage + 1 }, Items = links.Select(selector: x => new LinkResult(x)) }; return(Ok(result)); }
public IActionResult Get([FromQuery] GetLinkRequest request) { var(links, count) = _repository .Get(request.Search, request.Page.Value); var result = new SearchResult { PageInfo = new PageInfo { CurrentPage = request.Page.Value, MaxPage = count }, Items = links.Select(x => new LinkResult(x)) }; return(Ok(result)); }
public IActionResult Get([FromQuery] GetLinkRequest request) { var(links, count) = _repository.Get(request.Search, (request.Page.Value - 1) * ITEMS_PER_PAGE, ITEMS_PER_PAGE); var result = new SearchResult { PageInfo = new PageInfo { CurrentPage = request.Page.Value, MaxPage = count % ITEMS_PER_PAGE == 0 ? count / ITEMS_PER_PAGE : (count / ITEMS_PER_PAGE) + 1 }, Items = links.Select(l => new LinkResult(l)) }; return(Ok(result)); }
private void HandleOutput(GetLinkRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForLink(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetLink(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Link); }
protected override void ProcessRecord() { base.ProcessRecord(); GetLinkRequest request; try { request = new GetLinkRequest { LinkId = LinkId, OpcRequestId = OpcRequestId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <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 <GetLinkRequest, GetLinkResponse> ForLink(GetLinkRequest request, params LifecycleState[] targetStates) { return(this.ForLink(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }
public Link Get(GetLinkRequest request) { return Repository.GetById(request.Id); }