Skip to content

Commit be0bb9d

Browse files
feat: Add Archive Public API (box/box-openapi#540) (#543)
1 parent 4629365 commit be0bb9d

17 files changed

+514
-5
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "43a5daf", "specHash": "eaa9cf0", "version": "1.10.0" }
1+
{ "engineHash": "ac37b50", "specHash": "c27c421", "version": "1.10.0" }

Box.Sdk.Gen/Client/BoxClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public class BoxClient : IBoxClient {
165165

166166
public IShieldListsManager ShieldLists { get; }
167167

168+
public IArchivesManager Archives { get; }
169+
168170
public BoxClient(IAuthentication auth, NetworkSession? networkSession = default) {
169171
Auth = auth;
170172
NetworkSession = networkSession ?? new NetworkSession(baseUrls: new BaseUrls());
@@ -246,6 +248,7 @@ public BoxClient(IAuthentication auth, NetworkSession? networkSession = default)
246248
HubCollaborations = new HubCollaborationsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
247249
HubItems = new HubItemsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
248250
ShieldLists = new ShieldListsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
251+
Archives = new ArchivesManager(networkSession: this.NetworkSession) { Auth = this.Auth };
249252
}
250253
/// <summary>
251254
/// Make a custom http request using the client authentication and network session.

Box.Sdk.Gen/Client/IBoxClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,7 @@ public interface IBoxClient {
163163

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

166+
public IArchivesManager Archives { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
167+
166168
}
167169
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text.Json.Serialization;
5+
using Box.Sdk.Gen.Internal;
6+
using Box.Sdk.Gen.Schemas;
7+
using Box.Sdk.Gen.Parameters;
8+
9+
namespace Box.Sdk.Gen.Managers {
10+
public class ArchivesManager : IArchivesManager {
11+
public IAuthentication? Auth { get; init; }
12+
13+
public NetworkSession NetworkSession { get; }
14+
15+
public ArchivesManager(NetworkSession? networkSession = default) {
16+
NetworkSession = networkSession ?? new NetworkSession();
17+
}
18+
/// <summary>
19+
/// Retrieves archives for an enterprise.
20+
/// </summary>
21+
/// <param name="queryParams">
22+
/// Query parameters of getArchivesV2025R0 method
23+
/// </param>
24+
/// <param name="headers">
25+
/// Headers of getArchivesV2025R0 method
26+
/// </param>
27+
/// <param name="cancellationToken">
28+
/// Token used for request cancellation.
29+
/// </param>
30+
public async System.Threading.Tasks.Task<ArchivesV2025R0> GetArchivesV2025R0Async(GetArchivesV2025R0QueryParams? queryParams = default, GetArchivesV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
31+
queryParams = queryParams ?? new GetArchivesV2025R0QueryParams();
32+
headers = headers ?? new GetArchivesV2025R0Headers();
33+
Dictionary<string, string> queryParamsMap = Utils.PrepareParams(map: new Dictionary<string, string?>() { { "limit", StringUtils.ToStringRepresentation(queryParams.Limit) }, { "marker", StringUtils.ToStringRepresentation(queryParams.Marker) } });
34+
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { { "box-version", StringUtils.ToStringRepresentation(headers.BoxVersion) } }, headers.ExtraHeaders));
35+
FetchResponse response = await this.NetworkSession.NetworkClient.FetchAsync(options: new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/archives"), method: "GET", responseFormat: Box.Sdk.Gen.ResponseFormat.Json) { Parameters = queryParamsMap, Headers = headersMap, Auth = this.Auth, NetworkSession = this.NetworkSession, CancellationToken = cancellationToken }).ConfigureAwait(false);
36+
return SimpleJsonSerializer.Deserialize<ArchivesV2025R0>(NullableUtils.Unwrap(response.Data));
37+
}
38+
39+
/// <summary>
40+
/// Creates an archive.
41+
/// </summary>
42+
/// <param name="requestBody">
43+
/// Request body of createArchiveV2025R0 method
44+
/// </param>
45+
/// <param name="headers">
46+
/// Headers of createArchiveV2025R0 method
47+
/// </param>
48+
/// <param name="cancellationToken">
49+
/// Token used for request cancellation.
50+
/// </param>
51+
public async System.Threading.Tasks.Task<ArchiveV2025R0> CreateArchiveV2025R0Async(CreateArchiveV2025R0RequestBody requestBody, CreateArchiveV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
52+
headers = headers ?? new CreateArchiveV2025R0Headers();
53+
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { { "box-version", StringUtils.ToStringRepresentation(headers.BoxVersion) } }, headers.ExtraHeaders));
54+
FetchResponse response = await this.NetworkSession.NetworkClient.FetchAsync(options: new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/archives"), method: "POST", contentType: "application/json", responseFormat: Box.Sdk.Gen.ResponseFormat.Json) { Headers = headersMap, Data = SimpleJsonSerializer.Serialize(requestBody), Auth = this.Auth, NetworkSession = this.NetworkSession, CancellationToken = cancellationToken }).ConfigureAwait(false);
55+
return SimpleJsonSerializer.Deserialize<ArchiveV2025R0>(NullableUtils.Unwrap(response.Data));
56+
}
57+
58+
/// <summary>
59+
/// Permanently deletes an archive.
60+
/// </summary>
61+
/// <param name="archiveId">
62+
/// The ID of the archive.
63+
/// Example: "982312"
64+
/// </param>
65+
/// <param name="headers">
66+
/// Headers of deleteArchiveByIdV2025R0 method
67+
/// </param>
68+
/// <param name="cancellationToken">
69+
/// Token used for request cancellation.
70+
/// </param>
71+
public async System.Threading.Tasks.Task DeleteArchiveByIdV2025R0Async(string archiveId, DeleteArchiveByIdV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
72+
headers = headers ?? new DeleteArchiveByIdV2025R0Headers();
73+
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { { "box-version", StringUtils.ToStringRepresentation(headers.BoxVersion) } }, headers.ExtraHeaders));
74+
FetchResponse response = await this.NetworkSession.NetworkClient.FetchAsync(options: new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/archives/", StringUtils.ToStringRepresentation(archiveId)), method: "DELETE", responseFormat: Box.Sdk.Gen.ResponseFormat.NoContent) { Headers = headersMap, Auth = this.Auth, NetworkSession = this.NetworkSession, CancellationToken = cancellationToken }).ConfigureAwait(false);
75+
}
76+
77+
}
78+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text.Json.Serialization;
5+
using Box.Sdk.Gen.Internal;
6+
using Box.Sdk.Gen.Schemas;
7+
using Box.Sdk.Gen.Parameters;
8+
9+
namespace Box.Sdk.Gen.Managers {
10+
public class CreateArchiveV2025R0Headers {
11+
/// <summary>
12+
/// Version header.
13+
/// </summary>
14+
public StringEnum<BoxVersionHeaderV2025R0> BoxVersion { get; }
15+
16+
/// <summary>
17+
/// Extra headers that will be included in the HTTP request.
18+
/// </summary>
19+
public Dictionary<string, string?> ExtraHeaders { get; }
20+
21+
public CreateArchiveV2025R0Headers(BoxVersionHeaderV2025R0 boxVersion = BoxVersionHeaderV2025R0._20250, Dictionary<string, string?>? extraHeaders = default) {
22+
BoxVersion = boxVersion;
23+
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
24+
}
25+
}
26+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text.Json.Serialization;
5+
using Box.Sdk.Gen.Internal;
6+
using Box.Sdk.Gen.Schemas;
7+
using Box.Sdk.Gen.Parameters;
8+
9+
namespace Box.Sdk.Gen.Managers {
10+
public class CreateArchiveV2025R0RequestBody : ISerializable {
11+
/// <summary>
12+
/// The name of the archive.
13+
/// </summary>
14+
[JsonPropertyName("name")]
15+
public string Name { get; }
16+
17+
public CreateArchiveV2025R0RequestBody(string name) {
18+
Name = name;
19+
}
20+
internal string? RawJson { get; set; } = default;
21+
22+
void ISerializable.SetJson(string json) {
23+
RawJson = json;
24+
}
25+
26+
string? ISerializable.GetJson() {
27+
return RawJson;
28+
}
29+
30+
/// <summary>
31+
/// Returns raw json response returned from the API.
32+
/// </summary>
33+
public Dictionary<string, object?>? GetRawData() {
34+
return SimpleJsonSerializer.GetAllFields(this);
35+
}
36+
37+
}
38+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text.Json.Serialization;
5+
using Box.Sdk.Gen.Internal;
6+
using Box.Sdk.Gen.Schemas;
7+
using Box.Sdk.Gen.Parameters;
8+
9+
namespace Box.Sdk.Gen.Managers {
10+
public class DeleteArchiveByIdV2025R0Headers {
11+
/// <summary>
12+
/// Version header.
13+
/// </summary>
14+
public StringEnum<BoxVersionHeaderV2025R0> BoxVersion { get; }
15+
16+
/// <summary>
17+
/// Extra headers that will be included in the HTTP request.
18+
/// </summary>
19+
public Dictionary<string, string?> ExtraHeaders { get; }
20+
21+
public DeleteArchiveByIdV2025R0Headers(BoxVersionHeaderV2025R0 boxVersion = BoxVersionHeaderV2025R0._20250, Dictionary<string, string?>? extraHeaders = default) {
22+
BoxVersion = boxVersion;
23+
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
24+
}
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text.Json.Serialization;
5+
using Box.Sdk.Gen.Internal;
6+
using Box.Sdk.Gen.Schemas;
7+
using Box.Sdk.Gen.Parameters;
8+
9+
namespace Box.Sdk.Gen.Managers {
10+
public class GetArchivesV2025R0Headers {
11+
/// <summary>
12+
/// Version header.
13+
/// </summary>
14+
public StringEnum<BoxVersionHeaderV2025R0> BoxVersion { get; }
15+
16+
/// <summary>
17+
/// Extra headers that will be included in the HTTP request.
18+
/// </summary>
19+
public Dictionary<string, string?> ExtraHeaders { get; }
20+
21+
public GetArchivesV2025R0Headers(BoxVersionHeaderV2025R0 boxVersion = BoxVersionHeaderV2025R0._20250, Dictionary<string, string?>? extraHeaders = default) {
22+
BoxVersion = boxVersion;
23+
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
24+
}
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text.Json.Serialization;
5+
using Box.Sdk.Gen.Internal;
6+
using Box.Sdk.Gen.Schemas;
7+
using Box.Sdk.Gen.Parameters;
8+
9+
namespace Box.Sdk.Gen.Managers {
10+
public class GetArchivesV2025R0QueryParams {
11+
/// <summary>
12+
/// The maximum number of items to return per page.
13+
/// </summary>
14+
public long? Limit { get; init; }
15+
16+
/// <summary>
17+
/// Defines the position marker at which to begin returning results. This is
18+
/// used when paginating using marker-based pagination.
19+
/// </summary>
20+
public string? Marker { get; init; }
21+
22+
public GetArchivesV2025R0QueryParams() {
23+
24+
}
25+
}
26+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text.Json.Serialization;
5+
using Box.Sdk.Gen.Internal;
6+
using Box.Sdk.Gen.Schemas;
7+
using Box.Sdk.Gen.Parameters;
8+
9+
namespace Box.Sdk.Gen.Managers {
10+
public interface IArchivesManager {
11+
/// <summary>
12+
/// Retrieves archives for an enterprise.
13+
/// </summary>
14+
/// <param name="queryParams">
15+
/// Query parameters of getArchivesV2025R0 method
16+
/// </param>
17+
/// <param name="headers">
18+
/// Headers of getArchivesV2025R0 method
19+
/// </param>
20+
/// <param name="cancellationToken">
21+
/// Token used for request cancellation.
22+
/// </param>
23+
public System.Threading.Tasks.Task<ArchivesV2025R0> GetArchivesV2025R0Async(GetArchivesV2025R0QueryParams? queryParams = default, GetArchivesV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");
24+
25+
/// <summary>
26+
/// Creates an archive.
27+
/// </summary>
28+
/// <param name="requestBody">
29+
/// Request body of createArchiveV2025R0 method
30+
/// </param>
31+
/// <param name="headers">
32+
/// Headers of createArchiveV2025R0 method
33+
/// </param>
34+
/// <param name="cancellationToken">
35+
/// Token used for request cancellation.
36+
/// </param>
37+
public System.Threading.Tasks.Task<ArchiveV2025R0> CreateArchiveV2025R0Async(CreateArchiveV2025R0RequestBody requestBody, CreateArchiveV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");
38+
39+
/// <summary>
40+
/// Permanently deletes an archive.
41+
/// </summary>
42+
/// <param name="archiveId">
43+
/// The ID of the archive.
44+
/// Example: "982312"
45+
/// </param>
46+
/// <param name="headers">
47+
/// Headers of deleteArchiveByIdV2025R0 method
48+
/// </param>
49+
/// <param name="cancellationToken">
50+
/// Token used for request cancellation.
51+
/// </param>
52+
public System.Threading.Tasks.Task DeleteArchiveByIdV2025R0Async(string archiveId, DeleteArchiveByIdV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");
53+
54+
}
55+
}

0 commit comments

Comments
 (0)