Skip to content

Commit

Permalink
docs: Hubs Beta (box/box-openapi#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build committed Sep 2, 2024
1 parent 873a6bc commit fa91123
Show file tree
Hide file tree
Showing 20 changed files with 579 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": "2994c4a", "specHash": "739d87b", "version": "1.1.0" }
{ "engineHash": "2994c4a", "specHash": "6ca858e", "version": "1.1.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 @@ -15,6 +15,8 @@ public class BoxClient : IBoxClient {

public ITrashedFilesManager TrashedFiles { get; }

public IAppItemAssociationsManager AppItemAssociations { get; }

public IDownloadsManager Downloads { get; }

public IUploadsManager Uploads { get; }
Expand Down Expand Up @@ -153,6 +155,7 @@ public BoxClient(IAuthentication auth, NetworkSession? networkSession = default)
Authorization = new AuthorizationManager(networkSession: this.NetworkSession) { Auth = this.Auth };
Files = new FilesManager(networkSession: this.NetworkSession) { Auth = this.Auth };
TrashedFiles = new TrashedFilesManager(networkSession: this.NetworkSession) { Auth = this.Auth };
AppItemAssociations = new AppItemAssociationsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
Downloads = new DownloadsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
Uploads = new UploadsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
ChunkedUploads = new ChunkedUploadsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
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 @@ -13,6 +13,8 @@ public interface IBoxClient {

public ITrashedFilesManager TrashedFiles { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }

public IAppItemAssociationsManager AppItemAssociations { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }

public IDownloadsManager Downloads { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }

public IUploadsManager Uploads { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using Box.Sdk.Gen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Internal;
using Box.Sdk.Gen.Schemas;

namespace Box.Sdk.Gen.Managers {
public class AppItemAssociationsManager : IAppItemAssociationsManager {
public IAuthentication? Auth { get; init; }

public NetworkSession NetworkSession { get; }

public AppItemAssociationsManager(NetworkSession? networkSession = default) {
NetworkSession = networkSession ?? new NetworkSession();
}
/// <summary>
/// **This is a beta feature, which means that its availability might be limited.**
/// Returns all app items the file is associated with. This includes app items
/// associated with ancestors of the file. Assuming the context user has access
/// to the file, the type/ids are revealed even if the context user does not
/// have **View** permission on the app item.
/// </summary>
/// <param name="fileId">
/// The unique identifier that represents a file.
///
/// The ID for any file can be determined
/// by visiting a file in the web application
/// and copying the ID from the URL. For example,
/// for the URL `https://*.app.box.com/files/123`
/// the `file_id` is `123`.
/// Example: "12345"
/// </param>
/// <param name="queryParams">
/// Query parameters of getFileAppItemAssociations method
/// </param>
/// <param name="headers">
/// Headers of getFileAppItemAssociations method
/// </param>
/// <param name="cancellationToken">
/// Token used for request cancellation.
/// </param>
public async System.Threading.Tasks.Task<AppItemAssociations> GetFileAppItemAssociationsAsync(string fileId, GetFileAppItemAssociationsQueryParams? queryParams = default, GetFileAppItemAssociationsHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
queryParams = queryParams ?? new GetFileAppItemAssociationsQueryParams();
headers = headers ?? new GetFileAppItemAssociationsHeaders();
Dictionary<string, string> queryParamsMap = Utils.PrepareParams(map: new Dictionary<string, string?>() { { "limit", StringUtils.ToStringRepresentation(queryParams.Limit) }, { "marker", StringUtils.ToStringRepresentation(queryParams.Marker) }, { "application_type", StringUtils.ToStringRepresentation(queryParams.ApplicationType) } });
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { }, headers.ExtraHeaders));
FetchResponse response = await HttpClientAdapter.FetchAsync(new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/files/", StringUtils.ToStringRepresentation(fileId), "/app_item_associations"), networkSession: this.NetworkSession) { Method = "GET", Parameters = queryParamsMap, Headers = headersMap, ResponseFormat = "json", Auth = this.Auth, CancellationToken = cancellationToken }).ConfigureAwait(false);
return SimpleJsonSerializer.Deserialize<AppItemAssociations>(response.Data);
}

/// <summary>
/// **This is a beta feature, which means that its availability might be limited.**
/// Returns all app items the folder is associated with. This includes app items
/// associated with ancestors of the folder. Assuming the context user has access
/// to the folder, the type/ids are revealed even if the context user does not
/// have **View** permission on the app item.
/// </summary>
/// <param name="folderId">
/// The unique identifier that represent a folder.
///
/// The ID for any folder can be determined
/// by visiting this folder in the web application
/// and copying the ID from the URL. For example,
/// for the URL `https://*.app.box.com/folder/123`
/// the `folder_id` is `123`.
///
/// The root folder of a Box account is
/// always represented by the ID `0`.
/// Example: "12345"
/// </param>
/// <param name="queryParams">
/// Query parameters of getFolderAppItemAssociations method
/// </param>
/// <param name="headers">
/// Headers of getFolderAppItemAssociations method
/// </param>
/// <param name="cancellationToken">
/// Token used for request cancellation.
/// </param>
public async System.Threading.Tasks.Task<AppItemAssociations> GetFolderAppItemAssociationsAsync(string folderId, GetFolderAppItemAssociationsQueryParams? queryParams = default, GetFolderAppItemAssociationsHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
queryParams = queryParams ?? new GetFolderAppItemAssociationsQueryParams();
headers = headers ?? new GetFolderAppItemAssociationsHeaders();
Dictionary<string, string> queryParamsMap = Utils.PrepareParams(map: new Dictionary<string, string?>() { { "limit", StringUtils.ToStringRepresentation(queryParams.Limit) }, { "marker", StringUtils.ToStringRepresentation(queryParams.Marker) }, { "application_type", StringUtils.ToStringRepresentation(queryParams.ApplicationType) } });
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { }, headers.ExtraHeaders));
FetchResponse response = await HttpClientAdapter.FetchAsync(new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/folders/", StringUtils.ToStringRepresentation(folderId), "/app_item_associations"), networkSession: this.NetworkSession) { Method = "GET", Parameters = queryParamsMap, Headers = headersMap, ResponseFormat = "json", Auth = this.Auth, CancellationToken = cancellationToken }).ConfigureAwait(false);
return SimpleJsonSerializer.Deserialize<AppItemAssociations>(response.Data);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Box.Sdk.Gen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen.Internal;

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

public GetFileAppItemAssociationsHeaders(Dictionary<string, string?>? extraHeaders = default) {
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Box.Sdk.Gen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen.Internal;

namespace Box.Sdk.Gen.Managers {
public class GetFileAppItemAssociationsQueryParams {
/// <summary>
/// The maximum number of items to return per page.
/// </summary>
public long? Limit { get; init; }

/// <summary>
/// Defines the position marker at which to begin returning results. This is
/// used when paginating using marker-based pagination.
///
/// This requires `usemarker` to be set to `true`.
/// </summary>
public string? Marker { get; init; }

/// <summary>
/// If given, only return app items for this application type
/// </summary>
public string? ApplicationType { get; init; }

public GetFileAppItemAssociationsQueryParams() {

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Box.Sdk.Gen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen.Internal;

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

public GetFolderAppItemAssociationsHeaders(Dictionary<string, string?>? extraHeaders = default) {
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Box.Sdk.Gen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen.Internal;

namespace Box.Sdk.Gen.Managers {
public class GetFolderAppItemAssociationsQueryParams {
/// <summary>
/// The maximum number of items to return per page.
/// </summary>
public long? Limit { get; init; }

/// <summary>
/// Defines the position marker at which to begin returning results. This is
/// used when paginating using marker-based pagination.
///
/// This requires `usemarker` to be set to `true`.
/// </summary>
public string? Marker { get; init; }

/// <summary>
/// If given, returns only app items for this application type
/// </summary>
public string? ApplicationType { get; init; }

public GetFolderAppItemAssociationsQueryParams() {

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Box.Sdk.Gen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Box.Sdk.Gen.Schemas;
using Box.Sdk.Gen.Internal;

namespace Box.Sdk.Gen.Managers {
public interface IAppItemAssociationsManager {
/// <summary>
/// **This is a beta feature, which means that its availability might be limited.**
/// Returns all app items the file is associated with. This includes app items
/// associated with ancestors of the file. Assuming the context user has access
/// to the file, the type/ids are revealed even if the context user does not
/// have **View** permission on the app item.
/// </summary>
/// <param name="fileId">
/// The unique identifier that represents a file.
///
/// The ID for any file can be determined
/// by visiting a file in the web application
/// and copying the ID from the URL. For example,
/// for the URL `https://*.app.box.com/files/123`
/// the `file_id` is `123`.
/// Example: "12345"
/// </param>
/// <param name="queryParams">
/// Query parameters of getFileAppItemAssociations method
/// </param>
/// <param name="headers">
/// Headers of getFileAppItemAssociations method
/// </param>
/// <param name="cancellationToken">
/// Token used for request cancellation.
/// </param>
public System.Threading.Tasks.Task<AppItemAssociations> GetFileAppItemAssociationsAsync(string fileId, GetFileAppItemAssociationsQueryParams? queryParams = default, GetFileAppItemAssociationsHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");

/// <summary>
/// **This is a beta feature, which means that its availability might be limited.**
/// Returns all app items the folder is associated with. This includes app items
/// associated with ancestors of the folder. Assuming the context user has access
/// to the folder, the type/ids are revealed even if the context user does not
/// have **View** permission on the app item.
/// </summary>
/// <param name="folderId">
/// The unique identifier that represent a folder.
///
/// The ID for any folder can be determined
/// by visiting this folder in the web application
/// and copying the ID from the URL. For example,
/// for the URL `https://*.app.box.com/folder/123`
/// the `folder_id` is `123`.
///
/// The root folder of a Box account is
/// always represented by the ID `0`.
/// Example: "12345"
/// </param>
/// <param name="queryParams">
/// Query parameters of getFolderAppItemAssociations method
/// </param>
/// <param name="headers">
/// Headers of getFolderAppItemAssociations method
/// </param>
/// <param name="cancellationToken">
/// Token used for request cancellation.
/// </param>
public System.Threading.Tasks.Task<AppItemAssociations> GetFolderAppItemAssociationsAsync(string folderId, GetFolderAppItemAssociationsQueryParams? queryParams = default, GetFolderAppItemAssociationsHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");

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

namespace Box.Sdk.Gen.Schemas {
public class AppItem {
/// <summary>
/// The unique identifier for this app item.
/// </summary>
[JsonPropertyName("id")]
public string Id { get; }

/// <summary>
/// `app_item`
/// </summary>
[JsonPropertyName("type")]
[JsonConverter(typeof(StringEnumConverter<AppItemTypeField>))]
public StringEnum<AppItemTypeField> Type { get; }

/// <summary>
/// The type of the app that owns this app item.
/// </summary>
[JsonPropertyName("application_type")]
public string ApplicationType { get; }

public AppItem(string id, string applicationType, AppItemTypeField type = AppItemTypeField.AppItem) {
Id = id;
Type = type;
ApplicationType = applicationType;
}

[JsonConstructorAttribute]
internal AppItem(string id, string applicationType, StringEnum<AppItemTypeField> type) {
Id = id;
Type = AppItemTypeField.AppItem;
ApplicationType = applicationType;
}
}
}
8 changes: 8 additions & 0 deletions Box.Sdk.Gen/Schemas/AppItem/AppItemTypeField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.ComponentModel;

namespace Box.Sdk.Gen.Schemas {
public enum AppItemTypeField {
[Description("app_item")]
AppItem
}
}
42 changes: 42 additions & 0 deletions Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Box.Sdk.Gen;
using System.Text.Json.Serialization;
using Box.Sdk.Gen.Internal;
using Box.Sdk.Gen.Schemas;

namespace Box.Sdk.Gen.Schemas {
public class AppItemAssociation {
/// <summary>
/// The unique identifier for this app item association.
/// </summary>
[JsonPropertyName("id")]
public string Id { get; }

/// <summary>
/// `app_item_association`
/// </summary>
[JsonPropertyName("type")]
[JsonConverter(typeof(StringEnumConverter<AppItemAssociationTypeField>))]
public StringEnum<AppItemAssociationTypeField> Type { get; }

[JsonPropertyName("app_item")]
public AppItem AppItem { get; }

[JsonPropertyName("item")]
public FileBaseOrFolderBaseOrWebLinkBase Item { get; }

public AppItemAssociation(string id, AppItem appItem, FileBaseOrFolderBaseOrWebLinkBase item, AppItemAssociationTypeField type = AppItemAssociationTypeField.AppItemAssociation) {
Id = id;
Type = type;
AppItem = appItem;
Item = item;
}

[JsonConstructorAttribute]
internal AppItemAssociation(string id, AppItem appItem, FileBaseOrFolderBaseOrWebLinkBase item, StringEnum<AppItemAssociationTypeField> type) {
Id = id;
Type = AppItemAssociationTypeField.AppItemAssociation;
AppItem = appItem;
Item = item;
}
}
}
Loading

0 comments on commit fa91123

Please sign in to comment.