forked from microsoft/kernel-memory
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAzureAIDocIntelConfig.cs
46 lines (37 loc) · 1.36 KB
/
AzureAIDocIntelConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Text.Json.Serialization;
#pragma warning disable IDE0130 // reduce number of "using" statements
// ReSharper disable once CheckNamespace - reduce number of "using" statements
namespace Microsoft.KernelMemory;
public class AzureAIDocIntelConfig
{
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum AuthTypes
{
Unknown = -1,
AzureIdentity,
APIKey,
}
public AuthTypes Auth { get; set; } = AuthTypes.Unknown;
public string Endpoint { get; set; } = string.Empty;
public string APIKey { get; set; } = string.Empty;
/// <summary>
/// Verify that the current state is valid.
/// </summary>
public void Validate()
{
if (this.Auth == AuthTypes.APIKey && string.IsNullOrWhiteSpace(this.APIKey))
{
throw new ArgumentOutOfRangeException(nameof(this.APIKey), "The API Key is empty");
}
if (string.IsNullOrWhiteSpace(this.Endpoint))
{
throw new ArgumentOutOfRangeException(nameof(this.Endpoint), "The endpoint value is empty");
}
if (!this.Endpoint.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentOutOfRangeException(nameof(this.Endpoint), "The endpoint value must start with https://");
}
}
}