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