azure_event_grid 0.15.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/2018-01-01/generated/azure_event_grid.rb +37 -0
  4. data/lib/2018-01-01/generated/azure_event_grid/event_grid_client.rb +232 -0
  5. data/lib/2018-01-01/generated/azure_event_grid/models/event_grid_event.rb +124 -0
  6. data/lib/2018-01-01/generated/azure_event_grid/models/event_hub_capture_file_created_event_data.rb +135 -0
  7. data/lib/2018-01-01/generated/azure_event_grid/models/resource_delete_cancel_data.rb +158 -0
  8. data/lib/2018-01-01/generated/azure_event_grid/models/resource_delete_failure_data.rb +158 -0
  9. data/lib/2018-01-01/generated/azure_event_grid/models/resource_delete_success_data.rb +158 -0
  10. data/lib/2018-01-01/generated/azure_event_grid/models/resource_write_cancel_data.rb +158 -0
  11. data/lib/2018-01-01/generated/azure_event_grid/models/resource_write_failure_data.rb +158 -0
  12. data/lib/2018-01-01/generated/azure_event_grid/models/resource_write_success_data.rb +158 -0
  13. data/lib/2018-01-01/generated/azure_event_grid/models/storage_blob_created_event_data.rb +157 -0
  14. data/lib/2018-01-01/generated/azure_event_grid/models/storage_blob_deleted_event_data.rb +133 -0
  15. data/lib/2018-01-01/generated/azure_event_grid/module_definition.rb +8 -0
  16. data/lib/azure_event_grid.rb +6 -0
  17. data/lib/module_definition.rb +6 -0
  18. data/lib/profiles/latest/eventgrid_latest_profile_client.rb +38 -0
  19. data/lib/profiles/latest/eventgrid_module_definition.rb +8 -0
  20. data/lib/profiles/latest/modules/eventgrid_profile_module.rb +89 -0
  21. data/lib/version.rb +7 -0
  22. metadata +138 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 22521dd8643d19ece8ac9e2c985328147481d5cb
