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 ApiIssueAttachmentOperations(object): 19 """ApiIssueAttachmentOperations 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, api_id, issue_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): 43 """Lists all attachments for the Issue associated with the specified API. 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 api_id: API identifier. Must be unique in the current API 50 Management service instance. 51 :type api_id: str 52 :param issue_id: Issue identifier. Must be unique in the current API 53 Management service instance. 54 :type issue_id: str 55 :param filter: | Field | Usage | Supported operators 56 | Supported functions 57 |</br>|-------------|-------------|-------------|-------------|</br>| 58 name | filter | ge, le, eq, ne, gt, lt | substringof, contains, 59 startswith, endswith | </br>| userId | filter | ge, le, eq, ne, gt, lt 60 | substringof, contains, startswith, endswith | </br> 61 :type filter: str 62 :param top: Number of records to return. 63 :type top: int 64 :param skip: Number of records to skip. 65 :type skip: int 66 :param dict custom_headers: headers that will be added to the request 67 :param bool raw: returns the direct response alongside the 68 deserialized response 69 :param operation_config: :ref:`Operation configuration 70 overrides<msrest:optionsforoperations>`. 71 :return: An iterator like instance of IssueAttachmentContract 72 :rtype: 73 ~azure.mgmt.apimanagement.models.IssueAttachmentContractPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] 74 :raises: 75 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 76 """ 77 def prepare_request(next_link=None): 78 if not next_link: 79 # Construct URL 80 url = self.list_by_service.metadata['url'] 81 path_format_arguments = { 82 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 83 '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])?$'), 84 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 85 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 86 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 87 } 88 url = self._client.format_url(url, **path_format_arguments) 89 90 # Construct parameters 91 query_parameters = {} 92 if filter is not None: 93 query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') 94 if top is not None: 95 query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) 96 if skip is not None: 97 query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) 98 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 99 100 else: 101 url = next_link 102 query_parameters = {} 103 104 # Construct headers 105 header_parameters = {} 106 header_parameters['Accept'] = 'application/json' 107 if self.config.generate_client_request_id: 108 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 109 if custom_headers: 110 header_parameters.update(custom_headers) 111 if self.config.accept_language is not None: 112 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 113 114 # Construct and send request 115 request = self._client.get(url, query_parameters, header_parameters) 116 return request 117 118 def internal_paging(next_link=None): 119 request = prepare_request(next_link) 120 121 response = self._client.send(request, stream=False, **operation_config) 122 123 if response.status_code not in [200]: 124 raise models.ErrorResponseException(self._deserialize, response) 125 126 return response 127 128 # Deserialize response 129 header_dict = None 130 if raw: 131 header_dict = {} 132 deserialized = models.IssueAttachmentContractPaged(internal_paging, self._deserialize.dependencies, header_dict) 133 134 return deserialized 135 list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'} 136 137 def get_entity_tag( 138 self, resource_group_name, service_name, api_id, issue_id, attachment_id, custom_headers=None, raw=False, **operation_config): 139 """Gets the entity state (Etag) version of the issue Attachment for an API 140 specified by its identifier. 141 142 :param resource_group_name: The name of the resource group. 143 :type resource_group_name: str 144 :param service_name: The name of the API Management service. 145 :type service_name: str 146 :param api_id: API identifier. Must be unique in the current API 147 Management service instance. 148 :type api_id: str 149 :param issue_id: Issue identifier. Must be unique in the current API 150 Management service instance. 151 :type issue_id: str 152 :param attachment_id: Attachment identifier within an Issue. Must be 153 unique in the current Issue. 154 :type attachment_id: str 155 :param dict custom_headers: headers that will be added to the request 156 :param bool raw: returns the direct response alongside the 157 deserialized response 158 :param operation_config: :ref:`Operation configuration 159 overrides<msrest:optionsforoperations>`. 160 :return: None or ClientRawResponse if raw=true 161 :rtype: None or ~msrest.pipeline.ClientRawResponse 162 :raises: 163 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 164 """ 165 # Construct URL 166 url = self.get_entity_tag.metadata['url'] 167 path_format_arguments = { 168 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 169 '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])?$'), 170 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 171 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 172 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 173 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 174 } 175 url = self._client.format_url(url, **path_format_arguments) 176 177 # Construct parameters 178 query_parameters = {} 179 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 180 181 # Construct headers 182 header_parameters = {} 183 if self.config.generate_client_request_id: 184 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 185 if custom_headers: 186 header_parameters.update(custom_headers) 187 if self.config.accept_language is not None: 188 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 189 190 # Construct and send request 191 request = self._client.head(url, query_parameters, header_parameters) 192 response = self._client.send(request, stream=False, **operation_config) 193 194 if response.status_code not in [200]: 195 raise models.ErrorResponseException(self._deserialize, response) 196 197 if raw: 198 client_raw_response = ClientRawResponse(None, response) 199 client_raw_response.add_headers({ 200 'ETag': 'str', 201 }) 202 return client_raw_response 203 get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} 204 205 def get( 206 self, resource_group_name, service_name, api_id, issue_id, attachment_id, custom_headers=None, raw=False, **operation_config): 207 """Gets the details of the issue Attachment for an API specified by its 208 identifier. 209 210 :param resource_group_name: The name of the resource group. 211 :type resource_group_name: str 212 :param service_name: The name of the API Management service. 213 :type service_name: str 214 :param api_id: API identifier. Must be unique in the current API 215 Management service instance. 216 :type api_id: str 217 :param issue_id: Issue identifier. Must be unique in the current API 218 Management service instance. 219 :type issue_id: str 220 :param attachment_id: Attachment identifier within an Issue. Must be 221 unique in the current Issue. 222 :type attachment_id: str 223 :param dict custom_headers: headers that will be added to the request 224 :param bool raw: returns the direct response alongside the 225 deserialized response 226 :param operation_config: :ref:`Operation configuration 227 overrides<msrest:optionsforoperations>`. 228 :return: IssueAttachmentContract or ClientRawResponse if raw=true 229 :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or 230 ~msrest.pipeline.ClientRawResponse 231 :raises: 232 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 233 """ 234 # Construct URL 235 url = self.get.metadata['url'] 236 path_format_arguments = { 237 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 238 '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])?$'), 239 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 240 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 241 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 242 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 243 } 244 url = self._client.format_url(url, **path_format_arguments) 245 246 # Construct parameters 247 query_parameters = {} 248 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 249 250 # Construct headers 251 header_parameters = {} 252 header_parameters['Accept'] = 'application/json' 253 if self.config.generate_client_request_id: 254 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 255 if custom_headers: 256 header_parameters.update(custom_headers) 257 if self.config.accept_language is not None: 258 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 259 260 # Construct and send request 261 request = self._client.get(url, query_parameters, header_parameters) 262 response = self._client.send(request, stream=False, **operation_config) 263 264 if response.status_code not in [200]: 265 raise models.ErrorResponseException(self._deserialize, response) 266 267 header_dict = {} 268 deserialized = None 269 if response.status_code == 200: 270 deserialized = self._deserialize('IssueAttachmentContract', response) 271 header_dict = { 272 'ETag': 'str', 273 } 274 275 if raw: 276 client_raw_response = ClientRawResponse(deserialized, response) 277 client_raw_response.add_headers(header_dict) 278 return client_raw_response 279 280 return deserialized 281 get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} 282 283 def create_or_update( 284 self, resource_group_name, service_name, api_id, issue_id, attachment_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): 285 """Creates a new Attachment for the Issue in an API or updates an existing 286 one. 287 288 :param resource_group_name: The name of the resource group. 289 :type resource_group_name: str 290 :param service_name: The name of the API Management service. 291 :type service_name: str 292 :param api_id: API identifier. Must be unique in the current API 293 Management service instance. 294 :type api_id: str 295 :param issue_id: Issue identifier. Must be unique in the current API 296 Management service instance. 297 :type issue_id: str 298 :param attachment_id: Attachment identifier within an Issue. Must be 299 unique in the current Issue. 300 :type attachment_id: str 301 :param parameters: Create parameters. 302 :type parameters: 303 ~azure.mgmt.apimanagement.models.IssueAttachmentContract 304 :param if_match: ETag of the Entity. Not required when creating an 305 entity, but required when updating an entity. 306 :type if_match: str 307 :param dict custom_headers: headers that will be added to the request 308 :param bool raw: returns the direct response alongside the 309 deserialized response 310 :param operation_config: :ref:`Operation configuration 311 overrides<msrest:optionsforoperations>`. 312 :return: IssueAttachmentContract or ClientRawResponse if raw=true 313 :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or 314 ~msrest.pipeline.ClientRawResponse 315 :raises: 316 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 317 """ 318 # Construct URL 319 url = self.create_or_update.metadata['url'] 320 path_format_arguments = { 321 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 322 '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])?$'), 323 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 324 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 325 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 326 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 327 } 328 url = self._client.format_url(url, **path_format_arguments) 329 330 # Construct parameters 331 query_parameters = {} 332 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 333 334 # Construct headers 335 header_parameters = {} 336 header_parameters['Accept'] = 'application/json' 337 header_parameters['Content-Type'] = 'application/json; charset=utf-8' 338 if self.config.generate_client_request_id: 339 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 340 if custom_headers: 341 header_parameters.update(custom_headers) 342 if if_match is not None: 343 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 344 if self.config.accept_language is not None: 345 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 346 347 # Construct body 348 body_content = self._serialize.body(parameters, 'IssueAttachmentContract') 349 350 # Construct and send request 351 request = self._client.put(url, query_parameters, header_parameters, body_content) 352 response = self._client.send(request, stream=False, **operation_config) 353 354 if response.status_code not in [200, 201]: 355 raise models.ErrorResponseException(self._deserialize, response) 356 357 header_dict = {} 358 deserialized = None 359 if response.status_code == 200: 360 deserialized = self._deserialize('IssueAttachmentContract', response) 361 header_dict = { 362 'ETag': 'str', 363 } 364 if response.status_code == 201: 365 deserialized = self._deserialize('IssueAttachmentContract', response) 366 header_dict = { 367 'ETag': 'str', 368 } 369 370 if raw: 371 client_raw_response = ClientRawResponse(deserialized, response) 372 client_raw_response.add_headers(header_dict) 373 return client_raw_response 374 375 return deserialized 376 create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} 377 378 def delete( 379 self, resource_group_name, service_name, api_id, issue_id, attachment_id, if_match, custom_headers=None, raw=False, **operation_config): 380 """Deletes the specified comment from an Issue. 381 382 :param resource_group_name: The name of the resource group. 383 :type resource_group_name: str 384 :param service_name: The name of the API Management service. 385 :type service_name: str 386 :param api_id: API identifier. Must be unique in the current API 387 Management service instance. 388 :type api_id: str 389 :param issue_id: Issue identifier. Must be unique in the current API 390 Management service instance. 391 :type issue_id: str 392 :param attachment_id: Attachment identifier within an Issue. Must be 393 unique in the current Issue. 394 :type attachment_id: str 395 :param if_match: ETag of the Entity. ETag should match the current 396 entity state from the header response of the GET request or it should 397 be * for unconditional update. 398 :type if_match: str 399 :param dict custom_headers: headers that will be added to the request 400 :param bool raw: returns the direct response alongside the 401 deserialized response 402 :param operation_config: :ref:`Operation configuration 403 overrides<msrest:optionsforoperations>`. 404 :return: None or ClientRawResponse if raw=true 405 :rtype: None or ~msrest.pipeline.ClientRawResponse 406 :raises: 407 :class:`ErrorResponseException<azure.mgmt.apimanagement.models.ErrorResponseException>` 408 """ 409 # Construct URL 410 url = self.delete.metadata['url'] 411 path_format_arguments = { 412 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 413 '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])?$'), 414 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 415 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 416 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 417 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') 418 } 419 url = self._client.format_url(url, **path_format_arguments) 420 421 # Construct parameters 422 query_parameters = {} 423 query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') 424 425 # Construct headers 426 header_parameters = {} 427 if self.config.generate_client_request_id: 428 header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) 429 if custom_headers: 430 header_parameters.update(custom_headers) 431 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 432 if self.config.accept_language is not None: 433 header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') 434 435 # Construct and send request 436 request = self._client.delete(url, query_parameters, header_parameters) 437 response = self._client.send(request, stream=False, **operation_config) 438 439 if response.status_code not in [200, 204]: 440 raise models.ErrorResponseException(self._deserialize, response) 441 442 if raw: 443 client_raw_response = ClientRawResponse(None, response) 444 return client_raw_response 445 delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} 446