1+ // --------------------------------------------------------------------------------------------------------------------
2+ // <copyright company="Aspose" file="EmailApi.cs">
3+ // Copyright (c) 2018 Aspose.Email 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 . Email . Cloud . Sdk . Api
27+ {
28+ using System . Collections . Generic ;
29+ using System . Text . RegularExpressions ;
30+ using Model ;
31+ using Model . Requests ;
32+ using Client ;
33+ using Client . Internal . RequestHandlers ;
34+ #if ( NET452 || NETSTANDARD2_0 )
35+ using System . Threading . Tasks ;
36+ #endif
37+
38+ /// <summary>
39+ /// Aspose.Email for Cloud API.
40+ /// </summary>
41+ public class StorageApi
42+ {
43+ private readonly ApiInvoker apiInvoker ;
44+ private readonly Configuration configuration ;
45+
46+ /// <summary>
47+ /// Initializes a new instance of the <see cref="StorageApi"/> class.
48+ /// </summary>
49+ /// <param name="apiKey">
50+ /// The api Key.
51+ /// </param>
52+ /// <param name="appSid">
53+ /// The app Sid.
54+ /// </param>
55+ public StorageApi ( string apiKey , string appSid )
56+ : this ( new Configuration { AppKey = apiKey , AppSid = appSid } )
57+ {
58+ }
59+
60+ /// <summary>
61+ /// Initializes a new instance of the <see cref="StorageApi"/> class.
62+ /// </summary>
63+ /// <param name="configuration">Configuration settings</param>
64+ public StorageApi ( Configuration configuration )
65+ {
66+ this . configuration = configuration ;
67+
68+ var requestHandlers = new List < IRequestHandler >
69+ {
70+ new AuthRequestHandler ( this . configuration ) ,
71+ new DebugLogRequestHandler ( this . configuration ) ,
72+ new ApiExceptionRequestHandler ( )
73+ } ;
74+ apiInvoker = new ApiInvoker ( requestHandlers ) ;
75+ }
76+
77+ /// <summary>
78+ /// Get disc usage
79+ /// </summary>
80+ /// <param name="request">Request. <see cref="GetDiscUsageRequest" /></param>
81+ /// <returns><see cref="DiscUsage"/></returns>
82+ public DiscUsage GetDiscUsage ( Model . Requests . GetDiscUsageRequest request )
83+ {
84+ // create path and map variables
85+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/disc" ;
86+ resourcePath = Regex
87+ . Replace ( resourcePath , "\\ *" , string . Empty )
88+ . Replace ( "&" , "&" )
89+ . Replace ( "/?" , "?" ) ;
90+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "storageName" , request . storageName ) ;
91+ var response = apiInvoker . InvokeApi (
92+ resourcePath ,
93+ "GET" ,
94+ null ,
95+ null ,
96+ null ) ;
97+ if ( response != null )
98+ {
99+ return SerializationHelper . Deserialize < DiscUsage > ( response ) ;
100+ }
101+
102+ return null ;
103+ }
104+
105+ #if ( NET452 || NETSTANDARD2_0 )
106+ /// <summary>
107+ /// Get disc usage
108+ /// </summary>
109+ /// <param name="request">Request. <see cref="GetDiscUsageRequest" /></param>
110+ /// <returns><see cref="DiscUsage"/></returns>
111+ public async Task < DiscUsage > GetDiscUsageAsync ( Model . Requests . GetDiscUsageRequest request )
112+ {
113+ // create path and map variables
114+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/disc" ;
115+ resourcePath = Regex
116+ . Replace ( resourcePath , "\\ *" , string . Empty )
117+ . Replace ( "&" , "&" )
118+ . Replace ( "/?" , "?" ) ;
119+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "storageName" , request . storageName ) ;
120+ var response = await apiInvoker . InvokeApiAsync (
121+ resourcePath ,
122+ "GET" ,
123+ null ,
124+ null ,
125+ null ) ;
126+ if ( response != null )
127+ {
128+ return SerializationHelper . Deserialize < DiscUsage > ( response ) ;
129+ }
130+
131+ return null ;
132+ }
133+ #endif
134+
135+ /// <summary>
136+ /// Get file versions
137+ /// </summary>
138+ /// <param name="request">Request. <see cref="GetFileVersionsRequest" /></param>
139+ /// <returns><see cref="FileVersions"/></returns>
140+ public FileVersions GetFileVersions ( Model . Requests . GetFileVersionsRequest request )
141+ {
142+ // verify the required parameter 'path' is set
143+ if ( request . path == null )
144+ {
145+ throw new ApiException ( 400 ,
146+ "Missing required parameter 'path' when calling GetFileVersions" ) ;
147+ }
148+
149+ // create path and map variables
150+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/version/{path}" ;
151+ resourcePath = Regex
152+ . Replace ( resourcePath , "\\ *" , string . Empty )
153+ . Replace ( "&" , "&" )
154+ . Replace ( "/?" , "?" ) ;
155+ resourcePath = UrlHelper . AddPathParameter ( resourcePath , "path" , request . path ) ;
156+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "storageName" , request . storageName ) ;
157+ var response = apiInvoker . InvokeApi (
158+ resourcePath ,
159+ "GET" ,
160+ null ,
161+ null ,
162+ null ) ;
163+ if ( response != null )
164+ {
165+ return SerializationHelper . Deserialize < FileVersions > ( response ) ;
166+ }
167+
168+ return null ;
169+ }
170+
171+ #if ( NET452 || NETSTANDARD2_0 )
172+ /// <summary>
173+ /// Get file versions
174+ /// </summary>
175+ /// <param name="request">Request. <see cref="GetFileVersionsRequest" /></param>
176+ /// <returns><see cref="FileVersions"/></returns>
177+ public async Task < FileVersions > GetFileVersionsAsync ( Model . Requests . GetFileVersionsRequest request )
178+ {
179+ // verify the required parameter 'path' is set
180+ if ( request . path == null )
181+ {
182+ throw new ApiException ( 400 ,
183+ "Missing required parameter 'path' when calling GetFileVersions" ) ;
184+ }
185+
186+ // create path and map variables
187+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/version/{path}" ;
188+ resourcePath = Regex
189+ . Replace ( resourcePath , "\\ *" , string . Empty )
190+ . Replace ( "&" , "&" )
191+ . Replace ( "/?" , "?" ) ;
192+ resourcePath = UrlHelper . AddPathParameter ( resourcePath , "path" , request . path ) ;
193+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "storageName" , request . storageName ) ;
194+ var response = await apiInvoker . InvokeApiAsync (
195+ resourcePath ,
196+ "GET" ,
197+ null ,
198+ null ,
199+ null ) ;
200+ if ( response != null )
201+ {
202+ return SerializationHelper . Deserialize < FileVersions > ( response ) ;
203+ }
204+
205+ return null ;
206+ }
207+ #endif
208+
209+ /// <summary>
210+ /// Check if file or folder exists
211+ /// </summary>
212+ /// <param name="request">Request. <see cref="ObjectExistsRequest" /></param>
213+ /// <returns><see cref="ObjectExist"/></returns>
214+ public ObjectExist ObjectExists ( Model . Requests . ObjectExistsRequest request )
215+ {
216+ // verify the required parameter 'path' is set
217+ if ( request . path == null )
218+ {
219+ throw new ApiException ( 400 ,
220+ "Missing required parameter 'path' when calling ObjectExists" ) ;
221+ }
222+
223+ // create path and map variables
224+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/exist/{path}" ;
225+ resourcePath = Regex
226+ . Replace ( resourcePath , "\\ *" , string . Empty )
227+ . Replace ( "&" , "&" )
228+ . Replace ( "/?" , "?" ) ;
229+ resourcePath = UrlHelper . AddPathParameter ( resourcePath , "path" , request . path ) ;
230+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "storageName" , request . storageName ) ;
231+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "versionId" , request . versionId ) ;
232+ var response = apiInvoker . InvokeApi (
233+ resourcePath ,
234+ "GET" ,
235+ null ,
236+ null ,
237+ null ) ;
238+ if ( response != null )
239+ {
240+ return SerializationHelper . Deserialize < ObjectExist > ( response ) ;
241+ }
242+
243+ return null ;
244+ }
245+
246+ #if ( NET452 || NETSTANDARD2_0 )
247+ /// <summary>
248+ /// Check if file or folder exists
249+ /// </summary>
250+ /// <param name="request">Request. <see cref="ObjectExistsRequest" /></param>
251+ /// <returns><see cref="ObjectExist"/></returns>
252+ public async Task < ObjectExist > ObjectExistsAsync ( Model . Requests . ObjectExistsRequest request )
253+ {
254+ // verify the required parameter 'path' is set
255+ if ( request . path == null )
256+ {
257+ throw new ApiException ( 400 ,
258+ "Missing required parameter 'path' when calling ObjectExists" ) ;
259+ }
260+
261+ // create path and map variables
262+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/exist/{path}" ;
263+ resourcePath = Regex
264+ . Replace ( resourcePath , "\\ *" , string . Empty )
265+ . Replace ( "&" , "&" )
266+ . Replace ( "/?" , "?" ) ;
267+ resourcePath = UrlHelper . AddPathParameter ( resourcePath , "path" , request . path ) ;
268+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "storageName" , request . storageName ) ;
269+ resourcePath = UrlHelper . AddQueryParameterToUrl ( resourcePath , "versionId" , request . versionId ) ;
270+ var response = await apiInvoker . InvokeApiAsync (
271+ resourcePath ,
272+ "GET" ,
273+ null ,
274+ null ,
275+ null ) ;
276+ if ( response != null )
277+ {
278+ return SerializationHelper . Deserialize < ObjectExist > ( response ) ;
279+ }
280+
281+ return null ;
282+ }
283+ #endif
284+
285+ /// <summary>
286+ /// Check if storage exists
287+ /// </summary>
288+ /// <param name="request">Request. <see cref="StorageExistsRequest" /></param>
289+ /// <returns><see cref="StorageExist"/></returns>
290+ public StorageExist StorageExists ( Model . Requests . StorageExistsRequest request )
291+ {
292+ // verify the required parameter 'storageName' is set
293+ if ( request . storageName == null )
294+ {
295+ throw new ApiException ( 400 ,
296+ "Missing required parameter 'storageName' when calling StorageExists" ) ;
297+ }
298+
299+ // create path and map variables
300+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/{storageName}/exist" ;
301+ resourcePath = Regex
302+ . Replace ( resourcePath , "\\ *" , string . Empty )
303+ . Replace ( "&" , "&" )
304+ . Replace ( "/?" , "?" ) ;
305+ resourcePath = UrlHelper . AddPathParameter ( resourcePath , "storageName" , request . storageName ) ;
306+ var response = apiInvoker . InvokeApi (
307+ resourcePath ,
308+ "GET" ,
309+ null ,
310+ null ,
311+ null ) ;
312+ if ( response != null )
313+ {
314+ return SerializationHelper . Deserialize < StorageExist > ( response ) ;
315+ }
316+
317+ return null ;
318+ }
319+
320+ #if ( NET452 || NETSTANDARD2_0 )
321+ /// <summary>
322+ /// Check if storage exists
323+ /// </summary>
324+ /// <param name="request">Request. <see cref="StorageExistsRequest" /></param>
325+ /// <returns><see cref="StorageExist"/></returns>
326+ public async Task < StorageExist > StorageExistsAsync ( Model . Requests . StorageExistsRequest request )
327+ {
328+ // verify the required parameter 'storageName' is set
329+ if ( request . storageName == null )
330+ {
331+ throw new ApiException ( 400 ,
332+ "Missing required parameter 'storageName' when calling StorageExists" ) ;
333+ }
334+
335+ // create path and map variables
336+ var resourcePath = this . configuration . GetApiRootUrl ( ) + "/email/storage/{storageName}/exist" ;
337+ resourcePath = Regex
338+ . Replace ( resourcePath , "\\ *" , string . Empty )
339+ . Replace ( "&" , "&" )
340+ . Replace ( "/?" , "?" ) ;
341+ resourcePath = UrlHelper . AddPathParameter ( resourcePath , "storageName" , request . storageName ) ;
342+ var response = await apiInvoker . InvokeApiAsync (
343+ resourcePath ,
344+ "GET" ,
345+ null ,
346+ null ,
347+ null ) ;
348+ if ( response != null )
349+ {
350+ return SerializationHelper . Deserialize < StorageExist > ( response ) ;
351+ }
352+
353+ return null ;
354+ }
355+ #endif
356+ }
357+ }
0 commit comments