Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR azure-mgmt-resource] Auth locks examples #4540

Draft
wants to merge 1 commit into
base: release/v3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
# --------------------------------------------------------------------------

try:
from ._models_py3 import ErrorAdditionalInfo
from ._models_py3 import ErrorDetail
from ._models_py3 import ErrorResponse, ErrorResponseException
from ._models_py3 import ManagementLockObject
from ._models_py3 import ManagementLockOwner
from ._models_py3 import Operation
from ._models_py3 import OperationDisplay
except (SyntaxError, ImportError):
from ._models import ErrorAdditionalInfo
from ._models import ErrorDetail
from ._models import ErrorResponse, ErrorResponseException
from ._models import ManagementLockObject
from ._models import ManagementLockOwner
from ._models import Operation
Expand All @@ -26,6 +32,9 @@
)

__all__ = [
'ErrorAdditionalInfo',
'ErrorDetail',
'ErrorResponse', 'ErrorResponseException',
'ManagementLockObject',
'ManagementLockOwner',
'Operation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# --------------------------------------------------------------------------

from msrest.serialization import Model
from msrest.exceptions import HttpOperationError


class CloudError(Model):
Expand All @@ -20,6 +21,111 @@ class CloudError(Model):
}


class ErrorAdditionalInfo(Model):
"""The resource management error additional info.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""

_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}

_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}

def __init__(self, **kwargs):
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None


class ErrorDetail(Model):
"""The error detail.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details:
list[~azure.mgmt.resource.locks.v2016_09_01.models.ErrorDetail]
:ivar additional_info: The error additional info.
:vartype additional_info:
list[~azure.mgmt.resource.locks.v2016_09_01.models.ErrorAdditionalInfo]
"""

_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}

_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorDetail]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}

def __init__(self, **kwargs):
super(ErrorDetail, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None


class ErrorResponse(Model):
"""Error response.

Common error response for all Azure Resource Manager APIs to return error
details for failed operations. (This also follows the OData error response
format.).

:param error: The error object.
:type error: ~azure.mgmt.resource.locks.v2016_09_01.models.ErrorDetail
"""

_attribute_map = {
'error': {'key': 'error', 'type': 'ErrorDetail'},
}

def __init__(self, **kwargs):
super(ErrorResponse, self).__init__(**kwargs)
self.error = kwargs.get('error', None)


class ErrorResponseException(HttpOperationError):
"""Server responsed with exception of type: 'ErrorResponse'.

:param deserialize: A deserializer
:param response: Server response to be deserialized.
"""

def __init__(self, deserialize, response, *args):

super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args)


class ManagementLockObject(Model):
"""The lock information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# --------------------------------------------------------------------------

from msrest.serialization import Model
from msrest.exceptions import HttpOperationError


class CloudError(Model):
Expand All @@ -20,6 +21,111 @@ class CloudError(Model):
}


class ErrorAdditionalInfo(Model):
"""The resource management error additional info.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar type: The additional info type.
:vartype type: str
:ivar info: The additional info.
:vartype info: object
"""

_validation = {
'type': {'readonly': True},
'info': {'readonly': True},
}

_attribute_map = {
'type': {'key': 'type', 'type': 'str'},
'info': {'key': 'info', 'type': 'object'},
}

def __init__(self, **kwargs) -> None:
super(ErrorAdditionalInfo, self).__init__(**kwargs)
self.type = None
self.info = None


class ErrorDetail(Model):
"""The error detail.

Variables are only populated by the server, and will be ignored when
sending a request.

:ivar code: The error code.
:vartype code: str
:ivar message: The error message.
:vartype message: str
:ivar target: The error target.
:vartype target: str
:ivar details: The error details.
:vartype details:
list[~azure.mgmt.resource.locks.v2016_09_01.models.ErrorDetail]
:ivar additional_info: The error additional info.
:vartype additional_info:
list[~azure.mgmt.resource.locks.v2016_09_01.models.ErrorAdditionalInfo]
"""

_validation = {
'code': {'readonly': True},
'message': {'readonly': True},
'target': {'readonly': True},
'details': {'readonly': True},
'additional_info': {'readonly': True},
}

_attribute_map = {
'code': {'key': 'code', 'type': 'str'},
'message': {'key': 'message', 'type': 'str'},
'target': {'key': 'target', 'type': 'str'},
'details': {'key': 'details', 'type': '[ErrorDetail]'},
'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'},
}

def __init__(self, **kwargs) -> None:
super(ErrorDetail, self).__init__(**kwargs)
self.code = None
self.message = None
self.target = None
self.details = None
self.additional_info = None


class ErrorResponse(Model):
"""Error response.

Common error response for all Azure Resource Manager APIs to return error
details for failed operations. (This also follows the OData error response
format.).

:param error: The error object.
:type error: ~azure.mgmt.resource.locks.v2016_09_01.models.ErrorDetail
"""

_attribute_map = {
'error': {'key': 'error', 'type': 'ErrorDetail'},
}

def __init__(self, *, error=None, **kwargs) -> None:
super(ErrorResponse, self).__init__(**kwargs)
self.error = error


class ErrorResponseException(HttpOperationError):
"""Server responsed with exception of type: 'ErrorResponse'.

:param deserialize: A deserializer
:param response: Server response to be deserialized.
"""

def __init__(self, deserialize, response, *args):

super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args)


class ManagementLockObject(Model):
"""The lock information.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import uuid
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError

from .. import models

Expand Down Expand Up @@ -51,7 +50,8 @@ def list(
:return: An iterator like instance of Operation
:rtype:
~azure.mgmt.resource.locks.v2016_09_01.models.OperationPaged[~azure.mgmt.resource.locks.v2016_09_01.models.Operation]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
:raises:
:class:`ErrorResponseException<azure.mgmt.resource.locks.v2016_09_01.models.ErrorResponseException>`
"""
def prepare_request(next_link=None):
if not next_link:
Expand Down Expand Up @@ -86,9 +86,7 @@ def internal_paging(next_link=None):
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp
raise models.ErrorResponseException(self._deserialize, response)

return response

Expand Down
Loading