4
+ data.tar.gz: 64ffb2cf4413987ead55416ce5dda2444a26c513
5
+ SHA512:
6
+ metadata.gz: 7da5f7cdfaf2ed42b9b205a3bd6e2852499b9dbb9a9a02918b1e42b3cc9b4d36b2b12ba5cf008dca72ab8983ee4b2aa4502f7e4db3aa539d7a1bea6b6e79d97b
7
+ data.tar.gz: 3786d684eed749038bc35b79992da9af30f0d4db03f138e2be06129a626602268e12a9df4df554be9e7a532a0cdf4ac795d25ab0d97c5a85ab5da97a073a9c42
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Microsoft Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,37 @@
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
+ require 'uri'
7
+ require 'cgi'
8
+ require 'date'
9
+ require 'json'
10
+ require 'base64'
11
+ require 'erb'
12
+ require 'securerandom'
13
+ require 'time'
14
+ require 'timeliness'
15
+ require 'faraday'
16
+ require 'faraday-cookie_jar'
17
+ require 'concurrent'
18
+ require 'ms_rest'
19
+ require '2018-01-01/generated/azure_event_grid/module_definition'
20
+ require 'ms_rest_azure'
21
+
22
+ module Azure::EventGrid::V2018_01_01
23
+ autoload :EventGridClient, '2018-01-01/generated/azure_event_grid/event_grid_client.rb'
24
+
25
+ module Models
26
+ autoload :ResourceWriteCancelData, '2018-01-01/generated/azure_event_grid/models/resource_write_cancel_data.rb'
27
+ autoload :StorageBlobCreatedEventData, '2018-01-01/generated/azure_event_grid/models/storage_blob_created_event_data.rb'
28
+ autoload :ResourceDeleteSuccessData, '2018-01-01/generated/azure_event_grid/models/resource_delete_success_data.rb'
29
+ autoload :EventHubCaptureFileCreatedEventData, '2018-01-01/generated/azure_event_grid/models/event_hub_capture_file_created_event_data.rb'
30
+ autoload :ResourceDeleteFailureData, '2018-01-01/generated/azure_event_grid/models/resource_delete_failure_data.rb'
31
+ autoload :ResourceWriteFailureData, '2018-01-01/generated/azure_event_grid/models/resource_write_failure_data.rb'
32
+ autoload :ResourceDeleteCancelData, '2018-01-01/generated/azure_event_grid/models/resource_delete_cancel_data.rb'
33
+ autoload :ResourceWriteSuccessData, '2018-01-01/generated/azure_event_grid/models/resource_write_success_data.rb'
34
+ autoload :EventGridEvent, '2018-01-01/generated/azure_event_grid/models/event_grid_event.rb'
35
+ autoload :StorageBlobDeletedEventData, '2018-01-01/generated/azure_event_grid/models/storage_blob_deleted_event_data.rb'
36
+ end
37
+ end
@@ -0,0 +1,232 @@
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 Azure::EventGrid::V2018_01_01
7
+ #
8
+ # A service client - single point of access to the REST API.
9
+ #
10
+ class EventGridClient < MsRestAzure::AzureServiceClient
11
+ include MsRestAzure
12
+ include MsRestAzure::Serialization
13
+
14
+ # @return [String] the base URI of the service.
15
+ attr_reader :base_url
16
+
17
+ # @return Credentials needed for the client to connect to Azure.
18
+ attr_reader :credentials
19
+
20
+ # @return [String] Version of the API to be used with the client request.
21
+ attr_reader :api_version
22
+
23
+ # @return [String] Gets or sets the preferred language for the response.
24
+ attr_accessor :accept_language
25
+
26
+ # @return [Integer] Gets or sets the retry timeout in seconds for Long
27
+ # Running Operations. Default value is 30.
28
+ attr_accessor :long_running_operation_retry_timeout
29
+
30
+ # @return [Boolean] When set to true a unique x-ms-client-request-id value
31
+ # is generated and included in each request. Default is true.
32
+ attr_accessor :generate_client_request_id
33
+
34
+ #
35
+ # Creates initializes a new instance of the EventGridClient class.
36
+ # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
37
+ # @param options [Array] filters to be applied to the HTTP requests.
38
+ #
39
+ def initialize(credentials = nil, options = nil)
40
+ super(credentials, options)
41
+ @base_url = 'https://{topicHostname}'
42
+
43
+ fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
44
+ @credentials = credentials
45
+
46
+ @api_version = '2018-01-01'
47
+ @accept_language = 'en-US'
48
+ @long_running_operation_retry_timeout = 30
49
+ @generate_client_request_id = true
50
+ add_telemetry
51
+ end
52
+
53
+ #
54
+ # Makes a request and returns the body of the response.
55
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
56
+ # @param path [String] the path, relative to {base_url}.
57
+ # @param options [Hash{String=>String}] specifying any request options like :body.
58
+ # @return [Hash{String=>String}] containing the body of the response.
59
+ # Example:
60
+ #
61
+ # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
62
+ # path = "/path"
63
+ # options = {
64
+ # body: request_content,
65
+ # query_params: {'api-version' => '2016-02-01'}
66
+ # }
67
+ # result = @client.make_request(:put, path, options)
68
+ #
69
+ def make_request(method, path, options = {})
70
+ result = make_request_with_http_info(method, path, options)
71
+ result.body unless result.nil?
72
+ end
73
+
74
+ #
75
+ # Makes a request and returns the operation response.
76
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
77
+ # @param path [String] the path, relative to {base_url}.
78
+ # @param options [Hash{String=>String}] specifying any request options like :body.
79
+ # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
80
+ #
81
+ def make_request_with_http_info(method, path, options = {})
82
+ result = make_request_async(method, path, options).value!
83
+ result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
84
+ result
85
+ end
86
+
87
+ #
88
+ # Makes a request asynchronously.
89
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
90
+ # @param path [String] the path, relative to {base_url}.
91
+ # @param options [Hash{String=>String}] specifying any request options like :body.
92
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
93
+ #
94
+ def make_request_async(method, path, options = {})
95
+ fail ArgumentError, 'method is nil' if method.nil?
96
+ fail ArgumentError, 'path is nil' if path.nil?
97
+
98
+ request_url = options[:base_url] || @base_url
99
+ if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
100
+ @request_headers['Content-Type'] = options[:headers]['Content-Type']
101
+ end
102
+
103
+ request_headers = @request_headers
104
+ request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
105
+ options.merge!({headers: request_headers.merge(options[:headers] || {})})
106
+ options.merge!({credentials: @credentials}) unless @credentials.nil?
107
+
108
+ super(request_url, method, path, options)
109
+ end
110
+
111
+ #
112
+ # Publishes a batch of events to an Azure Event Grid topic.
113
+ #
114
+ # @param topic_hostname [String] The host name of the topic, e.g.
115
+ # topic1.westus2-1.eventgrid.azure.net
116
+ # @param events [Array<EventGridEvent>] An array of events to be published to
117
+ # Event Grid.
118
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
119
+ # will be added to the HTTP request.
120
+ #
121
+ #
122
+ def publish_events(topic_hostname, events, custom_headers = nil)
123
+ response = publish_events_async(topic_hostname, events, custom_headers).value!
124
+ nil
125
+ end
126
+
127
+ #
128
+ # Publishes a batch of events to an Azure Event Grid topic.
129
+ #
130
+ # @param topic_hostname [String] The host name of the topic, e.g.
131
+ # topic1.westus2-1.eventgrid.azure.net
132
+ # @param events [Array<EventGridEvent>] An array of events to be published to
133
+ # Event Grid.
134
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
135
+ # will be added to the HTTP request.
136
+ #
137
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
138
+ #
139
+ def publish_events_with_http_info(topic_hostname, events, custom_headers = nil)
140
+ publish_events_async(topic_hostname, events, custom_headers).value!
141
+ end
142
+
143
+ #
144
+ # Publishes a batch of events to an Azure Event Grid topic.
145
+ #
146
+ # @param topic_hostname [String] The host name of the topic, e.g.
147
+ # topic1.westus2-1.eventgrid.azure.net
148
+ # @param events [Array<EventGridEvent>] An array of events to be published to
149
+ # Event Grid.
150
+ # @param [Hash{String => String}] A hash of custom headers that will be added
151
+ # to the HTTP request.
152
+ #
153
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
154
+ #
155
+ def publish_events_async(topic_hostname, events, custom_headers = nil)
156
+ fail ArgumentError, 'topic_hostname is nil' if topic_hostname.nil?
157
+ fail ArgumentError, 'events is nil' if events.nil?
158
+ fail ArgumentError, 'api_version is nil' if api_version.nil?
159
+
160
+
161
+ request_headers = {}
162
+
163
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
164
+
165
+ # Set Headers
166
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
167
+ request_headers['accept-language'] = accept_language unless accept_language.nil?
168
+
169
+ # Serialize Request
170
+ request_mapper = {
171
+ client_side_validation: true,
172
+ required: true,
173
+ serialized_name: 'events',
174
+ type: {
175
+ name: 'Sequence',
176
+ element: {
177
+ client_side_validation: true,
178
+ required: false,
179
+ serialized_name: 'EventGridEventElementType',
180
+ type: {
181
+ name: 'Composite',
182
+ class_name: 'EventGridEvent'
183
+ }
184
+ }
185
+ }
186
+ }
187
+ request_content = self.serialize(request_mapper, events)
188
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
189
+
190
+ path_template = 'api/events'
191
+
192
+ request_url = @base_url || self.base_url
193
+ request_url = request_url.gsub('{topicHostname}', topic_hostname)
194
+
195
+ options = {
196
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
197
+ query_params: {'api-version' => api_version},
198
+ body: request_content,
199
+ headers: request_headers.merge(custom_headers || {}),
200
+ base_url: request_url
201
+ }
202
+ promise = self.make_request_async(:post, path_template, options)
203
+
204
+ promise = promise.then do |result|
205
+ http_response = result.response
206
+ status_code = http_response.status
207
+ response_content = http_response.body
208
+ unless status_code == 200
209
+ error_model = JSON.load(response_content)
210
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
211
+ end
212
+
213
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
214
+
215
+ result
216
+ end
217
+
218
+ promise.execute
219
+ end
220
+
221
+
222
+ private
223
+ #
224
+ # Adds telemetry information.
225
+ #
226
+ def add_telemetry
227
+ sdk_information = 'azure_event_grid'
228
+ sdk_information = "#{sdk_information}/0.15.3"
229
+ add_user_agent_information(sdk_information)
230
+ end
231
+ end
232
+ end
@@ -0,0 +1,124 @@
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 Azure::EventGrid::V2018_01_01
7
+ module Models
8
+ #
9
+ # Properties of an event published to an Event Grid topic.
10
+ #
11
+ class EventGridEvent
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] An unique identifier for the event.
16
+ attr_accessor :id
17
+
18
+ # @return [String] The resource path of the event source.
19
+ attr_accessor :topic
20
+
21
+ # @return [String] A resource path relative to the topic path.
22
+ attr_accessor :subject
23
+
24
+ # @return Event data specific to the event type.
25
+ attr_accessor :data
26
+
27
+ # @return [String] The type of the event that occurred.
28
+ attr_accessor :event_type
29
+
30
+ # @return [DateTime] The time (in UTC) the event was generated.
31
+ attr_accessor :event_time
32
+
33
+ # @return [String] The schema version of the event metadata.
34
+ attr_accessor :metadata_version
35
+
36
+ # @return [String] The schema version of the data object.
37
+ attr_accessor :data_version
38
+
39
+
40
+ #
41
+ # Mapper for EventGridEvent class as Ruby Hash.
42
+ # This will be used for serialization/deserialization.
43
+ #
44
+ def self.mapper()
45
+ {
46
+ client_side_validation: true,
47
+ required: false,
48
+ serialized_name: 'EventGridEvent',
49
+ type: {
50
+ name: 'Composite',
51
+ class_name: 'EventGridEvent',
52
+ model_properties: {
53
+ id: {
54
+ client_side_validation: true,
55
+ required: true,
56
+ serialized_name: 'id',
57
+ type: {
58
+ name: 'String'
59
+ }
60
+ },
61
+ topic: {
62
+ client_side_validation: true,
63
+ required: false,
64
+ serialized_name: 'topic',
65
+ type: {
66
+ name: 'String'
67
+ }
68
+ },
69
+ subject: {
70
+ client_side_validation: true,
71
+ required: true,
72
+ serialized_name: 'subject',
73
+ type: {
74
+ name: 'String'
75
+ }
76
+ },
77
+ data: {
78
+ client_side_validation: true,
79
+ required: true,
80
+ serialized_name: 'data',
81
+ type: {
82
+ name: 'Object'
83
+ }
84
+ },
85
+ event_type: {
86
+ client_side_validation: true,
87
+ required: true,
88
+ serialized_name: 'eventType',
89
+ type: {
90
+ name: 'String'
91
+ }
92
+ },
93
+ event_time: {
94
+ client_side_validation: true,
95
+ required: true,
96
+ serialized_name: 'eventTime',
97
+ type: {
98
+ name: 'DateTime'
99
+ }
100
+ },
101
+ metadata_version: {
102
+ client_side_validation: true,
103
+ required: false,
104
+ read_only: true,
105
+ serialized_name: 'metadataVersion',
106
+ type: {
107
+ name: 'String'
108
+ }
109
+ },
110
+ data_version: {
111
+ client_side_validation: true,
112
+ required: true,
113
+ serialized_name: 'dataVersion',
114
+ type: {
115
+ name: 'String'
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,135 @@
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 Azure::EventGrid::V2018_01_01
7
+ module Models
8
+ #
9
+ # Schema of the Data property of an EventGridEvent for an
10
+ # Microsoft.EventHub.CaptureFileCreated event.
11
+ #
12
+ class EventHubCaptureFileCreatedEventData
13
+
14
+ include MsRestAzure
15
+
16
+ # @return [String] The path to the capture file.
17
+ attr_accessor :fileurl
18
+
19
+ # @return [String] The file type of the capture file.
20
+ attr_accessor :file_type
21
+
22
+ # @return [String] The shard ID.
23
+ attr_accessor :partition_id
24
+
25
+ # @return [Integer] The file size.
26
+ attr_accessor :size_in_bytes
27
+
28
+ # @return [Integer] The number of events in the file.
29
+ attr_accessor :event_count
30
+
31
+ # @return [Integer] The smallest sequence number from the queue.
32
+ attr_accessor :first_sequence_number
33
+
34
+ # @return [Integer] The last sequence number from the queue.
35
+ attr_accessor :last_sequence_number
36
+
37
+ # @return [DateTime] The first time from the queue.
38
+ attr_accessor :first_enqueue_time
39
+
40
+ # @return [DateTime] The last time from the queue.
41
+ attr_accessor :last_enqueue_time
42
+
43
+
44
+ #
45
+ # Mapper for EventHubCaptureFileCreatedEventData class as Ruby Hash.
46
+ # This will be used for serialization/deserialization.
47
+ #
48
+ def self.mapper()
49
+ {
50
+ client_side_validation: true,
51
+ required: false,
52
+ serialized_name: 'EventHubCaptureFileCreatedEventData',
53
+ type: {
54
+ name: 'Composite',
55
+ class_name: 'EventHubCaptureFileCreatedEventData',
56
+ model_properties: {
57
+ fileurl: {
58
+ client_side_validation: true,
59
+ required: false,
60
+ serialized_name: 'fileurl',
61
+ type: {
62
+ name: 'String'
63
+ }
64
+ },
65
+ file_type: {
66
+ client_side_validation: true,
67
+ required: false,
68
+ serialized_name: 'fileType',
69
+ type: {
70
+ name: 'String'
71
+ }
72
+ },
73
+ partition_id: {
74
+ client_side_validation: true,
75
+ required: false,
76
+ serialized_name: 'partitionId',
77
+ type: {
78
+ name: 'String'
79
+ }
80
+ },
81
+ size_in_bytes: {
82
+ client_side_validation: true,
83
+ required: false,
84
+ serialized_name: 'sizeInBytes',
85
+ type: {
86
+ name: 'Number'
87
+ }
88
+ },
89
+ event_count: {
90
+ client_side_validation: true,
91
+ required: false,
92
+ serialized_name: 'eventCount',
93
+ type: {
94
+ name: 'Number'
95
+ }
96
+ },
97
+ first_sequence_number: {
98
+ client_side_validation: true,
99
+ required: false,
100
+ serialized_name: 'firstSequenceNumber',
101
+ type: {
102
+ name: 'Number'
103
+ }
104
+ },
105
+ last_sequence_number: {
106
+ client_side_validation: true,
107
+ required: false,
108
+ serialized_name: 'lastSequenceNumber',
109
+ type: {
110
+ name: 'Number'
111
+ }
112
+ },
113
+ first_enqueue_time: {
114
+ client_side_validation: true,
115
+ required: false,
116
+ serialized_name: 'firstEnqueueTime',
117
+ type: {
118
+ name: 'DateTime'
119
+ }
120
+ },
121
+ last_enqueue_time: {
122
+ client_side_validation: true,
123
+ required: false,
124
+ serialized_name: 'lastEnqueueTime',
125
+ type: {
126
+ name: 'DateTime'
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ end
133
+ end
134
+ end
135
+ end