|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +// <auto-generated/> |
| 5 | + |
| 6 | +#nullable disable |
| 7 | + |
| 8 | +using System; |
| 9 | +using System.Threading.Tasks; |
| 10 | +using Azure.Core; |
| 11 | +using Azure.Core.Pipeline; |
| 12 | + |
| 13 | +namespace Azure.Developer.Playwright |
| 14 | +{ |
| 15 | + // Data plane generated client. |
| 16 | + /// <summary> The TestRunUpdate service client. </summary> |
| 17 | + internal partial class TestRunUpdateClient |
| 18 | + { |
| 19 | + private readonly HttpPipeline _pipeline; |
| 20 | + private readonly Uri _endpoint; |
| 21 | + private readonly string _apiVersion; |
| 22 | + |
| 23 | + /// <summary> The ClientDiagnostics is used to provide tracing support for the client library. </summary> |
| 24 | + internal ClientDiagnostics ClientDiagnostics { get; } |
| 25 | + |
| 26 | + /// <summary> The HTTP pipeline for sending and receiving REST requests and responses. </summary> |
| 27 | + public virtual HttpPipeline Pipeline => _pipeline; |
| 28 | + |
| 29 | + /// <summary> Initializes a new instance of TestRunUpdateClient for mocking. </summary> |
| 30 | + protected TestRunUpdateClient() |
| 31 | + { |
| 32 | + } |
| 33 | + |
| 34 | + /// <summary> Initializes a new instance of TestRunUpdateClient. </summary> |
| 35 | + /// <param name="endpoint"> server parameter. </param> |
| 36 | + /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> is null. </exception> |
| 37 | + public TestRunUpdateClient(Uri endpoint) : this(endpoint, new TestRunUpdateClientOptions()) |
| 38 | + { |
| 39 | + } |
| 40 | + |
| 41 | + /// <summary> Initializes a new instance of TestRunUpdateClient. </summary> |
| 42 | + /// <param name="endpoint"> server parameter. </param> |
| 43 | + /// <param name="options"> The options for configuring the client. </param> |
| 44 | + /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> is null. </exception> |
| 45 | + public TestRunUpdateClient(Uri endpoint, TestRunUpdateClientOptions options) |
| 46 | + { |
| 47 | + Argument.AssertNotNull(endpoint, nameof(endpoint)); |
| 48 | + options ??= new TestRunUpdateClientOptions(); |
| 49 | + |
| 50 | + ClientDiagnostics = new ClientDiagnostics(options, true); |
| 51 | + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty<HttpPipelinePolicy>(), Array.Empty<HttpPipelinePolicy>(), new ResponseClassifier()); |
| 52 | + _endpoint = endpoint; |
| 53 | + _apiVersion = options.Version; |
| 54 | + } |
| 55 | + |
| 56 | + /// <summary> |
| 57 | + /// [Protocol Method] |
| 58 | + /// <list type="bullet"> |
| 59 | + /// <item> |
| 60 | + /// <description> |
| 61 | + /// This <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/ProtocolMethods.md">protocol method</see> allows explicit creation of the request and processing of the response for advanced scenarios. |
| 62 | + /// </description> |
| 63 | + /// </item> |
| 64 | + /// </list> |
| 65 | + /// </summary> |
| 66 | + /// <param name="workspaceId"> The <see cref="string"/> to use. </param> |
| 67 | + /// <param name="testRunId"> The <see cref="string"/> to use. </param> |
| 68 | + /// <param name="content"> The content to send as the body of the request. </param> |
| 69 | + /// <param name="authorization"> access token. </param> |
| 70 | + /// <param name="xCorrelationId"> Correlation-id used for tracing and debugging. </param> |
| 71 | + /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 72 | + /// <exception cref="ArgumentNullException"> <paramref name="workspaceId"/> or <paramref name="testRunId"/> is null. </exception> |
| 73 | + /// <exception cref="ArgumentException"> <paramref name="workspaceId"/> or <paramref name="testRunId"/> is an empty string, and was expected to be non-empty. </exception> |
| 74 | + /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception> |
| 75 | + /// <returns> The response returned from the service. </returns> |
| 76 | + public virtual async Task<Response> TestRunsAsync(string workspaceId, string testRunId, RequestContent content, string authorization = null, string xCorrelationId = null, RequestContext context = null) |
| 77 | + { |
| 78 | + Argument.AssertNotNullOrEmpty(workspaceId, nameof(workspaceId)); |
| 79 | + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); |
| 80 | + |
| 81 | + using var scope = ClientDiagnostics.CreateScope("TestRunUpdateClient.TestRuns"); |
| 82 | + scope.Start(); |
| 83 | + try |
| 84 | + { |
| 85 | + using HttpMessage message = CreateTestRunsRequest(workspaceId, testRunId, content, authorization, xCorrelationId, context); |
| 86 | + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); |
| 87 | + } |
| 88 | + catch (Exception e) |
| 89 | + { |
| 90 | + scope.Failed(e); |
| 91 | + throw; |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + /// <summary> |
| 96 | + /// [Protocol Method] |
| 97 | + /// <list type="bullet"> |
| 98 | + /// <item> |
| 99 | + /// <description> |
| 100 | + /// This <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/ProtocolMethods.md">protocol method</see> allows explicit creation of the request and processing of the response for advanced scenarios. |
| 101 | + /// </description> |
| 102 | + /// </item> |
| 103 | + /// </list> |
| 104 | + /// </summary> |
| 105 | + /// <param name="workspaceId"> The <see cref="string"/> to use. </param> |
| 106 | + /// <param name="testRunId"> The <see cref="string"/> to use. </param> |
| 107 | + /// <param name="content"> The content to send as the body of the request. </param> |
| 108 | + /// <param name="authorization"> access token. </param> |
| 109 | + /// <param name="xCorrelationId"> Correlation-id used for tracing and debugging. </param> |
| 110 | + /// <param name="context"> The request context, which can override default behaviors of the client pipeline on a per-call basis. </param> |
| 111 | + /// <exception cref="ArgumentNullException"> <paramref name="workspaceId"/> or <paramref name="testRunId"/> is null. </exception> |
| 112 | + /// <exception cref="ArgumentException"> <paramref name="workspaceId"/> or <paramref name="testRunId"/> is an empty string, and was expected to be non-empty. </exception> |
| 113 | + /// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception> |
| 114 | + /// <returns> The response returned from the service. </returns> |
| 115 | + public virtual Response TestRuns(string workspaceId, string testRunId, RequestContent content, string authorization = null, string xCorrelationId = null, RequestContext context = null) |
| 116 | + { |
| 117 | + Argument.AssertNotNullOrEmpty(workspaceId, nameof(workspaceId)); |
| 118 | + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); |
| 119 | + |
| 120 | + using var scope = ClientDiagnostics.CreateScope("TestRunUpdateClient.TestRuns"); |
| 121 | + scope.Start(); |
| 122 | + try |
| 123 | + { |
| 124 | + using HttpMessage message = CreateTestRunsRequest(workspaceId, testRunId, content, authorization, xCorrelationId, context); |
| 125 | + return _pipeline.ProcessMessage(message, context); |
| 126 | + } |
| 127 | + catch (Exception e) |
| 128 | + { |
| 129 | + scope.Failed(e); |
| 130 | + throw; |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + internal HttpMessage CreateTestRunsRequest(string workspaceId, string testRunId, RequestContent content, string authorization, string xCorrelationId, RequestContext context) |
| 135 | + { |
| 136 | + var message = _pipeline.CreateMessage(context, ResponseClassifier200); |
| 137 | + var request = message.Request; |
| 138 | + request.Method = RequestMethod.Patch; |
| 139 | + var uri = new RawRequestUriBuilder(); |
| 140 | + uri.Reset(_endpoint); |
| 141 | + uri.AppendPath("/playwrightworkspaces/", false); |
| 142 | + uri.AppendPath(workspaceId, true); |
| 143 | + uri.AppendPath("/test-runs/", false); |
| 144 | + uri.AppendPath(testRunId, true); |
| 145 | + uri.AppendQuery("api-version", _apiVersion, true); |
| 146 | + request.Uri = uri; |
| 147 | + request.Headers.Add("Accept", "application/json"); |
| 148 | + if (authorization != null) |
| 149 | + { |
| 150 | + request.Headers.Add("Authorization", authorization); |
| 151 | + } |
| 152 | + if (xCorrelationId != null) |
| 153 | + { |
| 154 | + request.Headers.Add("x-correlation-id", xCorrelationId); |
| 155 | + } |
| 156 | + request.Headers.Add("Content-Type", "application/merge-patch+json"); |
| 157 | + request.Content = content; |
| 158 | + return message; |
| 159 | + } |
| 160 | + |
| 161 | + private static ResponseClassifier _responseClassifier200; |
| 162 | + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); |
| 163 | + } |
| 164 | +} |
0 commit comments