diff --git a/azure-mgmt-resourcegraph/HISTORY.rst b/azure-mgmt-resourcegraph/HISTORY.rst new file mode 100644 index 000000000000..63d28455418b --- /dev/null +++ b/azure-mgmt-resourcegraph/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +Release History +=============== + +0.1.0 (2018-09-07) +++++++++++++++++++ + +* Initial Release diff --git a/azure-mgmt-resourcegraph/MANIFEST.in b/azure-mgmt-resourcegraph/MANIFEST.in new file mode 100644 index 000000000000..9ecaeb15de50 --- /dev/null +++ b/azure-mgmt-resourcegraph/MANIFEST.in @@ -0,0 +1,2 @@ +include *.rst +include azure_bdist_wheel.py \ No newline at end of file diff --git a/azure-mgmt-resourcegraph/README.rst b/azure-mgmt-resourcegraph/README.rst new file mode 100644 index 000000000000..96a089ff2698 --- /dev/null +++ b/azure-mgmt-resourcegraph/README.rst @@ -0,0 +1,49 @@ +Microsoft Azure SDK for Python +============================== + +This is the Microsoft Azure Resource Graph Client Library. + +Azure Resource Manager (ARM) is the next generation of management APIs that +replace the old Azure Service Management (ASM). + +This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. + +For the older Azure Service Management (ASM) libraries, see +`azure-servicemanagement-legacy `__ library. + +For a more complete set of Azure libraries, see the `azure `__ bundle package. + + +Compatibility +============= + +**IMPORTANT**: If you have an earlier version of the azure package +(version < 1.0), you should uninstall it before installing this package. + +You can check the version using pip: + +.. code:: shell + + pip freeze + +If you see azure==0.11.0 (or any version below 1.0), uninstall it first: + +.. code:: shell + + pip uninstall azure + + +Usage +===== + +For code examples, see `Resource Graph +`__ +on docs.microsoft.com. + + +Provide Feedback +================ + +If you encounter any bugs or have suggestions, please file an issue in the +`Issues `__ +section of the project. diff --git a/azure-mgmt-resourcegraph/azure/__init__.py b/azure-mgmt-resourcegraph/azure/__init__.py new file mode 100644 index 000000000000..849489fca33c --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/__init__.py b/azure-mgmt-resourcegraph/azure/mgmt/__init__.py new file mode 100644 index 000000000000..849489fca33c --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/__init__.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/__init__.py new file mode 100644 index 000000000000..7cab47e782dd --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource_graph_client import ResourceGraphClient +from .version import VERSION + +__all__ = ['ResourceGraphClient'] + +__version__ = VERSION + diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/__init__.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/__init__.py new file mode 100644 index 000000000000..b9665e9850d4 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/__init__.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +try: + from .query_request_options_py3 import QueryRequestOptions + from .facet_request_options_py3 import FacetRequestOptions + from .facet_request_py3 import FacetRequest + from .query_request_py3 import QueryRequest + from .column_py3 import Column + from .table_py3 import Table + from .facet_py3 import Facet + from .query_response_py3 import QueryResponse + from .facet_result_py3 import FacetResult + from .error_details_py3 import ErrorDetails + from .facet_error_py3 import FacetError + from .error_py3 import Error + from .error_response_py3 import ErrorResponse, ErrorResponseException + from .operation_display_py3 import OperationDisplay + from .operation_py3 import Operation +except (SyntaxError, ImportError): + from .query_request_options import QueryRequestOptions + from .facet_request_options import FacetRequestOptions + from .facet_request import FacetRequest + from .query_request import QueryRequest + from .column import Column + from .table import Table + from .facet import Facet + from .query_response import QueryResponse + from .facet_result import FacetResult + from .error_details import ErrorDetails + from .facet_error import FacetError + from .error import Error + from .error_response import ErrorResponse, ErrorResponseException + from .operation_display import OperationDisplay + from .operation import Operation +from .operation_paged import OperationPaged +from .resource_graph_client_enums import ( + FacetSortOrder, + ResultTruncated, + ColumnDataType, +) + +__all__ = [ + 'QueryRequestOptions', + 'FacetRequestOptions', + 'FacetRequest', + 'QueryRequest', + 'Column', + 'Table', + 'Facet', + 'QueryResponse', + 'FacetResult', + 'ErrorDetails', + 'FacetError', + 'Error', + 'ErrorResponse', 'ErrorResponseException', + 'OperationDisplay', + 'Operation', + 'OperationPaged', + 'FacetSortOrder', + 'ResultTruncated', + 'ColumnDataType', +] diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/column.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/column.py new file mode 100644 index 000000000000..5374aa3c8bcb --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/column.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Column(Model): + """Query result column descriptor. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Column name. + :type name: str + :param type: Required. Column data type. Possible values include: + 'string', 'integer', 'number', 'boolean', 'object' + :type type: str or ~azure.mgmt.resourcegraph.models.ColumnDataType + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'ColumnDataType'}, + } + + def __init__(self, **kwargs): + super(Column, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/column_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/column_py3.py new file mode 100644 index 000000000000..018db7627f50 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/column_py3.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Column(Model): + """Query result column descriptor. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. Column name. + :type name: str + :param type: Required. Column data type. Possible values include: + 'string', 'integer', 'number', 'boolean', 'object' + :type type: str or ~azure.mgmt.resourcegraph.models.ColumnDataType + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'ColumnDataType'}, + } + + def __init__(self, *, name: str, type, **kwargs) -> None: + super(Column, self).__init__(**kwargs) + self.name = name + self.type = type diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error.py new file mode 100644 index 000000000000..a636be2b606b --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Error(Model): + """Error info. + + Error details. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Error code identifying the specific error. + :type code: str + :param message: Required. A human readable error message. + :type message: str + :param details: Error details + :type details: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetails]'}, + } + + def __init__(self, **kwargs): + super(Error, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.details = kwargs.get('details', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_details.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_details.py new file mode 100644 index 000000000000..492ef064177f --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_details.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ErrorDetails(Model): + """Error details. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param code: Required. Error code identifying the specific error. + :type code: str + :param message: Required. A human readable error message. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorDetails, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_details_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_details_py3.py new file mode 100644 index 000000000000..9477601ee29f --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_details_py3.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ErrorDetails(Model): + """Error details. + + All required parameters must be populated in order to send to Azure. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param code: Required. Error code identifying the specific error. + :type code: str + :param message: Required. A human readable error message. + :type message: str + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code: str, message: str, additional_properties=None, **kwargs) -> None: + super(ErrorDetails, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.code = code + self.message = message diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_py3.py new file mode 100644 index 000000000000..794e64393602 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_py3.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Error(Model): + """Error info. + + Error details. + + All required parameters must be populated in order to send to Azure. + + :param code: Required. Error code identifying the specific error. + :type code: str + :param message: Required. A human readable error message. + :type message: str + :param details: Error details + :type details: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetails]'}, + } + + def __init__(self, *, code: str, message: str, details=None, **kwargs) -> None: + super(Error, self).__init__(**kwargs) + self.code = code + self.message = message + self.details = details diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_response.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_response.py new file mode 100644 index 000000000000..4edf5fbea873 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_response.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class ErrorResponse(Model): + """Error response. + + An error response from the API. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. Error information. + :type error: ~azure.mgmt.resourcegraph.models.Error + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'Error'}, + } + + 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) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_response_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_response_py3.py new file mode 100644 index 000000000000..f29ed91e8354 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/error_response_py3.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class ErrorResponse(Model): + """Error response. + + An error response from the API. + + All required parameters must be populated in order to send to Azure. + + :param error: Required. Error information. + :type error: ~azure.mgmt.resourcegraph.models.Error + """ + + _validation = { + 'error': {'required': True}, + } + + _attribute_map = { + 'error': {'key': 'error', 'type': 'Error'}, + } + + def __init__(self, *, error, **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) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet.py new file mode 100644 index 000000000000..9b9193356ed8 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Facet(Model): + """A facet containing additional statistics on the response of a query. Can be + either FacetResult or FacetError. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: FacetResult, FacetError + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. Facet expression, same as in the + corresponding facet request. + :type expression: str + :param result_type: Required. Constant filled by server. + :type result_type: str + """ + + _validation = { + 'expression': {'required': True}, + 'result_type': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'result_type': {'key': 'resultType', 'type': 'str'}, + } + + _subtype_map = { + 'result_type': {'FacetResult': 'FacetResult', 'FacetError': 'FacetError'} + } + + def __init__(self, **kwargs): + super(Facet, self).__init__(**kwargs) + self.expression = kwargs.get('expression', None) + self.result_type = None diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_error.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_error.py new file mode 100644 index 000000000000..aab89e709432 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_error.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .facet import Facet + + +class FacetError(Facet): + """A facet whose execution resulted in an error. + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. Facet expression, same as in the + corresponding facet request. + :type expression: str + :param result_type: Required. Constant filled by server. + :type result_type: str + :param errors: Required. An array containing detected facet errors with + details. + :type errors: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + """ + + _validation = { + 'expression': {'required': True}, + 'result_type': {'required': True}, + 'errors': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'result_type': {'key': 'resultType', 'type': 'str'}, + 'errors': {'key': 'errors', 'type': '[ErrorDetails]'}, + } + + def __init__(self, **kwargs): + super(FacetError, self).__init__(**kwargs) + self.errors = kwargs.get('errors', None) + self.result_type = 'FacetError' diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_error_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_error_py3.py new file mode 100644 index 000000000000..06da3acc4562 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_error_py3.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .facet_py3 import Facet + + +class FacetError(Facet): + """A facet whose execution resulted in an error. + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. Facet expression, same as in the + corresponding facet request. + :type expression: str + :param result_type: Required. Constant filled by server. + :type result_type: str + :param errors: Required. An array containing detected facet errors with + details. + :type errors: list[~azure.mgmt.resourcegraph.models.ErrorDetails] + """ + + _validation = { + 'expression': {'required': True}, + 'result_type': {'required': True}, + 'errors': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'result_type': {'key': 'resultType', 'type': 'str'}, + 'errors': {'key': 'errors', 'type': '[ErrorDetails]'}, + } + + def __init__(self, *, expression: str, errors, **kwargs) -> None: + super(FacetError, self).__init__(expression=expression, **kwargs) + self.errors = errors + self.result_type = 'FacetError' diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_py3.py new file mode 100644 index 000000000000..ffe29392108d --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_py3.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Facet(Model): + """A facet containing additional statistics on the response of a query. Can be + either FacetResult or FacetError. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: FacetResult, FacetError + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. Facet expression, same as in the + corresponding facet request. + :type expression: str + :param result_type: Required. Constant filled by server. + :type result_type: str + """ + + _validation = { + 'expression': {'required': True}, + 'result_type': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'result_type': {'key': 'resultType', 'type': 'str'}, + } + + _subtype_map = { + 'result_type': {'FacetResult': 'FacetResult', 'FacetError': 'FacetError'} + } + + def __init__(self, *, expression: str, **kwargs) -> None: + super(Facet, self).__init__(**kwargs) + self.expression = expression + self.result_type = None diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request.py new file mode 100644 index 000000000000..0f01fe8229d4 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FacetRequest(Model): + """A request to compute additional statistics (facets) over the query results. + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. The column or list of columns to summarize by + :type expression: str + :param options: The options for facet evaluation + :type options: ~azure.mgmt.resourcegraph.models.FacetRequestOptions + """ + + _validation = { + 'expression': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'options': {'key': 'options', 'type': 'FacetRequestOptions'}, + } + + def __init__(self, **kwargs): + super(FacetRequest, self).__init__(**kwargs) + self.expression = kwargs.get('expression', None) + self.options = kwargs.get('options', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_options.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_options.py new file mode 100644 index 000000000000..4ea94a3bd963 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_options.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FacetRequestOptions(Model): + """The options for facet evaluation. + + :param sort_order: The sorting order by the hit count. Possible values + include: 'asc', 'desc'. Default value: "desc" . + :type sort_order: str or ~azure.mgmt.resourcegraph.models.FacetSortOrder + :param top: The maximum number of facet rows that should be returned. + :type top: int + """ + + _validation = { + 'top': {'maximum': 1000, 'minimum': 1}, + } + + _attribute_map = { + 'sort_order': {'key': 'sortOrder', 'type': 'FacetSortOrder'}, + 'top': {'key': '$top', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(FacetRequestOptions, self).__init__(**kwargs) + self.sort_order = kwargs.get('sort_order', "desc") + self.top = kwargs.get('top', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_options_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_options_py3.py new file mode 100644 index 000000000000..677fda8ce26c --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_options_py3.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FacetRequestOptions(Model): + """The options for facet evaluation. + + :param sort_order: The sorting order by the hit count. Possible values + include: 'asc', 'desc'. Default value: "desc" . + :type sort_order: str or ~azure.mgmt.resourcegraph.models.FacetSortOrder + :param top: The maximum number of facet rows that should be returned. + :type top: int + """ + + _validation = { + 'top': {'maximum': 1000, 'minimum': 1}, + } + + _attribute_map = { + 'sort_order': {'key': 'sortOrder', 'type': 'FacetSortOrder'}, + 'top': {'key': '$top', 'type': 'int'}, + } + + def __init__(self, *, sort_order="desc", top: int=None, **kwargs) -> None: + super(FacetRequestOptions, self).__init__(**kwargs) + self.sort_order = sort_order + self.top = top diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_py3.py new file mode 100644 index 000000000000..cc0fd8b132df --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_request_py3.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class FacetRequest(Model): + """A request to compute additional statistics (facets) over the query results. + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. The column or list of columns to summarize by + :type expression: str + :param options: The options for facet evaluation + :type options: ~azure.mgmt.resourcegraph.models.FacetRequestOptions + """ + + _validation = { + 'expression': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'options': {'key': 'options', 'type': 'FacetRequestOptions'}, + } + + def __init__(self, *, expression: str, options=None, **kwargs) -> None: + super(FacetRequest, self).__init__(**kwargs) + self.expression = expression + self.options = options diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_result.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_result.py new file mode 100644 index 000000000000..82dede8eb06f --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_result.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .facet import Facet + + +class FacetResult(Facet): + """Successfully executed facet containing additional statistics on the + response of a query. + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. Facet expression, same as in the + corresponding facet request. + :type expression: str + :param result_type: Required. Constant filled by server. + :type result_type: str + :param total_records: Required. Number of total records in the facet + results. + :type total_records: long + :param count: Required. Number of records returned in the facet response. + :type count: int + :param data: Required. A table containing the desired facets. Only present + if the facet is valid. + :type data: ~azure.mgmt.resourcegraph.models.Table + """ + + _validation = { + 'expression': {'required': True}, + 'result_type': {'required': True}, + 'total_records': {'required': True}, + 'count': {'required': True}, + 'data': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'result_type': {'key': 'resultType', 'type': 'str'}, + 'total_records': {'key': 'totalRecords', 'type': 'long'}, + 'count': {'key': 'count', 'type': 'int'}, + 'data': {'key': 'data', 'type': 'Table'}, + } + + def __init__(self, **kwargs): + super(FacetResult, self).__init__(**kwargs) + self.total_records = kwargs.get('total_records', None) + self.count = kwargs.get('count', None) + self.data = kwargs.get('data', None) + self.result_type = 'FacetResult' diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_result_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_result_py3.py new file mode 100644 index 000000000000..4f3e9f499f75 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/facet_result_py3.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .facet_py3 import Facet + + +class FacetResult(Facet): + """Successfully executed facet containing additional statistics on the + response of a query. + + All required parameters must be populated in order to send to Azure. + + :param expression: Required. Facet expression, same as in the + corresponding facet request. + :type expression: str + :param result_type: Required. Constant filled by server. + :type result_type: str + :param total_records: Required. Number of total records in the facet + results. + :type total_records: long + :param count: Required. Number of records returned in the facet response. + :type count: int + :param data: Required. A table containing the desired facets. Only present + if the facet is valid. + :type data: ~azure.mgmt.resourcegraph.models.Table + """ + + _validation = { + 'expression': {'required': True}, + 'result_type': {'required': True}, + 'total_records': {'required': True}, + 'count': {'required': True}, + 'data': {'required': True}, + } + + _attribute_map = { + 'expression': {'key': 'expression', 'type': 'str'}, + 'result_type': {'key': 'resultType', 'type': 'str'}, + 'total_records': {'key': 'totalRecords', 'type': 'long'}, + 'count': {'key': 'count', 'type': 'int'}, + 'data': {'key': 'data', 'type': 'Table'}, + } + + def __init__(self, *, expression: str, total_records: int, count: int, data, **kwargs) -> None: + super(FacetResult, self).__init__(expression=expression, **kwargs) + self.total_records = total_records + self.count = count + self.data = data + self.result_type = 'FacetResult' diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation.py new file mode 100644 index 000000000000..d824b9fd31af --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Operation(Model): + """Resource Graph REST API operation definition. + + :param name: Operation name: {provider}/{resource}/{operation} + :type name: str + :param display: Display metadata associated with the operation. + :type display: ~azure.mgmt.resourcegraph.models.OperationDisplay + :param origin: The origin of operations. + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + self.origin = kwargs.get('origin', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_display.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_display.py new file mode 100644 index 000000000000..59392b296d7a --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_display.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class OperationDisplay(Model): + """Display metadata associated with the operation. + + :param provider: Service provider: Microsoft Resource Graph. + :type provider: str + :param resource: Resource on which the operation is performed etc. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description for the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_display_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_display_py3.py new file mode 100644 index 000000000000..6d4bd89ec8cc --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_display_py3.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class OperationDisplay(Model): + """Display metadata associated with the operation. + + :param provider: Service provider: Microsoft Resource Graph. + :type provider: str + :param resource: Resource on which the operation is performed etc. + :type resource: str + :param operation: Type of operation: get, read, delete, etc. + :type operation: str + :param description: Description for the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_paged.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_paged.py new file mode 100644 index 000000000000..ec7e9b01c05b --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class OperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`Operation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Operation]'} + } + + def __init__(self, *args, **kwargs): + + super(OperationPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_py3.py new file mode 100644 index 000000000000..886eb84942a7 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/operation_py3.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Operation(Model): + """Resource Graph REST API operation definition. + + :param name: Operation name: {provider}/{resource}/{operation} + :type name: str + :param display: Display metadata associated with the operation. + :type display: ~azure.mgmt.resourcegraph.models.OperationDisplay + :param origin: The origin of operations. + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__(self, *, name: str=None, display=None, origin: str=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request.py new file mode 100644 index 000000000000..e1290209ada6 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryRequest(Model): + """Describes a query to be executed. + + All required parameters must be populated in order to send to Azure. + + :param subscriptions: Required. Azure subscriptions against which to + execute the query. + :type subscriptions: list[str] + :param query: Required. The resources query. + :type query: str + :param options: The query evaluation options + :type options: ~azure.mgmt.resourcegraph.models.QueryRequestOptions + :param facets: An array of facet requests to be computed against the query + result. + :type facets: list[~azure.mgmt.resourcegraph.models.FacetRequest] + """ + + _validation = { + 'subscriptions': {'required': True}, + 'query': {'required': True}, + } + + _attribute_map = { + 'subscriptions': {'key': 'subscriptions', 'type': '[str]'}, + 'query': {'key': 'query', 'type': 'str'}, + 'options': {'key': 'options', 'type': 'QueryRequestOptions'}, + 'facets': {'key': 'facets', 'type': '[FacetRequest]'}, + } + + def __init__(self, **kwargs): + super(QueryRequest, self).__init__(**kwargs) + self.subscriptions = kwargs.get('subscriptions', None) + self.query = kwargs.get('query', None) + self.options = kwargs.get('options', None) + self.facets = kwargs.get('facets', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_options.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_options.py new file mode 100644 index 000000000000..f2a9fe75fd09 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_options.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryRequestOptions(Model): + """The options for query evaluation. + + :param skip_token: Continuation token for pagination, capturing the next + page size and offset, as well as the context of the query. + :type skip_token: str + :param top: The maximum number of rows that the query should return. + Overrides the page size when ```$skipToken``` property is present. + :type top: int + :param skip: The number of rows to skip from the beginning of the results. + Overrides the next page offset when ```$skipToken``` property is present. + :type skip: int + """ + + _validation = { + 'top': {'maximum': 1000, 'minimum': 1}, + 'skip': {'minimum': 0}, + } + + _attribute_map = { + 'skip_token': {'key': '$skipToken', 'type': 'str'}, + 'top': {'key': '$top', 'type': 'int'}, + 'skip': {'key': '$skip', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(QueryRequestOptions, self).__init__(**kwargs) + self.skip_token = kwargs.get('skip_token', None) + self.top = kwargs.get('top', None) + self.skip = kwargs.get('skip', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_options_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_options_py3.py new file mode 100644 index 000000000000..e6019a31a6fc --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_options_py3.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryRequestOptions(Model): + """The options for query evaluation. + + :param skip_token: Continuation token for pagination, capturing the next + page size and offset, as well as the context of the query. + :type skip_token: str + :param top: The maximum number of rows that the query should return. + Overrides the page size when ```$skipToken``` property is present. + :type top: int + :param skip: The number of rows to skip from the beginning of the results. + Overrides the next page offset when ```$skipToken``` property is present. + :type skip: int + """ + + _validation = { + 'top': {'maximum': 1000, 'minimum': 1}, + 'skip': {'minimum': 0}, + } + + _attribute_map = { + 'skip_token': {'key': '$skipToken', 'type': 'str'}, + 'top': {'key': '$top', 'type': 'int'}, + 'skip': {'key': '$skip', 'type': 'int'}, + } + + def __init__(self, *, skip_token: str=None, top: int=None, skip: int=None, **kwargs) -> None: + super(QueryRequestOptions, self).__init__(**kwargs) + self.skip_token = skip_token + self.top = top + self.skip = skip diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_py3.py new file mode 100644 index 000000000000..a4e251dd1016 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_request_py3.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryRequest(Model): + """Describes a query to be executed. + + All required parameters must be populated in order to send to Azure. + + :param subscriptions: Required. Azure subscriptions against which to + execute the query. + :type subscriptions: list[str] + :param query: Required. The resources query. + :type query: str + :param options: The query evaluation options + :type options: ~azure.mgmt.resourcegraph.models.QueryRequestOptions + :param facets: An array of facet requests to be computed against the query + result. + :type facets: list[~azure.mgmt.resourcegraph.models.FacetRequest] + """ + + _validation = { + 'subscriptions': {'required': True}, + 'query': {'required': True}, + } + + _attribute_map = { + 'subscriptions': {'key': 'subscriptions', 'type': '[str]'}, + 'query': {'key': 'query', 'type': 'str'}, + 'options': {'key': 'options', 'type': 'QueryRequestOptions'}, + 'facets': {'key': 'facets', 'type': '[FacetRequest]'}, + } + + def __init__(self, *, subscriptions, query: str, options=None, facets=None, **kwargs) -> None: + super(QueryRequest, self).__init__(**kwargs) + self.subscriptions = subscriptions + self.query = query + self.options = options + self.facets = facets diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_response.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_response.py new file mode 100644 index 000000000000..eb09fe97d757 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_response.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryResponse(Model): + """Query result. + + All required parameters must be populated in order to send to Azure. + + :param total_records: Required. Number of total records matching the + query. + :type total_records: long + :param count: Required. Number of records returned in the current + response. In the case of paging, this is the number of records in the + current page. + :type count: long + :param result_truncated: Required. Indicates whether the query results are + truncated. Possible values include: 'true', 'false' + :type result_truncated: str or + ~azure.mgmt.resourcegraph.models.ResultTruncated + :param skip_token: When present, the value can be passed to a subsequent + query call (together with the same query and subscriptions used in the + current request) to retrieve the next page of data. + :type skip_token: str + :param data: Required. Query output in tabular format. + :type data: ~azure.mgmt.resourcegraph.models.Table + :param facets: Query facets. + :type facets: list[~azure.mgmt.resourcegraph.models.Facet] + """ + + _validation = { + 'total_records': {'required': True}, + 'count': {'required': True}, + 'result_truncated': {'required': True}, + 'data': {'required': True}, + } + + _attribute_map = { + 'total_records': {'key': 'totalRecords', 'type': 'long'}, + 'count': {'key': 'count', 'type': 'long'}, + 'result_truncated': {'key': 'resultTruncated', 'type': 'ResultTruncated'}, + 'skip_token': {'key': '$skipToken', 'type': 'str'}, + 'data': {'key': 'data', 'type': 'Table'}, + 'facets': {'key': 'facets', 'type': '[Facet]'}, + } + + def __init__(self, **kwargs): + super(QueryResponse, self).__init__(**kwargs) + self.total_records = kwargs.get('total_records', None) + self.count = kwargs.get('count', None) + self.result_truncated = kwargs.get('result_truncated', None) + self.skip_token = kwargs.get('skip_token', None) + self.data = kwargs.get('data', None) + self.facets = kwargs.get('facets', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_response_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_response_py3.py new file mode 100644 index 000000000000..c86ed4df6f90 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/query_response_py3.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryResponse(Model): + """Query result. + + All required parameters must be populated in order to send to Azure. + + :param total_records: Required. Number of total records matching the + query. + :type total_records: long + :param count: Required. Number of records returned in the current + response. In the case of paging, this is the number of records in the + current page. + :type count: long + :param result_truncated: Required. Indicates whether the query results are + truncated. Possible values include: 'true', 'false' + :type result_truncated: str or + ~azure.mgmt.resourcegraph.models.ResultTruncated + :param skip_token: When present, the value can be passed to a subsequent + query call (together with the same query and subscriptions used in the + current request) to retrieve the next page of data. + :type skip_token: str + :param data: Required. Query output in tabular format. + :type data: ~azure.mgmt.resourcegraph.models.Table + :param facets: Query facets. + :type facets: list[~azure.mgmt.resourcegraph.models.Facet] + """ + + _validation = { + 'total_records': {'required': True}, + 'count': {'required': True}, + 'result_truncated': {'required': True}, + 'data': {'required': True}, + } + + _attribute_map = { + 'total_records': {'key': 'totalRecords', 'type': 'long'}, + 'count': {'key': 'count', 'type': 'long'}, + 'result_truncated': {'key': 'resultTruncated', 'type': 'ResultTruncated'}, + 'skip_token': {'key': '$skipToken', 'type': 'str'}, + 'data': {'key': 'data', 'type': 'Table'}, + 'facets': {'key': 'facets', 'type': '[Facet]'}, + } + + def __init__(self, *, total_records: int, count: int, result_truncated, data, skip_token: str=None, facets=None, **kwargs) -> None: + super(QueryResponse, self).__init__(**kwargs) + self.total_records = total_records + self.count = count + self.result_truncated = result_truncated + self.skip_token = skip_token + self.data = data + self.facets = facets diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/resource_graph_client_enums.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/resource_graph_client_enums.py new file mode 100644 index 000000000000..6973ac9c0e59 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/resource_graph_client_enums.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class FacetSortOrder(str, Enum): + + asc = "asc" + desc = "desc" + + +class ResultTruncated(str, Enum): + + true = "true" + false = "false" + + +class ColumnDataType(str, Enum): + + string = "string" + integer = "integer" + number = "number" + boolean = "boolean" + object_enum = "object" diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/table.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/table.py new file mode 100644 index 000000000000..03a8cd806eec --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/table.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Table(Model): + """Query output in tabular format. + + All required parameters must be populated in order to send to Azure. + + :param columns: Required. Query result column descriptors. + :type columns: list[~azure.mgmt.resourcegraph.models.Column] + :param rows: Required. Query result rows. + :type rows: list[list[object]] + """ + + _validation = { + 'columns': {'required': True}, + 'rows': {'required': True}, + } + + _attribute_map = { + 'columns': {'key': 'columns', 'type': '[Column]'}, + 'rows': {'key': 'rows', 'type': '[[object]]'}, + } + + def __init__(self, **kwargs): + super(Table, self).__init__(**kwargs) + self.columns = kwargs.get('columns', None) + self.rows = kwargs.get('rows', None) diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/table_py3.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/table_py3.py new file mode 100644 index 000000000000..e14b7dfe5790 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/models/table_py3.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Table(Model): + """Query output in tabular format. + + All required parameters must be populated in order to send to Azure. + + :param columns: Required. Query result column descriptors. + :type columns: list[~azure.mgmt.resourcegraph.models.Column] + :param rows: Required. Query result rows. + :type rows: list[list[object]] + """ + + _validation = { + 'columns': {'required': True}, + 'rows': {'required': True}, + } + + _attribute_map = { + 'columns': {'key': 'columns', 'type': '[Column]'}, + 'rows': {'key': 'rows', 'type': '[[object]]'}, + } + + def __init__(self, *, columns, rows, **kwargs) -> None: + super(Table, self).__init__(**kwargs) + self.columns = columns + self.rows = rows diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/__init__.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/__init__.py new file mode 100644 index 000000000000..6bddce0d5c34 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .operations import Operations + +__all__ = [ + 'Operations', +] diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/operations.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/operations.py new file mode 100644 index 000000000000..d8ee6f0a57a1 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/operations/operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class Operations(object): + """Operations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: API version. Constant value: "2018-09-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-09-01-preview" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Lists all of the available REST API operations. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Operation + :rtype: + ~azure.mgmt.resourcegraph.models.OperationPaged[~azure.mgmt.resourcegraph.models.Operation] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + 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 + + return response + + # Deserialize response + deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.ResourceGraph/operations'} diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/resource_graph_client.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/resource_graph_client.py new file mode 100644 index 000000000000..6f5ff0e93e33 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/resource_graph_client.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +import uuid +from .operations.operations import Operations +from . import models + + +class ResourceGraphClientConfiguration(AzureConfiguration): + """Configuration for ResourceGraphClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(ResourceGraphClientConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-mgmt-resourcegraph/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + + +class ResourceGraphClient(SDKClient): + """Azure Resource Graph API Reference + + :ivar config: Configuration for client. + :vartype config: ResourceGraphClientConfiguration + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.resourcegraph.operations.Operations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + self.config = ResourceGraphClientConfiguration(credentials, base_url) + super(ResourceGraphClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2018-09-01-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) + + def resources( + self, query, custom_headers=None, raw=False, **operation_config): + """Queries the resources managed by Azure Resource Manager for all + subscriptions specified in the request. + + :param query: Request specifying query and its options. + :type query: ~azure.mgmt.resourcegraph.models.QueryRequest + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: QueryResponse or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.resourcegraph.models.QueryResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.resources.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(query, 'QueryRequest') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('QueryResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + resources.metadata = {'url': '/providers/Microsoft.ResourceGraph/resources'} diff --git a/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/version.py b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/version.py new file mode 100644 index 000000000000..e0ec669828cb --- /dev/null +++ b/azure-mgmt-resourcegraph/azure/mgmt/resourcegraph/version.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" + diff --git a/azure-mgmt-resourcegraph/azure_bdist_wheel.py b/azure-mgmt-resourcegraph/azure_bdist_wheel.py new file mode 100644 index 000000000000..8a81d1b61775 --- /dev/null +++ b/azure-mgmt-resourcegraph/azure_bdist_wheel.py @@ -0,0 +1,54 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +from distutils import log as logger +import os.path + +from wheel.bdist_wheel import bdist_wheel +class azure_bdist_wheel(bdist_wheel): + """The purpose of this class is to build wheel a little differently than the sdist, + without requiring to build the wheel from the sdist (i.e. you can build the wheel + directly from source). + """ + + description = "Create an Azure wheel distribution" + + user_options = bdist_wheel.user_options + \ + [('azure-namespace-package=', None, + "Name of the deepest nspkg used")] + + def initialize_options(self): + bdist_wheel.initialize_options(self) + self.azure_namespace_package = None + + def finalize_options(self): + bdist_wheel.finalize_options(self) + if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): + raise ValueError("azure_namespace_package must finish by -nspkg") + + def run(self): + if not self.distribution.install_requires: + self.distribution.install_requires = [] + self.distribution.install_requires.append( + "{}>=2.0.0".format(self.azure_namespace_package)) + bdist_wheel.run(self) + + def write_record(self, bdist_dir, distinfo_dir): + if self.azure_namespace_package: + # Split and remove last part, assuming it's "nspkg" + subparts = self.azure_namespace_package.split('-')[0:-1] + folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] + for azure_sub_package in folder_with_init: + init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') + if os.path.isfile(init_file): + logger.info("manually remove {} while building the wheel".format(init_file)) + os.remove(init_file) + else: + raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) + bdist_wheel.write_record(self, bdist_dir, distinfo_dir) +cmdclass = { + 'bdist_wheel': azure_bdist_wheel, +} diff --git a/azure-mgmt-resourcegraph/sdk_packaging.toml b/azure-mgmt-resourcegraph/sdk_packaging.toml new file mode 100644 index 000000000000..d4d5cee093b4 --- /dev/null +++ b/azure-mgmt-resourcegraph/sdk_packaging.toml @@ -0,0 +1,6 @@ +[packaging] +package_name = "azure-mgmt-resourcegraph" +package_pprint_name = "Resource Graph" +package_doc_id = "" +is_stable = false +is_arm = true diff --git a/azure-mgmt-resourcegraph/setup.cfg b/azure-mgmt-resourcegraph/setup.cfg new file mode 100644 index 000000000000..856f4164982c --- /dev/null +++ b/azure-mgmt-resourcegraph/setup.cfg @@ -0,0 +1,3 @@ +[bdist_wheel] +universal=1 +azure-namespace-package=azure-mgmt-nspkg \ No newline at end of file diff --git a/azure-mgmt-resourcegraph/setup.py b/azure-mgmt-resourcegraph/setup.py new file mode 100644 index 000000000000..74d098629703 --- /dev/null +++ b/azure-mgmt-resourcegraph/setup.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + cmdclass = {} + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-resourcegraph" +PACKAGE_PPRINT_NAME = "Resource Graph" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.rst', encoding='utf-8') as f: + readme = f.read() +with open('HISTORY.rst', encoding='utf-8') as f: + history = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + history, + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=["tests"]), + install_requires=[ + 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', + 'azure-common~=1.1', + ], + cmdclass=cmdclass +) diff --git a/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_basic_query.yaml b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_basic_query.yaml new file mode 100644 index 000000000000..cad4b4aa7722 --- /dev/null +++ b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_basic_query.yaml @@ -0,0 +1,32 @@ +interactions: +- request: + body: 'b''b\''b\\\''b\\\\\\\''{"subscriptions": ["00000000-0000-0000-0000-000000000000"], + "query": "project id, tags, properties | limit 2"}\\\\\\\''\\\''\''''' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['110'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.4 + msrest_azure/0.4.34 azure-mgmt-resourcegraph/0.6.0 Azure-SDK-For-Python] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview + response: + body: {string: '{"totalRecords":2,"count":2,"data":{"columns":[{"name":"id","type":"string"},{"name":"tags","type":"object"},{"name":"properties","type":"object"}],"rows":[["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/zarttest1faaede5-14b9-43b9-8836-3b8df81aa6f2/providers/Microsoft.StreamAnalytics/streamingjobs/zarttest28000000",{},{"provisioningState":"Succeeded","sku":{"name":"Standard"},"eventsLateArrivalMaxDelayInSeconds":5,"createdDate":"2018-07-26T01:17:29.3470000Z","compatibilityLevel":"1.0","outputErrorPolicy":"Stop","dataLocale":"en-US","jobState":"Created","package":null,"jobType":"Cloud","jobId":"00000000-0000-0000-0000-000000000000"}],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttestefd4b1a7-6480-40bb-bac5-f23376ebb04d/providers/Microsoft.Storage/storageAccounts/zarttest9b000000",{},{"provisioningState":"Succeeded","creationTime":"2018-08-04T19:23:48.4690000Z","supportsHttpsTrafficOnly":true,"trustedDirectories":["72f988bf-86f1-41af-91ab-2d7cd011db47"],"primaryEndpoints":{"blob":"https://zarttest9b000000.blob.core.windows.net/","file":"https://zarttest9b000000.file.core.windows.net/","table":"https://zarttest9b000000.table.core.windows.net/","queue":"https://zarttest9b000000.queue.core.windows.net/"},"statusOfPrimary":"available","primaryLocation":"eastus","networkAcls":{"virtualNetworkRules":[],"defaultAction":"Allow","ipRules":[],"bypass":"AzureServices"},"encryption":{"services":{"blob":{"lastEnabledTime":"2018-08-04T19:23:48.5940000Z","enabled":true},"file":{"lastEnabledTime":"2018-08-04T19:23:48.5940000Z","enabled":true}},"keySource":"Microsoft.Storage"}}]]},"facets":[],"resultTruncated":"false"}'} + headers: + cache-control: [no-cache] + content-length: ['1679'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 29 Aug 2018 02:06:58 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-tenant-writes: ['1198'] + status: {code: 200, message: OK} +version: 1 diff --git a/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_facet_query.yaml b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_facet_query.yaml new file mode 100644 index 000000000000..fe886a974d58 --- /dev/null +++ b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_facet_query.yaml @@ -0,0 +1,36 @@ +interactions: +- request: + body: 'b''b\''b\\\''b\\\\\\\''{"subscriptions": ["00000000-0000-0000-0000-000000000000"], + "query": "project id, location | limit 10", "facets": [{"expression": "location", + "options": {"sortOrder": "desc", "$top": 4}}, {"expression": "nonExistingColumn", + "options": {"sortOrder": "desc", "$top": 4}}]}\\\\\\\''\\\''\''''' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['270'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.4 + msrest_azure/0.4.34 azure-mgmt-resourcegraph/0.6.0 Azure-SDK-For-Python] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview + response: + body: {string: '{"totalRecords":10,"count":10,"data":{"columns":[{"name":"id","type":"string"},{"name":"location","type":"string"}],"rows":[["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/zarttest1f000000-14b9-43b9-8836-3b8df81aa6f2/providers/Microsoft.StreamAnalytics/streamingjobs/zarttest28000000","southcentralus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/testsouthcentralus","southcentralus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttest30000000-5d0c-432c-8652-102e3aa336b6/providers/Microsoft.Storage/storageAccounts/zarttest93000000","eastus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.ClassicCompute/domainNames/rp-a","westcentralus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/test1","southcentralus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/k8stest_centralus/providers/Microsoft.Compute/virtualMachines/aks-default-34000000-0/extensions/cse-agent-0","centralus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pere/providers/Microsoft.Network/networkSecurityGroups/shouldFail-nsg","eastus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttestdd000000-bfc5-44f1-b6a9-aabdc7a1e614/providers/Microsoft.Storage/storageAccounts/zarttest43000000","eastus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttest60000000-3713-4c51-9e6b-c96a30f0fbb7/providers/Microsoft.Storage/storageAccounts/zarttestd2000000","eastus"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ManageRG/providers/Microsoft.EventHub/namespaces/resourceuse","eastus"]]},"facets":[{"expression":"location","totalRecords":4,"count":4,"data":{"columns":[{"name":"location","type":"string"},{"name":"count","type":"integer"}],"rows":[["eastus",5],["southcentralus",3],["centralus",1],["westcentralus",1]]},"resultType":"FacetResult"},{"expression":"nonExistingColumn","errors":[{"code":"NoValidColumns","message":"No + valid columns in facet expression."},{"code":"InvalidColumnNames","message":"Invalid + column names: [nonExistingColumn]."}],"resultType":"FacetError"}],"resultTruncated":"false"}'} + headers: + cache-control: [no-cache] + content-length: ['2472'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 29 Aug 2018 02:06:59 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-tenant-writes: ['1197'] + status: {code: 200, message: OK} +version: 1 diff --git a/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_malformed_query.yaml b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_malformed_query.yaml new file mode 100644 index 000000000000..135e7af84eeb --- /dev/null +++ b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_malformed_query.yaml @@ -0,0 +1,31 @@ +interactions: +- request: + body: 'b''b\''b\\\''b\\\\\\\''{"subscriptions": ["00000000-0000-0000-0000-000000000000"], + "query": "project id, location | where where"}\\\\\\\''\\\''\''''' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['106'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.4 + msrest_azure/0.4.34 azure-mgmt-resourcegraph/0.6.0 Azure-SDK-For-Python] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview + response: + body: {string: "{\"error\":{\"code\":\"InvalidQuery\",\"message\":\"Query validation + error\",\"details\":[{\"code\":\"ParserFailure\",\"message\":\"Parser failure\",\"line\":1,\"characterPositionInLine\":34,\"token\":\"\",\"expectedToken\":\"\u0178\"}]}}"} + headers: + cache-control: [no-cache] + content-length: ['232'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 29 Aug 2018 02:47:47 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-tenant-writes: ['1197'] + status: {code: 400, message: Bad Request} +version: 1 diff --git a/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_query_options.yaml b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_query_options.yaml new file mode 100644 index 000000000000..96d998889cc4 --- /dev/null +++ b/azure-mgmt-resourcegraph/tests/recordings/test_mgmt_resourcegraph.test_resources_query_options.yaml @@ -0,0 +1,33 @@ +interactions: +- request: + body: 'b''b\''b\\\''b\\\\\\\''{"subscriptions": ["00000000-0000-0000-0000-000000000000"], + "query": "project id", "options": {"$skipToken": "82aw3vQlArEastJ24LABY8oPgQLesIyAyzYs2g6/aOOOmJHSYFj39fODurJV5e2tTFFebWcfxn7n5edicA8u6HgSJe1GCEk5HjxwLkeJiye2LVZDC7TaValkJbsk9JqY4yv5c7iRiLqgO34RbHEeVfLJpa56u4RZu0K+GpQvnBRPyAhy3KbwhZWpU5Nnqnud2whGb5WKdlL8xF7wnQaUnUN2lns8WwqwM4rc0VK4BbQt/WfWWcYJivSAyB3m4Z5g73df1KiU4C+K8auvUMpLPYVxxnKC/YZz42YslVAWXXUmuGOaM2SfLHRO6o4O9DgXlUgYjeFWqIbAkmMiVEqU", + "$top": 4, "$skip": 8}}\\\\\\\''\\\''\''''' + headers: + Accept: [application/json] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + Content-Length: ['416'] + Content-Type: [application/json; charset=utf-8] + User-Agent: [python/3.6.3 (Windows-10-10.0.17134-SP0) requests/2.19.1 msrest/0.5.4 + msrest_azure/0.4.34 azure-mgmt-resourcegraph/0.6.0 Azure-SDK-For-Python] + accept-language: [en-US] + method: POST + uri: https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview + response: + body: {string: '{"totalRecords":743,"count":4,"data":{"columns":[{"name":"id","type":"string"}],"rows":[["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.ClassicCompute/domainNames/admin-a"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.ClassicCompute/domainNames/admin-b"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.Network/trafficmanagerprofiles/admin"],["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/RP/providers/Microsoft.ClassicCompute/domainNames/rp-a"]]},"facets":[],"resultTruncated":"false","$skipToken":"ceXHDV/5yajn1stYtSCyQ32ULLF0jGv9oazG14qvdgwdAQNDUPHjt6MIlJZ2Y/K8z7fb+qo9wguegf8QYW0c7rqwtXUghJvKkPBENcn1O17nQxtjXeq6s8sD64D8t5P9NIHntl70D95yuVUjHF6/dsvVK33wKyvORwPTCbZrSj+pfz2yd5spa93izzOu06PcyFvcvCJAzZ5scImnVDqS700hR63izVwyETJtQluoqSPYkhxAOVk/+ThWlN0DKy9OfUE34M9PZSQz2QTWXKpUK1+okRfH/B2RVdXro60ZnNMrdPtglA5w7oEs5Ivq20IE4RtPfg97UEbkfyMP9huC="}'} + headers: + cache-control: [no-cache] + content-length: ['1098'] + content-type: [application/json; charset=utf-8] + date: ['Wed, 29 Aug 2018 02:07:01 GMT'] + expires: ['-1'] + pragma: [no-cache] + server: [Microsoft-HTTPAPI/2.0] + strict-transport-security: [max-age=31536000; includeSubDomains] + transfer-encoding: [chunked] + vary: [Accept-Encoding] + x-content-type-options: [nosniff] + x-ms-ratelimit-remaining-tenant-writes: ['1199'] + status: {code: 200, message: OK} +version: 1 diff --git a/azure-mgmt-resourcegraph/tests/test_mgmt_resourcegraph.py b/azure-mgmt-resourcegraph/tests/test_mgmt_resourcegraph.py new file mode 100644 index 000000000000..d62f3d00f7b6 --- /dev/null +++ b/azure-mgmt-resourcegraph/tests/test_mgmt_resourcegraph.py @@ -0,0 +1,180 @@ +# coding: utf-8 + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- +import unittest + +from azure.mgmt.resourcegraph import ResourceGraphClient +from azure.mgmt.resourcegraph.models import * +from devtools_testutils import AzureMgmtTestCase +import six + + +class MgmtResourceGraphTest(AzureMgmtTestCase): + + def setUp(self): + super(MgmtResourceGraphTest, self).setUp() + self.resourcegraph_client = self.create_basic_client( + ResourceGraphClient + ) + + def test_resources_basic_query(self): + query = QueryRequest( + query='project id, tags, properties | limit 2', + subscriptions=[self.settings.SUBSCRIPTION_ID] + ) + + query_response = self.resourcegraph_client.resources(query) + + # Top-level response fields + self.assertEqual(query_response.count, 2) + self.assertEqual(query_response.total_records, 2) + self.assertIsNone(query_response.skip_token) + self.assertEqual(query_response.result_truncated, ResultTruncated.false) + self.assertIsNotNone(query_response.data) + self.assertIsNotNone(query_response.facets) + self.assertEqual(len(query_response.facets), 0) + + # Data columns + self.assertIsNotNone(query_response.data.columns) + self.assertEqual(len(query_response.data.columns), 3) + self.assertIsNotNone(query_response.data.columns[0].name) + self.assertIsNotNone(query_response.data.columns[1].name) + self.assertIsNotNone(query_response.data.columns[2].name) + self.assertEqual(query_response.data.columns[0].type, ColumnDataType.string) + self.assertEqual(query_response.data.columns[1].type, ColumnDataType.object_enum) + self.assertEqual(query_response.data.columns[2].type, ColumnDataType.object_enum) + + # Data rows + self.assertIsNotNone(query_response.data.rows) + self.assertEqual(len(query_response.data.rows), 2) + self.assertEqual(len(query_response.data.rows[0]), 3) + self.assertIsInstance(query_response.data.rows[0][0], six.string_types) + self.assertIsInstance(query_response.data.rows[0][1], dict) + self.assertIsInstance(query_response.data.rows[0][2], dict) + + def test_resources_query_options(self): + query = QueryRequest( + query='project id', + subscriptions=[self.settings.SUBSCRIPTION_ID], + options=QueryRequestOptions( + skip_token='82aw3vQlArEastJ24LABY8oPgQLesIyAyzYs2g6/aOOOmJHSYFj39fODurJV5e2tTFFebWcfxn7n5edicA8u6HgSJe1GCEk5HjxwLkeJiye2LVZDC7TaValkJbsk9JqY4yv5c7iRiLqgO34RbHEeVfLJpa56u4RZu0K+GpQvnBRPyAhy3KbwhZWpU5Nnqnud2whGb5WKdlL8xF7wnQaUnUN2lns8WwqwM4rc0VK4BbQt/WfWWcYJivSAyB3m4Z5g73df1KiU4C+K8auvUMpLPYVxxnKC/YZz42YslVAWXXUmuGOaM2SfLHRO6o4O9DgXlUgYjeFWqIbAkmMiVEqU', + top=4, + skip=8 + ) + ) + + query_response = self.resourcegraph_client.resources(query) + + # Top-level response fields + self.assertEqual(query_response.count, 4) + self.assertEqual(query_response.total_records, 743) + self.assertIsNotNone(query_response.skip_token) + self.assertEqual(query_response.result_truncated, ResultTruncated.false) + self.assertIsNotNone(query_response.data) + self.assertIsNotNone(query_response.facets) + self.assertEqual(len(query_response.facets), 0) + + # Data columns + self.assertIsNotNone(query_response.data.columns) + self.assertEqual(len(query_response.data.columns), 1) + self.assertIsNotNone(query_response.data.columns[0].name) + self.assertEqual(query_response.data.columns[0].type, ColumnDataType.string) + + # Data rows + self.assertIsNotNone(query_response.data.rows) + self.assertEqual(len(query_response.data.rows), 4) + self.assertEqual(len(query_response.data.rows[0]), 1) + self.assertIsInstance(query_response.data.rows[0][0], six.string_types) + + def test_resources_facet_query(self): + facet_expression0 = 'location' + facet_expression1 = 'nonExistingColumn' + + query = QueryRequest( + query='project id, location | limit 10', + subscriptions=[self.settings.SUBSCRIPTION_ID], + facets=[ + FacetRequest( + expression=facet_expression0, + options=FacetRequestOptions( + sort_order='desc', + top=4 + ) + ), + FacetRequest( + expression=facet_expression1, + options=FacetRequestOptions( + sort_order='desc', + top=4 + ) + ) + ] + ) + + query_response = self.resourcegraph_client.resources(query) + + # Top-level response fields + self.assertEqual(query_response.count, 10) + self.assertEqual(query_response.total_records, 10) + self.assertIsNone(query_response.skip_token) + self.assertEqual(query_response.result_truncated, ResultTruncated.false) + self.assertIsNotNone(query_response.data) + self.assertIsNotNone(query_response.facets) + self.assertEqual(len(query_response.facets), 2) + + # Successful facet fields + self.assertIsInstance(query_response.facets[0], FacetResult) + self.assertEqual(query_response.facets[0].expression, facet_expression0) + self.assertEqual(query_response.facets[0].total_records, 4) + self.assertEqual(query_response.facets[0].count, 4) + + # Successful facet columns + self.assertIsNotNone(query_response.facets[0].data.columns) + self.assertEqual(len(query_response.facets[0].data.columns), 2) + self.assertIsNotNone(query_response.facets[0].data.columns[0].name) + self.assertIsNotNone(query_response.facets[0].data.columns[1].name) + self.assertEqual(query_response.facets[0].data.columns[0].type, ColumnDataType.string) + self.assertEqual(query_response.facets[0].data.columns[1].type, ColumnDataType.integer) + + # Successful facet rows + self.assertIsNotNone(query_response.facets[0].data.rows) + self.assertEqual(len(query_response.facets[0].data.rows), 4) + self.assertEqual(len(query_response.facets[0].data.rows[0]), 2) + self.assertIsInstance(query_response.facets[0].data.rows[0][0], six.string_types) + self.assertIsInstance(query_response.facets[0].data.rows[0][1], six.integer_types) + + # Failed facet + self.assertIsInstance(query_response.facets[1], FacetError) + self.assertEqual(query_response.facets[1].expression, facet_expression1) + self.assertIsNotNone(query_response.facets[1].errors) + self.assertGreater(len(query_response.facets[1].errors), 0) + self.assertIsNotNone(query_response.facets[1].errors[0].code) + self.assertIsNotNone(query_response.facets[1].errors[0].message) + + def test_resources_malformed_query(self): + query = QueryRequest( + query='project id, location | where where', + subscriptions=[self.settings.SUBSCRIPTION_ID] + ) + + with self.assertRaises(ErrorResponseException) as cm: + self.resourcegraph_client.resources(query) + + error = cm.exception.error.error + self.assertIsNotNone(error.code) + self.assertIsNotNone(error.message) + self.assertIsNotNone(error.details) + self.assertGreater(len(error.details), 0) + self.assertIsNotNone(error.details[0].code) + self.assertIsNotNone(error.details[0].message) + self.assertIsNotNone(error.details[0].additional_properties) + self.assertEqual(len(error.details[0].additional_properties), 4) + + +#------------------------------------------------------------------------------ +if __name__ == '__main__': + unittest.main()