From fa91123e29f536e0dc1f87b5957b71a490eea72b Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Mon, 2 Sep 2024 10:12:12 -0700 Subject: [PATCH] docs: Hubs Beta (box/box-openapi#453) --- .codegen.json | 2 +- Box.Sdk.Gen/Client/BoxClient.cs | 3 + Box.Sdk.Gen/Client/IBoxClient.cs | 2 + .../AppItemAssociationsManager.cs | 90 +++++++++++++++++++ .../GetFileAppItemAssociationsHeaders.cs | 18 ++++ .../GetFileAppItemAssociationsQueryParams.cs | 31 +++++++ .../GetFolderAppItemAssociationsHeaders.cs | 18 ++++ ...GetFolderAppItemAssociationsQueryParams.cs | 31 +++++++ .../IAppItemAssociationsManager.cs | 69 ++++++++++++++ Box.Sdk.Gen/Schemas/AppItem/AppItem.cs | 39 ++++++++ .../Schemas/AppItem/AppItemTypeField.cs | 8 ++ .../AppItemAssociation/AppItemAssociation.cs | 42 +++++++++ .../AppItemAssociationTypeField.cs | 9 ++ .../AppItemAssociations.cs | 49 ++++++++++ .../Schemas/Collaboration/Collaboration.cs | 9 ++ .../FileBaseOrFolderBaseOrWebLinkBase.cs | 63 +++++++++++++ Box.Sdk.Gen/Schemas/FileFull/FileFull.cs | 9 ++ Box.Sdk.Gen/Schemas/FolderFull/FolderFull.cs | 9 ++ docs/AppItemAssociations.md | 78 ++++++++++++++++ docs/README.md | 1 + 20 files changed, 579 insertions(+), 1 deletion(-) create mode 100644 Box.Sdk.Gen/Managers/AppItemAssociations/AppItemAssociationsManager.cs create mode 100644 Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsHeaders.cs create mode 100644 Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsQueryParams.cs create mode 100644 Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsHeaders.cs create mode 100644 Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsQueryParams.cs create mode 100644 Box.Sdk.Gen/Managers/AppItemAssociations/IAppItemAssociationsManager.cs create mode 100644 Box.Sdk.Gen/Schemas/AppItem/AppItem.cs create mode 100644 Box.Sdk.Gen/Schemas/AppItem/AppItemTypeField.cs create mode 100644 Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociation.cs create mode 100644 Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociationTypeField.cs create mode 100644 Box.Sdk.Gen/Schemas/AppItemAssociations/AppItemAssociations.cs create mode 100644 Box.Sdk.Gen/Schemas/FileBaseOrFolderBaseOrWebLinkBase/FileBaseOrFolderBaseOrWebLinkBase.cs create mode 100644 docs/AppItemAssociations.md diff --git a/.codegen.json b/.codegen.json index 94f75f66..cfdecb97 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "2994c4a", "specHash": "739d87b", "version": "1.1.0" } +{ "engineHash": "2994c4a", "specHash": "6ca858e", "version": "1.1.0" } diff --git a/Box.Sdk.Gen/Client/BoxClient.cs b/Box.Sdk.Gen/Client/BoxClient.cs index 71c153a6..8bf32670 100644 --- a/Box.Sdk.Gen/Client/BoxClient.cs +++ b/Box.Sdk.Gen/Client/BoxClient.cs @@ -15,6 +15,8 @@ public class BoxClient : IBoxClient { public ITrashedFilesManager TrashedFiles { get; } + public IAppItemAssociationsManager AppItemAssociations { get; } + public IDownloadsManager Downloads { get; } public IUploadsManager Uploads { get; } @@ -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 }; diff --git a/Box.Sdk.Gen/Client/IBoxClient.cs b/Box.Sdk.Gen/Client/IBoxClient.cs index cf09bab1..78379a63 100644 --- a/Box.Sdk.Gen/Client/IBoxClient.cs +++ b/Box.Sdk.Gen/Client/IBoxClient.cs @@ -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."); } diff --git a/Box.Sdk.Gen/Managers/AppItemAssociations/AppItemAssociationsManager.cs b/Box.Sdk.Gen/Managers/AppItemAssociations/AppItemAssociationsManager.cs new file mode 100644 index 00000000..3322d242 --- /dev/null +++ b/Box.Sdk.Gen/Managers/AppItemAssociations/AppItemAssociationsManager.cs @@ -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(); + } + /// + /// **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. + /// + /// + /// 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" + /// + /// + /// Query parameters of getFileAppItemAssociations method + /// + /// + /// Headers of getFileAppItemAssociations method + /// + /// + /// Token used for request cancellation. + /// + public async System.Threading.Tasks.Task GetFileAppItemAssociationsAsync(string fileId, GetFileAppItemAssociationsQueryParams? queryParams = default, GetFileAppItemAssociationsHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) { + queryParams = queryParams ?? new GetFileAppItemAssociationsQueryParams(); + headers = headers ?? new GetFileAppItemAssociationsHeaders(); + Dictionary queryParamsMap = Utils.PrepareParams(map: new Dictionary() { { "limit", StringUtils.ToStringRepresentation(queryParams.Limit) }, { "marker", StringUtils.ToStringRepresentation(queryParams.Marker) }, { "application_type", StringUtils.ToStringRepresentation(queryParams.ApplicationType) } }); + Dictionary headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary() { }, 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(response.Data); + } + + /// + /// **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. + /// + /// + /// 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" + /// + /// + /// Query parameters of getFolderAppItemAssociations method + /// + /// + /// Headers of getFolderAppItemAssociations method + /// + /// + /// Token used for request cancellation. + /// + public async System.Threading.Tasks.Task GetFolderAppItemAssociationsAsync(string folderId, GetFolderAppItemAssociationsQueryParams? queryParams = default, GetFolderAppItemAssociationsHeaders? headers = default, System.Threading.CancellationToken? cancellationToken = null) { + queryParams = queryParams ?? new GetFolderAppItemAssociationsQueryParams(); + headers = headers ?? new GetFolderAppItemAssociationsHeaders(); + Dictionary queryParamsMap = Utils.PrepareParams(map: new Dictionary() { { "limit", StringUtils.ToStringRepresentation(queryParams.Limit) }, { "marker", StringUtils.ToStringRepresentation(queryParams.Marker) }, { "application_type", StringUtils.ToStringRepresentation(queryParams.ApplicationType) } }); + Dictionary headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary() { }, 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(response.Data); + } + + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsHeaders.cs b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsHeaders.cs new file mode 100644 index 00000000..0b7aee41 --- /dev/null +++ b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsHeaders.cs @@ -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 { + /// + /// Extra headers that will be included in the HTTP request. + /// + public Dictionary ExtraHeaders { get; } + + public GetFileAppItemAssociationsHeaders(Dictionary? extraHeaders = default) { + ExtraHeaders = extraHeaders ?? new Dictionary() { }; + } + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsQueryParams.cs b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsQueryParams.cs new file mode 100644 index 00000000..eb1183ec --- /dev/null +++ b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFileAppItemAssociationsQueryParams.cs @@ -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 { + /// + /// The maximum number of items to return per page. + /// + public long? Limit { get; init; } + + /// + /// 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`. + /// + public string? Marker { get; init; } + + /// + /// If given, only return app items for this application type + /// + public string? ApplicationType { get; init; } + + public GetFileAppItemAssociationsQueryParams() { + + } + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsHeaders.cs b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsHeaders.cs new file mode 100644 index 00000000..75a9252d --- /dev/null +++ b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsHeaders.cs @@ -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 { + /// + /// Extra headers that will be included in the HTTP request. + /// + public Dictionary ExtraHeaders { get; } + + public GetFolderAppItemAssociationsHeaders(Dictionary? extraHeaders = default) { + ExtraHeaders = extraHeaders ?? new Dictionary() { }; + } + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsQueryParams.cs b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsQueryParams.cs new file mode 100644 index 00000000..cf2bacca --- /dev/null +++ b/Box.Sdk.Gen/Managers/AppItemAssociations/GetFolderAppItemAssociationsQueryParams.cs @@ -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 { + /// + /// The maximum number of items to return per page. + /// + public long? Limit { get; init; } + + /// + /// 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`. + /// + public string? Marker { get; init; } + + /// + /// If given, returns only app items for this application type + /// + public string? ApplicationType { get; init; } + + public GetFolderAppItemAssociationsQueryParams() { + + } + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Managers/AppItemAssociations/IAppItemAssociationsManager.cs b/Box.Sdk.Gen/Managers/AppItemAssociations/IAppItemAssociationsManager.cs new file mode 100644 index 00000000..d7eb4e4b --- /dev/null +++ b/Box.Sdk.Gen/Managers/AppItemAssociations/IAppItemAssociationsManager.cs @@ -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 { + /// + /// **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. + /// + /// + /// 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" + /// + /// + /// Query parameters of getFileAppItemAssociations method + /// + /// + /// Headers of getFileAppItemAssociations method + /// + /// + /// Token used for request cancellation. + /// + public System.Threading.Tasks.Task 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."); + + /// + /// **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. + /// + /// + /// 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" + /// + /// + /// Query parameters of getFolderAppItemAssociations method + /// + /// + /// Headers of getFolderAppItemAssociations method + /// + /// + /// Token used for request cancellation. + /// + public System.Threading.Tasks.Task 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."); + + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AppItem/AppItem.cs b/Box.Sdk.Gen/Schemas/AppItem/AppItem.cs new file mode 100644 index 00000000..c8cd7e44 --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AppItem/AppItem.cs @@ -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 { + /// + /// The unique identifier for this app item. + /// + [JsonPropertyName("id")] + public string Id { get; } + + /// + /// `app_item` + /// + [JsonPropertyName("type")] + [JsonConverter(typeof(StringEnumConverter))] + public StringEnum Type { get; } + + /// + /// The type of the app that owns this app item. + /// + [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 type) { + Id = id; + Type = AppItemTypeField.AppItem; + ApplicationType = applicationType; + } + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AppItem/AppItemTypeField.cs b/Box.Sdk.Gen/Schemas/AppItem/AppItemTypeField.cs new file mode 100644 index 00000000..56f785ab --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AppItem/AppItemTypeField.cs @@ -0,0 +1,8 @@ +using System.ComponentModel; + +namespace Box.Sdk.Gen.Schemas { + public enum AppItemTypeField { + [Description("app_item")] + AppItem + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociation.cs b/Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociation.cs new file mode 100644 index 00000000..8d7196b9 --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociation.cs @@ -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 { + /// + /// The unique identifier for this app item association. + /// + [JsonPropertyName("id")] + public string Id { get; } + + /// + /// `app_item_association` + /// + [JsonPropertyName("type")] + [JsonConverter(typeof(StringEnumConverter))] + public StringEnum 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 type) { + Id = id; + Type = AppItemAssociationTypeField.AppItemAssociation; + AppItem = appItem; + Item = item; + } + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociationTypeField.cs b/Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociationTypeField.cs new file mode 100644 index 00000000..30565c62 --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AppItemAssociation/AppItemAssociationTypeField.cs @@ -0,0 +1,9 @@ +using System.ComponentModel; +using Box.Sdk.Gen.Schemas; + +namespace Box.Sdk.Gen.Schemas { + public enum AppItemAssociationTypeField { + [Description("app_item_association")] + AppItemAssociation + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/AppItemAssociations/AppItemAssociations.cs b/Box.Sdk.Gen/Schemas/AppItemAssociations/AppItemAssociations.cs new file mode 100644 index 00000000..2ec94380 --- /dev/null +++ b/Box.Sdk.Gen/Schemas/AppItemAssociations/AppItemAssociations.cs @@ -0,0 +1,49 @@ +using Box.Sdk.Gen; +using System; +using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.Text.Json.Serialization; +using Box.Sdk.Gen.Schemas; + +namespace Box.Sdk.Gen.Schemas { + public class AppItemAssociations { + [JsonInclude] + [JsonPropertyName("_isnext_markerSet")] + protected bool _isNextMarkerSet { get; set; } + + [JsonInclude] + [JsonPropertyName("_isprev_markerSet")] + protected bool _isPrevMarkerSet { get; set; } + + protected string? _nextMarker { get; set; } + + protected string? _prevMarker { get; set; } + + /// + /// The limit that was used for these entries. This will be the same as the + /// `limit` query parameter unless that value exceeded the maximum value + /// allowed. The maximum value varies by API. + /// + [JsonPropertyName("limit")] + public long? Limit { get; init; } + + /// + /// The marker for the start of the next page of results. + /// + [JsonPropertyName("next_marker")] + public string? NextMarker { get => _nextMarker; init { _nextMarker = value; _isNextMarkerSet = true; } } + + /// + /// The marker for the start of the previous page of results. + /// + [JsonPropertyName("prev_marker")] + public string? PrevMarker { get => _prevMarker; init { _prevMarker = value; _isPrevMarkerSet = true; } } + + [JsonPropertyName("entries")] + public IReadOnlyList? Entries { get; init; } + + public AppItemAssociations() { + + } + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/Collaboration/Collaboration.cs b/Box.Sdk.Gen/Schemas/Collaboration/Collaboration.cs index 7484e254..7b884050 100644 --- a/Box.Sdk.Gen/Schemas/Collaboration/Collaboration.cs +++ b/Box.Sdk.Gen/Schemas/Collaboration/Collaboration.cs @@ -9,6 +9,10 @@ public class Collaboration { [JsonPropertyName("_isitemSet")] protected bool _isItemSet { get; set; } + [JsonInclude] + [JsonPropertyName("_isapp_itemSet")] + protected bool _isAppItemSet { get; set; } + [JsonInclude] [JsonPropertyName("_isinvite_emailSet")] protected bool _isInviteEmailSet { get; set; } @@ -19,6 +23,8 @@ public class Collaboration { protected FileOrFolderOrWebLink? _item { get; set; } + protected AppItem? _appItem { get; set; } + protected string? _inviteEmail { get; set; } protected System.DateTimeOffset? _expiresAt { get; set; } @@ -39,6 +45,9 @@ public class Collaboration { [JsonPropertyName("item")] public FileOrFolderOrWebLink? Item { get => _item; init { _item = value; _isItemSet = true; } } + [JsonPropertyName("app_item")] + public AppItem? AppItem { get => _appItem; init { _appItem = value; _isAppItemSet = true; } } + [JsonPropertyName("accessible_by")] public GroupMiniOrUserCollaborations? AccessibleBy { get; init; } diff --git a/Box.Sdk.Gen/Schemas/FileBaseOrFolderBaseOrWebLinkBase/FileBaseOrFolderBaseOrWebLinkBase.cs b/Box.Sdk.Gen/Schemas/FileBaseOrFolderBaseOrWebLinkBase/FileBaseOrFolderBaseOrWebLinkBase.cs new file mode 100644 index 00000000..9c397d73 --- /dev/null +++ b/Box.Sdk.Gen/Schemas/FileBaseOrFolderBaseOrWebLinkBase/FileBaseOrFolderBaseOrWebLinkBase.cs @@ -0,0 +1,63 @@ +using Box.Sdk.Gen; +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Box.Sdk.Gen.Schemas; + +namespace Box.Sdk.Gen.Schemas { + [JsonConverter(typeof(FileBaseOrFolderBaseOrWebLinkBaseConverter))] + public class FileBaseOrFolderBaseOrWebLinkBase : OneOf { + public FileBase? FileBase => _val0; + + public FolderBase? FolderBase => _val1; + + public WebLinkBase? WebLinkBase => _val2; + + public FileBaseOrFolderBaseOrWebLinkBase(FileBase value) : base(value) {} + + public FileBaseOrFolderBaseOrWebLinkBase(FolderBase value) : base(value) {} + + public FileBaseOrFolderBaseOrWebLinkBase(WebLinkBase value) : base(value) {} + + public static implicit operator FileBaseOrFolderBaseOrWebLinkBase(FileBase value) => new FileBaseOrFolderBaseOrWebLinkBase(value); + + public static implicit operator FileBaseOrFolderBaseOrWebLinkBase(FolderBase value) => new FileBaseOrFolderBaseOrWebLinkBase(value); + + public static implicit operator FileBaseOrFolderBaseOrWebLinkBase(WebLinkBase value) => new FileBaseOrFolderBaseOrWebLinkBase(value); + + class FileBaseOrFolderBaseOrWebLinkBaseConverter : JsonConverter { + public override FileBaseOrFolderBaseOrWebLinkBase Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { + using var document = JsonDocument.ParseValue(ref reader); + var discriminant0Present = document.RootElement.TryGetProperty("type", out var discriminant0); + if (discriminant0Present) { + switch (discriminant0.ToString()){ + case "file": + return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to FileBase"); + case "folder": + return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to FolderBase"); + case "web_link": + return JsonSerializer.Deserialize(document) ?? throw new Exception($"Could not deserialize {document} to WebLinkBase"); + } + } + throw new Exception($"Discriminant not found in json payload {document.RootElement} while try to converting to type {typeToConvert}"); + } + + public override void Write(Utf8JsonWriter writer, FileBaseOrFolderBaseOrWebLinkBase? value, JsonSerializerOptions options) { + if (value?.FileBase != null) { + JsonSerializer.Serialize(writer, value.FileBase, options); + return; + } + if (value?.FolderBase != null) { + JsonSerializer.Serialize(writer, value.FolderBase, options); + return; + } + if (value?.WebLinkBase != null) { + JsonSerializer.Serialize(writer, value.WebLinkBase, options); + return; + } + } + + } + + } +} \ No newline at end of file diff --git a/Box.Sdk.Gen/Schemas/FileFull/FileFull.cs b/Box.Sdk.Gen/Schemas/FileFull/FileFull.cs index 2fb32ee0..8fafe853 100644 --- a/Box.Sdk.Gen/Schemas/FileFull/FileFull.cs +++ b/Box.Sdk.Gen/Schemas/FileFull/FileFull.cs @@ -136,6 +136,15 @@ public class FileFull : File { [JsonConverter(typeof(StringEnumListConverter))] public IReadOnlyList>? SharedLinkPermissionOptions { get => _sharedLinkPermissionOptions; init { _sharedLinkPermissionOptions = value; _isSharedLinkPermissionOptionsSet = true; } } + /// + /// This field will return true if the file or any ancestor of the file + /// is associated with at least one app item. Note that this will return + /// true even if the context user does not have access to the app item(s) + /// associated with the file. + /// + [JsonPropertyName("is_associated_with_app_item")] + public bool? IsAssociatedWithAppItem { get; init; } + public FileFull(string id, FileBaseTypeField type = FileBaseTypeField.File) : base(id, type) { } diff --git a/Box.Sdk.Gen/Schemas/FolderFull/FolderFull.cs b/Box.Sdk.Gen/Schemas/FolderFull/FolderFull.cs index d0111219..453fa8f7 100644 --- a/Box.Sdk.Gen/Schemas/FolderFull/FolderFull.cs +++ b/Box.Sdk.Gen/Schemas/FolderFull/FolderFull.cs @@ -86,6 +86,15 @@ public class FolderFull : Folder { [JsonPropertyName("classification")] public FolderFullClassificationField? Classification { get; init; } + /// + /// This field will return true if the folder or any ancestor of the + /// folder is associated with at least one app item. Note that this will + /// return true even if the context user does not have access to the + /// app item(s) associated with the folder. + /// + [JsonPropertyName("is_associated_with_app_item")] + public bool? IsAssociatedWithAppItem { get; init; } + public FolderFull(string id, FolderBaseTypeField type = FolderBaseTypeField.Folder) : base(id, type) { } diff --git a/docs/AppItemAssociations.md b/docs/AppItemAssociations.md new file mode 100644 index 00000000..c76ac956 --- /dev/null +++ b/docs/AppItemAssociations.md @@ -0,0 +1,78 @@ +# IAppItemAssociationsManager + + +- [List file app item associations](#list-file-app-item-associations) +- [List folder app item associations](#list-folder-app-item-associations) + +## List file app item associations + +**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. + +This operation is performed by calling function `GetFileAppItemAssociations`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/get-files-id-app-item-associations/). + +*Currently we don't have an example for calling `GetFileAppItemAssociations` in integration tests* + +### Arguments + +- fileId `string` + - 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" +- queryParams `GetFileAppItemAssociationsQueryParams` + - Query parameters of getFileAppItemAssociations method +- headers `GetFileAppItemAssociationsHeaders` + - Headers of getFileAppItemAssociations method +- cancellationToken `System.Threading.CancellationToken?` + - Token used for request cancellation. + + +### Returns + +This function returns a value of type `AppItemAssociations`. + +Returns a collection of app item objects. If there are no +app items on this file, an empty collection will be returned. +This list includes app items on ancestors of this File. + + +## List folder app item associations + +**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. + +This operation is performed by calling function `GetFolderAppItemAssociations`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/get-folders-id-app-item-associations/). + +*Currently we don't have an example for calling `GetFolderAppItemAssociations` in integration tests* + +### Arguments + +- folderId `string` + - 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" +- queryParams `GetFolderAppItemAssociationsQueryParams` + - Query parameters of getFolderAppItemAssociations method +- headers `GetFolderAppItemAssociationsHeaders` + - Headers of getFolderAppItemAssociations method +- cancellationToken `System.Threading.CancellationToken?` + - Token used for request cancellation. + + +### Returns + +This function returns a value of type `AppItemAssociations`. + +Returns a collection of app item objects. If there are no +app items on this folder an empty collection will be returned. +This list includes app items on ancestors of this folder. + + diff --git a/docs/README.md b/docs/README.md index 2473ed7b..05199a81 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,6 +6,7 @@ General explanations of the available functionality and examples of how to use the SDK are available by topic: * [Ai](Ai.md) +* [App item associations](AppItemAssociations.md) * [Authorization](Authorization.md) * [Avatars](Avatars.md) * [Chunked uploads](ChunkedUploads.md)