Skip to content

Commit 47d6b41

Browse files
Add ICloudinary interface for Cloudinary class
Fixes #317
1 parent a670986 commit 47d6b41

File tree

9 files changed

+2445
-6
lines changed

9 files changed

+2445
-6
lines changed

CloudinaryDotNet/Cloudinary.UploadApi.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,9 @@ internal class UploadLargeParams
10831083
public UploadLargeParams(BasicRawUploadParams parameters, int bufferSize, Api api)
10841084
{
10851085
parameters.File.Reset(bufferSize);
1086-
this.Parameters = parameters;
1087-
this.Url = GetUploadUrl(parameters, api);
1088-
this.BufferSize = bufferSize;
1086+
Parameters = parameters;
1087+
Url = GetUploadUrl(parameters, api);
1088+
BufferSize = bufferSize != 0 ? bufferSize : DEFAULT_CHUNK_SIZE;
10891089
}
10901090

10911091
/// <summary>

CloudinaryDotNet/Cloudinary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// Main class of Cloudinary .NET API.
1010
/// </summary>
1111
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Reviewed.")]
12-
public partial class Cloudinary
12+
public partial class Cloudinary : ICloudinary
1313
{
1414
/// <summary>
1515
/// Cloudinary <see cref="Api"/> object.

CloudinaryDotNet/CloudinaryDotNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</ItemGroup>
6464
<ItemGroup>
6565
<None Include=".\CloudinaryIcon.png" Pack="true" PackagePath="\" />
66-
<None Include="..\README.md" Pack="true" PackagePath="\"/>
66+
<None Include="..\README.md" Pack="true" PackagePath="\" />
6767
</ItemGroup>
6868
<ItemGroup>
6969
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.2">

CloudinaryDotNet/ICloudinary.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace CloudinaryDotNet
2+
{
3+
/// <summary>
4+
/// Cloudinary Interface.
5+
/// </summary>
6+
public interface ICloudinary : ICloudinaryAdminApi, ICloudinarySearchApi, ICloudinaryUploadApi
7+
{
8+
}
9+
}

CloudinaryDotNet/ICloudinaryAdminApi.cs

Lines changed: 1607 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace CloudinaryDotNet
2+
{
3+
/// <summary>
4+
/// Cloudinary Search API Interface.
5+
/// </summary>
6+
public interface ICloudinarySearchApi
7+
{
8+
/// <summary>
9+
/// Gets the advanced search provider used by the Cloudinary instance.
10+
/// </summary>
11+
/// <returns>Instance of the <see cref="Cloudinary.Search"/> class.</returns>
12+
Search Search();
13+
14+
/// <summary>
15+
/// Gets the advanced search folders provider used by the Cloudinary instance.
16+
/// </summary>
17+
/// <returns>Instance of the <see cref="Cloudinary.SearchFolders"/> class.</returns>
18+
SearchFolders SearchFolders();
19+
}
20+
}

CloudinaryDotNet/ICloudinaryUploadApi.cs

Lines changed: 517 additions & 0 deletions
Large diffs are not rendered by default.

CloudinaryDotNet/Provisioning/AccountProvisioning.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// <summary>
88
/// Account provisioning.
99
/// </summary>
10-
public class AccountProvisioning
10+
public class AccountProvisioning : IAccountProvisioning
1111
{
1212
/// <summary>
1313
/// Gets Provisioning API object that used by this instance.
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
namespace CloudinaryDotNet.Provisioning
2+
{
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using CloudinaryDotNet.Actions;
6+
7+
/// <summary>
8+
/// Account Provisioning Interface.
9+
/// </summary>
10+
public interface IAccountProvisioning
11+
{
12+
/// <summary>
13+
/// Retrieves the details of the specified sub-account.
14+
/// </summary>
15+
/// <param name="subAccountId">The ID of the sub-account.</param>
16+
/// <returns>Parsed information about sub-account.</returns>
17+
SubAccountResult SubAccount(string subAccountId);
18+
19+
/// <summary>
20+
/// Retrieves the details of the specified sub-account asynchronously.
21+
/// </summary>
22+
/// <param name="subAccountId">The ID of the sub-account.</param>
23+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
24+
/// <returns>Parsed information about sub-account.</returns>
25+
Task<SubAccountResult> SubAccountAsync(string subAccountId, CancellationToken? cancellationToken = null);
26+
27+
/// <summary>
28+
/// Lists sub-accounts.
29+
/// </summary>
30+
/// <param name="parameters">Parameters to list sub-accounts.</param>
31+
/// <returns>Parsed information about sub-accounts.</returns>
32+
ListSubAccountsResult SubAccounts(ListSubAccountsParams parameters);
33+
34+
/// <summary>
35+
/// Lists sub-accounts asynchronously.
36+
/// </summary>
37+
/// <param name="parameters">Parameters to list sub-accounts.</param>
38+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
39+
/// <returns>Parsed information about sub-accounts.</returns>
40+
Task<ListSubAccountsResult> SubAccountsAsync(ListSubAccountsParams parameters, CancellationToken? cancellationToken = null);
41+
42+
/// <summary>
43+
/// Creates a new sub-account. Any users that have access to all sub-accounts
44+
/// will also automatically have access to the new sub-account.
45+
/// </summary>
46+
/// <param name="parameters">Parameters to create sub-account.</param>
47+
/// <returns>Parsed information about created sub-account.</returns>
48+
SubAccountResult CreateSubAccount(CreateSubAccountParams parameters);
49+
50+
/// <summary>
51+
/// Creates a new sub-account asynchronously. Any users that have access to all sub-accounts
52+
/// will also automatically have access to the new sub-account.
53+
/// </summary>
54+
/// <param name="parameters">Parameters to create sub-account.</param>
55+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
56+
/// <returns>Parsed information about created sub-account.</returns>
57+
Task<SubAccountResult> CreateSubAccountAsync(CreateSubAccountParams parameters, CancellationToken? cancellationToken = null);
58+
59+
/// <summary>
60+
/// Updates the specified details of the sub-account.
61+
/// </summary>
62+
/// <param name="parameters">Parameters to update sub-account.</param>
63+
/// <returns>Parsed information about updated sub-account.</returns>
64+
SubAccountResult UpdateSubAccount(UpdateSubAccountParams parameters);
65+
66+
/// <summary>
67+
/// Updates the specified details of the sub-account asynchronously.
68+
/// </summary>
69+
/// <param name="parameters">Parameters to update sub-account.</param>
70+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
71+
/// <returns>Parsed information about updated sub-account.</returns>
72+
Task<SubAccountResult> UpdateSubAccountAsync(UpdateSubAccountParams parameters, CancellationToken? cancellationToken = null);
73+
74+
/// <summary>
75+
/// Deletes the specified sub-account. Supported only for accounts with fewer than 1000 assets.
76+
/// </summary>
77+
/// <param name="subAccountId">The ID of the sub-account to delete.</param>
78+
/// <returns>Parsed information about deleted sub-account.</returns>
79+
DelSubAccountResult DeleteSubAccount(string subAccountId);
80+
81+
/// <summary>
82+
/// Deletes the specified sub-account asynchronously. Supported only for accounts with fewer than 1000 assets.
83+
/// </summary>
84+
/// <param name="subAccountId">The ID of the sub-account to delete.</param>
85+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
86+
/// <returns>Parsed information about deleted sub-account.</returns>
87+
Task<DelSubAccountResult> DeleteSubAccountAsync(string subAccountId, CancellationToken? cancellationToken = null);
88+
89+
/// <summary>
90+
/// Returns the user with the specified ID.
91+
/// </summary>
92+
/// <param name="userId">The ID of the user.</param>
93+
/// <returns>Parsed information about sub-account.</returns>
94+
UserResult User(string userId);
95+
96+
/// <summary>
97+
/// Returns the user with the specified ID asynchronously.
98+
/// </summary>
99+
/// <param name="userId">The ID of the user.</param>
100+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
101+
/// <returns>Parsed information about sub-account.</returns>
102+
Task<UserResult> UserAsync(string userId, CancellationToken? cancellationToken = null);
103+
104+
/// <summary>
105+
/// Lists users in the account.
106+
/// </summary>
107+
/// <param name="parameters">Parameters to list users.</param>
108+
/// <returns>Parsed information about users.</returns>
109+
ListUsersResult Users(ListUsersParams parameters);
110+
111+
/// <summary>
112+
/// Lists users in the account asynchronously.
113+
/// </summary>
114+
/// <param name="parameters">Parameters to list users.</param>
115+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
116+
/// <returns>Parsed information about users.</returns>
117+
Task<ListUsersResult> UsersAsync(ListUsersParams parameters, CancellationToken? cancellationToken = null);
118+
119+
/// <summary>
120+
/// Creates a new user in the account.
121+
/// </summary>
122+
/// <param name="parameters">Parameters to create user.</param>
123+
/// <returns>Parsed information about created user.</returns>
124+
UserResult CreateUser(CreateUserParams parameters);
125+
126+
/// <summary>
127+
/// Creates a new user in the account asynchronously.
128+
/// </summary>
129+
/// <param name="parameters">Parameters to create user.</param>
130+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
131+
/// <returns>Parsed information about created user.</returns>
132+
Task<UserResult> CreateUserAsync(CreateUserParams parameters, CancellationToken? cancellationToken = null);
133+
134+
/// <summary>
135+
/// Updates the details of the specified user.
136+
/// </summary>
137+
/// <param name="parameters">Parameters to update user.</param>
138+
/// <returns>Parsed information about updated user.</returns>
139+
UserResult UpdateUser(UpdateUserParams parameters);
140+
141+
/// <summary>
142+
/// Updates the details of the specified user asynchronously.
143+
/// </summary>
144+
/// <param name="parameters">Parameters to update user.</param>
145+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
146+
/// <returns>Parsed information about updated user.</returns>
147+
Task<UserResult> UpdateUserAsync(UpdateUserParams parameters, CancellationToken? cancellationToken = null);
148+
149+
/// <summary>
150+
/// Deletes an existing user.
151+
/// </summary>
152+
/// <param name="userId">The ID of the user to delete.</param>
153+
/// <returns>Parsed information about deleted user.</returns>
154+
DelUserResult DeleteUser(string userId);
155+
156+
/// <summary>
157+
/// Deletes an existing user asynchronously.
158+
/// </summary>
159+
/// <param name="userId">The ID of the user to delete.</param>
160+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
161+
/// <returns>Parsed information about deleted user.</returns>
162+
Task<DelUserResult> DeleteUserAsync(string userId, CancellationToken? cancellationToken = null);
163+
164+
/// <summary>
165+
/// Creates a new user group.
166+
/// </summary>
167+
/// <param name="parameters">Parameters to create user group.</param>
168+
/// <returns>Parsed information about created user group.</returns>
169+
UserGroupResult CreateUserGroup(CreateUserGroupParams parameters);
170+
171+
/// <summary>
172+
/// Creates a new user group asynchronously.
173+
/// </summary>
174+
/// <param name="parameters">Parameters to create user group.</param>
175+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
176+
/// <returns>Parsed information about created user group.</returns>
177+
Task<UserGroupResult> CreateUserGroupAsync(CreateUserGroupParams parameters, CancellationToken? cancellationToken = null);
178+
179+
/// <summary>
180+
/// Updates the specified user group.
181+
/// </summary>
182+
/// <param name="parameters">Parameters to update user group.</param>
183+
/// <returns>Parsed information about updated user group.</returns>
184+
UserGroupResult UpdateUserGroup(UpdateUserGroupParams parameters);
185+
186+
/// <summary>
187+
/// Updates the specified user group asynchronously.
188+
/// </summary>
189+
/// <param name="parameters">Parameters to update user group.</param>
190+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
191+
/// <returns>Parsed information about updated user group.</returns>
192+
Task<UserGroupResult> UpdateUserGroupAsync(UpdateUserGroupParams parameters, CancellationToken? cancellationToken = null);
193+
194+
/// <summary>
195+
/// Deletes the user group with the specified ID.
196+
/// </summary>
197+
/// <param name="groupId">The ID of the user group to delete.</param>
198+
/// <returns>Parsed information about deleted user group.</returns>
199+
DelUserGroupResult DeleteUserGroup(string groupId);
200+
201+
/// <summary>
202+
/// Deletes the user group with the specified ID asynchronously.
203+
/// </summary>
204+
/// <param name="groupId">The ID of the user group to delete.</param>
205+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
206+
/// <returns>Parsed information about deleted user group.</returns>
207+
Task<DelUserGroupResult> DeleteUserGroupAsync(string groupId, CancellationToken? cancellationToken = null);
208+
209+
/// <summary>
210+
/// Retrieves the details of the specified user group.
211+
/// </summary>
212+
/// <param name="groupId">The ID of the user group to retrieve.</param>
213+
/// <returns>Parsed information about user group.</returns>
214+
UserGroupResult UserGroup(string groupId);
215+
216+
/// <summary>
217+
/// Retrieves the details of the specified user group asynchronously.
218+
/// </summary>
219+
/// <param name="groupId">The ID of the user group to retrieve.</param>
220+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
221+
/// <returns>Parsed information about user group.</returns>
222+
Task<UserGroupResult> UserGroupAsync(string groupId, CancellationToken? cancellationToken = null);
223+
224+
/// <summary>
225+
/// Lists user groups in the account.
226+
/// </summary>
227+
/// <returns>Parsed information about user groups.</returns>
228+
ListUserGroupsResult UserGroups();
229+
230+
/// <summary>
231+
/// Lists user groups in the account asynchronously.
232+
/// </summary>
233+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
234+
/// <returns>Parsed information about user groups.</returns>
235+
Task<ListUserGroupsResult> UserGroupsAsync(CancellationToken? cancellationToken = null);
236+
237+
/// <summary>
238+
/// Adds a user to a group with the specified ID.
239+
/// </summary>
240+
/// <param name="groupId">The ID of the user group.</param>
241+
/// <param name="userId">The ID of the user.</param>
242+
/// <returns>Parsed information about updated user group.</returns>
243+
ListUsersResult AddUserToGroup(string groupId, string userId);
244+
245+
/// <summary>
246+
/// Adds a user to a group with the specified ID asynchronously.
247+
/// </summary>
248+
/// <param name="groupId">The ID of the user group.</param>
249+
/// <param name="userId">The ID of the user.</param>
250+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
251+
/// <returns>Parsed information about updated user group.</returns>
252+
Task<ListUsersResult> AddUserToGroupAsync(string groupId, string userId, CancellationToken? cancellationToken = null);
253+
254+
/// <summary>
255+
/// Removes a user from a group with the specified ID.
256+
/// </summary>
257+
/// <param name="groupId">The ID of the user group.</param>
258+
/// <param name="userId">The ID of the user.</param>
259+
/// <returns>Parsed information about updated user group.</returns>
260+
ListUsersResult RemoveUserFromGroup(string groupId, string userId);
261+
262+
/// <summary>
263+
/// Removes a user from a group with the specified ID asynchronously.
264+
/// </summary>
265+
/// <param name="groupId">The ID of the user group.</param>
266+
/// <param name="userId">The ID of the user.</param>
267+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
268+
/// <returns>Parsed information about updated user group.</returns>
269+
Task<ListUsersResult> RemoveUserFromGroupAsync(string groupId, string userId, CancellationToken? cancellationToken = null);
270+
271+
/// <summary>
272+
/// Lists users in the specified user group.
273+
/// </summary>
274+
/// <param name="groupId">The ID of the user group.</param>
275+
/// <returns>Parsed information about users.</returns>
276+
ListUsersResult UsersGroupUsers(string groupId);
277+
278+
/// <summary>
279+
/// Lists users in the specified user group asynchronously.
280+
/// </summary>
281+
/// <param name="groupId">The ID of the user group.</param>
282+
/// <param name="cancellationToken">(Optional) Cancellation token.</param>
283+
/// <returns>Parsed information about users.</returns>
284+
Task<ListUsersResult> UsersGroupUsersAsync(string groupId, CancellationToken? cancellationToken = null);
285+
}
286+
}

0 commit comments

Comments
 (0)