1# -------------------------------------------------------------------------------------------- 2# Copyright (c) Microsoft Corporation. All rights reserved. 3# Licensed under the MIT License. See License.txt in the project root for license information. 4# -------------------------------------------------------------------------------------------- 5# Generated file, DO NOT EDIT 6# Changes may cause incorrect behavior and will be lost if the code is regenerated. 7# -------------------------------------------------------------------------------------------- 8 9from msrest import Serializer, Deserializer 10from ...vss_client import VssClient 11from . import models 12 13 14class ServiceHooksClient(VssClient): 15 """ServiceHooks 16 :param str base_url: Service URL 17 :param Authentication creds: Authenticated credentials. 18 """ 19 20 def __init__(self, base_url=None, creds=None): 21 super(ServiceHooksClient, self).__init__(base_url, creds) 22 client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} 23 self._serialize = Serializer(client_models) 24 self._deserialize = Deserializer(client_models) 25 26 resource_area_identifier = None 27 28 def get_consumer_action(self, consumer_id, consumer_action_id, publisher_id=None): 29 """GetConsumerAction. 30 Get details about a specific consumer action. 31 :param str consumer_id: ID for a consumer. 32 :param str consumer_action_id: ID for a consumerActionId. 33 :param str publisher_id: 34 :rtype: :class:`<ConsumerAction> <service-hooks.v4_1.models.ConsumerAction>` 35 """ 36 route_values = {} 37 if consumer_id is not None: 38 route_values['consumerId'] = self._serialize.url('consumer_id', consumer_id, 'str') 39 if consumer_action_id is not None: 40 route_values['consumerActionId'] = self._serialize.url('consumer_action_id', consumer_action_id, 'str') 41 query_parameters = {} 42 if publisher_id is not None: 43 query_parameters['publisherId'] = self._serialize.query('publisher_id', publisher_id, 'str') 44 response = self._send(http_method='GET', 45 location_id='c3428e90-7a69-4194-8ed8-0f153185ee0d', 46 version='4.1', 47 route_values=route_values, 48 query_parameters=query_parameters) 49 return self._deserialize('ConsumerAction', response) 50 51 def list_consumer_actions(self, consumer_id, publisher_id=None): 52 """ListConsumerActions. 53 Get a list of consumer actions for a specific consumer. 54 :param str consumer_id: ID for a consumer. 55 :param str publisher_id: 56 :rtype: [ConsumerAction] 57 """ 58 route_values = {} 59 if consumer_id is not None: 60 route_values['consumerId'] = self._serialize.url('consumer_id', consumer_id, 'str') 61 query_parameters = {} 62 if publisher_id is not None: 63 query_parameters['publisherId'] = self._serialize.query('publisher_id', publisher_id, 'str') 64 response = self._send(http_method='GET', 65 location_id='c3428e90-7a69-4194-8ed8-0f153185ee0d', 66 version='4.1', 67 route_values=route_values, 68 query_parameters=query_parameters) 69 return self._deserialize('[ConsumerAction]', self._unwrap_collection(response)) 70 71 def get_consumer(self, consumer_id, publisher_id=None): 72 """GetConsumer. 73 Get a specific consumer service. Optionally filter out consumer actions that do not support any event types for the specified publisher. 74 :param str consumer_id: ID for a consumer. 75 :param str publisher_id: 76 :rtype: :class:`<Consumer> <service-hooks.v4_1.models.Consumer>` 77 """ 78 route_values = {} 79 if consumer_id is not None: 80 route_values['consumerId'] = self._serialize.url('consumer_id', consumer_id, 'str') 81 query_parameters = {} 82 if publisher_id is not None: 83 query_parameters['publisherId'] = self._serialize.query('publisher_id', publisher_id, 'str') 84 response = self._send(http_method='GET', 85 location_id='4301c514-5f34-4f5d-a145-f0ea7b5b7d19', 86 version='4.1', 87 route_values=route_values, 88 query_parameters=query_parameters) 89 return self._deserialize('Consumer', response) 90 91 def list_consumers(self, publisher_id=None): 92 """ListConsumers. 93 Get a list of available service hook consumer services. Optionally filter by consumers that support at least one event type from the specific publisher. 94 :param str publisher_id: 95 :rtype: [Consumer] 96 """ 97 query_parameters = {} 98 if publisher_id is not None: 99 query_parameters['publisherId'] = self._serialize.query('publisher_id', publisher_id, 'str') 100 response = self._send(http_method='GET', 101 location_id='4301c514-5f34-4f5d-a145-f0ea7b5b7d19', 102 version='4.1', 103 query_parameters=query_parameters) 104 return self._deserialize('[Consumer]', self._unwrap_collection(response)) 105 106 def get_subscription_diagnostics(self, subscription_id): 107 """GetSubscriptionDiagnostics. 108 [Preview API] 109 :param str subscription_id: 110 :rtype: :class:`<SubscriptionDiagnostics> <service-hooks.v4_1.models.SubscriptionDiagnostics>` 111 """ 112 route_values = {} 113 if subscription_id is not None: 114 route_values['subscriptionId'] = self._serialize.url('subscription_id', subscription_id, 'str') 115 response = self._send(http_method='GET', 116 location_id='3b36bcb5-02ad-43c6-bbfa-6dfc6f8e9d68', 117 version='4.1-preview.1', 118 route_values=route_values) 119 return self._deserialize('SubscriptionDiagnostics', response) 120 121 def update_subscription_diagnostics(self, update_parameters, subscription_id): 122 """UpdateSubscriptionDiagnostics. 123 [Preview API] 124 :param :class:`<UpdateSubscripitonDiagnosticsParameters> <service-hooks.v4_1.models.UpdateSubscripitonDiagnosticsParameters>` update_parameters: 125 :param str subscription_id: 126 :rtype: :class:`<SubscriptionDiagnostics> <service-hooks.v4_1.models.SubscriptionDiagnostics>` 127 """ 128 route_values = {} 129 if subscription_id is not None: 130 route_values['subscriptionId'] = self._serialize.url('subscription_id', subscription_id, 'str') 131 content = self._serialize.body(update_parameters, 'UpdateSubscripitonDiagnosticsParameters') 132 response = self._send(http_method='PUT', 133 location_id='3b36bcb5-02ad-43c6-bbfa-6dfc6f8e9d68', 134 version='4.1-preview.1', 135 route_values=route_values, 136 content=content) 137 return self._deserialize('SubscriptionDiagnostics', response) 138 139 def get_event_type(self, publisher_id, event_type_id): 140 """GetEventType. 141 Get a specific event type. 142 :param str publisher_id: ID for a publisher. 143 :param str event_type_id: 144 :rtype: :class:`<EventTypeDescriptor> <service-hooks.v4_1.models.EventTypeDescriptor>` 145 """ 146 route_values = {} 147 if publisher_id is not None: 148 route_values['publisherId'] = self._serialize.url('publisher_id', publisher_id, 'str') 149 if event_type_id is not None: 150 route_values['eventTypeId'] = self._serialize.url('event_type_id', event_type_id, 'str') 151 response = self._send(http_method='GET', 152 location_id='db4777cd-8e08-4a84-8ba3-c974ea033718', 153 version='4.1', 154 route_values=route_values) 155 return self._deserialize('EventTypeDescriptor', response) 156 157 def list_event_types(self, publisher_id): 158 """ListEventTypes. 159 Get the event types for a specific publisher. 160 :param str publisher_id: ID for a publisher. 161 :rtype: [EventTypeDescriptor] 162 """ 163 route_values = {} 164 if publisher_id is not None: 165 route_values['publisherId'] = self._serialize.url('publisher_id', publisher_id, 'str') 166 response = self._send(http_method='GET', 167 location_id='db4777cd-8e08-4a84-8ba3-c974ea033718', 168 version='4.1', 169 route_values=route_values) 170 return self._deserialize('[EventTypeDescriptor]', self._unwrap_collection(response)) 171 172 def get_notification(self, subscription_id, notification_id): 173 """GetNotification. 174 Get a specific notification for a subscription. 175 :param str subscription_id: ID for a subscription. 176 :param int notification_id: 177 :rtype: :class:`<Notification> <service-hooks.v4_1.models.Notification>` 178 """ 179 route_values = {} 180 if subscription_id is not None: 181 route_values['subscriptionId'] = self._serialize.url('subscription_id', subscription_id, 'str') 182 if notification_id is not None: 183 route_values['notificationId'] = self._serialize.url('notification_id', notification_id, 'int') 184 response = self._send(http_method='GET', 185 location_id='0c62d343-21b0-4732-997b-017fde84dc28', 186 version='4.1', 187 route_values=route_values) 188 return self._deserialize('Notification', response) 189 190 def get_notifications(self, subscription_id, max_results=None, status=None, result=None): 191 """GetNotifications. 192 Get a list of notifications for a specific subscription. A notification includes details about the event, the request to and the response from the consumer service. 193 :param str subscription_id: ID for a subscription. 194 :param int max_results: Maximum number of notifications to return. Default is **100**. 195 :param str status: Get only notifications with this status. 196 :param str result: Get only notifications with this result type. 197 :rtype: [Notification] 198 """ 199 route_values = {} 200 if subscription_id is not None: 201 route_values['subscriptionId'] = self._serialize.url('subscription_id', subscription_id, 'str') 202 query_parameters = {} 203 if max_results is not None: 204 query_parameters['maxResults'] = self._serialize.query('max_results', max_results, 'int') 205 if status is not None: 206 query_parameters['status'] = self._serialize.query('status', status, 'str') 207 if result is not None: 208 query_parameters['result'] = self._serialize.query('result', result, 'str') 209 response = self._send(http_method='GET', 210 location_id='0c62d343-21b0-4732-997b-017fde84dc28', 211 version='4.1', 212 route_values=route_values, 213 query_parameters=query_parameters) 214 return self._deserialize('[Notification]', self._unwrap_collection(response)) 215 216 def query_notifications(self, query): 217 """QueryNotifications. 218 Query for notifications. A notification includes details about the event, the request to and the response from the consumer service. 219 :param :class:`<NotificationsQuery> <service-hooks.v4_1.models.NotificationsQuery>` query: 220 :rtype: :class:`<NotificationsQuery> <service-hooks.v4_1.models.NotificationsQuery>` 221 """ 222 content = self._serialize.body(query, 'NotificationsQuery') 223 response = self._send(http_method='POST', 224 location_id='1a57562f-160a-4b5c-9185-905e95b39d36', 225 version='4.1', 226 content=content) 227 return self._deserialize('NotificationsQuery', response) 228 229 def query_input_values(self, input_values_query, publisher_id): 230 """QueryInputValues. 231 :param :class:`<InputValuesQuery> <service-hooks.v4_1.models.InputValuesQuery>` input_values_query: 232 :param str publisher_id: 233 :rtype: :class:`<InputValuesQuery> <service-hooks.v4_1.models.InputValuesQuery>` 234 """ 235 route_values = {} 236 if publisher_id is not None: 237 route_values['publisherId'] = self._serialize.url('publisher_id', publisher_id, 'str') 238 content = self._serialize.body(input_values_query, 'InputValuesQuery') 239 response = self._send(http_method='POST', 240 location_id='d815d352-a566-4dc1-a3e3-fd245acf688c', 241 version='4.1', 242 route_values=route_values, 243 content=content) 244 return self._deserialize('InputValuesQuery', response) 245 246 def get_publisher(self, publisher_id): 247 """GetPublisher. 248 Get a specific service hooks publisher. 249 :param str publisher_id: ID for a publisher. 250 :rtype: :class:`<Publisher> <service-hooks.v4_1.models.Publisher>` 251 """ 252 route_values = {} 253 if publisher_id is not None: 254 route_values['publisherId'] = self._serialize.url('publisher_id', publisher_id, 'str') 255 response = self._send(http_method='GET', 256 location_id='1e83a210-5b53-43bc-90f0-d476a4e5d731', 257 version='4.1', 258 route_values=route_values) 259 return self._deserialize('Publisher', response) 260 261 def list_publishers(self): 262 """ListPublishers. 263 Get a list of publishers. 264 :rtype: [Publisher] 265 """ 266 response = self._send(http_method='GET', 267 location_id='1e83a210-5b53-43bc-90f0-d476a4e5d731', 268 version='4.1') 269 return self._deserialize('[Publisher]', self._unwrap_collection(response)) 270 271 def query_publishers(self, query): 272 """QueryPublishers. 273 Query for service hook publishers. 274 :param :class:`<PublishersQuery> <service-hooks.v4_1.models.PublishersQuery>` query: 275 :rtype: :class:`<PublishersQuery> <service-hooks.v4_1.models.PublishersQuery>` 276 """ 277 content = self._serialize.body(query, 'PublishersQuery') 278 response = self._send(http_method='POST', 279 location_id='99b44a8a-65a8-4670-8f3e-e7f7842cce64', 280 version='4.1', 281 content=content) 282 return self._deserialize('PublishersQuery', response) 283 284 def create_subscription(self, subscription): 285 """CreateSubscription. 286 Create a subscription. 287 :param :class:`<Subscription> <service-hooks.v4_1.models.Subscription>` subscription: Subscription to be created. 288 :rtype: :class:`<Subscription> <service-hooks.v4_1.models.Subscription>` 289 """ 290 content = self._serialize.body(subscription, 'Subscription') 291 response = self._send(http_method='POST', 292 location_id='fc50d02a-849f-41fb-8af1-0a5216103269', 293 version='4.1', 294 content=content) 295 return self._deserialize('Subscription', response) 296 297 def delete_subscription(self, subscription_id): 298 """DeleteSubscription. 299 Delete a specific service hooks subscription. 300 :param str subscription_id: ID for a subscription. 301 """ 302 route_values = {} 303 if subscription_id is not None: 304 route_values['subscriptionId'] = self._serialize.url('subscription_id', subscription_id, 'str') 305 self._send(http_method='DELETE', 306 location_id='fc50d02a-849f-41fb-8af1-0a5216103269', 307 version='4.1', 308 route_values=route_values) 309 310 def get_subscription(self, subscription_id): 311 """GetSubscription. 312 Get a specific service hooks subscription. 313 :param str subscription_id: ID for a subscription. 314 :rtype: :class:`<Subscription> <service-hooks.v4_1.models.Subscription>` 315 """ 316 route_values = {} 317 if subscription_id is not None: 318 route_values['subscriptionId'] = self._serialize.url('subscription_id', subscription_id, 'str') 319 response = self._send(http_method='GET', 320 location_id='fc50d02a-849f-41fb-8af1-0a5216103269', 321 version='4.1', 322 route_values=route_values) 323 return self._deserialize('Subscription', response) 324 325 def list_subscriptions(self, publisher_id=None, event_type=None, consumer_id=None, consumer_action_id=None): 326 """ListSubscriptions. 327 Get a list of subscriptions. 328 :param str publisher_id: ID for a subscription. 329 :param str event_type: Maximum number of notifications to return. Default is 100. 330 :param str consumer_id: ID for a consumer. 331 :param str consumer_action_id: ID for a consumerActionId. 332 :rtype: [Subscription] 333 """ 334 query_parameters = {} 335 if publisher_id is not None: 336 query_parameters['publisherId'] = self._serialize.query('publisher_id', publisher_id, 'str') 337 if event_type is not None: 338 query_parameters['eventType'] = self._serialize.query('event_type', event_type, 'str') 339 if consumer_id is not None: 340 query_parameters['consumerId'] = self._serialize.query('consumer_id', consumer_id, 'str') 341 if consumer_action_id is not None: 342 query_parameters['consumerActionId'] = self._serialize.query('consumer_action_id', consumer_action_id, 'str') 343 response = self._send(http_method='GET', 344 location_id='fc50d02a-849f-41fb-8af1-0a5216103269', 345 version='4.1', 346 query_parameters=query_parameters) 347 return self._deserialize('[Subscription]', self._unwrap_collection(response)) 348 349 def replace_subscription(self, subscription, subscription_id=None): 350 """ReplaceSubscription. 351 Update a subscription. <param name="subscriptionId">ID for a subscription that you wish to update.</param> 352 :param :class:`<Subscription> <service-hooks.v4_1.models.Subscription>` subscription: 353 :param str subscription_id: 354 :rtype: :class:`<Subscription> <service-hooks.v4_1.models.Subscription>` 355 """ 356 route_values = {} 357 if subscription_id is not None: 358 route_values['subscriptionId'] = self._serialize.url('subscription_id', subscription_id, 'str') 359 content = self._serialize.body(subscription, 'Subscription') 360 response = self._send(http_method='PUT', 361 location_id='fc50d02a-849f-41fb-8af1-0a5216103269', 362 version='4.1', 363 route_values=route_values, 364 content=content) 365 return self._deserialize('Subscription', response) 366 367 def create_subscriptions_query(self, query): 368 """CreateSubscriptionsQuery. 369 Query for service hook subscriptions. 370 :param :class:`<SubscriptionsQuery> <service-hooks.v4_1.models.SubscriptionsQuery>` query: 371 :rtype: :class:`<SubscriptionsQuery> <service-hooks.v4_1.models.SubscriptionsQuery>` 372 """ 373 content = self._serialize.body(query, 'SubscriptionsQuery') 374 response = self._send(http_method='POST', 375 location_id='c7c3c1cf-9e05-4c0d-a425-a0f922c2c6ed', 376 version='4.1', 377 content=content) 378 return self._deserialize('SubscriptionsQuery', response) 379 380 def create_test_notification(self, test_notification, use_real_data=None): 381 """CreateTestNotification. 382 Sends a test notification. This is useful for verifying the configuration of an updated or new service hooks subscription. 383 :param :class:`<Notification> <service-hooks.v4_1.models.Notification>` test_notification: 384 :param bool use_real_data: Only allow testing with real data in existing subscriptions. 385 :rtype: :class:`<Notification> <service-hooks.v4_1.models.Notification>` 386 """ 387 query_parameters = {} 388 if use_real_data is not None: 389 query_parameters['useRealData'] = self._serialize.query('use_real_data', use_real_data, 'bool') 390 content = self._serialize.body(test_notification, 'Notification') 391 response = self._send(http_method='POST', 392 location_id='1139462c-7e27-4524-a997-31b9b73551fe', 393 version='4.1', 394 query_parameters=query_parameters, 395 content=content) 396 return self._deserialize('Notification', response) 397 398