openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Files/Internal/InternalUploadsClient.cs
59lines · modecode
| 1 | using System; |
| 2 | using System.ClientModel; |
| 3 | using System.ClientModel.Primitives; |
| 4 | |
| 5 | namespace OpenAI.Files; |
| 6 | |
| 7 | [CodeGenClient("Uploads")] |
| 8 | [CodeGenSuppress("InternalUploadsClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))] |
| 9 | internal partial class InternalUploadsClient |
| 10 | { |
| 11 | // CUSTOM: Remove virtual keyword. |
| 12 | /// <summary> |
| 13 | /// The HTTP pipeline for sending and receiving REST requests and responses. |
| 14 | /// </summary> |
| 15 | public ClientPipeline Pipeline => _pipeline; |
| 16 | |
| 17 | // CUSTOM: |
| 18 | // - Used a custom pipeline. |
| 19 | // - Demoted the endpoint parameter to be a property in the options class. |
| 20 | /// <summary> Initializes a new instance of <see cref="InternalUploadsClient">. </summary> |
| 21 | /// <param name="credential"> The API key to authenticate with the service. </param> |
| 22 | /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception> |
| 23 | internal InternalUploadsClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) |
| 24 | { |
| 25 | } |
| 26 | |
| 27 | // CUSTOM: |
| 28 | // - Used a custom pipeline. |
| 29 | // - Demoted the endpoint parameter to be a property in the options class. |
| 30 | /// <summary> Initializes a new instance of <see cref="InternalUploadsClient">. </summary> |
| 31 | /// <param name="credential"> The API key to authenticate with the service. </param> |
| 32 | /// <param name="options"> The options to configure the client. </param> |
| 33 | /// <exception cref="ArgumentNullException"> <paramref name="credential"/> is null. </exception> |
| 34 | internal InternalUploadsClient(ApiKeyCredential credential, OpenAIClientOptions options) |
| 35 | { |
| 36 | Argument.AssertNotNull(credential, nameof(credential)); |
| 37 | options ??= new OpenAIClientOptions(); |
| 38 | |
| 39 | _pipeline = OpenAIClient.CreatePipeline(credential, options); |
| 40 | _endpoint = OpenAIClient.GetEndpoint(options); |
| 41 | } |
| 42 | |
| 43 | // CUSTOM: |
| 44 | // - Used a custom pipeline. |
| 45 | // - Demoted the endpoint parameter to be a property in the options class. |
| 46 | // - Made protected. |
| 47 | /// <summary> Initializes a new instance of <see cref="InternalUploadsClient">. </summary> |
| 48 | /// <param name="pipeline"> The HTTP pipeline to send and receive REST requests and responses. </param> |
| 49 | /// <param name="options"> The options to configure the client. </param> |
| 50 | /// <exception cref="ArgumentNullException"> <paramref name="pipeline"/> is null. </exception> |
| 51 | protected internal InternalUploadsClient(ClientPipeline pipeline, OpenAIClientOptions options) |
| 52 | { |
| 53 | Argument.AssertNotNull(pipeline, nameof(pipeline)); |
| 54 | options ??= new OpenAIClientOptions(); |
| 55 | |
| 56 | _pipeline = pipeline; |
| 57 | _endpoint = OpenAIClient.GetEndpoint(options); |
| 58 | } |
| 59 | } |
| 60 | |