diff --git a/pyproject.toml b/pyproject.toml index 02c9bfa..59b1fba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "microsoft_reports" -version = "1.5.3" +version = "1.5.4" description = "Microsoft Reports" authors = ["Cloublue"] license = "Apache Software License 2.0" diff --git a/reports.json b/reports.json index 2455787..b353653 100644 --- a/reports.json +++ b/reports.json @@ -163,6 +163,31 @@ "description": "Provide the time period to create the report", "required": true }, + { + "id": "status", + "type": "checkbox", + "name": "Subscription status", + "required": false, + "description": "Select the status of subscriptions to include in report", + "choices": [ + { + "value": "active", + "label": "Active" + }, + { + "value": "suspended", + "label": "Suspended" + }, + { + "value": "terminated", + "label": "Terminated" + }, + { + "value": "terminating", + "label": "Terminating" + } + ] + }, { "id": "connection_type", "type": "checkbox", diff --git a/reports/audit_tool/README.md b/reports/audit_tool/README.md index 46b4b6a..4b88996 100644 --- a/reports/audit_tool/README.md +++ b/reports/audit_tool/README.md @@ -9,5 +9,6 @@ Please take into account the following: You can configure the report according to the following: - List of products to be selected (Only one can be selected, else the report will fail) - Request creation date range (The range must be less than 2 months, anything else will fail the report) +- List of statuses of subscriptions (active, suspended, terminated, terminating. default all) - List of transaction types (test, production. Only one can be selected, else the report will fail) - List of marketplaces (Only one can be selected, else the report will fail) \ No newline at end of file diff --git a/reports/audit_tool/entrypoint.py b/reports/audit_tool/entrypoint.py index 950975a..a88c14c 100644 --- a/reports/audit_tool/entrypoint.py +++ b/reports/audit_tool/entrypoint.py @@ -156,7 +156,12 @@ def obtain_url_for_service(client): def _get_request_list(client, parameters): query = R() - query &= R().status.eq('active') + all_statuses = ['active', 'suspended', 'terminated', 'terminating'] + + if parameters.get('status') and parameters['status']['all'] is False and parameters['status']['choices']: + query &= R().status.oneof(parameters['status']['choices']) + else: + query &= R().status.oneof(all_statuses) if parameters.get('product') and parameters['product']['all'] is False: query &= R().product.id.oneof(parameters['product']['choices']) diff --git a/tests/test_microsoft_reports.py b/tests/test_microsoft_reports.py index a243741..841f499 100644 --- a/tests/test_microsoft_reports.py +++ b/tests/test_microsoft_reports.py @@ -304,7 +304,7 @@ def mock_get_customer_susbcriptions_from_service(*args, **kwargs): value=installation_list), response_factory(count=3), response_factory( - query='and(eq(status,active),' + query='and(in(status,(active,suspended,terminated,terminating)),' 'in(product.id,(PRD-183-233-565)),' 'eq(connection.type,test),' 'eq(marketplace.id,MP-123),'