Skip to content

Commit

Permalink
feat: update openapi specification [merge date may 2] (box/box-openap…
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed May 2, 2024
1 parent 9ca1b99 commit fcf8c8e
Show file tree
Hide file tree
Showing 21 changed files with 415 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "afd7974", "specHash": "1698c95", "version": "0.3.0" }
{ "engineHash": "afd7974", "specHash": "63d1af0", "version": "0.3.0" }
3 changes: 3 additions & 0 deletions Box.Sdk.Gen/Client/BoxClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public class BoxClient : IBoxClient {

public IIntegrationMappingsManager IntegrationMappings { get; set; }

public IAiManager Ai { get; set; }

public BoxClient(IAuthentication auth, NetworkSession networkSession = default) {

Check warning on line 150 in Box.Sdk.Gen/Client/BoxClient.cs

View workflow job for this annotation

GitHub Actions / .NET 6

Cannot convert null literal to non-nullable reference type.
Auth = auth;
NetworkSession = networkSession ?? new NetworkSession(baseUrls: new BaseUrls());
Expand Down Expand Up @@ -216,6 +218,7 @@ public BoxClient(IAuthentication auth, NetworkSession networkSession = default)
Workflows = new WorkflowsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
SignTemplates = new SignTemplatesManager(networkSession: this.NetworkSession) { Auth = this.Auth };
IntegrationMappings = new IntegrationMappingsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
Ai = new AiManager(networkSession: this.NetworkSession) { Auth = this.Auth };
}
/// <summary>
/// Create a new client to impersonate user with the provided ID. All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified.
Expand Down
2 changes: 2 additions & 0 deletions Box.Sdk.Gen/Client/IBoxClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,7 @@ public interface IBoxClient {

public IIntegrationMappingsManager IntegrationMappings { get; set; }

public IAiManager Ai { get; set; }

}
}
58 changes: 58 additions & 0 deletions Box.Sdk.Gen/Managers/Ai/AiManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Unions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using DictionaryExtensions;
using Serializer;
using Fetch;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen;

namespace Box.Sdk.Gen.Managers {
public class AiManager : IAiManager {
public IAuthentication? Auth { get; set; } = default;

public NetworkSession NetworkSession { get; set; }

public AiManager(NetworkSession networkSession = default) {

Check warning on line 16 in Box.Sdk.Gen/Managers/Ai/AiManager.cs

View workflow job for this annotation

GitHub Actions / .NET 6

Cannot convert null literal to non-nullable reference type.
NetworkSession = networkSession ?? new NetworkSession();
}
/// <summary>
/// Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context.
/// </summary>
/// <param name="requestBody">
/// Request body of createAiAsk method
/// </param>
/// <param name="headers">
/// Headers of createAiAsk method
/// </param>
/// <param name="cancellationToken">
/// Token used for request cancellation.
/// </param>
public async System.Threading.Tasks.Task<AiResponse> CreateAiAskAsync(AiAsk requestBody, CreateAiAskHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
headers = headers ?? new CreateAiAskHeaders();
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { }, headers.ExtraHeaders));
FetchResponse response = await HttpClientAdapter.FetchAsync(string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/v2/ai/ask"), new FetchOptions(method: "POST", headers: headersMap, data: SimpleJsonSerializer.Serialize(requestBody), contentType: "application/json", responseFormat: "json", auth: this.Auth, networkSession: this.NetworkSession, cancellationToken: cancellationToken)).ConfigureAwait(false);
return SimpleJsonSerializer.Deserialize<AiResponse>(response.Data);
}

/// <summary>
/// Sends an AI request to supported LLMs and returns an answer specifically focused on the creation of new text.
/// </summary>
/// <param name="requestBody">
/// Request body of createAiTextGen method
/// </param>
/// <param name="headers">
/// Headers of createAiTextGen method
/// </param>
/// <param name="cancellationToken">
/// Token used for request cancellation.
/// </param>
public async System.Threading.Tasks.Task<AiResponse> CreateAiTextGenAsync(AiTextGen requestBody, CreateAiTextGenHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
headers = headers ?? new CreateAiTextGenHeaders();
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { }, headers.ExtraHeaders));
FetchResponse response = await HttpClientAdapter.FetchAsync(string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/v2/ai/text_gen"), new FetchOptions(method: "POST", headers: headersMap, data: SimpleJsonSerializer.Serialize(requestBody), contentType: "application/json", responseFormat: "json", auth: this.Auth, networkSession: this.NetworkSession, cancellationToken: cancellationToken)).ConfigureAwait(false);
return SimpleJsonSerializer.Deserialize<AiResponse>(response.Data);
}

}
}
18 changes: 18 additions & 0 deletions Box.Sdk.Gen/Managers/Ai/CreateAiAskHeaders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Unions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen;

