Skip to content

Commit 5b8d6b9

Browse files
committed
added StorageApi
1 parent da578c7 commit 5b8d6b9

File tree

6 files changed

+515
-2
lines changed

6 files changed

+515
-2
lines changed

SDK/Aspose.OMR.Cloud.SDK/Api/OmrApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright company="Aspose" file="OmrApi.cs">
3-
// Copyright (c) 2019 Aspose.Omr for Cloud
3+
// Copyright (c) 2020 Aspose.Omr for Cloud
44
// </copyright>
55
// <summary>
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -76,7 +76,7 @@ public OmrApi(Configuration configuration)
7676
requestHandlers.Add(new JwtRequestHandler(this.configuration));
7777
break;
7878
default:
79-
throw new ApiException(1000, "Authorization method is not supported for OCR API. USE AuthType.JWT");
79+
throw new ApiException(1000, "Authorization method is not supported for OMR API. USE AuthType.JWT");
8080
}
8181

8282
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose" file="StorageApi.cs">
3+
// Copyright (c) 2020 Aspose.Omr for Cloud
4+
// </copyright>
5+
// <summary>
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
// </summary>
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
namespace Aspose.Omr.Cloud.Sdk.Api
27+
{
28+
using System.Collections.Generic;
29+
using System.Text.RegularExpressions;
30+
using Aspose.Omr.Cloud.Sdk.Model;
31+
using Aspose.Omr.Cloud.Sdk.Model.Requests;
32+
using Aspose.Omr.Cloud.Sdk.RequestHandlers;
33+
34+
/// <summary>
35+
/// Aspose.Omr for Cloud API.
36+
/// </summary>
37+
public class StorageApi
38+
{
39+
private readonly ApiInvoker apiInvoker;
40+
private readonly Configuration configuration;
41+
42+
/// <summary>
43+
/// Initializes a new instance of the <see cref="StorageApi"/> class.
44+
/// </summary>
45+
/// <param name="apiKey">
46+
/// The api Key.
47+
/// </param>
48+
/// <param name="appSid">
49+
/// The app Sid.
50+
/// </param>
51+
public StorageApi(string apiKey, string appSid)
52+
: this(new Configuration { AppKey = apiKey, AppSid = appSid })
53+
{
54+
}
55+
56+
public StorageApi(string jwtToken)
57+
: this(new Configuration { JwtToken = jwtToken, ApiVersion = ApiVersion.V3, AuthType = AuthType.ExternalAuth })
58+
{
59+
}
60+
61+
/// <summary>
62+
/// Initializes a new instance of the <see cref="StorageApi"/> class.
63+
/// </summary>
64+
/// <param name="configuration">Configuration settings</param>
65+
public StorageApi(Configuration configuration)
66+
{
67+
this.configuration = configuration;
68+
69+
var requestHandlers = new List<IRequestHandler>();
70+
switch (this.configuration.AuthType)
71+
{
72+
case AuthType.RequestSignature:
73+
requestHandlers.Add(new AuthWithSignatureRequestHandler(this.configuration));
74+
break;
75+
case AuthType.OAuth2:
76+
requestHandlers.Add(new OAuthRequestHandler(this.configuration));
77+
break;
78+
case AuthType.ExternalAuth:
79+
requestHandlers.Add(new ExternalAuthorizationRequestHandler(this.configuration));
80+
break;
81+
case AuthType.JWT:
82+
requestHandlers.Add(new JwtRequestHandler(this.configuration));
83+
break;
84+
}
85+
86+
requestHandlers.Add(new DebugLogRequestHandler(this.configuration));
87+
requestHandlers.Add(new ApiExceptionRequestHandler());
88+
this.apiInvoker = new ApiInvoker(requestHandlers);
89+
}
90+
91+
/// <summary>
92+
/// Get disc usage
93+
/// </summary>
94+
/// <param name="request">Request. <see cref="GetDiscUsageRequest" /></param>
95+
/// <returns><see cref="DiscUsage"/></returns>
96+
public DiscUsage GetDiscUsage(GetDiscUsageRequest request)
97+
{
98+
// create path and map variables
99+
var resourcePath = this.configuration.GetApiRootUrl() + "/omr/storage/disc";
100+
resourcePath = Regex
101+
.Replace(resourcePath, "\\*", string.Empty)
102+
.Replace("&amp;", "&")
103+
.Replace("/?", "?");
104+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.storageName);
105+
106+
try
107+
{
108+
var response = this.apiInvoker.InvokeApi(
109+
resourcePath,
110+
"GET",
111+
null,
112+
null,
113+
null);
114+
if (response != null)
115+
{
116+
return (DiscUsage)SerializationHelper.Deserialize(response, typeof(DiscUsage));
117+
}
118+
119+
return null;
120+
}
121+
catch (ApiException ex)
122+
{
123+
if (ex.ErrorCode == 404)
124+
{
125+
return null;
126+
}
127+
128+
throw;
129+
}
130+
}
131+
132+
/// <summary>
133+
/// Get file versions
134+
/// </summary>
135+
/// <param name="request">Request. <see cref="GetFileVersionsRequest" /></param>
136+
/// <returns><see cref="FileVersions"/></returns>
137+
public FileVersions GetFileVersions(GetFileVersionsRequest request)
138+
{
139+
// verify the required parameter 'path' is set
140+
if (request.path == null)
141+
{
142+
throw new ApiException(400, "Missing required parameter 'path' when calling GetFileVersions");
143+
}
144+
145+
// create path and map variables
146+
var resourcePath = this.configuration.GetApiRootUrl() + "/omr/storage/version/{path}";
147+
resourcePath = Regex
148+
.Replace(resourcePath, "\\*", string.Empty)
149+
.Replace("&amp;", "&")
150+
.Replace("/?", "?");
151+
resourcePath = UrlHelper.AddPathParameter(resourcePath, "path", request.path);
152+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.storageName);
153+
154+
try
155+
{
156+
var response = this.apiInvoker.InvokeApi(
157+
resourcePath,
158+
"GET",
159+
null,
160+
null,
161+
null);
162+
if (response != null)
163+
{
164+
return (FileVersions)SerializationHelper.Deserialize(response, typeof(FileVersions));
165+
}
166+
167+
return null;
168+
}
169+
catch (ApiException ex)
170+
{
171+
if (ex.ErrorCode == 404)
172+
{
173+
return null;
174+
}
175+
176+
throw;
177+
}
178+
}
179+
180+
/// <summary>
181+
/// Check if file or folder exists
182+
/// </summary>
183+
/// <param name="request">Request. <see cref="ObjectExistsRequest" /></param>
184+
/// <returns><see cref="ObjectExist"/></returns>
185+
public ObjectExist ObjectExists(ObjectExistsRequest request)
186+
{
187+
// verify the required parameter 'path' is set
188+
if (request.path == null)
189+
{
190+
throw new ApiException(400, "Missing required parameter 'path' when calling ObjectExists");
191+
}
192+
193+
// create path and map variables
194+
var resourcePath = this.configuration.GetApiRootUrl() + "/omr/storage/exist/{path}";
195+
resourcePath = Regex
196+
.Replace(resourcePath, "\\*", string.Empty)
197+
.Replace("&amp;", "&")
198+
.Replace("/?", "?");
199+
resourcePath = UrlHelper.AddPathParameter(resourcePath, "path", request.path);
200+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storageName", request.storageName);
201+
resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "versionId", request.versionId);
202+
203+
try
204+
{
205+
var response = this.apiInvoker.InvokeApi(
206+
resourcePath,
207+
"GET",
208+
null,
209+
null,
210+
null);
211+
if (response != null)
212+
{
213+
return (ObjectExist)SerializationHelper.Deserialize(response, typeof(ObjectExist));
214+
}
215+
216+
return null;
217+
}
218+
catch (ApiException ex)
219+
{
220+
if (ex.ErrorCode == 404)
221+
{
222+
return null;
223+
}
224+
225+
throw;
226+
}
227+
}
228+
229+
/// <summary>
230+
/// Check if storage exists
231+
/// </summary>
232+
/// <param name="request">Request. <see cref="StorageExistsRequest" /></param>
233+
/// <returns><see cref="StorageExist"/></returns>
234+
public StorageExist StorageExists(StorageExistsRequest request)
235+
{
236+
// verify the required parameter 'storageName' is set
237+
if (request.storageName == null)
238+
{
239+
throw new ApiException(400, "Missing required parameter 'storageName' when calling StorageExists");
240+
}
241+
242+
// create path and map variables
243+
var resourcePath = this.configuration.GetApiRootUrl() + "/omr/storage/{storageName}/exist";
244+
resourcePath = Regex
245+
.Replace(resourcePath, "\\*", string.Empty)
246+
.Replace("&amp;", "&")
247+
.Replace("/?", "?");
248+
resourcePath = UrlHelper.AddPathParameter(resourcePath, "storageName", request.storageName);
249+
250+
try
251+
{
252+
var response = this.apiInvoker.InvokeApi(
253+
resourcePath,
254+
"GET",
255+
null,
256+
null,
257+
null);
258+
if (response != null)
259+
{
260+
return (StorageExist)SerializationHelper.Deserialize(response, typeof(StorageExist));
261+
}
262+
263+
return null;
264+
}
265+
catch (ApiException ex)
266+
{
267+
if (ex.ErrorCode == 404)
268+
{
269+
return null;
270+
}
271+
272+
throw;
273+
}
274+
}
275+
}
276+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Aspose" file="GetDiscUsageRequest.cs">
3+
// Copyright (c) 2020 Aspose.Omr for Cloud
4+
// </copyright>
5+
// <summary>
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in all
14+
// copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
// SOFTWARE.
23+
// </summary>
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
namespace Aspose.Omr.Cloud.Sdk.Model.Requests
27+
{
28+
/// <summary>
29+
/// Request model for <see cref="Aspose.Omr.Cloud.Sdk.Api.OmrApi.GetDiscUsage" /> operation.
30+
/// </summary>
31+
public class GetDiscUsageRequest
32+
{
33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="GetDiscUsageRequest"/> class.
35+
/// </summary>
36+
public GetDiscUsageRequest()
37+
{
38+
}
39+
40+
/// <summary>
41+
/// Initializes a new instance of the <see cref="GetDiscUsageRequest"/> class.
42+
/// </summary>
43+
/// <param name="storageName">Storage name</param>
44+
public GetDiscUsageRequest(string storageName = null)
45+
{
46+
this.storageName = storageName;
47+
}
48+
49+
/// <summary>
50+
/// Storage name
51+
/// </summary>
52+
public string storageName { get; set; }
53+
}
54+
}

0 commit comments

Comments
 (0)