1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for 5# license information. 6# 7# Code generated by Microsoft (R) AutoRest Code Generator. 8# Changes may cause incorrect behavior and will be lost if the code is 9# regenerated. 10# -------------------------------------------------------------------------- 11 12import uuid 13from msrest.pipeline import ClientRawResponse 14 15from .. import models 16 17 18class OpenIdConnectProviderOperations(object): 19 """OpenIdConnectProviderOperations operations. 20 21 You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. 22 23 :param client: Client for service requests. 24 :param config: Configuration of service client. 25 :param serializer: An object model serializer. 26 :param deserializer: An object model deserializer. 27 :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". 28 """ 29 30 models = models 31 32 def __init__(self, client, config, serializer, deserializer): 33 34 self._client = client 35 self._serialize = serializer 36 self._deserialize = deserializer 37 self.api_version = "2019-12-01" 38 39 self.config = config 40 41 def list_by_service( 42 self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): 43 """Lists of all the OpenId Connect Providers. 44 45 :param resource_group_name: The name of the resource group. 46 :type resource_group_name: str 47 :param service_name: The name of the API Management service. 48 :type service_name: str 49 :param filter: | Field | Usage | Supported operators 50 | Supported functions 51 |</br>|-------------|-------------|-------------|-------------|</br>| 52 name | filter | ge, le, eq, ne, gt, lt | substringof, contains, 53 startswith, endswith | </br>| displayName | filter | ge, le, eq, ne, 54 gt, lt | substringof, contains, startswith, endswith | </br> 55 :type filter: str 56 :param top: Number of records to return. 57 :type top: int 58 :param skip: Number of records to skip. 59 :type skip: int 60 :param dict custom_headers: headers that will be added to the request 61 :param bool raw: returns the direct response alongside the 62 deserialized response 63 :param operation_config: :ref:`Operation configuration 64 overrides<msrest:optionsforoperations>`. 65 :return: An iterator like instance of OpenidConnectProviderContract 66 :rtype: 67 ~azure.mgmt.apimanagement.models.OpenidConnectProviderContractPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] 68 :raises: 69 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 70 """ 71 def prepare_request(next_link=None): 72 if not next_link: 73 # Construct URL 74 url = self.list_by_service.metadata['url'] 75 path_format_arguments = { 76 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 77 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 78 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 79 } 80 url = self._client.format_url(url, **path_format_arguments) 81 82 # Construct parameters 83 query_parameters = {} 84 if filter is not None: 85 query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') 86 if top is not None: 87 query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) 88 if skip is not None: 89 query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) 90 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 91 92 else: 93 url = next_link 94 query_parameters = {} 95 96 # Construct headers 97 header_parameters = {} 98 header_parameters['Accept'] = 'application/json' 99 if self.config.generate_client_request_id: 100 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 101 if custom_headers: 102 header_parameters.update(custom_headers) 103 if self.config.accept_language is not None: 104 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 105 106 # Construct and send request 107 request = self._client.get(url, query_parameters, header_parameters) 108 return request 109 110 def internal_paging(next_link=None): 111 request = prepare_request(next_link) 112 113 response = self._client.send(request, stream=False, **operation_config) 114 115 if response.status_code not in [200]: 116 raise models.ErrorResponseException(self._deserialize, response) 117 118 return response 119 120 # Deserialize response 121 header_dict = None 122 if raw: 123 header_dict = {} 124 deserialized = models.OpenidConnectProviderContractPaged(internal_paging, self._deserialize.dependencies, header_dict) 125 126 return deserialized 127 list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} 128 129 def get_entity_tag( 130 self, resource_group_name, service_name, opid, custom_headers=None, raw=False, **operation_config): 131 """Gets the entity state (Etag) version of the openIdConnectProvider 132 specified by its identifier. 133 134 :param resource_group_name: The name of the resource group. 135 :type resource_group_name: str 136 :param service_name: The name of the API Management service. 137 :type service_name: str 138 :param opid: Identifier of the OpenID Connect Provider. 139 :type opid: str 140 :param dict custom_headers: headers that will be added to the request 141 :param bool raw: returns the direct response alongside the 142 deserialized response 143 :param operation_config: :ref:`Operation configuration 144 overrides<msrest:optionsforoperations>`. 145 :return: None or ClientRawResponse if raw=true 146 :rtype: None or ~msrest.pipeline.ClientRawResponse 147 :raises: 148 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 149 """ 150 # Construct URL 151 url = self.get_entity_tag.metadata['url'] 152 path_format_arguments = { 153 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 154 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 155 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), 156 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 157 } 158 url = self._client.format_url(url, **path_format_arguments) 159 160 # Construct parameters 161 query_parameters = {} 162 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 163 164 # Construct headers 165 header_parameters = {} 166 if self.config.generate_client_request_id: 167 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 168 if custom_headers: 169 header_parameters.update(custom_headers) 170 if self.config.accept_language is not None: 171 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 172 173 # Construct and send request 174 request = self._client.head(url, query_parameters, header_parameters) 175 response = self._client.send(request, stream=False, **operation_config) 176 177 if response.status_code not in [200]: 178 raise models.ErrorResponseException(self._deserialize, response) 179 180 if raw: 181 client_raw_response = ClientRawResponse(None, response) 182 client_raw_response.add_headers({ 183 'ETag': 'str', 184 }) 185 return client_raw_response 186 get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} 187 188 def get( 189 self, resource_group_name, service_name, opid, custom_headers=None, raw=False, **operation_config): 190 """Gets specific OpenID Connect Provider. 191 192 :param resource_group_name: The name of the resource group. 193 :type resource_group_name: str 194 :param service_name: The name of the API Management service. 195 :type service_name: str 196 :param opid: Identifier of the OpenID Connect Provider. 197 :type opid: str 198 :param dict custom_headers: headers that will be added to the request 199 :param bool raw: returns the direct response alongside the 200 deserialized response 201 :param operation_config: :ref:`Operation configuration 202 overrides<msrest:optionsforoperations>`. 203 :return: OpenidConnectProviderContract or ClientRawResponse if 204 raw=true 205 :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract 206 or ~msrest.pipeline.ClientRawResponse 207 :raises: 208 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 209 """ 210 # Construct URL 211 url = self.get.metadata['url'] 212 path_format_arguments = { 213 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 214 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 215 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), 216 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 217 } 218 url = self._client.format_url(url, **path_format_arguments) 219 220 # Construct parameters 221 query_parameters = {} 222 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 223 224 # Construct headers 225 header_parameters = {} 226 header_parameters['Accept'] = 'application/json' 227 if self.config.generate_client_request_id: 228 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 229 if custom_headers: 230 header_parameters.update(custom_headers) 231 if self.config.accept_language is not None: 232 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 233 234 # Construct and send request 235 request = self._client.get(url, query_parameters, header_parameters) 236 response = self._client.send(request, stream=False, **operation_config) 237 238 if response.status_code not in [200]: 239 raise models.ErrorResponseException(self._deserialize, response) 240 241 header_dict = {} 242 deserialized = None 243 if response.status_code == 200: 244 deserialized = self._deserialize('OpenidConnectProviderContract', response) 245 header_dict = { 246 'ETag': 'str', 247 } 248 249 if raw: 250 client_raw_response = ClientRawResponse(deserialized, response) 251 client_raw_response.add_headers(header_dict) 252 return client_raw_response 253 254 return deserialized 255 get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} 256 257 def create_or_update( 258 self, resource_group_name, service_name, opid, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): 259 """Creates or updates the OpenID Connect Provider. 260 261 :param resource_group_name: The name of the resource group. 262 :type resource_group_name: str 263 :param service_name: The name of the API Management service. 264 :type service_name: str 265 :param opid: Identifier of the OpenID Connect Provider. 266 :type opid: str 267 :param parameters: Create parameters. 268 :type parameters: 269 ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract 270 :param if_match: ETag of the Entity. Not required when creating an 271 entity, but required when updating an entity. 272 :type if_match: str 273 :param dict custom_headers: headers that will be added to the request 274 :param bool raw: returns the direct response alongside the 275 deserialized response 276 :param operation_config: :ref:`Operation configuration 277 overrides<msrest:optionsforoperations>`. 278 :return: OpenidConnectProviderContract or ClientRawResponse if 279 raw=true 280 :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract 281 or ~msrest.pipeline.ClientRawResponse 282 :raises: 283 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 284 """ 285 # Construct URL 286 url = self.create_or_update.metadata['url'] 287 path_format_arguments = { 288 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 289 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 290 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), 291 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 292 } 293 url = self._client.format_url(url, **path_format_arguments) 294 295 # Construct parameters 296 query_parameters = {} 297 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 298 299 # Construct headers 300 header_parameters = {} 301 header_parameters['Accept'] = 'application/json' 302 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 303 if self.config.generate_client_request_id: 304 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 305 if custom_headers: 306 header_parameters.update(custom_headers) 307 if if_match is not None: 308 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 309 if self.config.accept_language is not None: 310 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 311 312 # Construct body 313 body_content = self._serialize.body(parameters, 'OpenidConnectProviderContract') 314 315 # Construct and send request 316 request = self._client.put(url, query_parameters, header_parameters, body_content) 317 response = self._client.send(request, stream=False, **operation_config) 318 319 if response.status_code not in [200, 201]: 320 raise models.ErrorResponseException(self._deserialize, response) 321 322 header_dict = {} 323 deserialized = None 324 if response.status_code == 200: 325 deserialized = self._deserialize('OpenidConnectProviderContract', response) 326 header_dict = { 327 'ETag': 'str', 328 } 329 if response.status_code == 201: 330 deserialized = self._deserialize('OpenidConnectProviderContract', response) 331 header_dict = { 332 'ETag': 'str', 333 } 334 335 if raw: 336 client_raw_response = ClientRawResponse(deserialized, response) 337 client_raw_response.add_headers(header_dict) 338 return client_raw_response 339 340 return deserialized 341 create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} 342 343 def update( 344 self, resource_group_name, service_name, opid, parameters, if_match, custom_headers=None, raw=False, **operation_config): 345 """Updates the specific OpenID Connect Provider. 346 347 :param resource_group_name: The name of the resource group. 348 :type resource_group_name: str 349 :param service_name: The name of the API Management service. 350 :type service_name: str 351 :param opid: Identifier of the OpenID Connect Provider. 352 :type opid: str 353 :param parameters: Update parameters. 354 :type parameters: 355 ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract 356 :param if_match: ETag of the Entity. ETag should match the current 357 entity state from the header response of the GET request or it should 358 be * for unconditional update. 359 :type if_match: str 360 :param dict custom_headers: headers that will be added to the request 361 :param bool raw: returns the direct response alongside the 362 deserialized response 363 :param operation_config: :ref:`Operation configuration 364 overrides<msrest:optionsforoperations>`. 365 :return: None or ClientRawResponse if raw=true 366 :rtype: None or ~msrest.pipeline.ClientRawResponse 367 :raises: 368 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 369 """ 370 # Construct URL 371 url = self.update.metadata['url'] 372 path_format_arguments = { 373 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 374 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 375 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), 376 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 377 } 378 url = self._client.format_url(url, **path_format_arguments) 379 380 # Construct parameters 381 query_parameters = {} 382 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 383 384 # Construct headers 385 header_parameters = {} 386 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 387 if self.config.generate_client_request_id: 388 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 389 if custom_headers: 390 header_parameters.update(custom_headers) 391 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 392 if self.config.accept_language is not None: 393 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 394 395 # Construct body 396 body_content = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') 397 398 # Construct and send request 399 request = self._client.patch(url, query_parameters, header_parameters, body_content) 400 response = self._client.send(request, stream=False, **operation_config) 401 402 if response.status_code not in [204]: 403 raise models.ErrorResponseException(self._deserialize, response) 404 405 if raw: 406 client_raw_response = ClientRawResponse(None, response) 407 return client_raw_response 408 update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} 409 410 def delete( 411 self, resource_group_name, service_name, opid, if_match, custom_headers=None, raw=False, **operation_config): 412 """Deletes specific OpenID Connect Provider of the API Management service 413 instance. 414 415 :param resource_group_name: The name of the resource group. 416 :type resource_group_name: str 417 :param service_name: The name of the API Management service. 418 :type service_name: str 419 :param opid: Identifier of the OpenID Connect Provider. 420 :type opid: str 421 :param if_match: ETag of the Entity. ETag should match the current 422 entity state from the header response of the GET request or it should 423 be * for unconditional update. 424 :type if_match: str 425 :param dict custom_headers: headers that will be added to the request 426 :param bool raw: returns the direct response alongside the 427 deserialized response 428 :param operation_config: :ref:`Operation configuration 429 overrides<msrest:optionsforoperations>`. 430 :return: None or ClientRawResponse if raw=true 431 :rtype: None or ~msrest.pipeline.ClientRawResponse 432 :raises: 433 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 434 """ 435 # Construct URL 436 url = self.delete.metadata['url'] 437 path_format_arguments = { 438 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 439 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 440 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), 441 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 442 } 443 url = self._client.format_url(url, **path_format_arguments) 444 445 # Construct parameters 446 query_parameters = {} 447 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 448 449 # Construct headers 450 header_parameters = {} 451 if self.config.generate_client_request_id: 452 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 453 if custom_headers: 454 header_parameters.update(custom_headers) 455 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 456 if self.config.accept_language is not None: 457 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 458 459 # Construct and send request 460 request = self._client.delete(url, query_parameters, header_parameters) 461 response = self._client.send(request, stream=False, **operation_config) 462 463 if response.status_code not in [200, 204]: 464 raise models.ErrorResponseException(self._deserialize, response) 465 466 if raw: 467 client_raw_response = ClientRawResponse(None, response) 468 return client_raw_response 469 delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} 470 471 def list_secrets( 472 self, resource_group_name, service_name, opid, custom_headers=None, raw=False, **operation_config): 473 """Gets the client secret details of the OpenID Connect Provider. 474 475 :param resource_group_name: The name of the resource group. 476 :type resource_group_name: str 477 :param service_name: The name of the API Management service. 478 :type service_name: str 479 :param opid: Identifier of the OpenID Connect Provider. 480 :type opid: str 481 :param dict custom_headers: headers that will be added to the request 482 :param bool raw: returns the direct response alongside the 483 deserialized response 484 :param operation_config: :ref:`Operation configuration 485 overrides<msrest:optionsforoperations>`. 486 :return: ClientSecretContract or ClientRawResponse if raw=true 487 :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract or 488 ~msrest.pipeline.ClientRawResponse 489 :raises: 490 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 491 """ 492 # Construct URL 493 url = self.list_secrets.metadata['url'] 494 path_format_arguments = { 495 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 496 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 497 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), 498 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 499 } 500 url = self._client.format_url(url, **path_format_arguments) 501 502 # Construct parameters 503 query_parameters = {} 504 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 505 506 # Construct headers 507 header_parameters = {} 508 header_parameters['Accept'] = 'application/json' 509 if self.config.generate_client_request_id: 510 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 511 if custom_headers: 512 header_parameters.update(custom_headers) 513 if self.config.accept_language is not None: 514 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 515 516 # Construct and send request 517 request = self._client.post(url, query_parameters, header_parameters) 518 response = self._client.send(request, stream=False, **operation_config) 519 520 if response.status_code not in [200]: 521 raise models.ErrorResponseException(self._deserialize, response) 522 523 deserialized = None 524 if response.status_code == 200: 525 deserialized = self._deserialize('ClientSecretContract', response) 526 527 if raw: 528 client_raw_response = ClientRawResponse(deserialized, response) 529 return client_raw_response 530 531 return deserialized 532 list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets'} 533