namespace Box.Sdk.Gen.Managers {
public class CreateAiAskHeaders {
/// <summary>
/// Extra headers that will be included in the HTTP request.
/// </summary>
public Dictionary<string, string?> ExtraHeaders { get; set; }

public CreateAiAskHeaders(Dictionary<string, string?> extraHeaders = default) {
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
}
}
}
18 changes: 18 additions & 0 deletions Box.Sdk.Gen/Managers/Ai/CreateAiTextGenHeaders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Unions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen;

namespace Box.Sdk.Gen.Managers {
public class CreateAiTextGenHeaders {
/// <summary>
/// Extra headers that will be included in the HTTP request.
/// </summary>
public Dictionary<string, string?> ExtraHeaders { get; set; }

public CreateAiTextGenHeaders(Dictionary<string, string?> extraHeaders = default) {
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
}
}
}
18 changes: 18 additions & 0 deletions Box.Sdk.Gen/Managers/Ai/IAiManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Unions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen;

namespace Box.Sdk.Gen.Managers {
public interface IAiManager {
public IAuthentication? Auth { get; set; }

public NetworkSession NetworkSession { get; set; }

public System.Threading.Tasks.Task<AiResponse> CreateAiAskAsync(AiAsk requestBody, CreateAiAskHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null);

public System.Threading.Tasks.Task<AiResponse> CreateAiTextGenAsync(AiTextGen requestBody, CreateAiTextGenHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null);

}
}
33 changes: 33 additions & 0 deletions Box.Sdk.Gen/Schemas/AiAsk.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Unions;
using System.Text.Json.Serialization;
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Box.Sdk.Gen.Schemas {
public class AiAsk {
/// <summary>
/// The mode specifies if this request is for a single or multiple items.
/// </summary>
[JsonPropertyName("mode")]
public AiAskModeField Mode { get; set; }

/// <summary>
/// The prompt provided by the client to be answered by the LLM.
/// </summary>
[JsonPropertyName("prompt")]
public string Prompt { get; set; }

/// <summary>
/// The items to be processed by the LLM, often files.
/// </summary>
[JsonPropertyName("items")]
public IReadOnlyList<AiAskItemsField> Items { get; set; }

public AiAsk(AiAskModeField mode, string prompt, IReadOnlyList<AiAskItemsField> items) {
Mode = mode;
Prompt = prompt;
Items = items;
}
}
}
29 changes: 29 additions & 0 deletions Box.Sdk.Gen/Schemas/AiAskItemsField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Unions;
using System.Text.Json.Serialization;

namespace Box.Sdk.Gen.Schemas {
public class AiAskItemsField {
/// <summary>
/// The id of the item
/// </summary>
[JsonPropertyName("id")]
public string Id { get; set; }

/// <summary>
/// The type of the item
/// </summary>
[JsonPropertyName("type")]
public AiAskItemsTypeField Type { get; set; }

/// <summary>
/// The content of the item, often the text representation.
/// </summary>
[JsonPropertyName("content")]
public string? Content { get; set; } = default;

public AiAskItemsField(string id, AiAskItemsTypeField type = AiAskItemsTypeField.File) {
Id = id;
Type = type;
}
}
}
11 changes: 11 additions & 0 deletions Box.Sdk.Gen/Schemas/AiAskItemsTypeField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.ComponentModel;
using Serializer;
using System.Text.Json.Serialization;

namespace Box.Sdk.Gen.Schemas {
[JsonConverter(typeof(StringEnumConverter<AiAskItemsTypeField>))]
public enum AiAskItemsTypeField {
[Description("file")]
File
}
}
13 changes: 13 additions & 0 deletions Box.Sdk.Gen/Schemas/AiAskModeField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.ComponentModel;
using Serializer;
using System.Text.Json.Serialization;

