mailosaur 3.0.1 → 5.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +14 -13
  3. data/README.md +42 -8
  4. data/lib/Mailosaur/analysis.rb +184 -0
  5. data/lib/Mailosaur/files.rb +291 -0
  6. data/lib/Mailosaur/mailosaur_base_client.rb +120 -0
  7. data/lib/Mailosaur/mailosaur_error.rb +23 -0
  8. data/lib/Mailosaur/messages.rb +673 -0
  9. data/lib/Mailosaur/models/attachment.rb +99 -0
  10. data/lib/Mailosaur/models/forwarding_rule.rb +78 -0
  11. data/lib/Mailosaur/models/image.rb +55 -0
  12. data/lib/Mailosaur/models/link.rb +55 -0
  13. data/lib/Mailosaur/models/message.rb +219 -0
  14. data/lib/Mailosaur/models/message_address.rb +66 -0
  15. data/lib/Mailosaur/models/message_content.rb +84 -0
  16. data/lib/Mailosaur/models/message_header.rb +55 -0
  17. data/lib/Mailosaur/models/message_list_result.rb +54 -0
  18. data/lib/Mailosaur/models/message_summary.rb +199 -0
  19. data/lib/Mailosaur/models/metadata.rb +52 -0
  20. data/lib/Mailosaur/models/search_criteria.rb +69 -0
  21. data/lib/Mailosaur/models/server.rb +118 -0
  22. data/lib/Mailosaur/models/server_create_options.rb +44 -0
  23. data/lib/Mailosaur/models/server_list_result.rb +54 -0
  24. data/lib/Mailosaur/models/spam_analysis_result.rb +56 -0
  25. data/lib/Mailosaur/models/spam_assassin_rule.rb +66 -0
  26. data/lib/Mailosaur/models/spam_filter_results.rb +53 -0
  27. data/lib/Mailosaur/module_definition.rb +6 -0
  28. data/lib/Mailosaur/servers.rb +542 -0
  29. data/lib/Mailosaur/version.rb +8 -0
  30. data/lib/mailosaur.rb +52 -108
  31. metadata +78 -46
  32. data/lib/helper.rb +0 -6
  33. data/lib/mailosaur/attachment.rb +0 -10
  34. data/lib/mailosaur/email.rb +0 -23
  35. data/lib/mailosaur/email_address.rb +0 -9
  36. data/lib/mailosaur/email_data.rb +0 -13
  37. data/lib/mailosaur/image.rb +0 -8
  38. data/lib/mailosaur/link.rb +0 -8
  39. data/lib/mailosaur/message_generator.rb +0 -31
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Mailosaur
7
+ module Models
8
+ #
9
+ # Model object.
10
+ #
11
+ #
12
+ class SpamAssassinRule
13
+ # @return [Float]
14
+ attr_accessor :score
15
+
16
+ # @return [String]
17
+ attr_accessor :rule
18
+
19
+ # @return [String]
20
+ attr_accessor :description
21
+
22
+
23
+ #
24
+ # Mapper for SpamAssassinRule class as Ruby Hash.
25
+ # This will be used for serialization/deserialization.
26
+ #
27
+ def self.mapper()
28
+ {
29
+ client_side_validation: true,
30
+ required: false,
31
+ serialized_name: 'SpamAssassinRule',
32
+ type: {
33
+ name: 'Composite',
34
+ class_name: 'SpamAssassinRule',
35
+ model_properties: {
36
+ score: {
37
+ client_side_validation: true,
38
+ required: false,
39
+ serialized_name: 'score',
40
+ type: {
41
+ name: 'Double'
42
+ }
43
+ },
44
+ rule: {
45
+ client_side_validation: true,
46
+ required: false,
47
+ serialized_name: 'rule',
48
+ type: {
49
+ name: 'String'
50
+ }
51
+ },
52
+ description: {
53
+ client_side_validation: true,
54
+ required: false,
55
+ serialized_name: 'description',
56
+ type: {
57
+ name: 'String'
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Mailosaur
7
+ module Models
8
+ #
9
+ # Model object.
10
+ #
11
+ #
12
+ class SpamFilterResults
13
+ # @return [Array<SpamAssassinRule>]
14
+ attr_accessor :spam_assassin
15
+
16
+
17
+ #
18
+ # Mapper for SpamFilterResults class as Ruby Hash.
19
+ # This will be used for serialization/deserialization.
20
+ #
21
+ def self.mapper()
22
+ {
23
+ client_side_validation: true,
24
+ required: false,
25
+ serialized_name: 'SpamFilterResults',
26
+ type: {
27
+ name: 'Composite',
28
+ class_name: 'SpamFilterResults',
29
+ model_properties: {
30
+ spam_assassin: {
31
+ client_side_validation: true,
32
+ required: false,
33
+ serialized_name: 'spamAssassin',
34
+ type: {
35
+ name: 'Sequence',
36
+ element: {
37
+ client_side_validation: true,
38
+ required: false,
39
+ serialized_name: 'SpamAssassinRuleElementType',
40
+ type: {
41
+ name: 'Composite',
42
+ class_name: 'SpamAssassinRule'
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Mailosaur end
@@ -0,0 +1,542 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Mailosaur
7
+ #
8
+ # # Introduction
9
+ #
10
+ # This is an overview of the Mailosaur API. This API a RESTful JSON interface
11
+ # with predictable, resource-oriented URLs. We make use of HTTP response
12
+ # codes to indicate
13
+ # API errors.
14
+ #
15
+ # We use built-in HTTP features, like HTTP authentication and HTTP verbs,
16
+ # which are understood
17
+ # by off-the-shelf HTTP clients.
18
+ #
19
+ # [Official client libraries](/docs/client-libraries/) available for most
20
+ # popular languages.
21
+ #
22
+ # # Authentication
23
+ #
24
+ # Authenticate your account when using the API by including your API key in
25
+ # the request.
26
+ # You can [manage your API keys](/app/account/api-access/) in the Mailosaur
27
+ # UI. Your API key carrys many privileges,
28
+ # so be sure to keep it secret! Do not share your API key in
29
+ # publicly-accessible areas such
30
+ # GitHub, client-side code, and so on.
31
+ #
32
+ # All API requests must be made over HTTPS. Calls made over plain HTTP will
33
+ # fail.
34
+ # API requests without authentication will also fail.
35
+ #
36
+ # # Errors
37
+ #
38
+ # ## HTTP status codes
39
+ #
40
+ # Mailosaur uses conventional HTTP response codes to indicate the success or
41
+ # failure of an
42
+ # API request. In general, codes in the `2xx` range indicate success, codes
43
+ # in the `4xx` range
44
+ # indicate an error that failed given the information provided (e.g., a
45
+ # required parameter
46
+ # was omitted), and codes in the `5xx` range indicate an error with
47
+ # Mailosaur's servers (give us a shout in the unlikely event that you see one
48
+ # of those).
49
+ #
50
+ # | Code | Description |
51
+ # |---|---|
52
+ # | 200 - OK | Request was successful. |
53
+ # | 204 - No Content | Request was successful, no response content. |
54
+ # | 400 - Bad Request | The request could be handled, often due to missing a
55
+ # required parameter. |
56
+ # | 401 - Unauthorized | No valid API key provided. |
57
+ # | 404 - Not Found | The requested resource doesn't exist. |
58
+ # | 5XX - Server Errors | Something went wrong at Mailosaur. (Give us a
59
+ # shout). |
60
+ #
61
+ # ## Error handling
62
+ #
63
+ # In of an error the server will return as much information as possible. In
64
+ # the case of a `401` or
65
+ # `404` error the status code gives as much information as you'd need. But
66
+ # for `400` errors
67
+ # Mailosaur will return a JSON object containing the structure below.
68
+ #
69
+ # Note that our client libraries convert responses to appropriate
70
+ # language-specific objects.
71
+ #
72
+ # | Property | Description |
73
+ # |---|---|
74
+ # | `type` | The type of error returned. Can be: api_connection_error,
75
+ # api_error, authentication_error, card_error, idempotency_error
76
+ # invalid_request_error, or rate_limit_error. |
77
+ # | `message` | A human-readable message providing more details about the
78
+ # error. |
79
+ # | `parameters` | A JSON object containing a key for each property name at
80
+ # fault, with a human-readable message per field |
81
+ # | `model` | The request model that we sent and failed to be processed |
82
+ #
83
+ class Servers
84
+
85
+ #
86
+ # Creates and initializes a new instance of the Servers class.
87
+ # @param client service class for accessing basic functionality.
88
+ #
89
+ def initialize(client)
90
+ @client = client
91
+ end
92
+
93
+ # @return [MailosaurBaseClient] reference to the MailosaurBaseClient
94
+ attr_reader :client
95
+
96
+ #
97
+ # List all servers
98
+ #
99
+ # Returns a list of your virtual SMTP servers. Servers are returned sorted in
100
+ # alphabetical order.
101
+ #
102
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
103
+ # will be added to the HTTP request.
104
+ #
105
+ # @return [ServerListResult] operation results.
106
+ #
107
+ def list(custom_headers:nil)
108
+ response = list_async(custom_headers:custom_headers).value!
109
+ response.body unless response.nil?
110
+ end
111
+
112
+ #
113
+ # List all servers
114
+ #
115
+ # Returns a list of your virtual SMTP servers. Servers are returned sorted in
116
+ # alphabetical order.
117
+ #
118
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
119
+ # will be added to the HTTP request.
120
+ #
121
+ # @return [MsRest::HttpOperationResponse] HTTP response information.
122
+ #
123
+ def list_with_http_info(custom_headers:nil)
124
+ list_async(custom_headers:custom_headers).value!
125
+ end
126
+
127
+ #
128
+ # List all servers
129
+ #
130
+ # Returns a list of your virtual SMTP servers. Servers are returned sorted in
131
+ # alphabetical order.
132
+ #
133
+ # @param [Hash{String => String}] A hash of custom headers that will be added
134
+ # to the HTTP request.
135
+ #
136
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
137
+ #
138
+ def list_async(custom_headers:nil)
139
+
140
+
141
+ request_headers = {}
142
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
143
+ path_template = 'api/servers'
144
+
145
+ request_url = @base_url || @client.base_url
146
+
147
+ options = {
148
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
149
+ headers: request_headers.merge(custom_headers || {}),
150
+ base_url: request_url
151
+ }
152
+ promise = @client.make_request_async(:get, path_template, options)
153
+
154
+ promise = promise.then do |result|
155
+ http_response = result.response
156
+ status_code = http_response.status
157
+ response_content = http_response.body
158
+ unless status_code == 200
159
+ error_model = JSON.load(response_content)
160
+ mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
161
+ raise mailosaur_error
162
+ end
163
+
164
+ # Deserialize Response
165
+ if status_code == 200
166
+ begin
167
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
168
+ result_mapper = Mailosaur::Models::ServerListResult.mapper()
169
+ result.body = @client.deserialize(result_mapper, parsed_response)
170
+ rescue Exception => e
171
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
172
+ end
173
+ end
174
+
175
+ result
176
+ end
177
+
178
+ promise.execute
179
+ end
180
+
181
+ #
182
+ # Create a server
183
+ #
184
+ # Creates a new virtual SMTP server and returns it.
185
+ #
186
+ # @param server_create_options [ServerCreateOptions]
187
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
188
+ # will be added to the HTTP request.
189
+ #
190
+ # @return [Server] operation results.
191
+ #
192
+ def create(server_create_options, custom_headers:nil)
193
+ response = create_async(server_create_options, custom_headers:custom_headers).value!
194
+ response.body unless response.nil?
195
+ end
196
+
197
+ #
198
+ # Create a server
199
+ #
200
+ # Creates a new virtual SMTP server and returns it.
201
+ #
202
+ # @param server_create_options [ServerCreateOptions]
203
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
204
+ # will be added to the HTTP request.
205
+ #
206
+ # @return [MsRest::HttpOperationResponse] HTTP response information.
207
+ #
208
+ def create_with_http_info(server_create_options, custom_headers:nil)
209
+ create_async(server_create_options, custom_headers:custom_headers).value!
210
+ end
211
+
212
+ #
213
+ # Create a server
214
+ #
215
+ # Creates a new virtual SMTP server and returns it.
216
+ #
217
+ # @param server_create_options [ServerCreateOptions]
218
+ # @param [Hash{String => String}] A hash of custom headers that will be added
219
+ # to the HTTP request.
220
+ #
221
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
222
+ #
223
+ def create_async(server_create_options, custom_headers:nil)
224
+ fail ArgumentError, 'server_create_options is nil' if server_create_options.nil?
225
+
226
+
227
+ request_headers = {}
228
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
229
+
230
+ # Serialize Request
231
+ request_mapper = Mailosaur::Models::ServerCreateOptions.mapper()
232
+ request_content = @client.serialize(request_mapper, server_create_options)
233
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
234
+
235
+ path_template = 'api/servers'
236
+
237
+ request_url = @base_url || @client.base_url
238
+
239
+ options = {
240
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
241
+ body: request_content,
242
+ headers: request_headers.merge(custom_headers || {}),
243
+ base_url: request_url
244
+ }
245
+ promise = @client.make_request_async(:post, path_template, options)
246
+
247
+ promise = promise.then do |result|
248
+ http_response = result.response
249
+ status_code = http_response.status
250
+ response_content = http_response.body
251
+ unless status_code == 200
252
+ error_model = JSON.load(response_content)
253
+ mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
254
+ raise mailosaur_error
255
+ end
256
+
257
+ # Deserialize Response
258
+ if status_code == 200
259
+ begin
260
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
261
+ result_mapper = Mailosaur::Models::Server.mapper()
262
+ result.body = @client.deserialize(result_mapper, parsed_response)
263
+ rescue Exception => e
264
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
265
+ end
266
+ end
267
+
268
+ result
269
+ end
270
+
271
+ promise.execute
272
+ end
273
+
274
+ #
275
+ # Retrieve a server
276
+ #
277
+ # Retrieves the detail for a single server. Simply supply the unique identifier
278
+ # for the required server.
279
+ #
280
+ # @param id [String] The identifier of the server to be retrieved.
281
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
282
+ # will be added to the HTTP request.
283
+ #
284
+ # @return [Server] operation results.
285
+ #
286
+ def get(id, custom_headers:nil)
287
+ response = get_async(id, custom_headers:custom_headers).value!
288
+ response.body unless response.nil?
289
+ end
290
+
291
+ #
292
+ # Retrieve a server
293
+ #
294
+ # Retrieves the detail for a single server. Simply supply the unique identifier
295
+ # for the required server.
296
+ #
297
+ # @param id [String] The identifier of the server to be retrieved.
298
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
299
+ # will be added to the HTTP request.
300
+ #
301
+ # @return [MsRest::HttpOperationResponse] HTTP response information.
302
+ #
303
+ def get_with_http_info(id, custom_headers:nil)
304
+ get_async(id, custom_headers:custom_headers).value!
305
+ end
306
+
307
+ #
308
+ # Retrieve a server
309
+ #
310
+ # Retrieves the detail for a single server. Simply supply the unique identifier
311
+ # for the required server.
312
+ #
313
+ # @param id [String] The identifier of the server to be retrieved.
314
+ # @param [Hash{String => String}] A hash of custom headers that will be added
315
+ # to the HTTP request.
316
+ #
317
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
318
+ #
319
+ def get_async(id, custom_headers:nil)
320
+ fail ArgumentError, 'id is nil' if id.nil?
321
+
322
+
323
+ request_headers = {}
324
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
325
+ path_template = 'api/servers/{id}'
326
+
327
+ request_url = @base_url || @client.base_url
328
+
329
+ options = {
330
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
331
+ path_params: {'id' => id},
332
+ headers: request_headers.merge(custom_headers || {}),
333
+ base_url: request_url
334
+ }
335
+ promise = @client.make_request_async(:get, path_template, options)
336
+
337
+ promise = promise.then do |result|
338
+ http_response = result.response
339
+ status_code = http_response.status
340
+ response_content = http_response.body
341
+ unless status_code == 200
342
+ error_model = JSON.load(response_content)
343
+ mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
344
+ raise mailosaur_error
345
+ end
346
+
347
+ # Deserialize Response
348
+ if status_code == 200
349
+ begin
350
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
351
+ result_mapper = Mailosaur::Models::Server.mapper()
352
+ result.body = @client.deserialize(result_mapper, parsed_response)
353
+ rescue Exception => e
354
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
355
+ end
356
+ end
357
+
358
+ result
359
+ end
360
+
361
+ promise.execute
362
+ end
363
+
364
+ #
365
+ # Update a server
366
+ #
367
+ # Updats a single server and returns it.
368
+ #
369
+ # @param id [String] The identifier of the server to be updated.
370
+ # @param server [Server]
371
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
372
+ # will be added to the HTTP request.
373
+ #
374
+ # @return [Server] operation results.
375
+ #
376
+ def update(id, server, custom_headers:nil)
377
+ response = update_async(id, server, custom_headers:custom_headers).value!
378
+ response.body unless response.nil?
379
+ end
380
+
381
+ #
382
+ # Update a server
383
+ #
384
+ # Updats a single server and returns it.
385
+ #
386
+ # @param id [String] The identifier of the server to be updated.
387
+ # @param server [Server]
388
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
389
+ # will be added to the HTTP request.
390
+ #
391
+ # @return [MsRest::HttpOperationResponse] HTTP response information.
392
+ #
393
+ def update_with_http_info(id, server, custom_headers:nil)
394
+ update_async(id, server, custom_headers:custom_headers).value!
395
+ end
396
+
397
+ #
398
+ # Update a server
399
+ #
400
+ # Updats a single server and returns it.
401
+ #
402
+ # @param id [String] The identifier of the server to be updated.
403
+ # @param server [Server]
404
+ # @param [Hash{String => String}] A hash of custom headers that will be added
405
+ # to the HTTP request.
406
+ #
407
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
408
+ #
409
+ def update_async(id, server, custom_headers:nil)
410
+ fail ArgumentError, 'id is nil' if id.nil?
411
+ fail ArgumentError, 'server is nil' if server.nil?
412
+
413
+
414
+ request_headers = {}
415
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
416
+
417
+ # Serialize Request
418
+ request_mapper = Mailosaur::Models::Server.mapper()
419
+ request_content = @client.serialize(request_mapper, server)
420
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
421
+
422
+ path_template = 'api/servers/{id}'
423
+
424
+ request_url = @base_url || @client.base_url
425
+
426
+ options = {
427
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
428
+ path_params: {'id' => id},
429
+ body: request_content,
430
+ headers: request_headers.merge(custom_headers || {}),
431
+ base_url: request_url
432
+ }
433
+ promise = @client.make_request_async(:put, path_template, options)
434
+
435
+ promise = promise.then do |result|
436
+ http_response = result.response
437
+ status_code = http_response.status
438
+ response_content = http_response.body
439
+ unless status_code == 200
440
+ error_model = JSON.load(response_content)
441
+ mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
442
+ raise mailosaur_error
443
+ end
444
+
445
+ # Deserialize Response
446
+ if status_code == 200
447
+ begin
448
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
449
+ result_mapper = Mailosaur::Models::Server.mapper()
450
+ result.body = @client.deserialize(result_mapper, parsed_response)
451
+ rescue Exception => e
452
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
453
+ end
454
+ end
455
+
456
+ result
457
+ end
458
+
459
+ promise.execute
460
+ end
461
+
462
+ #
463
+ # Delete a server
464
+ #
465
+ # Permanently deletes a server. This operation cannot be undone. Also deletes
466
+ # all messages and associated attachments within the server.
467
+ #
468
+ # @param id [String] The identifier of the server to be deleted.
469
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
470
+ # will be added to the HTTP request.
471
+ #
472
+ #
473
+ def delete(id, custom_headers:nil)
474
+ response = delete_async(id, custom_headers:custom_headers).value!
475
+ nil
476
+ end
477
+
478
+ #
479
+ # Delete a server
480
+ #
481
+ # Permanently deletes a server. This operation cannot be undone. Also deletes
482
+ # all messages and associated attachments within the server.
483
+ #
484
+ # @param id [String] The identifier of the server to be deleted.
485
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
486
+ # will be added to the HTTP request.
487
+ #
488
+ # @return [MsRest::HttpOperationResponse] HTTP response information.
489
+ #
490
+ def delete_with_http_info(id, custom_headers:nil)
491
+ delete_async(id, custom_headers:custom_headers).value!
492
+ end
493
+
494
+ #
495
+ # Delete a server
496
+ #
497
+ # Permanently deletes a server. This operation cannot be undone. Also deletes
498
+ # all messages and associated attachments within the server.
499
+ #
500
+ # @param id [String] The identifier of the server to be deleted.
501
+ # @param [Hash{String => String}] A hash of custom headers that will be added
502
+ # to the HTTP request.
503
+ #
504
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
505
+ #
506
+ def delete_async(id, custom_headers:nil)
507
+ fail ArgumentError, 'id is nil' if id.nil?
508
+
509
+
510
+ request_headers = {}
511
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
512
+ path_template = 'api/servers/{id}'
513
+
514
+ request_url = @base_url || @client.base_url
515
+
516
+ options = {
517
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
518
+ path_params: {'id' => id},
519
+ headers: request_headers.merge(custom_headers || {}),
520
+ base_url: request_url
521
+ }
522
+ promise = @client.make_request_async(:delete, path_template, options)
523
+
524
+ promise = promise.then do |result|
525
+ http_response = result.response
526
+ status_code = http_response.status
527
+ response_content = http_response.body
528
+ unless status_code == 204
529
+ error_model = JSON.load(response_content)
530
+ mailosaur_error = Mailosaur::MailosaurError.new('Operation returned an invalid status code \'' + status_code.to_s + '\'', error_model)
531
+ raise mailosaur_error
532
+ end
533
+
534
+
535
+ result
536
+ end
537
+
538
+ promise.execute
539
+ end
540
+
541
+ end
542
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Mailosaur
7
+ VERSION = '5.0.1.pre'
8
+ end