namespace Box.Sdk.Gen.Schemas {
[JsonConverter(typeof(StringEnumConverter<AiAskModeField>))]
public enum AiAskModeField {
[Description("multiple_item_qa")]
MultipleItemQa,
[Description("single_item_qa")]
SingleItemQa
}
}
32 changes: 32 additions & 0 deletions Box.Sdk.Gen/Schemas/AiResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Unions;
using System.Text.Json.Serialization;
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Box.Sdk.Gen.Schemas {
public class AiResponse {
/// <summary>
/// The answer provided by the LLM.
/// </summary>
[JsonPropertyName("answer")]
public string Answer { get; set; }

/// <summary>
/// The ISO date formatted timestamp of when the answer to the prompt was created.
/// </summary>
[JsonPropertyName("created_at")]
public System.DateTimeOffset CreatedAt { get; set; }

/// <summary>
/// The reason the response finishes.
/// </summary>
[JsonPropertyName("completion_reason")]
public string? CompletionReason { get; set; } = default;

public AiResponse(string answer, System.DateTimeOffset createdAt) {
Answer = answer;
CreatedAt = createdAt;
}
}
}
32 changes: 32 additions & 0 deletions Box.Sdk.Gen/Schemas/AiTextGen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Unions;
using System.Text.Json.Serialization;
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Box.Sdk.Gen.Schemas {
public class AiTextGen {
/// <summary>
/// The prompt provided by the client to be answered by the LLM.
/// </summary>
[JsonPropertyName("prompt")]
public string Prompt { get; set; }

/// <summary>
/// The items to be processed by the LLM, often files.
/// </summary>
[JsonPropertyName("items")]
public IReadOnlyList<AiTextGenItemsField> Items { get; set; }

/// <summary>
/// The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response.
/// </summary>
[JsonPropertyName("dialogue_history")]
public IReadOnlyList<AiTextGenDialogueHistoryField>? DialogueHistory { get; set; } = default;

public AiTextGen(string prompt, IReadOnlyList<AiTextGenItemsField> items) {
Prompt = prompt;
Items = items;
}
}
}
31 changes: 31 additions & 0 deletions Box.Sdk.Gen/Schemas/AiTextGenDialogueHistoryField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Unions;
using System.Text.Json.Serialization;
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Box.Sdk.Gen.Schemas {
public class AiTextGenDialogueHistoryField {
/// <summary>
/// The prompt previously provided by the client and answered by the LLM.
/// </summary>
[JsonPropertyName("prompt")]
public string? Prompt { get; set; } = default;

/// <summary>
/// The answer previously provided by the LLM.
/// </summary>
[JsonPropertyName("answer")]
public string? Answer { get; set; } = default;

/// <summary>
/// The ISO date formatted timestamp of when the previous answer to the prompt was created.
/// </summary>
[JsonPropertyName("created_at")]
public System.DateTimeOffset? CreatedAt { get; set; } = default;

public AiTextGenDialogueHistoryField() {

}
}
}
31 changes: 31 additions & 0 deletions Box.Sdk.Gen/Schemas/AiTextGenItemsField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Unions;
using System.Text.Json.Serialization;
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Box.Sdk.Gen.Schemas {
public class AiTextGenItemsField {
/// <summary>
/// The id of the item.
/// </summary>
[JsonPropertyName("id")]
public string? Id { get; set; } = default;

/// <summary>
/// The type of the item.
/// </summary>
[JsonPropertyName("type")]
public AiTextGenItemsTypeField? Type { get; set; } = default;

/// <summary>
/// The content to use as context for generating new text or editing existing text.
/// </summary>
[JsonPropertyName("content")]
public string? Content { get; set; } = default;

public AiTextGenItemsField() {

}
}
}
11 changes: 11 additions & 0 deletions Box.Sdk.Gen/Schemas/AiTextGenItemsTypeField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.ComponentModel;
using Serializer;
using System.Text.Json.Serialization;

namespace Box.Sdk.Gen.Schemas {
[JsonConverter(typeof(StringEnumConverter<AiTextGenItemsTypeField>))]
public enum AiTextGenItemsTypeField {
[Description("file")]
File
}
}
3 changes: 3 additions & 0 deletions Box.Sdk.Gen/Schemas/PostOAuth2Revoke.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Unions;
using System.Text.Json.Serialization;
using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Box.Sdk.Gen.Schemas {
public class PostOAuth2Revoke {
Expand Down
Loading

0 comments on commit fcf8c8e

Please sign in to comment.