From 22a246d7ae66b29d7afacefba23dc47234e60b02 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Mon, 16 Mar 2020 12:09:26 +0100 Subject: [PATCH 01/20] LITE-11458 Add TAR to SDK --- .gitignore | 2 ++ connect/__init__.py | 2 +- connect/config.py | 7 +++- connect/exceptions.py | 2 +- connect/logger/__init__.py | 2 +- connect/logger/logger.py | 2 +- connect/models/__init__.py | 3 +- connect/models/activation.py | 2 +- .../models/activation_template_response.py | 2 +- connect/models/activation_tile_response.py | 2 +- connect/models/agreement.py | 2 +- connect/models/agreement_stats.py | 2 +- connect/models/asset.py | 2 +- connect/models/base.py | 2 +- connect/models/company.py | 2 +- connect/models/configuration.py | 2 +- connect/models/connection.py | 2 +- connect/models/constraints.py | 2 +- connect/models/contact.py | 2 +- connect/models/contact_info.py | 2 +- connect/models/contract.py | 2 +- connect/models/conversation.py | 2 +- connect/models/conversation_message.py | 2 +- connect/models/country.py | 2 +- connect/models/customer_ui_settings.py | 2 +- connect/models/document.py | 2 +- connect/models/download_link.py | 2 +- connect/models/event.py | 2 +- connect/models/events.py | 2 +- connect/models/exception.py | 2 +- connect/models/ext_id_hub.py | 2 +- connect/models/fulfillment.py | 2 +- connect/models/hub.py | 2 +- connect/models/hub_instance.py | 2 +- connect/models/hub_stats.py | 2 +- connect/models/item.py | 2 +- connect/models/marketplace.py | 2 +- connect/models/param.py | 2 +- connect/models/phone_number.py | 2 +- connect/models/product.py | 2 +- connect/models/product_category.py | 2 +- connect/models/product_configuration.py | 2 +- .../models/product_configuration_parameter.py | 2 +- connect/models/product_family.py | 2 +- connect/models/product_stats.py | 2 +- connect/models/product_stats_info.py | 2 +- connect/models/renewal.py | 2 +- connect/models/schemas.py | 35 ++++++++++++++++--- connect/models/server_error_response.py | 2 +- connect/models/template.py | 2 +- connect/models/tier_account.py | 27 ++++++-------- connect/models/tier_accounts.py | 2 +- connect/models/tier_config.py | 2 +- connect/models/tier_config_request.py | 2 +- connect/models/usage_file.py | 2 +- connect/models/usage_listing.py | 2 +- connect/models/usage_record.py | 2 +- connect/models/usage_records.py | 2 +- connect/models/user.py | 2 +- connect/models/value_choice.py | 2 +- connect/resources/__init__.py | 5 ++- connect/resources/automation_engine.py | 6 +++- connect/resources/base.py | 27 +++++++++++--- connect/resources/directory.py | 10 +++++- connect/resources/fulfillment_automation.py | 4 +-- connect/resources/template.py | 2 +- connect/resources/tier_config_automation.py | 2 +- connect/resources/usage_automation.py | 22 ++++++++---- connect/resources/usage_file_automation.py | 2 +- connect/rql/__init__.py | 2 +- connect/rql/query.py | 2 +- examples/config.json | 6 ++-- examples/fulfillment.py | 2 +- examples/tier_config.py | 2 +- examples/usage.py | 4 +-- examples/usage_file.py | 2 +- setup.py | 2 +- tests/__init__.py | 2 +- tests/common.py | 2 +- tests/test_config.py | 2 +- tests/test_conversation.py | 2 +- tests/test_deprecated.py | 2 +- tests/test_directory.py | 2 +- tests/test_models.py | 2 +- tests/test_query.py | 2 +- tests/test_server_error_response.py | 2 +- tests/test_tier_config.py | 2 +- tests/test_usage.py | 2 +- tests/test_usage_file.py | 2 +- 89 files changed, 191 insertions(+), 119 deletions(-) diff --git a/.gitignore b/.gitignore index 0518b62..564a4d3 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,5 @@ venv.bak/ # idea .vscode/ .idea/ +.devcontainer/ +.notes.txt \ No newline at end of file diff --git a/connect/__init__.py b/connect/__init__.py index 85282ad..fee4623 100644 --- a/connect/__init__.py +++ b/connect/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from abc import ABCMeta diff --git a/connect/config.py b/connect/config.py index f403754..b716661 100644 --- a/connect/config.py +++ b/connect/config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import json import os @@ -99,3 +99,8 @@ def products(self): :rtype: list[str] """ return self._products + + def __str__(self): + return ''.format( + self.api_url + ) diff --git a/connect/exceptions.py b/connect/exceptions.py index 45bb4fd..eb08dcb 100644 --- a/connect/exceptions.py +++ b/connect/exceptions.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/logger/__init__.py b/connect/logger/__init__.py index fff901a..c9bbd35 100644 --- a/connect/logger/__init__.py +++ b/connect/logger/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .logger import function_log, logger diff --git a/connect/logger/logger.py b/connect/logger/logger.py index c68e9eb..af91ce5 100644 --- a/connect/logger/logger.py +++ b/connect/logger/logger.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from functools import wraps import json diff --git a/connect/models/__init__.py b/connect/models/__init__.py index 78dc957..c80d57a 100644 --- a/connect/models/__init__.py +++ b/connect/models/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .activation import Activation from .activation_template_response import ActivationTemplateResponse @@ -46,6 +46,7 @@ from .template import Template from .tier_account import TierAccount from .tier_accounts import TierAccounts +from .tier_account_request import TierAccountRequest from .tier_config import TierConfig from .tier_config_request import TierConfigRequest from .usage_file import UsageFile diff --git a/connect/models/activation.py b/connect/models/activation.py index 0e73633..7addc80 100644 --- a/connect/models/activation.py +++ b/connect/models/activation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional diff --git a/connect/models/activation_template_response.py b/connect/models/activation_template_response.py index 310b92a..e3fff2a 100644 --- a/connect/models/activation_template_response.py +++ b/connect/models/activation_template_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. class ActivationTemplateResponse(object): diff --git a/connect/models/activation_tile_response.py b/connect/models/activation_tile_response.py index cec94c9..9789ecd 100644 --- a/connect/models/activation_tile_response.py +++ b/connect/models/activation_tile_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import json diff --git a/connect/models/agreement.py b/connect/models/agreement.py index 0126d41..12d12a0 100644 --- a/connect/models/agreement.py +++ b/connect/models/agreement.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional, List diff --git a/connect/models/agreement_stats.py b/connect/models/agreement_stats.py index ec86fc3..e3b4022 100644 --- a/connect/models/agreement_stats.py +++ b/connect/models/agreement_stats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/asset.py b/connect/models/asset.py index 06ea5c1..c7a577e 100644 --- a/connect/models/asset.py +++ b/connect/models/asset.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List, Optional diff --git a/connect/models/base.py b/connect/models/base.py index 696c1c2..0ceb7cf 100644 --- a/connect/models/base.py +++ b/connect/models/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import json diff --git a/connect/models/company.py b/connect/models/company.py index a09f563..ae5d03f 100644 --- a/connect/models/company.py +++ b/connect/models/company.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import CompanySchema diff --git a/connect/models/configuration.py b/connect/models/configuration.py index 158fe7f..6f92eef 100644 --- a/connect/models/configuration.py +++ b/connect/models/configuration.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/connection.py b/connect/models/connection.py index 998264f..e03cf9c 100644 --- a/connect/models/connection.py +++ b/connect/models/connection.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/constraints.py b/connect/models/constraints.py index 69fa8f1..81ebb37 100644 --- a/connect/models/constraints.py +++ b/connect/models/constraints.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/contact.py b/connect/models/contact.py index b47d5a7..92b1e82 100644 --- a/connect/models/contact.py +++ b/connect/models/contact.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/contact_info.py b/connect/models/contact_info.py index c91eb49..f489ab2 100644 --- a/connect/models/contact_info.py +++ b/connect/models/contact_info.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/contract.py b/connect/models/contract.py index 078690c..bf5362d 100644 --- a/connect/models/contract.py +++ b/connect/models/contract.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional diff --git a/connect/models/conversation.py b/connect/models/conversation.py index 0322478..09c3923 100644 --- a/connect/models/conversation.py +++ b/connect/models/conversation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/conversation_message.py b/connect/models/conversation_message.py index 12e2f5a..721b44b 100644 --- a/connect/models/conversation_message.py +++ b/connect/models/conversation_message.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/country.py b/connect/models/country.py index f26e649..3cbbea3 100644 --- a/connect/models/country.py +++ b/connect/models/country.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import CountrySchema diff --git a/connect/models/customer_ui_settings.py b/connect/models/customer_ui_settings.py index cb409e8..66b0001 100644 --- a/connect/models/customer_ui_settings.py +++ b/connect/models/customer_ui_settings.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/document.py b/connect/models/document.py index 6feb09c..99de38b 100644 --- a/connect/models/document.py +++ b/connect/models/document.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import DocumentSchema diff --git a/connect/models/download_link.py b/connect/models/download_link.py index cccbd6d..834b2d4 100644 --- a/connect/models/download_link.py +++ b/connect/models/download_link.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import DownloadLinkSchema diff --git a/connect/models/event.py b/connect/models/event.py index 463cd59..93e5f0c 100644 --- a/connect/models/event.py +++ b/connect/models/event.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional diff --git a/connect/models/events.py b/connect/models/events.py index f340a36..80f6036 100644 --- a/connect/models/events.py +++ b/connect/models/events.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .event import Event from .schemas import EventsSchema diff --git a/connect/models/exception.py b/connect/models/exception.py index da3509e..5e583a7 100644 --- a/connect/models/exception.py +++ b/connect/models/exception.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. # This file provides backwards compatibility with the previous location # and names of exception classes diff --git a/connect/models/ext_id_hub.py b/connect/models/ext_id_hub.py index 4799ada..791b893 100644 --- a/connect/models/ext_id_hub.py +++ b/connect/models/ext_id_hub.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .hub import Hub diff --git a/connect/models/fulfillment.py b/connect/models/fulfillment.py index d35aa47..c655ac2 100644 --- a/connect/models/fulfillment.py +++ b/connect/models/fulfillment.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime from typing import Union diff --git a/connect/models/hub.py b/connect/models/hub.py index a1e5031..82af7ae 100644 --- a/connect/models/hub.py +++ b/connect/models/hub.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/hub_instance.py b/connect/models/hub_instance.py index 0984491..ee90e01 100644 --- a/connect/models/hub_instance.py +++ b/connect/models/hub_instance.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import HubInstanceSchema diff --git a/connect/models/hub_stats.py b/connect/models/hub_stats.py index 17e9d10..fdfd7af 100644 --- a/connect/models/hub_stats.py +++ b/connect/models/hub_stats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import HubStatsSchema diff --git a/connect/models/item.py b/connect/models/item.py index 8a42855..fee4cc3 100644 --- a/connect/models/item.py +++ b/connect/models/item.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List, Optional, Union diff --git a/connect/models/marketplace.py b/connect/models/marketplace.py index 7d919c3..81d8b08 100644 --- a/connect/models/marketplace.py +++ b/connect/models/marketplace.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/param.py b/connect/models/param.py index 5fd7881..180a640 100644 --- a/connect/models/param.py +++ b/connect/models/param.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List, Optional diff --git a/connect/models/phone_number.py b/connect/models/phone_number.py index 990d917..0469c28 100644 --- a/connect/models/phone_number.py +++ b/connect/models/phone_number.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/product.py b/connect/models/product.py index 5fb7a17..94e468a 100644 --- a/connect/models/product.py +++ b/connect/models/product.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from copy import copy import datetime diff --git a/connect/models/product_category.py b/connect/models/product_category.py index ac4e5b4..b1f5e94 100644 --- a/connect/models/product_category.py +++ b/connect/models/product_category.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List, Optional diff --git a/connect/models/product_configuration.py b/connect/models/product_configuration.py index b667496..9123d32 100644 --- a/connect/models/product_configuration.py +++ b/connect/models/product_configuration.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ProductConfigurationSchema diff --git a/connect/models/product_configuration_parameter.py b/connect/models/product_configuration_parameter.py index 27c6cab..f53a6ea 100644 --- a/connect/models/product_configuration_parameter.py +++ b/connect/models/product_configuration_parameter.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .constraints import Constraints diff --git a/connect/models/product_family.py b/connect/models/product_family.py index 89466d8..d1ff563 100644 --- a/connect/models/product_family.py +++ b/connect/models/product_family.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ProductFamilySchema diff --git a/connect/models/product_stats.py b/connect/models/product_stats.py index 4b6d65e..99cb396 100644 --- a/connect/models/product_stats.py +++ b/connect/models/product_stats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .product_stats_info import ProductStatsInfo diff --git a/connect/models/product_stats_info.py b/connect/models/product_stats_info.py index 8db1d53..7e6c572 100644 --- a/connect/models/product_stats_info.py +++ b/connect/models/product_stats_info.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ProductStatsInfoSchema diff --git a/connect/models/renewal.py b/connect/models/renewal.py index 5be94c7..f65d4d1 100644 --- a/connect/models/renewal.py +++ b/connect/models/renewal.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/schemas.py b/connect/models/schemas.py index 3075a90..b572684 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from marshmallow import Schema, fields, post_load import six @@ -206,7 +206,7 @@ def make_object(self, data): class ExternalIdField(fields.Field): - def _deserialize(self, value, attr, obj, **kwargs): + def _deserialize(self, value, attr=None, data=None): if isinstance(value, six.string_types): return value elif isinstance(value, int): @@ -238,7 +238,7 @@ def make_object(self, data): class QuantityField(fields.Field): - def _deserialize(self, value, attr, obj, **kwargs): + def _deserialize(self, value, attr=None, data=None): if isinstance(value, six.string_types): if value == 'unlimited': return -1 @@ -508,6 +508,13 @@ class TierAccountSchema(BaseSchema): contact_info = fields.Nested(ContactInfoSchema) external_id = ExternalIdField() external_uid = fields.Str() + environment = fields.Str() + marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name', 'icon')) + hub = fields.Nested(HubSchema, only=('id', 'name')) + version = fields.Int() + + events = fields.Nested(EventsSchema) + scopes = fields.List(fields.Str()) @post_load def make_object(self, data): @@ -526,6 +533,26 @@ def make_object(self, data): return TierAccounts(**data) +class TierAccountRequestSchema(BaseSchema): + type = fields.Str() + status = fields.Str() + account = fields.Nested(TierAccountSchema) + provider = fields.Nested(CompanySchema, only=('id', 'name')) + vendor = fields.Nested(CompanySchema, only=('id', 'name')) + product = fields.Nested(ProductSchema, only=('id', 'icon', 'name', 'status')) + reason = fields.Str() + contact_info = fields.Nested(ContactInfoSchema) + external_id = ExternalIdField() + external_uid = fields.Str() + events = fields.Nested(EventsSchema) + + @post_load + def make_object(self, data): + from connect.models import TierAccountRequest + return TierAccountRequest(**data) + + + class ConnectionSchema(BaseSchema): type = fields.Str() provider = fields.Nested(CompanySchema, only=('id', 'name')) @@ -565,7 +592,7 @@ def make_object(self, data): class AssigneeField(fields.Field): - def _deserialize(self, value, attr, obj, **kwargs): + def _deserialize(self, value, attr=None, data=None): from connect.models.user import User if isinstance(value, six.string_types): return value diff --git a/connect/models/server_error_response.py b/connect/models/server_error_response.py index 7c0d616..4867c4d 100644 --- a/connect/models/server_error_response.py +++ b/connect/models/server_error_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/template.py b/connect/models/template.py index ed36f3c..47edf9d 100644 --- a/connect/models/template.py +++ b/connect/models/template.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import TemplateSchema diff --git a/connect/models/tier_account.py b/connect/models/tier_account.py index 31272c0..083a783 100644 --- a/connect/models/tier_account.py +++ b/connect/models/tier_account.py @@ -1,28 +1,23 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. - -from typing import Optional +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel -from .contact_info import ContactInfo from .schemas import TierAccountSchema - class TierAccount(BaseModel): """ Tier account. """ _schema = TierAccountSchema() - name = None # type: str - """ (str) Tier name. """ - - contact_info = None # type: ContactInfo - """ (:py:class:`.ContactInfo`) Tier Contact Object. """ - - external_id = None # type: Optional[str] - """ (str|None) Only in case of filtering by this field. """ - - external_uid = None # type: Optional[str] - """ (str|None) Only in case of filtering by this field. """ + name = None + contact_info = None + external_id = None + external_uid = None + environment = None + marketplace = None + hub = None + version = None + events = None + scopes = None diff --git a/connect/models/tier_accounts.py b/connect/models/tier_accounts.py index 5a8486a..a09acf0 100644 --- a/connect/models/tier_accounts.py +++ b/connect/models/tier_accounts.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/tier_config.py b/connect/models/tier_config.py index 7491199..b2e1e15 100644 --- a/connect/models/tier_config.py +++ b/connect/models/tier_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional, List diff --git a/connect/models/tier_config_request.py b/connect/models/tier_config_request.py index 940938a..973f28e 100644 --- a/connect/models/tier_config_request.py +++ b/connect/models/tier_config_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Optional, List diff --git a/connect/models/usage_file.py b/connect/models/usage_file.py index 69952d5..e4e0e5e 100644 --- a/connect/models/usage_file.py +++ b/connect/models/usage_file.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .company import Company diff --git a/connect/models/usage_listing.py b/connect/models/usage_listing.py index df168f2..ad7b945 100644 --- a/connect/models/usage_listing.py +++ b/connect/models/usage_listing.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .company import Company diff --git a/connect/models/usage_record.py b/connect/models/usage_record.py index 2bfc35b..40ea644 100644 --- a/connect/models/usage_record.py +++ b/connect/models/usage_record.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import UsageRecordSchema diff --git a/connect/models/usage_records.py b/connect/models/usage_records.py index fecd7fe..ea37443 100644 --- a/connect/models/usage_records.py +++ b/connect/models/usage_records.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import UsageRecordsSchema diff --git a/connect/models/user.py b/connect/models/user.py index ba68051..08a08fa 100644 --- a/connect/models/user.py +++ b/connect/models/user.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import UserSchema diff --git a/connect/models/value_choice.py b/connect/models/value_choice.py index d6ac899..3827dd3 100644 --- a/connect/models/value_choice.py +++ b/connect/models/value_choice.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ValueChoiceSchema diff --git a/connect/resources/__init__.py b/connect/resources/__init__.py index c618b05..febd68c 100644 --- a/connect/resources/__init__.py +++ b/connect/resources/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .directory import Directory from .fulfillment_automation import FulfillmentAutomation @@ -9,6 +9,7 @@ from .tier_config_automation import TierConfigAutomation from .usage_automation import UsageAutomation from .usage_file_automation import UsageFileAutomation +from .tier_account_request_automation import TierAccountRequestAutomation __all__ = [ @@ -18,4 +19,6 @@ 'TierConfigAutomation', 'UsageAutomation', 'UsageFileAutomation', + 'TierAccountRequestAutomation' + # 'DirectoryExample', ] diff --git a/connect/resources/automation_engine.py b/connect/resources/automation_engine.py index 922b597..5448b2f 100644 --- a/connect/resources/automation_engine.py +++ b/connect/resources/automation_engine.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import copy import logging @@ -22,8 +22,12 @@ def filters(self, status='pending', **kwargs): # type: (str, Dict[str, Any]) -> Dict[str, Any] return super(AutomationEngine, self).filters(status=status, **kwargs) + @function_log(custom_logger=logger) def process(self, filters=None): + self.logger.info('We are here!!!!') + ''' # type: (Dict[str, Any]) -> None + ''' for request in self.list(filters): self.dispatch(request) diff --git a/connect/resources/base.py b/connect/resources/base.py index 0377118..94db578 100644 --- a/connect/resources/base.py +++ b/connect/resources/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import functools import logging @@ -51,7 +51,9 @@ def headers(self): def get_url(self, path=''): # type: (str) -> str - return self.urljoin(self.config.api_url, self.base_path, path) + url = self.urljoin(self.config.api_url, self.base_path, path) + print(url) + return url @staticmethod def urljoin(*args): @@ -118,7 +120,7 @@ def _check_and_pack_response(response): class BaseResource(object): - """ Base class of all resources. + """ Base class of ∫all resources. :param Config config: Config object or ``None`` to use environment config (default). """ @@ -147,6 +149,8 @@ def get(self, pk): objects = self.model_class.deserialize(response) if isinstance(objects, list) and len(objects) > 0: return objects[0] + return objects + def filters(self, **kwargs): # type: (Dict[str, Any]) -> Dict[str, Any] @@ -157,9 +161,24 @@ def filters(self, **kwargs): filters[key] = val return filters - def list(self, filters=None): + def search(self, filters=None): # type: (Dict[str, Any]) -> List[Any] filters = filters or self.filters() self.logger.info('Get list request with filters - {}'.format(filters)) response, _ = self._api.get(params=filters) return self.model_class.deserialize(response) + + + def create(self, obj): + response, _ = self._api.post(json=obj) + objects = self.model_class.deserialize(response) + return objects + + def update(self, pk, obj): + pass + + def delete(self, pk): + pass + + def list(self, filters=None): + return self.search(filters) \ No newline at end of file diff --git a/connect/resources/directory.py b/connect/resources/directory.py index f4ad552..7dba82e 100644 --- a/connect/resources/directory.py +++ b/connect/resources/directory.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from copy import copy @@ -10,6 +10,7 @@ from connect.models.product import Product from connect.models.tier_config import TierConfig from connect.resources.base import ApiClient +from connect.resources.tier_account import TierAccountResource from connect.rql import Query @@ -23,6 +24,7 @@ class Directory(object): def __init__(self, config=None): self._config = config or Config.get_instance() + self._tier_accounts = TierAccountResource(config=self._config) def list_assets(self, filters=None): """ List the assets. @@ -98,3 +100,9 @@ def _get_filters_query(self, filters, add_product): if add_product and self._config.products: query.in_('product.id', self._config.products) return query + + def search_tier_accounts(self, filters): + return self._tier_accounts.search(filters) + + def get_tier_account(self, pk): + return self._tier_accounts.get(pk) \ No newline at end of file diff --git a/connect/resources/fulfillment_automation.py b/connect/resources/fulfillment_automation.py index 3533e19..38ca7aa 100644 --- a/connect/resources/fulfillment_automation.py +++ b/connect/resources/fulfillment_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from abc import ABCMeta import logging @@ -17,7 +17,7 @@ from connect.models.fulfillment import Fulfillment from connect.models.tier_config_request import TierConfigRequest from connect.models.conversation import Conversation -from .automation_engine import AutomationEngine +from connect.resources.automation_engine import AutomationEngine class FulfillmentAutomation(AutomationEngine): diff --git a/connect/resources/template.py b/connect/resources/template.py index a514c77..acfedd9 100644 --- a/connect/resources/template.py +++ b/connect/resources/template.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import List, Any, Dict diff --git a/connect/resources/tier_config_automation.py b/connect/resources/tier_config_automation.py index d1869e5..c277c05 100644 --- a/connect/resources/tier_config_automation.py +++ b/connect/resources/tier_config_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from abc import ABCMeta import logging diff --git a/connect/resources/usage_automation.py b/connect/resources/usage_automation.py index 91e7083..cebd10d 100644 --- a/connect/resources/usage_automation.py +++ b/connect/resources/usage_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import json import logging @@ -16,7 +16,7 @@ from connect.models.usage_listing import UsageListing from connect.models.usage_file import UsageFile from connect.models.usage_record import UsageRecord -from .automation_engine import AutomationEngine +from connect.resources.automation_engine import AutomationEngine class UsageAutomation(AutomationEngine): @@ -52,11 +52,19 @@ def dispatch(self, request): and request.product.id not in self.config.products: return 'Listing not handled by this processor' - self.logger.info( - 'Processing Usage for Product {} ({}) '.format(request.product.id, - request.product.name) + - 'on Contract {} '.format(request.contract.id) + - 'and provider {}({})'.format(request.provider.id, request.provider.name)) + '' + + self.logger.info(( + 'Processing Usage for Product {product_id} ({product_name}) ' + 'on Contract {contract_id} ' + 'and provider {provider_id}({provider_name})').format( + product_id=request.product.id, + product_name=request.product.name, + contract_id=request.contract.id, + provider_id=request.provider.id, + provider_name=request.provider.name, + ) + ) try: result = self.process_request(request) diff --git a/connect/resources/usage_file_automation.py b/connect/resources/usage_file_automation.py index a2a1612..9a3b12b 100644 --- a/connect/resources/usage_file_automation.py +++ b/connect/resources/usage_file_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import json import logging diff --git a/connect/rql/__init__.py b/connect/rql/__init__.py index 977d942..fadc4b6 100644 --- a/connect/rql/__init__.py +++ b/connect/rql/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from .query import Query diff --git a/connect/rql/query.py b/connect/rql/query.py index 2730c3f..c8ffc71 100644 --- a/connect/rql/query.py +++ b/connect/rql/query.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from copy import copy from typing import Dict, List, Optional diff --git a/examples/config.json b/examples/config.json index bf76fa7..ca96196 100644 --- a/examples/config.json +++ b/examples/config.json @@ -1,5 +1,5 @@ { - "apiEndpoint": "http://localhost:8080/api/public/v1/", - "apiKey": "ApiKey XXXX:YYYYY", - "products": "CN-631-322-000" + "apiEndpoint": "https://api.cnct.tech/public/v1", + "apiKey": "ApiKey SU-771-994-269:553158141b425b106f4099dc15c7fe6064789312", + "products": "PRD-226-811-341" } diff --git a/examples/fulfillment.py b/examples/fulfillment.py index 35ede92..f99f731 100644 --- a/examples/fulfillment.py +++ b/examples/fulfillment.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from typing import Union import warnings diff --git a/examples/tier_config.py b/examples/tier_config.py index eca015d..d1fa14a 100644 --- a/examples/tier_config.py +++ b/examples/tier_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. # NOTE: This example development is in progress. This is just a skeleton. diff --git a/examples/usage.py b/examples/usage.py index 22cdb33..a68a77f 100644 --- a/examples/usage.py +++ b/examples/usage.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from datetime import datetime, timedelta import warnings @@ -26,7 +26,7 @@ def process_request(self, request): # type: (UsageListing) -> None # Detect specific provider contract - if request.contract.id == 'CRD-41560-05399-123': + if request.contract.id == 'CRD-00000-00000-00000': # Can also be seen from request.provider.id and parametrized further # via marketplace available at request.marketplace.id usage_file = UsageFile( diff --git a/examples/usage_file.py b/examples/usage_file.py index 6cf2d58..abfed25 100644 --- a/examples/usage_file.py +++ b/examples/usage_file.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import warnings diff --git a/setup.py b/setup.py index 8c74394..ebf6ff4 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from os.path import abspath, dirname, exists, join from setuptools import find_packages, setup diff --git a/tests/__init__.py b/tests/__init__.py index dd1d1cc..7ee6406 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. diff --git a/tests/common.py b/tests/common.py index fe92c4b..90a38d7 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from collections import namedtuple from typing import Optional diff --git a/tests/test_config.py b/tests/test_config.py index 812fc7b..04210f4 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import os diff --git a/tests/test_conversation.py b/tests/test_conversation.py index 4c8a6c1..af15142 100644 --- a/tests/test_conversation.py +++ b/tests/test_conversation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import datetime import os diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index bd28181..edf96b6 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import pytest diff --git a/tests/test_directory.py b/tests/test_directory.py index 6ceb4c1..b5ab476 100644 --- a/tests/test_directory.py +++ b/tests/test_directory.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. # TODO: Assert received request data diff --git a/tests/test_models.py b/tests/test_models.py index 18e7748..156bb81 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import json import os diff --git a/tests/test_query.py b/tests/test_query.py index a56a08c..ce0611d 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. from connect.rql import Query diff --git a/tests/test_server_error_response.py b/tests/test_server_error_response.py index 6b662fe..d26028e 100644 --- a/tests/test_server_error_response.py +++ b/tests/test_server_error_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import os diff --git a/tests/test_tier_config.py b/tests/test_tier_config.py index 7d55fb2..ed6e662 100644 --- a/tests/test_tier_config.py +++ b/tests/test_tier_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import os from datetime import datetime diff --git a/tests/test_usage.py b/tests/test_usage.py index 22ca64f..adfea0d 100644 --- a/tests/test_usage.py +++ b/tests/test_usage.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import os import time diff --git a/tests/test_usage_file.py b/tests/test_usage_file.py index 22c6843..ee949d1 100644 --- a/tests/test_usage_file.py +++ b/tests/test_usage_file.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. import os from datetime import datetime From 1a5b9c3b2380a2d19cf6452ebf86ff4fc4c14c90 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Mon, 16 Mar 2020 12:14:07 +0100 Subject: [PATCH 02/20] LITE-11458 Add TAr to SDK --- .gitignore | 3 +- .pylintrc | 585 ++++++++++++++++++ connect/models/tier_account_request.py | 23 + connect/resources/fulfillment.py | 29 + connect/resources/tier_account.py | 47 ++ .../tier_account_request_automation.py | 57 ++ examples/tier_account_request.py | 47 ++ examples/tier_account_request_automation.py | 30 + tests/data/tier_configuration_request.json | 28 + 9 files changed, 848 insertions(+), 1 deletion(-) create mode 100644 .pylintrc create mode 100644 connect/models/tier_account_request.py create mode 100644 connect/resources/fulfillment.py create mode 100644 connect/resources/tier_account.py create mode 100644 connect/resources/tier_account_request_automation.py create mode 100644 examples/tier_account_request.py create mode 100644 examples/tier_account_request_automation.py create mode 100644 tests/data/tier_configuration_request.json diff --git a/.gitignore b/.gitignore index 564a4d3..f19ecac 100644 --- a/.gitignore +++ b/.gitignore @@ -107,4 +107,5 @@ venv.bak/ .vscode/ .idea/ .devcontainer/ -.notes.txt \ No newline at end of file +.notes.txt +notes.txt diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..99c70f8 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,585 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use. +jobs=1 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python module names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=print-statement, + parameter-unpacking, + unpacking-in-except, + old-raise-syntax, + backtick, + long-suffix, + old-ne-operator, + old-octal-literal, + import-star-module-level, + non-ascii-bytes-literal, + raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead, + apply-builtin, + basestring-builtin, + buffer-builtin, + cmp-builtin, + coerce-builtin, + execfile-builtin, + file-builtin, + long-builtin, + raw_input-builtin, + reduce-builtin, + standarderror-builtin, + unicode-builtin, + xrange-builtin, + coerce-method, + delslice-method, + getslice-method, + setslice-method, + no-absolute-import, + old-division, + dict-iter-method, + dict-view-method, + next-method-called, + metaclass-assignment, + indexing-exception, + raising-string, + reload-builtin, + oct-method, + hex-method, + nonzero-method, + cmp-method, + input-builtin, + round-builtin, + intern-builtin, + unichr-builtin, + map-builtin-not-iterating, + zip-builtin-not-iterating, + range-builtin-not-iterating, + filter-builtin-not-iterating, + using-cmp-argument, + eq-without-hash, + div-method, + idiv-method, + rdiv-method, + exception-message-attribute, + invalid-str-codec, + sys-max-int, + bad-python3-import, + deprecated-string-function, + deprecated-str-translate-call, + deprecated-itertools-function, + deprecated-types-field, + next-method-defined, + dict-items-not-iterating, + dict-keys-not-iterating, + dict-values-not-iterating, + deprecated-operator-function, + deprecated-urllib-function, + xreadlines-attribute, + deprecated-sys-function, + exception-escape, + comprehension-escape, + missing-class-docstring, + missing-module-docstring, + missing-function-docstring, + import-outside-toplevel + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a score less than or equal to 10. You +# have access to the variables 'error', 'warning', 'refactor', and 'convention' +# which contain the number of messages in each category, as well as 'statement' +# which is the total number of statements analyzed. This score is used by the +# global evaluation report (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit + + +[LOGGING] + +# Format style used to check logging format string. `old` means using % +# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[STRING] + +# This flag controls whether the implicit-str-concat-in-sequence should +# generate a warning on implicit string concatenation in sequences defined over +# several lines. +check-str-concat-over-line-jumps=no + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. +#argument-rgx= + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. +#class-attribute-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + Run, + _ + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=no + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. +#variable-rgx= + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it work, +# install the python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains the private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to the private dictionary (see the +# --spelling-private-dict-file option) instead of raising a message. +spelling-store-unknown-words=no + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=100 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis). It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + +# List of decorators that change the signature of a decorated function. +signature-mutators= + + +[DESIGN] + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement (see R0916). +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[IMPORTS] + +# List of modules that can be imported at any level, not just the top level +# one. +allow-any-import-level= + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules=optparse,tkinter.tix + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled). +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled). +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + +# Couples of modules and preferred modules, separated by a comma. +preferred-modules= + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp, + __post_init__ + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=cls + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "BaseException, Exception". +overgeneral-exceptions=BaseException, + Exception diff --git a/connect/models/tier_account_request.py b/connect/models/tier_account_request.py new file mode 100644 index 0000000..f19416b --- /dev/null +++ b/connect/models/tier_account_request.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import TierAccountRequestSchema + +class TierAccountRequest(BaseModel): + """ Tier account request. """ + _schema = TierAccountRequestSchema() + + type = None + status = None + account = None + provider = None + vendor = None + product = None + reason = None + contact_info = None + external_id = None + external_uid = None + events = None diff --git a/connect/resources/fulfillment.py b/connect/resources/fulfillment.py new file mode 100644 index 0000000..d00831a --- /dev/null +++ b/connect/resources/fulfillment.py @@ -0,0 +1,29 @@ +from connect.config import Config +from connect.resources.tier_account import TierAccountRequestResource + +class Fulfillment(object): + """ Allows listing and obtaining several types of objects. + + :param Config config: Config object or ``None`` to use environment config (default). + """ + + _config = None # type: Config + + def __init__(self, config=None): + self._config = config or Config.get_instance() + self._tier_account_requests = TierAccountRequestResource(config=self._config) + + def create_tier_account_request(self, obj): + return self._tier_account_requests.create(obj) + + def accept_tier_account_request(self, pk): + return self._tier_account_requests.accept(pk) + + def ignore_tier_account_request(self, pk, reason): + return self._tier_account_requests.ignore(pk, reason) + + def get_pending_tier_account_requests(self): + return self._tier_account_requests.search(dict(status='pending')) + + def create_purchase_request(self, obj): + pass \ No newline at end of file diff --git a/connect/resources/tier_account.py b/connect/resources/tier_account.py new file mode 100644 index 0000000..761971e --- /dev/null +++ b/connect/resources/tier_account.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from connect.models.tier_account import TierAccount +from connect.models.tier_account_request import TierAccountRequest + +from .base import BaseResource + + +class TierAccountResource(BaseResource): + """ Tier Account Resource. """ + + resource = 'tier/accounts' + model_class = TierAccount + +class TierAccountRequestResource(BaseResource): + """ Tier Account Request Resource. """ + resource = 'tier/account-requests' + model_class = TierAccountRequest + + def accept(self, id_tar): + """ Accept a Tier Configuration Request. + :param str id_tar: Primary key of the tier configuration request to accept. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tar: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post(path='{}/accept'.format(id_tar)) + return response + + def ignore(self, id_tar, reason): + """ Ignore a Tier Configuration Request + :param str id_tar: Primary key of the tier configuration request to ignore. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tar: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post( + path='{}/ignore'.format(id_tar), + json={ + 'reason': reason, + }) + return response diff --git a/connect/resources/tier_account_request_automation.py b/connect/resources/tier_account_request_automation.py new file mode 100644 index 0000000..1405cd8 --- /dev/null +++ b/connect/resources/tier_account_request_automation.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from abc import ABCMeta +import logging + +from deprecation import deprecated +from typing import Optional + +from connect.logger import function_log +from connect.models.tier_account import TierAccount +from connect.models.tier_account_request import TierAccountRequest +from connect.resources.automation_engine import AutomationEngine +from connect.resources.fulfillment import Fulfillment + +class TierAccountRequestAutomation(AutomationEngine): + """ This is the automation engine for the Tier Account Request API. If you want to process + tier account request, subclass this and implement the ``process_request`` method, which receives a + :py:class:`connect.models.tierAccountRequest` request as argument and must return an + :py:class:`connect.models.ActivationTemplateResponse` or + :py:class:`connect.models.ActivationTileResponse` object in case the request has to be approved. + + In other case, you must raise one of these exceptions: + + - :py:class:`connect.exceptions.InquireRequest`: Inquire for more information. + - :py:class:`connect.exceptions.FailRequest`: Causes the request to fail. + - :py:class:`connect.exceptions.SkipRequest`: Skips processing the request. + + Create an instance of your subclass and call its ``process`` method to begin processing. + + For an example on how to use this class, see :ref:`fulfillment_example`. + """ + + __metaclass__ = ABCMeta + resource = 'tier/account-requests' + model_class = TierAccountRequest + logger = logging.getLogger('TierAccountRequest.logger') + + @function_log(custom_logger=logger) + def dispatch(self, request): + tier = Fulfillment(config=self.configuration) + print('==============================') + print(self.config.products) + print('==============================') + # print(tier.get_pending_tier_account_requests()) + print('==============================') + + + ''' + if self.config.products \ + and request.asset.product.id not in self.config.products: + self.logger.info('Invalid Product') + return 'Invalid product' + ''' + \ No newline at end of file diff --git a/examples/tier_account_request.py b/examples/tier_account_request.py new file mode 100644 index 0000000..b1af6a9 --- /dev/null +++ b/examples/tier_account_request.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +import json +from connect.config import Config +from connect.resources.fulfillment import Fulfillment +from connect.resources.directory import Directory + +class TierAccountRequest(): + configuration = Config(file='examples/config.json') + + def get_pending(self): + tier = Fulfillment(config=self.configuration) + return tier.get_pending_tier_account_requests() + + def get_tier_account(self): + tier = Directory(config=self.configuration) + t_account = tier.get_tier_account('TA-6458-9737-0065') + print(t_account.id) + print(t_account.external_id) + print(t_account.external_uid) + print(t_account.contact_info.address_line1) + + def accept_tier_account_request(self, id_tar): + tier = Fulfillment(config=self.configuration) + response = tier.accept_tier_account_request(id_tar) + print(response) + + def ignore_tier_account_request(self, id_tar, reason): + tier = Fulfillment(config=self.configuration) + response = tier.ignore_tier_account_request(id_tar, reason) + print(response) + + def create_tier_account_request(self, data): + tier = Fulfillment(config=self.configuration) + response = tier.create_tier_account_request(data) + print(response) + +def main(): + tier_account_example = TierAccountRequest() + with open('./tests/data/tier_configuration_request.json') as json_file: + data = json.load(json_file) + # tier_account_example.create_tier_account_request(data) + print(tier_account_example.get_tier_account()) +if __name__ == '__main__': + main() diff --git a/examples/tier_account_request_automation.py b/examples/tier_account_request_automation.py new file mode 100644 index 0000000..fb8ce29 --- /dev/null +++ b/examples/tier_account_request_automation.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +import json +from connect.config import Config +from connect.resources.fulfillment import Fulfillment +from connect.resources.directory import Directory +from connect.resources import TierAccountRequestAutomation + +class TierAccountRequestExample(TierAccountRequestAutomation): + configuration = Config(file='examples/config.json') + + def process_request(self, request): + pass + # return TierAccountRequestAutomation.dispatch(self, request) + +def main(): + tier_account_example = TierAccountRequestExample() + with open('./tests/data/tier_configuration_request.json') as json_file: + data = json.load(json_file) + # tier_account_example.create_tier_account_request(data) + print(tier_account_example.process()) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/tests/data/tier_configuration_request.json b/tests/data/tier_configuration_request.json new file mode 100644 index 0000000..7aa65c1 --- /dev/null +++ b/tests/data/tier_configuration_request.json @@ -0,0 +1,28 @@ +{ + "type": "update", + "account": { + "id": "TA-6458-9737-0065", + "external_id": "13110", + "external_uid" : "80ff5f75-c1a9-4b50-9110-9d80ee217471", + "name": "string", + "contact_info": { + "address_line1": "Yalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Pirulo", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + } +} \ No newline at end of file From 0a597f188c7a3fb6e49b2b41c5b64aa8191d2899 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 27 Mar 2020 13:58:27 +0100 Subject: [PATCH 03/20] tests --- .gitignore | 1 + connect/__init__.py | 1 + connect/models/__init__.py | 16 +++++ connect/models/company.py | 6 ++ connect/models/schemas.py | 119 ++++++++++++++++++++++++++++++++-- connect/resources/__init__.py | 8 ++- connect/resources/base.py | 2 +- tests/config.json | 2 +- 8 files changed, 144 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index f19ecac..cb9ec57 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,4 @@ venv.bak/ .devcontainer/ .notes.txt notes.txt +postcreate.sh diff --git a/connect/__init__.py b/connect/__init__.py index fee4623..bb242fc 100644 --- a/connect/__init__.py +++ b/connect/__init__.py @@ -45,4 +45,5 @@ def __init__(self, config=None): 'rql', 'FulfillmentAutomation', 'TierConfigAutomation', + 'TierRequestAutomation', ] diff --git a/connect/models/__init__.py b/connect/models/__init__.py index c80d57a..105b62e 100644 --- a/connect/models/__init__.py +++ b/connect/models/__init__.py @@ -8,8 +8,10 @@ from .activation_tile_response import ActivationTileResponse from .agreement import Agreement from .agreement_stats import AgreementStats +from .aniversary import Aniversary from .asset import Asset from .base import BaseModel +from .billing import Billing from .company import Company from .configuration import Configuration from .connection import Connection @@ -31,6 +33,7 @@ from .hub_instance import HubInstance from .hub_stats import HubStats from .item import Item +from .last_request import LastRequest from .marketplace import Marketplace from .param import Param from .phone_number import PhoneNumber @@ -43,6 +46,8 @@ from .product_stats_info import ProductStatsInfo from .renewal import Renewal from .server_error_response import ServerErrorResponse +from .stat import Stat +from .stats import Stats from .template import Template from .tier_account import TierAccount from .tier_accounts import TierAccounts @@ -55,6 +60,11 @@ from .usage_records import UsageRecords from .user import User from .value_choice import ValueChoice +from .billing_request import BillingRequest +from .period import Period +from .attributes import Attributes +from .recurring_asset import RecurringAsset + __all__ = [ 'Activation', @@ -64,6 +74,8 @@ 'AgreementStats', 'Asset', 'BaseModel', + 'Billing', + 'BillingRequest', 'Company', 'Configuration', 'Connection', @@ -85,6 +97,7 @@ 'HubInstance', 'HubStats', 'Item', + 'LastRequest', 'Marketplace', 'Param', 'PhoneNumber', @@ -95,8 +108,11 @@ 'ProductFamily', 'ProductStats', 'ProductStatsInfo', + 'RecurringAsset', 'Renewal', 'ServerErrorResponse', + 'Stat', + 'Stats', 'Template', 'TierAccount', 'TierAccounts', diff --git a/connect/models/company.py b/connect/models/company.py index ae5d03f..a142df6 100644 --- a/connect/models/company.py +++ b/connect/models/company.py @@ -14,3 +14,9 @@ class Company(BaseModel): name = None # type: str """ (str) Company name. """ + + last_request = None # type: LastRequest + """ (:py:class:`.LastRequest`) Last Request of companySchema. """ + + count = None # type: integer + """ (integer) Count. """ diff --git a/connect/models/schemas.py b/connect/models/schemas.py index b572684..07e2efc 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -31,7 +31,6 @@ def make_object(self, data): from connect.models import Activation return Activation(**data) - class AgreementStatsSchema(BaseSchema): contracts = fields.Int() versions = fields.Int() @@ -41,9 +40,30 @@ def make_object(self, data): from connect.models import AgreementStats return AgreementStats(**data) +class PeriodSchema(BaseSchema): + period_from = fields.DateTime(data_key='from') + period_to = fields.DateTime(data_key='to') + delta = fields.Decimal() + uom = fields.Str() + + @post_load + def make_object(self, data): + from connect.models import Period + return Period(**data) + +class LastRequestSchema(BaseSchema): + type = fields.String() + period = fields.Nested(PeriodSchema) + + @post_load + def make_object(self, data): + from connect.models import LastRequest + return LastRequest(**data) class CompanySchema(BaseSchema): name = fields.Str() + last_request = fields.Nested(LastRequestSchema, many=True) + count = fields.Integer() @post_load def make_object(self, data): @@ -327,9 +347,9 @@ def make_object(self, data): class AgreementSchema(BaseSchema): - type = fields.Str() + type = fields.String() title = fields.Str() - description = fields.Str() + description = fields.String() created = fields.DateTime() updated = fields.DateTime() owner = fields.Nested(CompanySchema) @@ -343,7 +363,7 @@ class AgreementSchema(BaseSchema): agreements = fields.Nested('AgreementSchema', many=True) parent = fields.Nested('AgreementSchema', only=('id', 'name')) marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name')) - name = fields.Str() + name = fields.String() @post_load def make_object(self, data): @@ -352,10 +372,10 @@ def make_object(self, data): class ContractSchema(BaseSchema): - name = fields.Str() + name = fields.String() version = fields.Int() - type = fields.Str() - status = fields.Str() + type = fields.String() + status = fields.String() agreement = fields.Nested(AgreementSchema, only=('id', 'name')) marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name')) owner = fields.Nested(CompanySchema, only=('id', 'name')) @@ -758,3 +778,88 @@ class ConversationSchema(BaseSchema): def make_object(self, data): from connect.models import Conversation return Conversation(**data) + +class AttributesSchema(BaseSchema): + provider = fields.Nested(CompanySchema, only=('external_id')) + vendor = fields.Nested(CompanySchema, only=('external_id')) + + @post_load + def make_object(self, data): + from connect.models import Attributes + return Attributes(**data) + +class AniversarySchema(BaseSchema): + day = fields.Integer() + month = fields.Integer() + + @post_load + def make_object(self, data): + from connect.models import Aniversary + return Aniversary(**data) + +class StatSchema(BaseSchema): + count = fields.Integer() + last_request = fields.Nested(LastRequestSchema) + + @post_load + def make_object(self, data): + from connect.models import Stat + return Stat(**data) + + +class StatsSchema(BaseSchema): + provider = fields.Nested(StatSchema) + vendor = fields.Nested(StatSchema) + + @post_load + def make_object(self, data): + from connect.models import Stats + return Stats(**data) + +class BillingSchema(BaseSchema): + stats = fields.Nested(StatsSchema) + period = fields.Nested(PeriodSchema) + next_date = fields.DateTime() + aniversary = fields.Nested(AniversarySchema) + + @post_load + def make_object(self, data): + from connect.models import Billing + return Billing(**data) + +class BillingRequestSchema(BaseSchema): + type = fields.String() + events = fields.Nested(EventsSchema, only=('created', 'updated')) + asset = fields.Nested(AssetSchema) + items = fields.Nested(ItemSchema, many=True) + attributes = fields.Nested(AttributesSchema) + period = fields.Nested(PeriodSchema) + + @post_load + def make_object(self, data): + from connect.models import BillingRequest + return BillingRequest(**data) + +class RecurringAssetSchema(BaseSchema): + id = fields.String() + status = fields.String() + events = fields.Nested(EventsSchema, only=('created', 'updated')) + external_id = fields.String() + external_uuid = fields.String() + product = fields.Nested(ProductSchema, only=('id', 'name', 'status', 'icon')) + connection = fields.Nested(ConnectionSchema) + items = fields.Nested(ItemSchema, many=True) + params = fields.Nested(ParamSchema, many=True) + tiers = fields.Nested(TierAccountSchema) + marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name', 'icon')) + contract = fields.Nested(ContractSchema, only=('id', 'name')) + billing = fields.Nested(BillingSchema) + + @post_load + def make_object(self, data): + from connect.models import RecurringAsset + return RecurringAsset(**data) + + + + diff --git a/connect/resources/__init__.py b/connect/resources/__init__.py index febd68c..75bdddb 100644 --- a/connect/resources/__init__.py +++ b/connect/resources/__init__.py @@ -10,7 +10,8 @@ from .usage_automation import UsageAutomation from .usage_file_automation import UsageFileAutomation from .tier_account_request_automation import TierAccountRequestAutomation - +from .billing_request import BillingRequest +from .recurring_asset import RecurringAsset __all__ = [ 'Directory', @@ -19,6 +20,9 @@ 'TierConfigAutomation', 'UsageAutomation', 'UsageFileAutomation', - 'TierAccountRequestAutomation' + 'TierAccountRequestAutomation', + 'Subscription', + 'BillingRequest', + 'RecurringAsset' # 'DirectoryExample', ] diff --git a/connect/resources/base.py b/connect/resources/base.py index 94db578..58f3b89 100644 --- a/connect/resources/base.py +++ b/connect/resources/base.py @@ -120,7 +120,7 @@ def _check_and_pack_response(response): class BaseResource(object): - """ Base class of ∫all resources. + """ Base class of all resources. :param Config config: Config object or ``None`` to use environment config (default). """ diff --git a/tests/config.json b/tests/config.json index bf76fa7..b2bc6a3 100644 --- a/tests/config.json +++ b/tests/config.json @@ -1,5 +1,5 @@ { "apiEndpoint": "http://localhost:8080/api/public/v1/", "apiKey": "ApiKey XXXX:YYYYY", - "products": "CN-631-322-000" + "products": "CN-631-322-000" } From bbccd950484fe7c27e85f505c8465ff9a2ca1cf3 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 27 Mar 2020 13:58:58 +0100 Subject: [PATCH 04/20] test --- connect/models/activation copy.py | 25 ++ connect/models/aniversary.py | 18 ++ connect/models/attributes copy.py | 22 ++ connect/models/attributes.py | 22 ++ connect/models/billing.py | 24 ++ connect/models/billing_request.py | 30 ++ connect/models/last_request.py | 16 + connect/models/period.py | 28 ++ connect/models/recurring_asset.py | 49 +++ connect/models/stat.py | 22 ++ connect/models/stats.py | 22 ++ connect/resources/billing_request.py | 27 ++ connect/resources/recurring_asset.py | 12 + connect/resources/subscription.py | 23 ++ connect/resources/tier_config.py | 98 ++++++ examples/billing_request.py | 37 +++ examples/recurring_asset.py | 33 ++ tests/data/response_get_billing_request.json | 109 +++++++ tests/data/response_get_recurring_asset.json | 161 ++++++++++ tests/data/response_list_billing_request.json | 300 ++++++++++++++++++ tests/data/response_list_recurring_asset.json | 260 +++++++++++++++ tests/test_billing_request.py | 83 +++++ tests/test_recurring_asset.py | 83 +++++ 23 files changed, 1504 insertions(+) create mode 100644 connect/models/activation copy.py create mode 100644 connect/models/aniversary.py create mode 100644 connect/models/attributes copy.py create mode 100644 connect/models/attributes.py create mode 100644 connect/models/billing.py create mode 100644 connect/models/billing_request.py create mode 100644 connect/models/last_request.py create mode 100644 connect/models/period.py create mode 100644 connect/models/recurring_asset.py create mode 100644 connect/models/stat.py create mode 100644 connect/models/stats.py create mode 100644 connect/resources/billing_request.py create mode 100644 connect/resources/recurring_asset.py create mode 100644 connect/resources/subscription.py create mode 100644 connect/resources/tier_config.py create mode 100644 examples/billing_request.py create mode 100644 examples/recurring_asset.py create mode 100644 tests/data/response_get_billing_request.json create mode 100644 tests/data/response_get_recurring_asset.json create mode 100644 tests/data/response_list_billing_request.json create mode 100644 tests/data/response_list_recurring_asset.json create mode 100644 tests/test_billing_request.py create mode 100644 tests/test_recurring_asset.py diff --git a/connect/models/activation copy.py b/connect/models/activation copy.py new file mode 100644 index 0000000..7addc80 --- /dev/null +++ b/connect/models/activation copy.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional + +from .base import BaseModel +from .schemas import ActivationSchema + + +class Activation(BaseModel): + """ Activation object. """ + + _schema = ActivationSchema() + + link = None # type: Optional[str] + """ (str|None) Activation link. """ + + message = None # type: str + """ (str) Activation message. """ + + date = None # type: Optional[datetime.datetime] + """ (datetime.datetime|None) Activation date. """ diff --git a/connect/models/aniversary.py b/connect/models/aniversary.py new file mode 100644 index 0000000..0c436e8 --- /dev/null +++ b/connect/models/aniversary.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import AniversarySchema + +class Aniversary(BaseModel): + """ An Aniversary object. """ + + _schema = AniversarySchema() + + day = None # type: str + """ (str) Day of the aniversay. """ + + month = None # type: str + """ (str) Month of the aniversary. """ \ No newline at end of file diff --git a/connect/models/attributes copy.py b/connect/models/attributes copy.py new file mode 100644 index 0000000..f5dd2d1 --- /dev/null +++ b/connect/models/attributes copy.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional + +from .base import BaseModel +from .schemas import AttributesSchema + + +class Attributes(BaseModel): + """ Activation object. """ + + _schema = AttributesSchema() + + vendor = None # type: obj + """ (obj) Attributes Vendor. """ + + provider = None # type: obj + """ (obj) Attributes Provider. """ diff --git a/connect/models/attributes.py b/connect/models/attributes.py new file mode 100644 index 0000000..a23feaa --- /dev/null +++ b/connect/models/attributes.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional + +from .base import BaseModel +from .schemas import AttributesSchema + + +class Attributes(BaseModel): + """ Attributes object. """ + + _schema = AttributesSchema() + + vendor = None # type: obj + """ (obj) Attributes Vendor. """ + + provider = None # type: obj + """ (obj) Attributes Provider. """ diff --git a/connect/models/billing.py b/connect/models/billing.py new file mode 100644 index 0000000..56417e4 --- /dev/null +++ b/connect/models/billing.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import BillingSchema + +class Billing(BaseModel): + """ Billing object. """ + + _schema = BillingSchema() + + stats = None # type: Stats + """ (:py:class:`.Stats`) Stats of companySchema. """ + + period = None # type: Period + """ (:py:class:`.Period`) Period of the billing. """ + + next_date = None # type: str + """ (str) Next date of the billing. """ + + aniversary = None # type: Aniversary + """ (:py:class:`.Aniversary`) Aniversary. """ diff --git a/connect/models/billing_request.py b/connect/models/billing_request.py new file mode 100644 index 0000000..e8b935a --- /dev/null +++ b/connect/models/billing_request.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import BillingRequestSchema + +class BillingRequest(BaseModel): + """ BillingRequest object. """ + + _schema = BillingRequestSchema() + + type = None # type: [str] + """ (vendor|provider) Billing Request type. """ + + events = None # type: obj + """ (obj) Billing Request Events. """ + + asset = None # type: obj + """ (obj) Billing Request Asset. """ + + item = None # type: obj + """ (obj) Billing Request Item. """ + + asset = None # type: obj + """ (obj) Billing Request Asset. """ + + period = None # type: obj + """ (obj) Billing Request Period. """ diff --git a/connect/models/last_request.py b/connect/models/last_request.py new file mode 100644 index 0000000..7255355 --- /dev/null +++ b/connect/models/last_request.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import LastRequestSchema + + +class LastRequest(BaseModel): + """ Last Request object. """ + + _schema = LastRequestSchema() + + type = None # type: str + """ (str) Type of last request. """ diff --git a/connect/models/period.py b/connect/models/period.py new file mode 100644 index 0000000..aba4a61 --- /dev/null +++ b/connect/models/period.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional + +from .base import BaseModel +from .schemas import PeriodSchema + + +class Period(BaseModel): + """ Period object. """ + + _schema = PeriodSchema() + + period_from = None # type: date + """ (date) Period From. """ + + period_to = None # type: date + """ (date) Period To. """ + + delta = None # type: string + """ (string) Period Delta. """ + + uom = None # type: string + """ (string) Period uom. """ diff --git a/connect/models/recurring_asset.py b/connect/models/recurring_asset.py new file mode 100644 index 0000000..9aaa6e5 --- /dev/null +++ b/connect/models/recurring_asset.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import RecurringAssetSchema + + +class RecurringAsset(BaseModel): + """ RecurringAsset object. """ + + _schema = RecurringAssetSchema() + + status = None # type: ([)str) + """ (vendor|provider) Billing Request status. """ + + events = None # type: obj + """ (obj) Billing Request Events. """ + + external_id = None # type: (str) + """ (str) External Id. """ + + external_uuid = None # type: (str) + """ (str) External uuId. """ + + product = None # type: obj + """ (obj) product. """ + + connection = None # type: obj + """ (obj) Billing Request connection. """ + + items = None # type: obj + """ (obj) Billing Request Item. """ + + params = None # type: obj + """ (obj) Billing Request Params. """ + + tiers = None # type: obj + """ (obj) Billing Request tiers. """ + + marketplace = None # type: obj + """ (obj) Billing Request marketplace. """ + + contract = None # type: obj + """ (obj) Billing Request Contract. """ + + billing = None # type: obj + """ (obj) Billing Request billing. """ diff --git a/connect/models/stat.py b/connect/models/stat.py new file mode 100644 index 0000000..b5e8e82 --- /dev/null +++ b/connect/models/stat.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional + +from .base import BaseModel +from .schemas import StatSchema + + +class Stat(BaseModel): + """ Stats object. """ + + _schema = StatSchema() + + count = None # type: Int + """ (Int) Count. """ + + last_request = None # type: last_request + """ (:py:class:`.LastRequest`) Last Request. """ diff --git a/connect/models/stats.py b/connect/models/stats.py new file mode 100644 index 0000000..a270592 --- /dev/null +++ b/connect/models/stats.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional + +from .base import BaseModel +from .schemas import StatsSchema + + +class Stats(BaseModel): + """ Stats object. """ + + _schema = StatsSchema() + + vendor = None # type: Company + """ (:py:class:`.Company`) Vendor. """ + + provider = None # type: Company + """ (:py:class:`.Company`) Provider. """ diff --git a/connect/resources/billing_request.py b/connect/resources/billing_request.py new file mode 100644 index 0000000..69c73f9 --- /dev/null +++ b/connect/resources/billing_request.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from connect.models.billing_request import BillingRequest +from .base import BaseResource + +class BillingRequestResource(BaseResource): + """ Billing Request Request Resource. """ + resource = 'subscriptions/requests' + model_class = BillingRequest + + def update_billing_request(self, id_billing_request, body): + """ Update Billing Request Attribute + :param str id_billing_request: Primary key of the billing request to update. + :param str body: Obj to update. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_billing_request: + raise ValueError('Billing Request not exist') + response = self._api.put( + path='{}/attributes'.format(id_billing_request), + json=body + ) + return response \ No newline at end of file diff --git a/connect/resources/recurring_asset.py b/connect/resources/recurring_asset.py new file mode 100644 index 0000000..b9a5147 --- /dev/null +++ b/connect/resources/recurring_asset.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from connect.models.recurring_asset import RecurringAsset +from .base import BaseResource + +class RecurringAssetResource(BaseResource): + """ Recurring Asset Request Resource. """ + resource = 'subscriptions/assets' + model_class = RecurringAsset diff --git a/connect/resources/subscription.py b/connect/resources/subscription.py new file mode 100644 index 0000000..bad72c3 --- /dev/null +++ b/connect/resources/subscription.py @@ -0,0 +1,23 @@ +from connect.config import Config +from connect.resources.billing_request import BillingRequestResource +from connect.resources.recurring_asset import RecurringAssetResource + + +class Subscription(object): + """ Allows listing and obtaining several types of objects. + + :param Config config: Config object or ``None`` to use environment config (default). + """ + + _config = None # type: Config + + def __init__(self, config=None): + self._config = config or Config.get_instance() + self._billing_request = BillingRequestResource(config=self._config) + self._recurring_asset = RecurringAssetResource(config=self._config) + + def create_billing_request(self, obj): + return self._billing_request.create(obj) + + def update_billing_request(self, pk, body): + return self._billing_request.update_billing_request(pk,body) diff --git a/connect/resources/tier_config.py b/connect/resources/tier_config.py new file mode 100644 index 0000000..f7406ca --- /dev/null +++ b/connect/resources/tier_config.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +from connect.models.tier_config import TierConfig +from connect.models.tier_config_request import TierConfigRequest + +from .base import BaseResource + + +class TierConfigResource(BaseResource): + """ Tier Config Resource. """ + resource = 'tier/configs' + model_class = TierConfig + +class TierConfigRequestResource(BaseResource): + """ Tier Config Request Resource. """ + resource = 'tier/config-requests' + model_class = TierConfigRequest + + def pend(self, id_tcr): + """ Set a Tier Configuration Request to pend status. + :param str id_tar: Primary key of the tier configuration request to set. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tcr: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post(path='{}/pend'.format(id_tcr)) + return response + + def inquire(self, id_tcr): + """ Set a Tier Configuration Request to inquire status. + :param str id_tar: Primary key of the tier configuration request to set. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tcr: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post(path='{}/inquire'.format(id_tcr)) + return response + + def approve(self, id_tcr, id_template): + """ Approve a Tier Configuration Request + :param str id_tcr: Primary key of the tier configuration request to approve. + :param str id_template: Primary key of the template. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tcr: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post( + path='{}/approve'.format(id_tcr), + json={ + 'template': { + 'id': id_template, + } + }) + return response + + def fail(self, id_tcr, reason): + """ Set fail a Tier Configuration Request + :param str id_tar: Primary key of the tier configuration request to ignore. + :param str reason: Reason of the fail. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tcr: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post( + path='{}/fail'.format(id_tcr), + json={ + 'reason': reason, + }) + return response + + def assign(self, id_tcr): + """ Assign a Tier Configuration Request. + :param str id_tar: Primary key of the tier configuration request to set. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tcr: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post(path='{}/assign'.format(id_tcr)) + return response + + def unassign(self, id_tcr): + """ Unassign a Tier Configuration Request. + :param str id_tar: Primary key of the tier configuration request to set. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_tcr: + raise ValueError('Tier Configuration Request not exist') + response = self._api.post(path='{}/unassign'.format(id_tcr)) + return response \ No newline at end of file diff --git a/examples/billing_request.py b/examples/billing_request.py new file mode 100644 index 0000000..88a97a6 --- /dev/null +++ b/examples/billing_request.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +import json +from connect.config import Config +from connect.resources.subscription import Subscription +# from connect.resources.directory import Directory + +class BillingRequest(): + configuration = Config(file='examples/config.json') + + def list_billing_request(self): + tier = Subscription(config=self.configuration) + return tier._billing_request.list() + + def get_billing_request(self,id): + tier = Subscription(config=self.configuration) + return tier._billing_request.get(id) + +def main(): + billing_request_example = BillingRequest() + with open('./tests/data/tier_configuration_request.json') as json_file: + data = json.load(json_file) + # tier_account_example.create_tier_account_request(data) + ''' List example ''' + billing_request = billing_request_example.list_billing_request() + print(billing_request[0].id) + + + ''' Get example + billing_request = billing_request_example.get_billing_request('BRP-7986-6756-4144-0001') + print(billing_request.type) + ''' + +if __name__ == '__main__': + main() diff --git a/examples/recurring_asset.py b/examples/recurring_asset.py new file mode 100644 index 0000000..9461a84 --- /dev/null +++ b/examples/recurring_asset.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +import json +from connect.config import Config +from connect.resources.subscription import Subscription +# from connect.resources.directory import Directory + +class RecurringAsset(): + configuration = Config(file='examples/config.json') + + def list_recurring_asset(self): + tier = Subscription(config=self.configuration) + return tier._recurring_asset.list() + + def get_recurring_asset(self, id): + tier = Subscription(config=self.configuration) + return tier._recurring_asset.get(id) + + +def main(): + recurring_asset_example = RecurringAsset() + with open('./tests/data/tier_configuration_request.json') as json_file: + data = json.load(json_file) + # tier_account_example.create_tier_account_request(data) + result = recurring_asset_example.get_recurring_asset('AS-3110-7077-0368') + print(result.status) + + # for element in result + # print(element.status) +if __name__ == '__main__': + main() diff --git a/tests/data/response_get_billing_request.json b/tests/data/response_get_billing_request.json new file mode 100644 index 0000000..d8dd43e --- /dev/null +++ b/tests/data/response_get_billing_request.json @@ -0,0 +1,109 @@ +{ + "id": "BRP-3110-7077-0368-0001", + "type": "provider", + "events": { + "created": { + "at": "2020-03-18T10:30:27.742389+00:00" + }, + "updated": { + "at": "2020-03-18T10:30:27.742412+00:00" + } + }, + "asset": { + "id": "AS-3110-7077-0368", + "status": "active", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00" + }, + "updated": { + "at": "2020-03-09T15:50:42+00:00" + } + }, + "external_id": "BSM4FJZ7U3", + "external_uid": "054922da-ceae-47de-8e5d-7a2950acbfe1", + "product": { + "id": "PRD-226-811-341", + "name": "Bender01", + "status": "published", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview" + }, + "params": [ + { + "id": "param_b", + "name": "Coupon", + "description": "Unique activation coupon code", + "type": "text", + "value": "toto" + }, + { + "id": "param_a", + "name": "Color", + "description": "Choose your color", + "type": "text", + "value": "pepe" + } + ], + "tiers": { + "customer": {}, + "tier1": {} + }, + "marketplace": { + "id": "MP-93255", + "name": "Market01", + "icon": "" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": 1.0, + "uom": "monthly" + }, + "next_date": "2020-04-09T15:50:42+00:00", + "anniversary": { + "day": 9 + } + } + }, + "items": [ + { + "id": "SKU_A", + "global_id": "PRD-226-811-341-0001", + "display_name": "Sku A", + "mpn": "MPN-A", + "item_type": "reservation", + "period": "monthly", + "quantity": 50.0, + "type": "Gb", + "billing": { + "cycle_number": 1 + } + } + ], + "attributes": {}, + "period": { + "from": "2019-01-01T00:00:00+00:00", + "to": "2019-10-01T00:00:00+00:00", + "delta": 1.0, + "uom": "monthly" + } +} \ No newline at end of file diff --git a/tests/data/response_get_recurring_asset.json b/tests/data/response_get_recurring_asset.json new file mode 100644 index 0000000..4f114dd --- /dev/null +++ b/tests/data/response_get_recurring_asset.json @@ -0,0 +1,161 @@ +{ + "id": "AS-3110-7077-0368", + "status": "active", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00" + }, + "updated": { + "at": "2020-03-09T15:50:42+00:00" + } + }, + "external_id": "BSM4FJZ7U3", + "external_uid": "054922da-ceae-47de-8e5d-7a2950acbfe1", + "product": { + "id": "PRD-226-811-341", + "name": "Bender01", + "status": "published", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview" + }, + "items": [ + { + "id": "SKU_A", + "global_id": "PRD-226-811-341-0001", + "display_name": "Sku A", + "mpn": "MPN-A", + "item_type": "reservation", + "period": "monthly", + "quantity": 50.0, + "type": "Gb", + "billing": { + "stats": { + "provider": { + "last_request": { + "id": "BRP-3110-7077-0368-0001", + "type": "provider", + "period": { + "from": "2019-01-01T00:00:00+00:00", + "to": "2019-10-01T00:00:00+00:00", + "delta": 1.0, + "uom": "monthly" + } + }, + "count": 1 + } + } + } + } + ], + "params": [ + { + "id": "param_a", + "name": "Color", + "description": "Choose your color", + "type": "text", + "value": "pepe" + }, + { + "id": "param_b", + "name": "Coupon", + "description": "Unique activation coupon code", + "type": "text", + "value": "toto" + } + ], + "tiers": { + "customer": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": {} + } + } + }, + "tier1": { + "id": "TA-6458-9737-0065", + "external_id": "13110", + "external_uid": "ef57c2ba-25f8-49ce-ae81-5d17584ec596", + "name": "string", + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "90", + "area_code": "546", + "phone_number": "6317546" + } + } + } + } + }, + "marketplace": { + "id": "MP-93255", + "name": "Market01", + "icon": "" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": 1.0, + "uom": "monthly" + }, + "next_date": "2020-04-09T15:50:42+00:00", + "anniversary": { + "day": 9 + }, + "stats": { + "provider": { + "last_request": { + "id": "BRP-3110-7077-0368-0001", + "type": "provider", + "period": { + "from": "2019-01-01T00:00:00+00:00", + "to": "2019-10-01T00:00:00+00:00", + "delta": 1.0, + "uom": "monthly" + } + }, + "count": 1 + } + } + } +} \ No newline at end of file diff --git a/tests/data/response_list_billing_request.json b/tests/data/response_list_billing_request.json new file mode 100644 index 0000000..62b53cf --- /dev/null +++ b/tests/data/response_list_billing_request.json @@ -0,0 +1,300 @@ +[ + { + "id": "BRP-7986-6756-4144-0001", + "type": "provider", + "events": { + "created": { + "at": "2020-03-27T09:03:24.371706+00:00" + }, + "updated": { + "at": "2020-03-27T09:03:24.371717+00:00" + } + }, + "asset": { + "id": "AS-7986-6756-4144", + "status": "active", + "events": { + "created": { + "at": "2020-03-25T15:36:55+00:00" + }, + "updated": { + "at": "2020-03-25T15:37:46+00:00" + } + }, + "external_id": "UTD1FD42NL", + "external_uid": "b5682160-cd35-4f34-bd28-a84536686ad8", + "product": { + "id": "PRD-053-648-279", + "name": "Windows XP", + "status": "published", + "icon": "/media/VA-111-016/PRD-053-648-279/media/PRD-053-648-279-logo.png" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview" + }, + "params": [ + { + "id": "param_a", + "name": "Title of the Parameter", + "description": "Description of the Parameter A", + "type": "text", + "value": "" + }, + { + "id": "param_b", + "name": "Title of the Parameter B", + "description": "Description of the Parameter B", + "type": "text", + "value": "pepe" + } + ], + "tiers": { + "customer": { + "id": "TA-9213-6509-6069", + "external_id": "44732", + "external_uid": "3f551945-6406-4c14-9cde-978bb192759e", + "name": "Erdman - Wilderman", + "contact_info": { + "address_line1": "Luciano Shoals", + "address_line2": "Davonte Knolls", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Arnulfo", + "last_name": "Cormier", + "email": "martin.constante++Arnulfo_Cormier@odin.com", + "phone_number": {} + } + } + }, + "tier1": { + "id": "TA-6477-0797-9892", + "external_id": "29378", + "external_uid": "f6cd1139-0bb1-423f-acba-cb233d71d29c", + "name": "McGlynn Inc", + "contact_info": { + "address_line1": "Bailey Keys", + "address_line2": "Considine Shoal", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Luna", + "last_name": "Casper", + "email": "martin.constante++Luna_Casper@odin.com", + "phone_number": {} + } + } + } + }, + "marketplace": { + "id": "MP-93255", + "name": "Market01", + "icon": "" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": 1.0, + "uom": "monthly" + }, + "next_date": "2020-04-25T15:37:46+00:00", + "anniversary": { + "day": 25 + } + } + }, + "items": [ + { + "id": "SKU_A", + "global_id": "PRD-053-648-279-0001", + "display_name": "10 Pax Licence Company Essentials", + "mpn": "MPN-A", + "item_type": "reservation", + "period": "monthly", + "quantity": 11.0, + "type": "Gb", + "billing": { + "cycle_number": 1 + } + } + ], + "attributes": {}, + "period": { + "from": "2019-01-01T00:00:00+00:00", + "to": "2019-10-01T00:00:00+00:00", + "delta": 1.0, + "uom": "monthly" + } + }, + { + "id": "BRP-3110-7077-0368-0001", + "type": "provider", + "events": { + "created": { + "at": "2020-03-18T10:30:27.742389+00:00" + }, + "updated": { + "at": "2020-03-18T10:30:27.742412+00:00" + } + }, + "asset": { + "id": "AS-3110-7077-0368", + "status": "active", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00" + }, + "updated": { + "at": "2020-03-09T15:50:42+00:00" + } + }, + "external_id": "BSM4FJZ7U3", + "external_uid": "054922da-ceae-47de-8e5d-7a2950acbfe1", + "product": { + "id": "PRD-226-811-341", + "name": "Bender01", + "status": "published", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview" + }, + "params": [ + { + "id": "param_a", + "name": "Color", + "description": "Choose your color", + "type": "text", + "value": "pepe" + }, + { + "id": "param_b", + "name": "Coupon", + "description": "Unique activation coupon code", + "type": "text", + "value": "toto" + } + ], + "tiers": { + "customer": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": {} + } + } + }, + "tier1": { + "id": "TA-6458-9737-0065", + "external_id": "13110", + "external_uid": "ef57c2ba-25f8-49ce-ae81-5d17584ec596", + "name": "string", + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "90", + "area_code": "546", + "phone_number": "6317546" + } + } + } + } + }, + "marketplace": { + "id": "MP-93255", + "name": "Market01", + "icon": "" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": 1.0, + "uom": "monthly" + }, + "next_date": "2020-04-09T15:50:42+00:00", + "anniversary": { + "day": 9 + } + } + }, + "items": [ + { + "id": "SKU_A", + "global_id": "PRD-226-811-341-0001", + "display_name": "Sku A", + "mpn": "MPN-A", + "item_type": "reservation", + "period": "monthly", + "quantity": 50.0, + "type": "Gb", + "billing": { + "cycle_number": 1 + } + } + ], + "attributes": {}, + "period": { + "from": "2019-01-01T00:00:00+00:00", + "to": "2019-10-01T00:00:00+00:00", + "delta": 1.0, + "uom": "monthly" + } + } +] \ No newline at end of file diff --git a/tests/data/response_list_recurring_asset.json b/tests/data/response_list_recurring_asset.json new file mode 100644 index 0000000..182c744 --- /dev/null +++ b/tests/data/response_list_recurring_asset.json @@ -0,0 +1,260 @@ +[ + { + "id": "AS-1569-8134-0489", + "status": "active", + "events": { + "created": { + "at": "2020-03-25T10:13:08+00:00" + }, + "updated": { + "at": "2020-03-25T10:14:19+00:00" + } + }, + "external_id": "ABJTERZJC1", + "external_uid": "feb4e10d-7d49-4f47-aebe-5152d21eb8d3", + "product": { + "id": "PRD-226-811-341", + "name": "Bender01", + "status": "published", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview" + }, + "items": [ + { + "id": "SKU_B", + "global_id": "PRD-226-811-341-0002", + "display_name": "Sku B", + "mpn": "MPN-B", + "item_type": "reservation", + "period": "monthly", + "quantity": 39.0, + "type": "Devices" + } + ], + "params": [ + { + "id": "param_a", + "name": "Title of the Parameter A", + "description": "Description of the Parameter A", + "type": "text", + "value": "toto" + }, + { + "id": "param_b", + "name": "Title of the Parameter B", + "description": "Description of the Parameter B", + "type": "text", + "value": "pepe" + } + ], + "tiers": { + "customer": { + "id": "TA-6458-9737-0065", + "external_id": "13110", + "external_uid": "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "name": "string", + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "90", + "area_code": "546", + "phone_number": "6317546" + } + } + } + }, + "tier1": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": {} + } + } + } + }, + "marketplace": { + "id": "MP-93255", + "name": "Market01", + "icon": "" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": 1.0, + "uom": "monthly" + }, + "next_date": "2020-04-25T10:14:19+00:00", + "anniversary": { + "day": 25 + } + } + }, + { + "id": "AS-3110-7077-0368", + "status": "active", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00" + }, + "updated": { + "at": "2020-03-09T15:50:42+00:00" + } + }, + "external_id": "BSM4FJZ7U3", + "external_uid": "054922da-ceae-47de-8e5d-7a2950acbfe1", + "product": { + "id": "PRD-226-811-341", + "name": "Bender01", + "status": "published", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview" + }, + "items": [ + { + "id": "SKU_A", + "global_id": "PRD-226-811-341-0001", + "display_name": "Sku A", + "mpn": "MPN-A", + "item_type": "reservation", + "period": "monthly", + "quantity": 50.0, + "type": "Gb" + } + ], + "params": [ + { + "id": "param_a", + "name": "Color", + "description": "Choose your color", + "type": "text", + "value": "pepe" + }, + { + "id": "param_b", + "name": "Coupon", + "description": "Unique activation coupon code", + "type": "text", + "value": "toto" + } + ], + "tiers": { + "customer": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": {} + } + } + }, + "tier1": { + "id": "TA-6458-9737-0065", + "external_id": "13110", + "external_uid": "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "name": "string", + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "90", + "area_code": "546", + "phone_number": "6317546" + } + } + } + } + }, + "marketplace": { + "id": "MP-93255", + "name": "Market01", + "icon": "" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": 1.0, + "uom": "monthly" + }, + "next_date": "2020-04-09T15:50:42+00:00", + "anniversary": { + "day": 9 + } + } + } +] \ No newline at end of file diff --git a/tests/test_billing_request.py b/tests/test_billing_request.py new file mode 100644 index 0000000..9619b2b --- /dev/null +++ b/tests/test_billing_request.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +import os +import unittest +from mock import patch, call, Mock +from connect.models import BillingRequest +from connect.resources.subscription import BillingRequestResource +from .common import Response, load_str + +get_billing_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_get_billing_request.json')) +list_billing_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_list_billing_request.json')) + +class testBillingRequest(unittest.TestCase): + + @patch('requests.get') + def test_get_billing_request_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, '[' + get_billing_request_contents + ']', 200), + Response(True, get_billing_request_contents, 200) + ] + + request = BillingRequestResource() + billing_request = request.get('BRP-3110-7077-0368-0001') + assert get_mock.call_count == 1 + self.assertEqual(billing_request.type, 'provider', msg=None) + # 054922da-ceae-47de-8e5d-7a2950acbfe1 + + + get_mock.assert_has_calls([ + call( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/requests/BRP-3110-7077-0368-0001') + ]) + assert isinstance(billing_request, BillingRequest) + + @patch('requests.get') + def test_billing_request_empty(self, get_mock): + # type: (Mock) -> None + get_mock.return_value = Response(True, '[]', 200) + + request = BillingRequestResource() + billing_request = request.get('BPR-0000-0000-0000-0000') + assert get_mock.call_count == 1 + + get_mock.assert_has_calls([ + call( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/requests/BPR-0000-0000-0000-0000') + ]) + self.assertEqual(billing_request, [], msg=None) + + @patch('requests.get') + def test_list_billing_request_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, list_billing_request_contents, 200), + Response(True, list_billing_request_contents, 200) + ] + + request = BillingRequestResource() + billing_request = request.list() + assert get_mock.call_count == 1 + + get_mock.assert_has_calls([ + call( + headers={'Authorization': 'ApiKey XXXX:YYYYY', 'Content-Type': 'application/json'}, + params={'limit': 100}, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/requests') + ]) + self.assertEqual(len(billing_request), 2, msg=None) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_recurring_asset.py b/tests/test_recurring_asset.py new file mode 100644 index 0000000..f2a5614 --- /dev/null +++ b/tests/test_recurring_asset.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import datetime +import os +import unittest +from mock import patch, call, Mock +from connect.models import RecurringAsset +from connect.resources.subscription import RecurringAssetResource +from .common import Response, load_str + +get_recurring_asset_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_get_recurring_asset.json')) +list_recurring_asset_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_list_recurring_asset.json')) + +class testRecurringAsset(unittest.TestCase): + + @patch('requests.get') + def test_get_recurring_asset_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, '[' + get_recurring_asset_contents + ']', 200), + Response(True, get_recurring_asset_contents, 200) + ] + + request = RecurringAssetResource() + recurring_asset = request.get('AS-3110-7077-0368') + assert get_mock.call_count == 1 + self.assertEqual(recurring_asset.external_id, 'BSM4FJZ7U3', msg=None) + # 054922da-ceae-47de-8e5d-7a2950acbfe1 + + + get_mock.assert_has_calls([ + call( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/assets/AS-3110-7077-0368') + ]) + assert isinstance(recurring_asset, RecurringAsset) + + @patch('requests.get') + def test_get_recurring_asset_empty(self, get_mock): + # type: (Mock) -> None + get_mock.return_value = Response(True, '[]', 200) + + request = RecurringAssetResource() + recurring_asset = request.get('AS-0000-0000-0000') + assert get_mock.call_count == 1 + + get_mock.assert_has_calls([ + call( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/assets/AS-0000-0000-0000') + ]) + self.assertEqual(recurring_asset, [], msg=None) + + @patch('requests.get') + def test_list_recurring_asset_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, list_recurring_asset_contents, 200), + Response(True, list_recurring_asset_contents, 200) + ] + + request = RecurringAssetResource() + recurring_asset = request.list() + assert get_mock.call_count == 1 + + get_mock.assert_has_calls([ + call( + headers={'Authorization': 'ApiKey XXXX:YYYYY', 'Content-Type': 'application/json'}, + params={'limit': 100}, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/assets') + ]) + self.assertEqual(len(recurring_asset), 2, msg=None) + +if __name__ == "__main__": + unittest.main() From 130050919c87e7605cd2ab168dee8b86b308fc83 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Wed, 1 Apr 2020 18:17:26 +0200 Subject: [PATCH 05/20] Test TCR --- .pylintrc | 3 +- .travis.yml | 2 - connect/models/recurring_asset.py | 1 - connect/resources/billing_request.py | 3 +- connect/resources/fulfillment.py | 14 +- connect/resources/subscription.py | 5 +- connect/resources/tier_account.py | 10 +- ...{tier_config.py => tier_config_request.py} | 7 +- connect/resources/usage_automation.py | 3 - requirements/sdk.txt | 1 + tests/common.py | 8 + .../accept_tier_account_request_response.json | 82 ++++++ tests/data/add_billing_request.json | 17 ++ tests/data/create_tier_account_body.json | 28 ++ .../create_tier_account_request_response.json | 167 +++++++++++ .../data/create_tier_config_request_body.json | 12 + .../get_tier_config_request_response.json | 129 +++++++++ .../ignore_tier_account_request_response.json | 83 ++++++ ...t_tier_configuration_request_response.json | 260 ++++++++++++++++++ tests/data/response_add_billing_request.json | 151 ++++++++++ .../response_get_tier_account_request.json | 86 ++++++ .../response_list_tier_account_request.json | 260 ++++++++++++++++++ tests/test_billing_request.py | 68 ++++- tests/test_recurring_asset.py | 14 +- tests/test_tier_account_request.py | 135 +++++++++ tests/test_tier_config_request.py | 172 ++++++++++++ 26 files changed, 1681 insertions(+), 40 deletions(-) rename connect/resources/{tier_config.py => tier_config_request.py} (97%) create mode 100644 tests/data/accept_tier_account_request_response.json create mode 100644 tests/data/add_billing_request.json create mode 100644 tests/data/create_tier_account_body.json create mode 100644 tests/data/create_tier_account_request_response.json create mode 100644 tests/data/create_tier_config_request_body.json create mode 100644 tests/data/get_tier_config_request_response.json create mode 100644 tests/data/ignore_tier_account_request_response.json create mode 100644 tests/data/list_tier_configuration_request_response.json create mode 100644 tests/data/response_add_billing_request.json create mode 100644 tests/data/response_get_tier_account_request.json create mode 100644 tests/data/response_list_tier_account_request.json create mode 100644 tests/test_tier_account_request.py create mode 100644 tests/test_tier_config_request.py diff --git a/.pylintrc b/.pylintrc index 99c70f8..93580a2 100644 --- a/.pylintrc +++ b/.pylintrc @@ -142,7 +142,8 @@ disable=print-statement, missing-class-docstring, missing-module-docstring, missing-function-docstring, - import-outside-toplevel + import-outside-toplevel, + invalid-name # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/.travis.yml b/.travis.yml index 788b4e4..88dc7d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,6 @@ matrix: - os: linux python: 2.7 env: BUILD=PYPI - - os: linux - python: 3.4 - os: linux python: 3.5 - os: linux diff --git a/connect/models/recurring_asset.py b/connect/models/recurring_asset.py index 9aaa6e5..f731e95 100644 --- a/connect/models/recurring_asset.py +++ b/connect/models/recurring_asset.py @@ -6,7 +6,6 @@ from .base import BaseModel from .schemas import RecurringAssetSchema - class RecurringAsset(BaseModel): """ RecurringAsset object. """ diff --git a/connect/resources/billing_request.py b/connect/resources/billing_request.py index 69c73f9..4447c91 100644 --- a/connect/resources/billing_request.py +++ b/connect/resources/billing_request.py @@ -24,4 +24,5 @@ def update_billing_request(self, id_billing_request, body): path='{}/attributes'.format(id_billing_request), json=body ) - return response \ No newline at end of file + return response + \ No newline at end of file diff --git a/connect/resources/fulfillment.py b/connect/resources/fulfillment.py index d00831a..fd77098 100644 --- a/connect/resources/fulfillment.py +++ b/connect/resources/fulfillment.py @@ -1,5 +1,7 @@ from connect.config import Config from connect.resources.tier_account import TierAccountRequestResource +from connect.resources.tier_config_request import TierConfigRequestResource + class Fulfillment(object): """ Allows listing and obtaining several types of objects. @@ -12,18 +14,20 @@ class Fulfillment(object): def __init__(self, config=None): self._config = config or Config.get_instance() self._tier_account_requests = TierAccountRequestResource(config=self._config) + self._tier_config_requests = TierConfigRequestResource(config=self._config) def create_tier_account_request(self, obj): return self._tier_account_requests.create(obj) - def accept_tier_account_request(self, pk): - return self._tier_account_requests.accept(pk) + def accept_tier_account_request(self, id_tar): + return self._tier_account_requests.accept(id_tar) - def ignore_tier_account_request(self, pk, reason): - return self._tier_account_requests.ignore(pk, reason) + def ignore_tier_account_request(self, id_tar, reason): + return self._tier_account_requests.ignore(id_tar, reason) def get_pending_tier_account_requests(self): return self._tier_account_requests.search(dict(status='pending')) def create_purchase_request(self, obj): - pass \ No newline at end of file + pass + \ No newline at end of file diff --git a/connect/resources/subscription.py b/connect/resources/subscription.py index bad72c3..4c637c1 100644 --- a/connect/resources/subscription.py +++ b/connect/resources/subscription.py @@ -2,7 +2,6 @@ from connect.resources.billing_request import BillingRequestResource from connect.resources.recurring_asset import RecurringAssetResource - class Subscription(object): """ Allows listing and obtaining several types of objects. @@ -19,5 +18,5 @@ def __init__(self, config=None): def create_billing_request(self, obj): return self._billing_request.create(obj) - def update_billing_request(self, pk, body): - return self._billing_request.update_billing_request(pk,body) + def update_billing_request(self, id_br, body): + return self._billing_request.update_billing_request(id_br, body) diff --git a/connect/resources/tier_account.py b/connect/resources/tier_account.py index 761971e..4c34a94 100644 --- a/connect/resources/tier_account.py +++ b/connect/resources/tier_account.py @@ -19,7 +19,7 @@ class TierAccountRequestResource(BaseResource): """ Tier Account Request Resource. """ resource = 'tier/account-requests' model_class = TierAccountRequest - + def accept(self, id_tar): """ Accept a Tier Configuration Request. :param str id_tar: Primary key of the tier configuration request to accept. @@ -28,8 +28,8 @@ def accept(self, id_tar): """ if not id_tar: raise ValueError('Tier Configuration Request not exist') - response = self._api.post(path='{}/accept'.format(id_tar)) - return response + response, _ = self._api.post(path='{}/accept'.format(id_tar)) + return self.model_class.deserialize(response) def ignore(self, id_tar, reason): """ Ignore a Tier Configuration Request @@ -39,9 +39,9 @@ def ignore(self, id_tar, reason): """ if not id_tar: raise ValueError('Tier Configuration Request not exist') - response = self._api.post( + response, _ = self._api.post( path='{}/ignore'.format(id_tar), json={ 'reason': reason, }) - return response + return self.model_class.deserialize(response) diff --git a/connect/resources/tier_config.py b/connect/resources/tier_config_request.py similarity index 97% rename from connect/resources/tier_config.py rename to connect/resources/tier_config_request.py index f7406ca..923e348 100644 --- a/connect/resources/tier_config.py +++ b/connect/resources/tier_config_request.py @@ -62,7 +62,7 @@ def approve(self, id_tcr, id_template): def fail(self, id_tcr, reason): """ Set fail a Tier Configuration Request :param str id_tar: Primary key of the tier configuration request to ignore. - :param str reason: Reason of the fail. + :param str reason: Reason of the fail. :return: ActivationTileResponse object with tile contents. :rtype: ActivationTileResponse """ @@ -85,7 +85,7 @@ def assign(self, id_tcr): raise ValueError('Tier Configuration Request not exist') response = self._api.post(path='{}/assign'.format(id_tcr)) return response - + def unassign(self, id_tcr): """ Unassign a Tier Configuration Request. :param str id_tar: Primary key of the tier configuration request to set. @@ -95,4 +95,5 @@ def unassign(self, id_tcr): if not id_tcr: raise ValueError('Tier Configuration Request not exist') response = self._api.post(path='{}/unassign'.format(id_tcr)) - return response \ No newline at end of file + return response + \ No newline at end of file diff --git a/connect/resources/usage_automation.py b/connect/resources/usage_automation.py index cebd10d..2534d52 100644 --- a/connect/resources/usage_automation.py +++ b/connect/resources/usage_automation.py @@ -52,8 +52,6 @@ def dispatch(self, request): and request.product.id not in self.config.products: return 'Listing not handled by this processor' - '' - self.logger.info(( 'Processing Usage for Product {product_id} ({product_name}) ' 'on Contract {contract_id} ' @@ -65,7 +63,6 @@ def dispatch(self, request): provider_name=request.provider.name, ) ) - try: result = self.process_request(request) except FileCreationError: diff --git a/requirements/sdk.txt b/requirements/sdk.txt index b251dcb..a014e78 100644 --- a/requirements/sdk.txt +++ b/requirements/sdk.txt @@ -3,3 +3,4 @@ marshmallow==2.18.0 openpyxl==2.5.14 requests==2.21.0 six==1.12.0 +mock==2.0.0 diff --git a/tests/common.py b/tests/common.py index 90a38d7..dd45e21 100644 --- a/tests/common.py +++ b/tests/common.py @@ -5,6 +5,7 @@ from collections import namedtuple from typing import Optional +import json Response = namedtuple('Response', ('ok', 'text', 'status_code')) BinaryResponse = namedtuple('BinaryResponse', ('ok', 'content', 'status_code')) @@ -17,3 +18,10 @@ def load_str(filename): return file_handle.read() except IOError: return None + +def load_json(filename): + try: + with open(filename) as file_handle: + return json.loads(file_handle.read()) + except IOError: + return None diff --git a/tests/data/accept_tier_account_request_response.json b/tests/data/accept_tier_account_request_response.json new file mode 100644 index 0000000..43a0231 --- /dev/null +++ b/tests/data/accept_tier_account_request_response.json @@ -0,0 +1,82 @@ +{ + "id": "TAR-6458-9737-0065-004-001", + "type": "update", + "status": "accepted", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "ef57c2ba-25f8-49ce-ae81-5d17584ec596", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00" + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 5, + "contact_info": { + "address_line1": "Yalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Pirulo", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-226-811-341", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png", + "name": "Bender01", + "status": "published" + }, + "events": { + "created": { + "at": "2020-03-11T16:08:39+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-31T11:45:11+00:00" + } + } +} \ No newline at end of file diff --git a/tests/data/add_billing_request.json b/tests/data/add_billing_request.json new file mode 100644 index 0000000..0dbce4b --- /dev/null +++ b/tests/data/add_billing_request.json @@ -0,0 +1,17 @@ +{ + "asset": { + "external_uid": "ec34665f-9322-403f-b01b-a54dedc6cde4" + }, + "type": "provider", + "items": [ + { + "id": "SKU_A" + } + ], + "period": { + "from": "2019-01-01T00:00:00Z", + "to": "2019-10-01T00:00:00Z", + "delta": 1.0, + "uom": "monthly" + } +} \ No newline at end of file diff --git a/tests/data/create_tier_account_body.json b/tests/data/create_tier_account_body.json new file mode 100644 index 0000000..dfda924 --- /dev/null +++ b/tests/data/create_tier_account_body.json @@ -0,0 +1,28 @@ +{ + "type": "update", + "account": { + "id": "TA-6458-9737-0065", + "external_id": "13110", + "external_uid" : "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "name": "string", + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdekk", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + } +} \ No newline at end of file diff --git a/tests/data/create_tier_account_request_response.json b/tests/data/create_tier_account_request_response.json new file mode 100644 index 0000000..3e4fb6f --- /dev/null +++ b/tests/data/create_tier_account_request_response.json @@ -0,0 +1,167 @@ +[ + { + "id": "TAR-6458-9737-0065-004-001", + "type": "update", + "status": "pending", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "ef57c2ba-25f8-49ce-ae81-5d17584ec596", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00" + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 8, + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdekk", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-226-811-341", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png", + "name": "Bender01", + "status": "published" + }, + "events": { + "created": { + "at": "2020-03-31T10:47:13+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-31T10:47:13+00:00" + } + } + }, + { + "id": "TAR-6458-9737-0065-007-002", + "type": "update", + "status": "unsupported", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "ef57c2ba-25f8-49ce-ae81-5d17584ec596", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00" + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 8, + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdekk", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-053-648-279", + "icon": "/media/VA-111-016/PRD-053-648-279/media/PRD-053-648-279-logo.png", + "name": "Windows XP", + "status": "published" + }, + "reason": "Product does not support contact details change.", + "events": { + "created": { + "at": "2020-03-31T10:47:13+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-31T10:47:13+00:00" + } + } + } +] \ No newline at end of file diff --git a/tests/data/create_tier_config_request_body.json b/tests/data/create_tier_config_request_body.json new file mode 100644 index 0000000..829668d --- /dev/null +++ b/tests/data/create_tier_config_request_body.json @@ -0,0 +1,12 @@ +{ + "configuration": { + "product": { + "id": "PRD-418-056-738" + }, + "account": { + "id": "TA-1208-1373-1762", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa" + }, + "tier_level": 1 + } + } \ No newline at end of file diff --git a/tests/data/get_tier_config_request_response.json b/tests/data/get_tier_config_request_response.json new file mode 100644 index 0000000..e5c926e --- /dev/null +++ b/tests/data/get_tier_config_request_response.json @@ -0,0 +1,129 @@ +{ + "id": "TCR-195-110-021-001", + "type": "setup", + "status": "pending", + "configuration": { + "id": "TC-195-110-021", + "name": "Configuration of TA-1208-1373-1762", + "account": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": { + "country_code": "", + "area_code": "", + "phone_number": "", + "extension": "" + } + } + } + }, + "product": { + "id": "PRD-418-056-738", + "icon": "/media/VA-111-016/PRD-418-056-738/media/PRD-418-056-738-logo.png", + "name": "Mobile Assurance", + "status": "published" + }, + "tier_level": 1, + "connection": { + "id": "CT-0000-0000-0000", + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + } + }, + "events": { + "created": { + "at": "2020-04-01T10:05:04+00:00" + }, + "updated": { + "at": "2020-04-01T10:05:04+00:00" + } + }, + "params": [ + { + "id": "param2", + "title": "param2", + "description": "param2", + "type": "text", + "scope": "tier1", + "phase": "ordering", + "constraints": { + "required": false, + "hidden": false, + "unique": false + } + } + ], + "open_request": { + "id": "TCR-195-110-021-001" + }, + "status": "processing", + "marketplace": { + "id": "MP-93255", + "name": "Market01" + } + }, + "events": { + "created": { + "at": "2020-04-01T10:05:04+00:00" + }, + "updated": { + "at": "2020-04-01T10:05:04+00:00" + }, + "pended": { + "at": "2020-04-01T10:05:04+00:00" + } + }, + "params": [], + "environment": "preview", + "tiers": { + "tier1": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": { + "country_code": "", + "area_code": "", + "phone_number": "", + "extension": "" + } + } + } + }, + "tier2": null + } +} \ No newline at end of file diff --git a/tests/data/ignore_tier_account_request_response.json b/tests/data/ignore_tier_account_request_response.json new file mode 100644 index 0000000..7a1a103 --- /dev/null +++ b/tests/data/ignore_tier_account_request_response.json @@ -0,0 +1,83 @@ +{ + "id": "TAR-6458-9737-0065-005-001", + "type": "update", + "status": "ignored", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "ef57c2ba-25f8-49ce-ae81-5d17584ec596", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00" + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 6, + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-226-811-341", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png", + "name": "Bender01", + "status": "published" + }, + "reason": "some reason", + "events": { + "created": { + "at": "2020-03-13T08:53:23+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-31T18:39:06+00:00" + } + } +} \ No newline at end of file diff --git a/tests/data/list_tier_configuration_request_response.json b/tests/data/list_tier_configuration_request_response.json new file mode 100644 index 0000000..9d1a6db --- /dev/null +++ b/tests/data/list_tier_configuration_request_response.json @@ -0,0 +1,260 @@ +[ + { + "id": "TCR-707-778-671-001", + "type": "setup", + "status": "pending", + "configuration": { + "id": "TC-707-778-671", + "name": "Configuration of TA-9213-6509-6069", + "account": { + "id": "TA-9213-6509-6069", + "external_id": "44732", + "external_uid": "3f551945-6406-4c14-9cde-978bb192759e", + "name": "Erdman - Wilderman", + "contact_info": { + "address_line1": "Luciano Shoals", + "address_line2": "Davonte Knolls", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Arnulfo", + "last_name": "Cormier", + "email": "martin.constante++Arnulfo_Cormier@odin.com", + "phone_number": { + "country_code": "", + "area_code": "", + "phone_number": "", + "extension": "" + } + } + } + }, + "product": { + "id": "PRD-418-056-738", + "icon": "/media/VA-111-016/PRD-418-056-738/media/PRD-418-056-738-logo.png", + "name": "Mobile Assurance", + "status": "published" + }, + "tier_level": 1, + "connection": { + "id": "CT-0000-0000-0000", + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + } + }, + "events": { + "created": { + "at": "2020-04-01T12:11:55+00:00" + }, + "updated": { + "at": "2020-04-01T12:11:55+00:00" + } + }, + "params": [ + { + "id": "param2", + "title": "param2", + "description": "param2", + "type": "text", + "scope": "tier1", + "phase": "ordering", + "constraints": { + "required": false, + "hidden": false, + "unique": false + } + } + ], + "open_request": { + "id": "TCR-707-778-671-001" + }, + "status": "processing", + "marketplace": { + "id": "MP-93255", + "name": "Market01" + } + }, + "events": { + "created": { + "at": "2020-04-01T12:11:55+00:00" + }, + "updated": { + "at": "2020-04-01T12:11:55+00:00" + }, + "pended": { + "at": "2020-04-01T12:11:55+00:00" + } + }, + "params": [], + "environment": "preview", + "tiers": { + "tier1": { + "id": "TA-9213-6509-6069", + "external_id": "44732", + "external_uid": "3f551945-6406-4c14-9cde-978bb192759e", + "name": "Erdman - Wilderman", + "contact_info": { + "address_line1": "Luciano Shoals", + "address_line2": "Davonte Knolls", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Arnulfo", + "last_name": "Cormier", + "email": "martin.constante++Arnulfo_Cormier@odin.com", + "phone_number": { + "country_code": "", + "area_code": "", + "phone_number": "", + "extension": "" + } + } + } + }, + "tier2": null + } + }, + { + "id": "TCR-195-110-021-001", + "type": "setup", + "status": "pending", + "configuration": { + "id": "TC-195-110-021", + "name": "Configuration of TA-1208-1373-1762", + "account": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": { + "country_code": "", + "area_code": "", + "phone_number": "", + "extension": "" + } + } + } + }, + "product": { + "id": "PRD-418-056-738", + "icon": "/media/VA-111-016/PRD-418-056-738/media/PRD-418-056-738-logo.png", + "name": "Mobile Assurance", + "status": "published" + }, + "tier_level": 1, + "connection": { + "id": "CT-0000-0000-0000", + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + } + }, + "events": { + "created": { + "at": "2020-04-01T10:05:04+00:00" + }, + "updated": { + "at": "2020-04-01T10:05:04+00:00" + } + }, + "params": [ + { + "id": "param2", + "title": "param2", + "description": "param2", + "type": "text", + "scope": "tier1", + "phase": "ordering", + "constraints": { + "required": false, + "hidden": false, + "unique": false + } + } + ], + "open_request": { + "id": "TCR-195-110-021-001" + }, + "status": "processing", + "marketplace": { + "id": "MP-93255", + "name": "Market01" + } + }, + "events": { + "created": { + "at": "2020-04-01T10:05:04+00:00" + }, + "updated": { + "at": "2020-04-01T10:05:04+00:00" + }, + "pended": { + "at": "2020-04-01T10:05:04+00:00" + } + }, + "params": [], + "environment": "preview", + "tiers": { + "tier1": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": { + "country_code": "", + "area_code": "", + "phone_number": "", + "extension": "" + } + } + } + }, + "tier2": null + } + } +] \ No newline at end of file diff --git a/tests/data/response_add_billing_request.json b/tests/data/response_add_billing_request.json new file mode 100644 index 0000000..1fb7051 --- /dev/null +++ b/tests/data/response_add_billing_request.json @@ -0,0 +1,151 @@ +{ + "id": "BRP-6750-9514-7931-0001", + "type": "provider", + "events": { + "created": { + "at": "2020-03-30T10:51:39.666079+00:00" + }, + "updated": { + "at": "2020-03-30T10:51:39.666090+00:00" + } + }, + "asset": { + "id": "AS-6750-9514-7931", + "status": "active", + "events": { + "created": { + "at": "2020-03-27T08:46:17+00:00" + }, + "updated": { + "at": "2020-03-30T10:47:23+00:00" + } + }, + "external_id": "M86NFM4GCS", + "external_uid": "ec34665f-9322-403f-b01b-a54dedc6cde4", + "product": { + "id": "PRD-053-648-279", + "name": "Windows XP", + "status": "published", + "icon": "/media/VA-111-016/PRD-053-648-279/media/PRD-053-648-279-logo.png" + }, + "connection": { + "id": "CT-0000-0000-0000", + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "type": "preview" + }, + "params": [ + { + "id": "param_a", + "name": "Title of the Parameter", + "description": "Description of the Parameter A", + "type": "text", + "value": "aaa" + }, + { + "id": "param_b", + "name": "Title of the Parameter B", + "description": "Description of the Parameter B", + "type": "text", + "value": "aaaa" + } + ], + "tiers": { + "customer": { + "id": "TA-6458-9737-0065", + "external_id": "13110", + "external_uid": "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "name": "string", + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "90", + "area_code": "546", + "phone_number": "6317546" + } + } + } + }, + "tier1": { + "id": "TA-1208-1373-1762", + "external_id": "75851", + "external_uid": "6a2f37e8-9ad3-4b7c-bed3-601f425d15fa", + "name": "Ratke Group", + "contact_info": { + "address_line1": "Crona Causeway", + "address_line2": "Miles Place", + "city": "Ceuta", + "state": "Ceuta", + "postal_code": "51004", + "country": "ES", + "contact": { + "first_name": "Buford", + "last_name": "Hackett", + "email": "martin.constante++Buford_Hackett@gmail.com", + "phone_number": {} + } + } + } + }, + "marketplace": { + "id": "MP-93255", + "name": "Market01", + "icon": "" + }, + "contract": { + "id": "CRD-00000-00000-00000", + "name": "ACME Distribution Contract" + }, + "billing": { + "period": { + "delta": 1.0, + "uom": "monthly" + }, + "next_date": "2020-04-30T10:47:23+00:00", + "anniversary": { + "day": 30 + } + } + }, + "items": [ + { + "id": "SKU_A", + "global_id": "PRD-053-648-279-0001", + "display_name": "10 Pax Licence Company Essentials", + "mpn": "MPN-A", + "item_type": "reservation", + "period": "monthly", + "quantity": 93.0, + "type": "Gb", + "billing": { + "cycle_number": 1 + } + } + ], + "attributes": {}, + "period": { + "from": "2019-01-01T00:00:00+00:00", + "to": "2019-10-01T00:00:00+00:00", + "delta": 1.0, + "uom": "monthly" + } +} \ No newline at end of file diff --git a/tests/data/response_get_tier_account_request.json b/tests/data/response_get_tier_account_request.json new file mode 100644 index 0000000..c18cba6 --- /dev/null +++ b/tests/data/response_get_tier_account_request.json @@ -0,0 +1,86 @@ +{ + "id": "TAR-6458-9737-0065-004-001", + "type": "update", + "status": "pending", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 5, + "contact_info": { + "address_line1": "Yalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Pirulo", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-226-811-341", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png", + "name": "Bender01", + "status": "published" + }, + "events": { + "created": { + "at": "2020-03-11T16:08:39+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-11T16:08:39+00:00" + } + } +} \ No newline at end of file diff --git a/tests/data/response_list_tier_account_request.json b/tests/data/response_list_tier_account_request.json new file mode 100644 index 0000000..d0836ac --- /dev/null +++ b/tests/data/response_list_tier_account_request.json @@ -0,0 +1,260 @@ +[ + { + "id": "TAR-6458-9737-0065-004-001", + "type": "update", + "status": "pending", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 5, + "contact_info": { + "address_line1": "Yalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Pirulo", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-226-811-341", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png", + "name": "Bender01", + "status": "published" + }, + "events": { + "created": { + "at": "2020-03-11T16:08:39+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-11T16:08:39+00:00" + } + } + }, + { + "id": "TAR-6458-9737-0065-005-001", + "type": "update", + "status": "pending", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 6, + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-226-811-341", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png", + "name": "Bender01", + "status": "published" + }, + "events": { + "created": { + "at": "2020-03-13T08:53:23+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-13T08:53:23+00:00" + } + } + }, + { + "id": "TAR-6458-9737-0065-006-001", + "type": "update", + "status": "pending", + "account": { + "id": "TA-6458-9737-0065", + "environment": "preview", + "name": "string", + "external_id": "13110", + "external_uid": "dac1a3e0-11bb-4ecb-91a5-f57c24a75adc", + "events": { + "created": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + }, + "updated": { + "at": "2020-03-09T14:31:17+00:00", + "by": { + "id": "UR-232-867-185", + "name": "Martin" + } + } + }, + "scopes": [ + "customer", + "tier1" + ], + "marketplace": { + "id": "MP-93255", + "name": "Market01" + }, + "hub": { + "id": "HB-0000-0000", + "name": "ACME Hub" + }, + "version": 7, + "contact_info": { + "address_line1": "Yaaalı Mahallesi", + "address_line2": "", + "city": "Erdek", + "state": "string", + "postal_code": "10www500", + "country": "tr", + "contact": { + "first_name": "Quickstart", + "last_name": "Long Running Operation", + "email": "qlro@softcom.com", + "phone_number": { + "country_code": "+90", + "area_code": "546", + "phone_number": "6317546", + "extension": "" + } + } + } + }, + "vendor": { + "id": "VA-111-016", + "name": "Ingram Micro Cloud" + }, + "provider": { + "id": "PA-687-574", + "name": "Ergonomic even-keeled complexity" + }, + "product": { + "id": "PRD-226-811-341", + "icon": "/media/VA-111-016/PRD-226-811-341/media/PRD-226-811-341-logo.png", + "name": "Bender01", + "status": "published" + }, + "events": { + "created": { + "at": "2020-03-13T08:53:35+00:00", + "by": { + "id": "SU-771-994-269", + "name": "mconstante_provider" + } + }, + "updated": { + "at": "2020-03-13T08:53:35+00:00" + } + } + } +] \ No newline at end of file diff --git a/tests/test_billing_request.py b/tests/test_billing_request.py index 9619b2b..21634ca 100644 --- a/tests/test_billing_request.py +++ b/tests/test_billing_request.py @@ -3,21 +3,32 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. -import datetime import os import unittest -from mock import patch, call, Mock + +from mock import Mock, call, patch + +from connect.config import Config from connect.models import BillingRequest from connect.resources.subscription import BillingRequestResource -from .common import Response, load_str + +from .common import Response, load_json, load_str get_billing_request_contents = load_str( os.path.join(os.path.dirname(__file__), 'data', 'response_get_billing_request.json')) list_billing_request_contents = load_str( os.path.join(os.path.dirname(__file__), 'data', 'response_list_billing_request.json')) +add_billing_request_body = load_json( + os.path.join(os.path.dirname(__file__), 'data', 'add_billing_request.json')) +add_billing_request_response = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_add_billing_request.json')) + class testBillingRequest(unittest.TestCase): + def setUp(self): + self.config = Config(file='tests/config.json') + @patch('requests.get') def test_get_billing_request_ok(self, get_mock): # type: (Mock) -> None @@ -26,7 +37,7 @@ def test_get_billing_request_ok(self, get_mock): Response(True, get_billing_request_contents, 200) ] - request = BillingRequestResource() + request = BillingRequestResource(config=self.config) billing_request = request.get('BRP-3110-7077-0368-0001') assert get_mock.call_count == 1 self.assertEqual(billing_request.type, 'provider', msg=None) @@ -46,15 +57,16 @@ def test_billing_request_empty(self, get_mock): # type: (Mock) -> None get_mock.return_value = Response(True, '[]', 200) - request = BillingRequestResource() + request = BillingRequestResource(config=self.config) billing_request = request.get('BPR-0000-0000-0000-0000') assert get_mock.call_count == 1 - + url = 'http://localhost:8080/api/public/v1/subscriptions/requests/BPR-0000-0000-0000-0000' get_mock.assert_has_calls([ call( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/subscriptions/requests/BPR-0000-0000-0000-0000') + url=url + ) ]) self.assertEqual(billing_request, [], msg=None) @@ -62,11 +74,10 @@ def test_billing_request_empty(self, get_mock): def test_list_billing_request_ok(self, get_mock): # type: (Mock) -> None get_mock.side_effect = [ - Response(True, list_billing_request_contents, 200), Response(True, list_billing_request_contents, 200) ] - request = BillingRequestResource() + request = BillingRequestResource(config=self.config) billing_request = request.list() assert get_mock.call_count == 1 @@ -79,5 +90,44 @@ def test_list_billing_request_ok(self, get_mock): ]) self.assertEqual(len(billing_request), 2, msg=None) + @patch('requests.post') + def test_add_billing_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, add_billing_request_response, 200) + body = add_billing_request_body + # print(body) + request = BillingRequestResource(config=self.config) + billing_request = request.create(body) + + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + json=body, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/requests') + + assert isinstance(billing_request, BillingRequest) + assert billing_request.id == 'BRP-6750-9514-7931-0001' + + + @patch('requests.put') + def test_modify_billing_request(self, put_mock): + modify_billing_request_response = {'provider': {'external_id': '321-123'}} + put_mock.return_value = Response(True, modify_billing_request_response, 200) + body = modify_billing_request_response + # print(body) + pk = 'BRP-6750-9514-7931-0001' + request = BillingRequestResource(config=self.config) + billing_request = request.update_billing_request(pk, body) + print(billing_request) + + put_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + json=body, + timeout=300, + url='http://localhost:8080/api/public/v1/subscriptions/requests/BRP-6750-9514-7931-0001/attributes') + + assert billing_request == ({'provider': {'external_id': '321-123'}}, 200) + + if __name__ == "__main__": unittest.main() diff --git a/tests/test_recurring_asset.py b/tests/test_recurring_asset.py index f2a5614..be3d4ca 100644 --- a/tests/test_recurring_asset.py +++ b/tests/test_recurring_asset.py @@ -3,12 +3,12 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. -import datetime import os import unittest from mock import patch, call, Mock from connect.models import RecurringAsset from connect.resources.subscription import RecurringAssetResource +from connect.config import Config from .common import Response, load_str get_recurring_asset_contents = load_str( @@ -16,7 +16,9 @@ list_recurring_asset_contents = load_str( os.path.join(os.path.dirname(__file__), 'data', 'response_list_recurring_asset.json')) -class testRecurringAsset(unittest.TestCase): +class TestRecurringAsset(unittest.TestCase): + def setUp(self): + self.config = Config(file='tests/config.json') @patch('requests.get') def test_get_recurring_asset_ok(self, get_mock): @@ -26,13 +28,11 @@ def test_get_recurring_asset_ok(self, get_mock): Response(True, get_recurring_asset_contents, 200) ] - request = RecurringAssetResource() + request = RecurringAssetResource(config=self.config) recurring_asset = request.get('AS-3110-7077-0368') assert get_mock.call_count == 1 self.assertEqual(recurring_asset.external_id, 'BSM4FJZ7U3', msg=None) # 054922da-ceae-47de-8e5d-7a2950acbfe1 - - get_mock.assert_has_calls([ call( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, @@ -46,7 +46,7 @@ def test_get_recurring_asset_empty(self, get_mock): # type: (Mock) -> None get_mock.return_value = Response(True, '[]', 200) - request = RecurringAssetResource() + request = RecurringAssetResource(config=self.config) recurring_asset = request.get('AS-0000-0000-0000') assert get_mock.call_count == 1 @@ -66,7 +66,7 @@ def test_list_recurring_asset_ok(self, get_mock): Response(True, list_recurring_asset_contents, 200) ] - request = RecurringAssetResource() + request = RecurringAssetResource(config=self.config) recurring_asset = request.list() assert get_mock.call_count == 1 diff --git a/tests/test_tier_account_request.py b/tests/test_tier_account_request.py new file mode 100644 index 0000000..d40ae9d --- /dev/null +++ b/tests/test_tier_account_request.py @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import os +import unittest +from mock import patch, call, mock +from connect.models import TierAccountRequest +from connect.resources.fulfillment import TierAccountRequestResource +from connect.config import Config +from .common import Response, load_str, load_json + +get_tier_account_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_get_tier_account_request.json')) +list_tier_account_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_list_tier_account_request.json')) +create_tier_account_request_body = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'create_tier_account_request_body.json')) +create_tier_account_request_response = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'create_tier_account_request_response.json')) +accept_tier_account_request_response = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'accept_tier_account_request_response.json')) +ignore_tier_account_request_response = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'ignore_tier_account_request_response.json')) + + +class TestTierAccountRequest(unittest.TestCase): + def setUp(self): + self.config = Config(file='tests/config.json') + + @patch('requests.get') + def test_get_tier_account_request_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, '[' + get_tier_account_request_contents + ']', 200), + Response(True, get_tier_account_request_contents, 200) + ] + + request = TierAccountRequestResource(config=self.config) + tier_account_request = request.get('TAR-6458-9737-0065-004-001') + assert get_mock.call_count == 1 + self.assertEqual(tier_account_request.status, 'pending', msg=None) + # 054922da-ceae-47de-8e5d-7a2950acbfe1 + get_mock.assert_has_calls([ + call( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-6458-9737-0065-004-001') + ]) + assert isinstance(tier_account_request, TierAccountRequest) + + @patch('requests.get') + def test_get_tier_account_request_empty(self, get_mock): + # type: (Mock) -> None + get_mock.return_value = Response(True, '[]', 200) + + request = TierAccountRequestResource(config=self.config) + tier_account_request = request.get('TAR-0000-0000-0000-000-000') + assert get_mock.call_count == 1 + + get_mock.assert_has_calls([ + call( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-0000-0000-0000-000-000') + ]) + self.assertEqual(tier_account_request, [], msg=None) + + @patch('requests.get') + def test_list_tier_account_request_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, list_tier_account_request_contents, 200) + ] + request = TierAccountRequestResource(config=self.config) + tier_account_request = request.list() + assert get_mock.call_count == 1 + get_mock.assert_has_calls([ + call( + headers={'Authorization': 'ApiKey XXXX:YYYYY', 'Content-Type': 'application/json'}, + params={'limit': 100}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/account-requests') + ]) + self.assertEqual(len(tier_account_request), 3, msg=None) + + @patch('requests.post') + def test_create_tier_account_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, create_tier_account_request_response, 200) + body = create_tier_account_request_body + # print(body) + request = TierAccountRequestResource(config=self.config) + tier_account_request = request.create(body) + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + json=body, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/account-requests') + assert tier_account_request[0].id == 'TAR-6458-9737-0065-004-001' + + @patch('requests.post') + def test_accept_tier_account_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, accept_tier_account_request_response, 200) + request = TierAccountRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-004-001' + tier_account_request = request.accept(id_tar) + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-6458-9737-0065-004-001/accept') + # print(tier_account_request) + assert tier_account_request.id == 'TAR-6458-9737-0065-004-001' + + @patch('requests.post') + def test_ignore_tier_account_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, ignore_tier_account_request_response, 200) + request = TierAccountRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-005-001' + tier_account_request = request.ignore(id_tar, 'some reason') + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + json={'reason': 'some reason'}, + url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-6458-9737-0065-005-001/ignore') + assert tier_account_request.id == 'TAR-6458-9737-0065-005-001' + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_tier_config_request.py b/tests/test_tier_config_request.py new file mode 100644 index 0000000..7562a23 --- /dev/null +++ b/tests/test_tier_config_request.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import os +import unittest +from connect.models import TierConfigRequest +from connect.resources.fulfillment import TierConfigRequestResource +from connect.config import Config +from .common import Response, load_str +from mock import patch, call + +get_tier_config_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'get_tier_config_request_response.json')) +list_tier_config_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'list_tier_config_request_response.json')) +create_tier_config_request_body = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'create_tier_config_request_body.json')) + +class TestTierConfigRequest(unittest.TestCase): + def setUp(self): + self.config = Config(file='tests/config.json') + + @patch('requests.get') + def test_get_tier_config_request_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, '[' + get_tier_config_request_contents + ']', 200), + Response(True, get_tier_config_request_contents, 200) + ] + request = TierConfigRequestResource(config=self.config) + tier_config_request = request.get('TCR-6458-9737-0065-004-001') + assert get_mock.call_count == 1 + self.assertEqual(tier_config_request.status, 'pending', msg=None) + # 054922da-ceae-47de-8e5d-7a2950acbfe1 + get_mock.assert_has_calls([ + call( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/config-requests/TCR-6458-9737-0065-004-001') + ]) + assert isinstance(tier_config_request, TierConfigRequest) + + @patch('requests.get') + def test_list_tier_config_request_ok(self, get_mock): + # type: (Mock) -> None + get_mock.side_effect = [ + Response(True, list_tier_config_request_contents, 200) + ] + request = TierConfigRequestResource(config=self.config) + tier_config_request = request.list() + assert get_mock.call_count == 1 + get_mock.assert_has_calls([ + call( + headers={'Authorization': 'ApiKey XXXX:YYYYY', 'Content-Type': 'application/json'}, + params={'limit': 100}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/config-requests') + ]) + self.assertEqual(len(tier_config_request), 3, msg=None) + ''' + @patch('requests.post') + def test_create_tier_config_request(self, post_mock): + # type: (Mock) -> None + body_return = { + "error_code": "VAL_001", + "errors": ["errors: ['Tier Configuration with this Tier level, Tier and Product already exists.']"] + } + post_mock.return_value = Response(True, body_return, 200) + # print(body) + request = TierConfigRequestResource(config=self.config) + tier_config_request = request.create(create_tier_config_request_body) + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + json=create_tier_config_request_body, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/config-requests') + assert tier_config_request[0].id == 'TAR-6458-9737-0065-004-001' + + ''' + @patch('requests.post') + def test_inquire_tier_account_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, '', 204) + request = TierConfigRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-004-001' + tier_config_request = request.inquire(id_tar) + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/inquire') + assert tier_config_request == ('', 204) + + @patch('requests.post') + def test_pending_tier_account_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, '', 200) + request = TierConfigRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-004-001' + tier_config_request = request.pend(id_tar) + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/pend') + assert tier_config_request == ('', 200) + + @patch('requests.post') + def test_assign_tier_account_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, '', 200) + request = TierConfigRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-004-001' + tier_config_request = request.assign(id_tar) + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/assign') + assert tier_config_request == ('', 200) + + @patch('requests.post') + def test_unassign_tier_account_request(self, post_mock): + # type: (Mock) -> None + post_mock.return_value = Response(True, '', 200) + request = TierConfigRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-004-001' + tier_config_request = request.unassign(id_tar) + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/unassign') + assert tier_config_request == ('', 200) + + @patch('requests.post') + def test_approve_tier_account_request(self, post_mock): + # type: (Mock) -> None + body_request = {"template": {"id": "TP-1234-123-123"}} + body_response = {"template": {"id": "TP-123-123-123", "representation": "Rendered template" }} + post_mock.return_value = Response(True, body_response, 200) + request = TierConfigRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-004-001' + tier_config_request = request.approve(id_tar, 'TP-1234-123-123') + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + json=body_request, + url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/approve') + assert tier_config_request == (body_response, 200) + + @patch('requests.post') + def test_fail_tier_account_request(self, post_mock): + # type: (Mock) -> None + body_request = {"reason": "some reason"} + post_mock.return_value = Response(True, '', 204) + request = TierConfigRequestResource(config=self.config) + id_tar = 'TAR-6458-9737-0065-004-001' + tier_config_request = request.fail(id_tar, 'some reason') + assert post_mock.call_count == 1 + post_mock.assert_called_with( + headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, + timeout=300, + json=body_request, + url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/fail') + assert tier_config_request == ('', 204) + +if __name__ == "__main__": + unittest.main() From 8c232e23e9336f35e0c9bd20a32fb10e24a93c8a Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Wed, 1 Apr 2020 18:39:41 +0200 Subject: [PATCH 06/20] Test TCR --- ...est_response.json => list_tier_config_request_response.json} | 0 tests/test_tier_config_request.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/data/{list_tier_configuration_request_response.json => list_tier_config_request_response.json} (100%) diff --git a/tests/data/list_tier_configuration_request_response.json b/tests/data/list_tier_config_request_response.json similarity index 100% rename from tests/data/list_tier_configuration_request_response.json rename to tests/data/list_tier_config_request_response.json diff --git a/tests/test_tier_config_request.py b/tests/test_tier_config_request.py index 7562a23..daa1456 100644 --- a/tests/test_tier_config_request.py +++ b/tests/test_tier_config_request.py @@ -58,7 +58,7 @@ def test_list_tier_config_request_ok(self, get_mock): timeout=300, url='http://localhost:8080/api/public/v1/tier/config-requests') ]) - self.assertEqual(len(tier_config_request), 3, msg=None) + self.assertEqual(len(tier_config_request), 2, msg=None) ''' @patch('requests.post') def test_create_tier_config_request(self, post_mock): From 495b5234dd42a994dd7c4c2c41a283dbba8271f4 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 3 Apr 2020 15:25:34 +0200 Subject: [PATCH 07/20] V19 --- connect/models/activation copy.py | 25 ------ connect/models/attributes copy.py | 22 ----- connect/resources/base.py | 19 ++-- connect/resources/fulfillment.py | 4 + connect/resources/subscription.py | 2 +- .../tier_account_request_automation.py | 88 +++++++++++-------- examples/billing_request.py | 5 +- examples/tier_account_request_automation.py | 40 ++++----- .../response_list_tier_account_request.json | 6 +- tests/test_billing_request.py | 4 +- tests/test_tier_account_request_automation.py | 66 ++++++++++++++ tests/test_tier_config_request.py | 24 ++--- 12 files changed, 175 insertions(+), 130 deletions(-) delete mode 100644 connect/models/activation copy.py delete mode 100644 connect/models/attributes copy.py create mode 100644 tests/test_tier_account_request_automation.py diff --git a/connect/models/activation copy.py b/connect/models/activation copy.py deleted file mode 100644 index 7addc80..0000000 --- a/connect/models/activation copy.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -# This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. - -import datetime -from typing import Optional - -from .base import BaseModel -from .schemas import ActivationSchema - - -class Activation(BaseModel): - """ Activation object. """ - - _schema = ActivationSchema() - - link = None # type: Optional[str] - """ (str|None) Activation link. """ - - message = None # type: str - """ (str) Activation message. """ - - date = None # type: Optional[datetime.datetime] - """ (datetime.datetime|None) Activation date. """ diff --git a/connect/models/attributes copy.py b/connect/models/attributes copy.py deleted file mode 100644 index f5dd2d1..0000000 --- a/connect/models/attributes copy.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- - -# This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. - -import datetime -from typing import Optional - -from .base import BaseModel -from .schemas import AttributesSchema - - -class Attributes(BaseModel): - """ Activation object. """ - - _schema = AttributesSchema() - - vendor = None # type: obj - """ (obj) Attributes Vendor. """ - - provider = None # type: obj - """ (obj) Attributes Provider. """ diff --git a/connect/resources/base.py b/connect/resources/base.py index 69ddc6e..517bfa8 100644 --- a/connect/resources/base.py +++ b/connect/resources/base.py @@ -180,11 +180,20 @@ def create(self, obj): objects = self.model_class.deserialize(response) return objects - def update(self, pk, obj): - pass - - def delete(self, pk): - pass + def update(self, id_obj, body): + """ Update Object + :param str id_item: Primary key of the object request to update. + :param str body: Object to update. + :return: ActivationTileResponse object with tile contents. + :rtype: ActivationTileResponse + """ + if not id_obj: + raise ValueError('Object Request not exist') + response = self._api.put( + path='{}/attributes'.format(id_obj), + json=body + ) + return response def list(self, filters=None): return self.search(filters) \ No newline at end of file diff --git a/connect/resources/fulfillment.py b/connect/resources/fulfillment.py index fd77098..cdfc0f4 100644 --- a/connect/resources/fulfillment.py +++ b/connect/resources/fulfillment.py @@ -28,6 +28,10 @@ def ignore_tier_account_request(self, id_tar, reason): def get_pending_tier_account_requests(self): return self._tier_account_requests.search(dict(status='pending')) + def search_tier_account_requests(self,filters): + return self._tier_account_requests.search(filters) + + def create_purchase_request(self, obj): pass \ No newline at end of file diff --git a/connect/resources/subscription.py b/connect/resources/subscription.py index 4c637c1..8555308 100644 --- a/connect/resources/subscription.py +++ b/connect/resources/subscription.py @@ -19,4 +19,4 @@ def create_billing_request(self, obj): return self._billing_request.create(obj) def update_billing_request(self, id_br, body): - return self._billing_request.update_billing_request(id_br, body) + return self._billing_request.update(id_br, body) diff --git a/connect/resources/tier_account_request_automation.py b/connect/resources/tier_account_request_automation.py index 1405cd8..c4d164a 100644 --- a/connect/resources/tier_account_request_automation.py +++ b/connect/resources/tier_account_request_automation.py @@ -3,55 +3,65 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. -from abc import ABCMeta import logging -from deprecation import deprecated -from typing import Optional - from connect.logger import function_log -from connect.models.tier_account import TierAccount -from connect.models.tier_account_request import TierAccountRequest -from connect.resources.automation_engine import AutomationEngine from connect.resources.fulfillment import Fulfillment -class TierAccountRequestAutomation(AutomationEngine): - """ This is the automation engine for the Tier Account Request API. If you want to process - tier account request, subclass this and implement the ``process_request`` method, which receives a - :py:class:`connect.models.tierAccountRequest` request as argument and must return an - :py:class:`connect.models.ActivationTemplateResponse` or - :py:class:`connect.models.ActivationTileResponse` object in case the request has to be approved. - - In other case, you must raise one of these exceptions: - - - :py:class:`connect.exceptions.InquireRequest`: Inquire for more information. - - :py:class:`connect.exceptions.FailRequest`: Causes the request to fail. - - :py:class:`connect.exceptions.SkipRequest`: Skips processing the request. +class TierAccountRequestAction: + """ This is the automation engine for the Tier Account Request API. If you want to process + Tier Account requests, subclass this and implement the ``process_request`` method, + which receives a :py:class:`connect.models.TierAccountRequest` request as argument and returns + a collection of Tier Account Request Object, this is processed calling to method dispatch and + redirect to proccess_request. + Create an instance of your subclass and call its ``process`` method to begin processing. - For an example on how to use this class, see :ref:`fulfillment_example`. + For an example on how to use this class, see :ref:`tier_account_example`. """ + ACCEPT = 'accept' + IGNORE = 'ignore' + SKIP = 'skip' + + def __init__(self, action, data=None): + if action not in ('accept', 'ignore', 'skip'): + raise Exception("Action no valid") + self._action = action + self._data = data + + @property + def action(self): + return self._action - __metaclass__ = ABCMeta - resource = 'tier/account-requests' - model_class = TierAccountRequest - logger = logging.getLogger('TierAccountRequest.logger') + @property + def data(self): + return self._data + +class TierAccountRequestAutomation: + logger = logging.getLogger(__name__) + + def __init__(self, config): + self.config = config + self.fulfillment = Fulfillment(config=self.config) + + + def process(self, filters=None): + for request in self.fulfillment.search_tier_account_requests( + filters or dict(status='pending') + ): + self.dispatch(request) @function_log(custom_logger=logger) def dispatch(self, request): - tier = Fulfillment(config=self.configuration) - print('==============================') - print(self.config.products) - print('==============================') - # print(tier.get_pending_tier_account_requests()) - print('==============================') - - - ''' - if self.config.products \ - and request.asset.product.id not in self.config.products: - self.logger.info('Invalid Product') - return 'Invalid product' - ''' - \ No newline at end of file + result = self.process_request(request) + if result.action == TierAccountRequestAction.ACCEPT: + self.fulfillment.accept_tier_account_request(request.id) + if result.action == TierAccountRequestAction.IGNORE: + self.fulfillment.ignore_tier_account_request(request.id, result.data) + if result.action == TierAccountRequestAction.SKIP: + pass + + def process_request(self, request): + raise NotImplementedError('Please implement `{}.process_request` method' + .format(self.__class__.__name__)) diff --git a/examples/billing_request.py b/examples/billing_request.py index 88a97a6..f9f1dc9 100644 --- a/examples/billing_request.py +++ b/examples/billing_request.py @@ -23,12 +23,13 @@ def main(): with open('./tests/data/tier_configuration_request.json') as json_file: data = json.load(json_file) # tier_account_example.create_tier_account_request(data) + ''' List example ''' billing_request = billing_request_example.list_billing_request() print(billing_request[0].id) - - ''' Get example + ''' + Get example billing_request = billing_request_example.get_billing_request('BRP-7986-6756-4144-0001') print(billing_request.type) ''' diff --git a/examples/tier_account_request_automation.py b/examples/tier_account_request_automation.py index fb8ce29..4f98ddc 100644 --- a/examples/tier_account_request_automation.py +++ b/examples/tier_account_request_automation.py @@ -2,29 +2,29 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. -# -*- coding: utf-8 -*- - -# This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. -import json +from connect.resources.tier_account_request_automation import ( + TierAccountRequestAutomation, + TierAccountRequestAction, +) from connect.config import Config -from connect.resources.fulfillment import Fulfillment -from connect.resources.directory import Directory -from connect.resources import TierAccountRequestAutomation - -class TierAccountRequestExample(TierAccountRequestAutomation): - configuration = Config(file='examples/config.json') +class MyExampleTARAutomation(TierAccountRequestAutomation): def process_request(self, request): - pass - # return TierAccountRequestAutomation.dispatch(self, request) + if request.account.contact_info.country == 'AR': + stat = TierAccountRequestAction(TierAccountRequestAction.ACCEPT) + print(stat) + return stat + elif request.account.contact_info.country == 'IT': + stat = TierAccountRequestAction(TierAccountRequestAction.IGNORE, 'No data') + print(stat) + return stat + else: + stat = TierAccountRequestAction(TierAccountRequestAction.SKIP) + # print(stat) + return stat -def main(): - tier_account_example = TierAccountRequestExample() - with open('./tests/data/tier_configuration_request.json') as json_file: - data = json.load(json_file) - # tier_account_example.create_tier_account_request(data) - print(tier_account_example.process()) if __name__ == '__main__': - main() \ No newline at end of file + configuration = Config(file='examples/config.json') + tier_account_example = MyExampleTARAutomation(config=configuration) + tier_account_example.process() diff --git a/tests/data/response_list_tier_account_request.json b/tests/data/response_list_tier_account_request.json index d0836ac..f837562 100644 --- a/tests/data/response_list_tier_account_request.json +++ b/tests/data/response_list_tier_account_request.json @@ -44,7 +44,7 @@ "city": "Erdek", "state": "string", "postal_code": "10500", - "country": "tr", + "country": "ES", "contact": { "first_name": "Pirulo", "last_name": "Long Running Operation", @@ -130,7 +130,7 @@ "city": "Erdek", "state": "string", "postal_code": "10500", - "country": "tr", + "country": "AR", "contact": { "first_name": "Quickstart", "last_name": "Long Running Operation", @@ -216,7 +216,7 @@ "city": "Erdek", "state": "string", "postal_code": "10www500", - "country": "tr", + "country": "IT", "contact": { "first_name": "Quickstart", "last_name": "Long Running Operation", diff --git a/tests/test_billing_request.py b/tests/test_billing_request.py index 21634ca..fa6f16f 100644 --- a/tests/test_billing_request.py +++ b/tests/test_billing_request.py @@ -119,12 +119,12 @@ def test_modify_billing_request(self, put_mock): request = BillingRequestResource(config=self.config) billing_request = request.update_billing_request(pk, body) print(billing_request) - + url='http://localhost:8080/api/public/v1/subscriptions/requests/BRP-6750-9514-7931-0001/attributes' put_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, json=body, timeout=300, - url='http://localhost:8080/api/public/v1/subscriptions/requests/BRP-6750-9514-7931-0001/attributes') + url=url) assert billing_request == ({'provider': {'external_id': '321-123'}}, 200) diff --git a/tests/test_tier_account_request_automation.py b/tests/test_tier_account_request_automation.py new file mode 100644 index 0000000..82d368e --- /dev/null +++ b/tests/test_tier_account_request_automation.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2020 Ingram Micro. All Rights Reserved. + +import os +import unittest + +from mock import MagicMock, call, mock, patch + +from connect.config import Config +from connect.resources.tier_account_request_automation import ( + TierAccountRequestAction, TierAccountRequestAutomation) + +from .common import Response, load_json, load_str + +list_tier_account_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_list_tier_account_request.json')) +get_tier_account_request_contents = load_str( + os.path.join(os.path.dirname(__file__), 'data', 'response_get_tier_account_request.json')) + + +def _get_response_list(): + return Response( + ok=True, + text= list_tier_account_request_contents, + status_code=200) + +def _get_response_get(): + return Response( + ok=True, + text= get_tier_account_request_contents, + status_code=200) + + +class MyExampleTARAutomation(TierAccountRequestAutomation): + def process_request(self, request): + print('====================================') + print(request.id, request.account.contact_info.country) + print('====================================') + if request.account.contact_info.country == 'ES': + stat = TierAccountRequestAction(TierAccountRequestAction.ACCEPT) + print(stat) + return stat + elif request.account.contact_info.country == 'IT': + stat = TierAccountRequestAction(TierAccountRequestAction.IGNORE, 'No data') + print(stat) + return stat + else: + stat = TierAccountRequestAction(TierAccountRequestAction.SKIP) + print(stat) + return stat + + +class TestTierAccountRequestAutomation(unittest.TestCase): + def setUp(self): + self.config = Config(file='tests/config.json') + + @patch('requests.post') + @patch('requests.get', MagicMock(return_value=_get_response_list())) + def test_request_automation(self, post_mock): + post_mock.return_value = _get_response_get() + configuration = Config(file='examples/config.json') + tier_account_example = MyExampleTARAutomation(config=configuration) + tier_account_example.process() + assert post_mock.call_count == 2 diff --git a/tests/test_tier_config_request.py b/tests/test_tier_config_request.py index daa1456..ba680e3 100644 --- a/tests/test_tier_config_request.py +++ b/tests/test_tier_config_request.py @@ -5,11 +5,14 @@ import os import unittest + +from mock import call, patch + +from connect.config import Config from connect.models import TierConfigRequest from connect.resources.fulfillment import TierConfigRequestResource -from connect.config import Config + from .common import Response, load_str -from mock import patch, call get_tier_config_request_contents = load_str( os.path.join(os.path.dirname(__file__), 'data', 'get_tier_config_request_response.json')) @@ -34,11 +37,13 @@ def test_get_tier_config_request_ok(self, get_mock): assert get_mock.call_count == 1 self.assertEqual(tier_config_request.status, 'pending', msg=None) # 054922da-ceae-47de-8e5d-7a2950acbfe1 + url = 'http://localhost:8080/api/public/v1/tier/config-requests/TCR-6458-9737-0065-004-001' get_mock.assert_has_calls([ call( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/config-requests/TCR-6458-9737-0065-004-001') + url=url + ) ]) assert isinstance(tier_config_request, TierConfigRequest) @@ -59,15 +64,12 @@ def test_list_tier_config_request_ok(self, get_mock): url='http://localhost:8080/api/public/v1/tier/config-requests') ]) self.assertEqual(len(tier_config_request), 2, msg=None) - ''' + @patch('requests.post') def test_create_tier_config_request(self, post_mock): # type: (Mock) -> None - body_return = { - "error_code": "VAL_001", - "errors": ["errors: ['Tier Configuration with this Tier level, Tier and Product already exists.']"] - } - post_mock.return_value = Response(True, body_return, 200) + body_return = get_tier_config_request_contents + post_mock.return_value = Response(True, body_return, 201) # print(body) request = TierConfigRequestResource(config=self.config) tier_config_request = request.create(create_tier_config_request_body) @@ -76,9 +78,9 @@ def test_create_tier_config_request(self, post_mock): json=create_tier_config_request_body, timeout=300, url='http://localhost:8080/api/public/v1/tier/config-requests') - assert tier_config_request[0].id == 'TAR-6458-9737-0065-004-001' + assert tier_config_request.id == 'TCR-195-110-021-001' - ''' + @patch('requests.post') def test_inquire_tier_account_request(self, post_mock): # type: (Mock) -> None From f167f25381ebc59d4922f843a2007072d7f8620f Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 3 Apr 2020 15:26:12 +0200 Subject: [PATCH 08/20] no message --- .coveragerc | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..38734a2 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,3 @@ +[run] +omit = + connect/models/exception.py \ No newline at end of file From 9866d028012df461a205761f065377e16bab23a1 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 3 Apr 2020 15:35:51 +0200 Subject: [PATCH 09/20] no message --- connect/models/schemas.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/connect/models/schemas.py b/connect/models/schemas.py index 07e2efc..3a1624a 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -374,12 +374,12 @@ def make_object(self, data): class ContractSchema(BaseSchema): name = fields.String() version = fields.Int() - type = fields.String() - status = fields.String() - agreement = fields.Nested(AgreementSchema, only=('id', 'name')) - marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name')) - owner = fields.Nested(CompanySchema, only=('id', 'name')) - creator = fields.Nested(UserSchema, only=('id', 'name')) + type = fields.Str() + status = fields.Str() + agreement = fields.Nested(AgreementSchema) + marketplace = fields.Nested(MarketplaceSchema) + owner = fields.Nested(CompanySchema) + creator = fields.Nested(UserSchema) created = fields.DateTime() updated = fields.DateTime() enrolled = fields.DateTime() From 0018e7e2e7b47ef8dbc8888fead6ce4780728a55 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 3 Apr 2020 15:38:08 +0200 Subject: [PATCH 10/20] no message --- connect/models/schemas.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connect/models/schemas.py b/connect/models/schemas.py index 3a1624a..37e8cc7 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -361,10 +361,10 @@ class AgreementSchema(BaseSchema): version_created = fields.DateTime() version_contracts = fields.Int() agreements = fields.Nested('AgreementSchema', many=True) - parent = fields.Nested('AgreementSchema', only=('id', 'name')) - marketplace = fields.Nested(MarketplaceSchema, only=('id', 'name')) - name = fields.String() - + parent = fields.Nested('AgreementSchema') + marketplace = fields.Nested(MarketplaceSchema) + name = fields.Str() + @post_load def make_object(self, data): from connect.models import Agreement From dd40df6f6713f96aea5f8c07e6f7023d4c076b20 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 3 Apr 2020 18:58:32 +0200 Subject: [PATCH 11/20] Fix Flake8 errors --- connect/models/__init__.py | 4 ++ connect/models/aniversary.py | 3 +- connect/models/attributes.py | 7 +--- connect/models/billing.py | 7 ++-- connect/models/billing_request.py | 21 +++++----- connect/models/company.py | 4 +- connect/models/period.py | 12 +++--- connect/models/recurring_asset.py | 41 +++++++++--------- connect/models/schemas.py | 23 ++++++---- connect/models/stat.py | 7 +--- connect/models/stats.py | 7 +--- connect/models/tier_account.py | 1 + connect/models/tier_account_request.py | 1 + connect/resources/base.py | 6 +-- connect/resources/billing_request.py | 2 +- connect/resources/directory.py | 2 +- connect/resources/fulfillment.py | 4 +- connect/resources/recurring_asset.py | 1 + connect/resources/subscription.py | 1 + connect/resources/tier_account.py | 1 + .../tier_account_request_automation.py | 7 ++-- connect/resources/tier_config_request.py | 4 +- examples/billing_request.py | 12 ++---- examples/recurring_asset.py | 9 ++-- examples/tier_account_request.py | 6 ++- examples/tier_account_request_automation.py | 1 + tests/common.py | 1 + tests/test_billing_request.py | 16 ++++--- tests/test_recurring_asset.py | 2 + tests/test_tier_account_request.py | 25 +++++------ tests/test_tier_account_request_automation.py | 25 +++++------ tests/test_tier_config_request.py | 42 +++++++++---------- 32 files changed, 149 insertions(+), 156 deletions(-) diff --git a/connect/models/__init__.py b/connect/models/__init__.py index 105b62e..cb1b915 100644 --- a/connect/models/__init__.py +++ b/connect/models/__init__.py @@ -72,7 +72,9 @@ 'ActivationTileResponse', 'Agreement', 'AgreementStats', + 'Aniversary', 'Asset', + 'Attributes', 'BaseModel', 'Billing', 'BillingRequest', @@ -100,6 +102,7 @@ 'LastRequest', 'Marketplace', 'Param', + 'Period', 'PhoneNumber', 'Product', 'ProductCategory', @@ -115,6 +118,7 @@ 'Stats', 'Template', 'TierAccount', + 'TierAccountRequest', 'TierAccounts', 'TierConfig', 'TierConfigRequest', diff --git a/connect/models/aniversary.py b/connect/models/aniversary.py index 0c436e8..30f0083 100644 --- a/connect/models/aniversary.py +++ b/connect/models/aniversary.py @@ -6,6 +6,7 @@ from .base import BaseModel from .schemas import AniversarySchema + class Aniversary(BaseModel): """ An Aniversary object. """ @@ -15,4 +16,4 @@ class Aniversary(BaseModel): """ (str) Day of the aniversay. """ month = None # type: str - """ (str) Month of the aniversary. """ \ No newline at end of file + """ (str) Month of the aniversary. """ diff --git a/connect/models/attributes.py b/connect/models/attributes.py index a23feaa..50d0a96 100644 --- a/connect/models/attributes.py +++ b/connect/models/attributes.py @@ -3,9 +3,6 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. -import datetime -from typing import Optional - from .base import BaseModel from .schemas import AttributesSchema @@ -15,8 +12,8 @@ class Attributes(BaseModel): _schema = AttributesSchema() - vendor = None # type: obj + vendor = None # type: object """ (obj) Attributes Vendor. """ - provider = None # type: obj + provider = None # type: object """ (obj) Attributes Provider. """ diff --git a/connect/models/billing.py b/connect/models/billing.py index 56417e4..d21366a 100644 --- a/connect/models/billing.py +++ b/connect/models/billing.py @@ -6,19 +6,20 @@ from .base import BaseModel from .schemas import BillingSchema + class Billing(BaseModel): """ Billing object. """ _schema = BillingSchema() - stats = None # type: Stats + stats = None # type: object """ (:py:class:`.Stats`) Stats of companySchema. """ - period = None # type: Period + period = None # type: object """ (:py:class:`.Period`) Period of the billing. """ next_date = None # type: str """ (str) Next date of the billing. """ - aniversary = None # type: Aniversary + aniversary = None # type: object """ (:py:class:`.Aniversary`) Aniversary. """ diff --git a/connect/models/billing_request.py b/connect/models/billing_request.py index e8b935a..ee00478 100644 --- a/connect/models/billing_request.py +++ b/connect/models/billing_request.py @@ -6,6 +6,7 @@ from .base import BaseModel from .schemas import BillingRequestSchema + class BillingRequest(BaseModel): """ BillingRequest object. """ @@ -14,17 +15,17 @@ class BillingRequest(BaseModel): type = None # type: [str] """ (vendor|provider) Billing Request type. """ - events = None # type: obj - """ (obj) Billing Request Events. """ + events = None # type: object + """ (object) Billing Request Events. """ - asset = None # type: obj - """ (obj) Billing Request Asset. """ + asset = None # type: object + """ (object) Billing Request Asset. """ - item = None # type: obj - """ (obj) Billing Request Item. """ + item = None # type: object + """ (object) Billing Request Item. """ - asset = None # type: obj - """ (obj) Billing Request Asset. """ + asset = None # type: object + """ (object) Billing Request Asset. """ - period = None # type: obj - """ (obj) Billing Request Period. """ + period = None # type: object + """ (object) Billing Request Period. """ diff --git a/connect/models/company.py b/connect/models/company.py index a142df6..01a2338 100644 --- a/connect/models/company.py +++ b/connect/models/company.py @@ -15,8 +15,8 @@ class Company(BaseModel): name = None # type: str """ (str) Company name. """ - last_request = None # type: LastRequest + last_request = None # type: object """ (:py:class:`.LastRequest`) Last Request of companySchema. """ - count = None # type: integer + count = None # type: int """ (integer) Count. """ diff --git a/connect/models/period.py b/connect/models/period.py index aba4a61..1d08409 100644 --- a/connect/models/period.py +++ b/connect/models/period.py @@ -15,14 +15,14 @@ class Period(BaseModel): _schema = PeriodSchema() - period_from = None # type: date - """ (date) Period From. """ + period_from = None # type: Optional[datetime.date] + """ (datetime.date) Period From. """ - period_to = None # type: date - """ (date) Period To. """ + period_to = None # type: Optional[datetime.date] + """ (datetime.date) Period To. """ - delta = None # type: string + delta = None # type: str """ (string) Period Delta. """ - uom = None # type: string + uom = None # type: str """ (string) Period uom. """ diff --git a/connect/models/recurring_asset.py b/connect/models/recurring_asset.py index f731e95..15270e9 100644 --- a/connect/models/recurring_asset.py +++ b/connect/models/recurring_asset.py @@ -6,16 +6,17 @@ from .base import BaseModel from .schemas import RecurringAssetSchema + class RecurringAsset(BaseModel): """ RecurringAsset object. """ _schema = RecurringAssetSchema() - status = None # type: ([)str) + status = None # type: (str) """ (vendor|provider) Billing Request status. """ - events = None # type: obj - """ (obj) Billing Request Events. """ + events = None # type: (object) + """ (object) Billing Request Events. """ external_id = None # type: (str) """ (str) External Id. """ @@ -23,26 +24,26 @@ class RecurringAsset(BaseModel): external_uuid = None # type: (str) """ (str) External uuId. """ - product = None # type: obj - """ (obj) product. """ + product = None # type: (object) + """ (object) product. """ + + connection = None # type: (object) + """ (object) Billing Request connection. """ - connection = None # type: obj - """ (obj) Billing Request connection. """ + items = None # type: (object) + """ (object) Billing Request Item. """ - items = None # type: obj - """ (obj) Billing Request Item. """ + params = None # type: (object) + """ (object) Billing Request Params. """ - params = None # type: obj - """ (obj) Billing Request Params. """ + tiers = None # type: (object) + """ (object) Billing Request tiers. """ - tiers = None # type: obj - """ (obj) Billing Request tiers. """ + marketplace = None # type: (object) + """ (object) Billing Request marketplace. """ - marketplace = None # type: obj - """ (obj) Billing Request marketplace. """ - - contract = None # type: obj - """ (obj) Billing Request Contract. """ + contract = None # type: (object) + """ (object) Billing Request Contract. """ - billing = None # type: obj - """ (obj) Billing Request billing. """ + billing = None # type: (object) + """ (object) Billing Request billing. """ diff --git a/connect/models/schemas.py b/connect/models/schemas.py index 37e8cc7..b02d904 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -31,6 +31,7 @@ def make_object(self, data): from connect.models import Activation return Activation(**data) + class AgreementStatsSchema(BaseSchema): contracts = fields.Int() versions = fields.Int() @@ -40,26 +41,29 @@ def make_object(self, data): from connect.models import AgreementStats return AgreementStats(**data) + class PeriodSchema(BaseSchema): period_from = fields.DateTime(data_key='from') period_to = fields.DateTime(data_key='to') delta = fields.Decimal() uom = fields.Str() - + @post_load def make_object(self, data): from connect.models import Period return Period(**data) + class LastRequestSchema(BaseSchema): type = fields.String() period = fields.Nested(PeriodSchema) - + @post_load def make_object(self, data): from connect.models import LastRequest return LastRequest(**data) + class CompanySchema(BaseSchema): name = fields.Str() last_request = fields.Nested(LastRequestSchema, many=True) @@ -364,7 +368,7 @@ class AgreementSchema(BaseSchema): parent = fields.Nested('AgreementSchema') marketplace = fields.Nested(MarketplaceSchema) name = fields.Str() - + @post_load def make_object(self, data): from connect.models import Agreement @@ -572,7 +576,6 @@ def make_object(self, data): return TierAccountRequest(**data) - class ConnectionSchema(BaseSchema): type = fields.Str() provider = fields.Nested(CompanySchema, only=('id', 'name')) @@ -779,15 +782,17 @@ def make_object(self, data): from connect.models import Conversation return Conversation(**data) + class AttributesSchema(BaseSchema): provider = fields.Nested(CompanySchema, only=('external_id')) vendor = fields.Nested(CompanySchema, only=('external_id')) - + @post_load def make_object(self, data): from connect.models import Attributes return Attributes(**data) + class AniversarySchema(BaseSchema): day = fields.Integer() month = fields.Integer() @@ -797,6 +802,7 @@ def make_object(self, data): from connect.models import Aniversary return Aniversary(**data) + class StatSchema(BaseSchema): count = fields.Integer() last_request = fields.Nested(LastRequestSchema) @@ -816,6 +822,7 @@ def make_object(self, data): from connect.models import Stats return Stats(**data) + class BillingSchema(BaseSchema): stats = fields.Nested(StatsSchema) period = fields.Nested(PeriodSchema) @@ -827,6 +834,7 @@ def make_object(self, data): from connect.models import Billing return Billing(**data) + class BillingRequestSchema(BaseSchema): type = fields.String() events = fields.Nested(EventsSchema, only=('created', 'updated')) @@ -840,6 +848,7 @@ def make_object(self, data): from connect.models import BillingRequest return BillingRequest(**data) + class RecurringAssetSchema(BaseSchema): id = fields.String() status = fields.String() @@ -859,7 +868,3 @@ class RecurringAssetSchema(BaseSchema): def make_object(self, data): from connect.models import RecurringAsset return RecurringAsset(**data) - - - - diff --git a/connect/models/stat.py b/connect/models/stat.py index b5e8e82..4418564 100644 --- a/connect/models/stat.py +++ b/connect/models/stat.py @@ -3,9 +3,6 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. -import datetime -from typing import Optional - from .base import BaseModel from .schemas import StatSchema @@ -15,8 +12,8 @@ class Stat(BaseModel): _schema = StatSchema() - count = None # type: Int + count = None # type: int """ (Int) Count. """ - last_request = None # type: last_request + last_request = None # type: last_request """ (:py:class:`.LastRequest`) Last Request. """ diff --git a/connect/models/stats.py b/connect/models/stats.py index a270592..5a7bd2a 100644 --- a/connect/models/stats.py +++ b/connect/models/stats.py @@ -3,9 +3,6 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. -import datetime -from typing import Optional - from .base import BaseModel from .schemas import StatsSchema @@ -15,8 +12,8 @@ class Stats(BaseModel): _schema = StatsSchema() - vendor = None # type: Company + vendor = None # type: object """ (:py:class:`.Company`) Vendor. """ - provider = None # type: Company + provider = None # type: object """ (:py:class:`.Company`) Provider. """ diff --git a/connect/models/tier_account.py b/connect/models/tier_account.py index 083a783..7592158 100644 --- a/connect/models/tier_account.py +++ b/connect/models/tier_account.py @@ -6,6 +6,7 @@ from .base import BaseModel from .schemas import TierAccountSchema + class TierAccount(BaseModel): """ Tier account. """ diff --git a/connect/models/tier_account_request.py b/connect/models/tier_account_request.py index f19416b..dcb229a 100644 --- a/connect/models/tier_account_request.py +++ b/connect/models/tier_account_request.py @@ -6,6 +6,7 @@ from .base import BaseModel from .schemas import TierAccountRequestSchema + class TierAccountRequest(BaseModel): """ Tier account request. """ _schema = TierAccountRequestSchema() diff --git a/connect/resources/base.py b/connect/resources/base.py index 517bfa8..b636b66 100644 --- a/connect/resources/base.py +++ b/connect/resources/base.py @@ -5,7 +5,7 @@ import functools import logging -from typing import Any, List, Dict, Tuple, Union +from typing import Any, List, Dict, Tuple import requests from requests import compat @@ -152,7 +152,6 @@ def get(self, pk): return objects[0] return objects - def filters(self, **kwargs): # type: (Dict[str, Any]) -> Dict[str, Any] filters = {} @@ -174,7 +173,6 @@ def search(self, filters=None): response, _ = self._api.get(params=filters) return self.model_class.deserialize(response) - def create(self, obj): response, _ = self._api.post(json=obj) objects = self.model_class.deserialize(response) @@ -196,4 +194,4 @@ def update(self, id_obj, body): return response def list(self, filters=None): - return self.search(filters) \ No newline at end of file + return self.search(filters) diff --git a/connect/resources/billing_request.py b/connect/resources/billing_request.py index 4447c91..d4fd515 100644 --- a/connect/resources/billing_request.py +++ b/connect/resources/billing_request.py @@ -6,6 +6,7 @@ from connect.models.billing_request import BillingRequest from .base import BaseResource + class BillingRequestResource(BaseResource): """ Billing Request Request Resource. """ resource = 'subscriptions/requests' @@ -25,4 +26,3 @@ def update_billing_request(self, id_billing_request, body): json=body ) return response - \ No newline at end of file diff --git a/connect/resources/directory.py b/connect/resources/directory.py index 7dba82e..6fa92d2 100644 --- a/connect/resources/directory.py +++ b/connect/resources/directory.py @@ -105,4 +105,4 @@ def search_tier_accounts(self, filters): return self._tier_accounts.search(filters) def get_tier_account(self, pk): - return self._tier_accounts.get(pk) \ No newline at end of file + return self._tier_accounts.get(pk) diff --git a/connect/resources/fulfillment.py b/connect/resources/fulfillment.py index cdfc0f4..abab1ad 100644 --- a/connect/resources/fulfillment.py +++ b/connect/resources/fulfillment.py @@ -28,10 +28,8 @@ def ignore_tier_account_request(self, id_tar, reason): def get_pending_tier_account_requests(self): return self._tier_account_requests.search(dict(status='pending')) - def search_tier_account_requests(self,filters): + def search_tier_account_requests(self, filters): return self._tier_account_requests.search(filters) - def create_purchase_request(self, obj): pass - \ No newline at end of file diff --git a/connect/resources/recurring_asset.py b/connect/resources/recurring_asset.py index b9a5147..c3bf222 100644 --- a/connect/resources/recurring_asset.py +++ b/connect/resources/recurring_asset.py @@ -6,6 +6,7 @@ from connect.models.recurring_asset import RecurringAsset from .base import BaseResource + class RecurringAssetResource(BaseResource): """ Recurring Asset Request Resource. """ resource = 'subscriptions/assets' diff --git a/connect/resources/subscription.py b/connect/resources/subscription.py index 8555308..3e83405 100644 --- a/connect/resources/subscription.py +++ b/connect/resources/subscription.py @@ -2,6 +2,7 @@ from connect.resources.billing_request import BillingRequestResource from connect.resources.recurring_asset import RecurringAssetResource + class Subscription(object): """ Allows listing and obtaining several types of objects. diff --git a/connect/resources/tier_account.py b/connect/resources/tier_account.py index 4c34a94..7c50022 100644 --- a/connect/resources/tier_account.py +++ b/connect/resources/tier_account.py @@ -15,6 +15,7 @@ class TierAccountResource(BaseResource): resource = 'tier/accounts' model_class = TierAccount + class TierAccountRequestResource(BaseResource): """ Tier Account Request Resource. """ resource = 'tier/account-requests' diff --git a/connect/resources/tier_account_request_automation.py b/connect/resources/tier_account_request_automation.py index c4d164a..714e3f2 100644 --- a/connect/resources/tier_account_request_automation.py +++ b/connect/resources/tier_account_request_automation.py @@ -12,10 +12,9 @@ class TierAccountRequestAction: """ This is the automation engine for the Tier Account Request API. If you want to process Tier Account requests, subclass this and implement the ``process_request`` method, - which receives a :py:class:`connect.models.TierAccountRequest` request as argument and returns - a collection of Tier Account Request Object, this is processed calling to method dispatch and + which receives a :py:class:`connect.models.TierAccountRequest` request as argument and returns + a collection of Tier Account Request Object, this is processed calling to method dispatch and redirect to proccess_request. - Create an instance of your subclass and call its ``process`` method to begin processing. For an example on how to use this class, see :ref:`tier_account_example`. @@ -38,6 +37,7 @@ def action(self): def data(self): return self._data + class TierAccountRequestAutomation: logger = logging.getLogger(__name__) @@ -45,7 +45,6 @@ def __init__(self, config): self.config = config self.fulfillment = Fulfillment(config=self.config) - def process(self, filters=None): for request in self.fulfillment.search_tier_account_requests( filters or dict(status='pending') diff --git a/connect/resources/tier_config_request.py b/connect/resources/tier_config_request.py index 923e348..610b8df 100644 --- a/connect/resources/tier_config_request.py +++ b/connect/resources/tier_config_request.py @@ -14,11 +14,12 @@ class TierConfigResource(BaseResource): resource = 'tier/configs' model_class = TierConfig + class TierConfigRequestResource(BaseResource): """ Tier Config Request Resource. """ resource = 'tier/config-requests' model_class = TierConfigRequest - + def pend(self, id_tcr): """ Set a Tier Configuration Request to pend status. :param str id_tar: Primary key of the tier configuration request to set. @@ -96,4 +97,3 @@ def unassign(self, id_tcr): raise ValueError('Tier Configuration Request not exist') response = self._api.post(path='{}/unassign'.format(id_tcr)) return response - \ No newline at end of file diff --git a/examples/billing_request.py b/examples/billing_request.py index f9f1dc9..e614cd1 100644 --- a/examples/billing_request.py +++ b/examples/billing_request.py @@ -5,7 +5,7 @@ import json from connect.config import Config from connect.resources.subscription import Subscription -# from connect.resources.directory import Directory + class BillingRequest(): configuration = Config(file='examples/config.json') @@ -14,25 +14,21 @@ def list_billing_request(self): tier = Subscription(config=self.configuration) return tier._billing_request.list() - def get_billing_request(self,id): + def get_billing_request(self, id): tier = Subscription(config=self.configuration) return tier._billing_request.get(id) + def main(): billing_request_example = BillingRequest() with open('./tests/data/tier_configuration_request.json') as json_file: data = json.load(json_file) - # tier_account_example.create_tier_account_request(data) + billing_request_example.create_tier_account_request(data) ''' List example ''' billing_request = billing_request_example.list_billing_request() print(billing_request[0].id) - ''' - Get example - billing_request = billing_request_example.get_billing_request('BRP-7986-6756-4144-0001') - print(billing_request.type) - ''' if __name__ == '__main__': main() diff --git a/examples/recurring_asset.py b/examples/recurring_asset.py index 9461a84..b83ebc1 100644 --- a/examples/recurring_asset.py +++ b/examples/recurring_asset.py @@ -5,7 +5,7 @@ import json from connect.config import Config from connect.resources.subscription import Subscription -# from connect.resources.directory import Directory + class RecurringAsset(): configuration = Config(file='examples/config.json') @@ -23,11 +23,10 @@ def main(): recurring_asset_example = RecurringAsset() with open('./tests/data/tier_configuration_request.json') as json_file: data = json.load(json_file) - # tier_account_example.create_tier_account_request(data) + recurring_asset_example.create_tier_account_request(data) result = recurring_asset_example.get_recurring_asset('AS-3110-7077-0368') print(result.status) - - # for element in result - # print(element.status) + + if __name__ == '__main__': main() diff --git a/examples/tier_account_request.py b/examples/tier_account_request.py index b1af6a9..d43f812 100644 --- a/examples/tier_account_request.py +++ b/examples/tier_account_request.py @@ -7,6 +7,7 @@ from connect.resources.fulfillment import Fulfillment from connect.resources.directory import Directory + class TierAccountRequest(): configuration = Config(file='examples/config.json') @@ -37,11 +38,14 @@ def create_tier_account_request(self, data): response = tier.create_tier_account_request(data) print(response) + def main(): tier_account_example = TierAccountRequest() with open('./tests/data/tier_configuration_request.json') as json_file: data = json.load(json_file) - # tier_account_example.create_tier_account_request(data) + tier_account_example.create_tier_account_request(data) print(tier_account_example.get_tier_account()) + + if __name__ == '__main__': main() diff --git a/examples/tier_account_request_automation.py b/examples/tier_account_request_automation.py index 4f98ddc..15d570b 100644 --- a/examples/tier_account_request_automation.py +++ b/examples/tier_account_request_automation.py @@ -8,6 +8,7 @@ ) from connect.config import Config + class MyExampleTARAutomation(TierAccountRequestAutomation): def process_request(self, request): if request.account.contact_info.country == 'AR': diff --git a/tests/common.py b/tests/common.py index dd45e21..136a9e5 100644 --- a/tests/common.py +++ b/tests/common.py @@ -19,6 +19,7 @@ def load_str(filename): except IOError: return None + def load_json(filename): try: with open(filename) as file_handle: diff --git a/tests/test_billing_request.py b/tests/test_billing_request.py index fa6f16f..1a1c837 100644 --- a/tests/test_billing_request.py +++ b/tests/test_billing_request.py @@ -25,10 +25,10 @@ class testBillingRequest(unittest.TestCase): - + def setUp(self): self.config = Config(file='tests/config.json') - + @patch('requests.get') def test_get_billing_request_ok(self, get_mock): # type: (Mock) -> None @@ -43,12 +43,12 @@ def test_get_billing_request_ok(self, get_mock): self.assertEqual(billing_request.type, 'provider', msg=None) # 054922da-ceae-47de-8e5d-7a2950acbfe1 - get_mock.assert_has_calls([ call( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/subscriptions/requests/BRP-3110-7077-0368-0001') + url=('http://localhost:8080/api/public/v1/' + 'subscriptions/requests/BRP-3110-7077-0368-0001')) ]) assert isinstance(billing_request, BillingRequest) @@ -69,7 +69,7 @@ def test_billing_request_empty(self, get_mock): ) ]) self.assertEqual(billing_request, [], msg=None) - + @patch('requests.get') def test_list_billing_request_ok(self, get_mock): # type: (Mock) -> None @@ -95,7 +95,6 @@ def test_add_billing_request(self, post_mock): # type: (Mock) -> None post_mock.return_value = Response(True, add_billing_request_response, 200) body = add_billing_request_body - # print(body) request = BillingRequestResource(config=self.config) billing_request = request.create(body) @@ -108,18 +107,17 @@ def test_add_billing_request(self, post_mock): assert isinstance(billing_request, BillingRequest) assert billing_request.id == 'BRP-6750-9514-7931-0001' - @patch('requests.put') def test_modify_billing_request(self, put_mock): modify_billing_request_response = {'provider': {'external_id': '321-123'}} put_mock.return_value = Response(True, modify_billing_request_response, 200) body = modify_billing_request_response - # print(body) pk = 'BRP-6750-9514-7931-0001' request = BillingRequestResource(config=self.config) billing_request = request.update_billing_request(pk, body) print(billing_request) - url='http://localhost:8080/api/public/v1/subscriptions/requests/BRP-6750-9514-7931-0001/attributes' + url = ('http://localhost:8080/api/public/v1' + '/subscriptions/requests/BRP-6750-9514-7931-0001/attributes') put_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, json=body, diff --git a/tests/test_recurring_asset.py b/tests/test_recurring_asset.py index be3d4ca..66cecd0 100644 --- a/tests/test_recurring_asset.py +++ b/tests/test_recurring_asset.py @@ -16,6 +16,7 @@ list_recurring_asset_contents = load_str( os.path.join(os.path.dirname(__file__), 'data', 'response_list_recurring_asset.json')) + class TestRecurringAsset(unittest.TestCase): def setUp(self): self.config = Config(file='tests/config.json') @@ -79,5 +80,6 @@ def test_list_recurring_asset_ok(self, get_mock): ]) self.assertEqual(len(recurring_asset), 2, msg=None) + if __name__ == "__main__": unittest.main() diff --git a/tests/test_tier_account_request.py b/tests/test_tier_account_request.py index d40ae9d..1872af0 100644 --- a/tests/test_tier_account_request.py +++ b/tests/test_tier_account_request.py @@ -1,15 +1,14 @@ # -*- coding: utf-8 -*- - # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2020 Ingram Micro. All Rights Reserved. import os import unittest -from mock import patch, call, mock +from mock import patch, call from connect.models import TierAccountRequest from connect.resources.fulfillment import TierAccountRequestResource from connect.config import Config -from .common import Response, load_str, load_json +from .common import Response, load_str get_tier_account_request_contents = load_str( os.path.join(os.path.dirname(__file__), 'data', 'response_get_tier_account_request.json')) @@ -31,7 +30,6 @@ def setUp(self): @patch('requests.get') def test_get_tier_account_request_ok(self, get_mock): - # type: (Mock) -> None get_mock.side_effect = [ Response(True, '[' + get_tier_account_request_contents + ']', 200), Response(True, get_tier_account_request_contents, 200) @@ -46,13 +44,13 @@ def test_get_tier_account_request_ok(self, get_mock): call( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-6458-9737-0065-004-001') + url=('http://localhost:8080/api/public/' + 'v1/tier/account-requests/TAR-6458-9737-0065-004-001')) ]) assert isinstance(tier_account_request, TierAccountRequest) @patch('requests.get') def test_get_tier_account_request_empty(self, get_mock): - # type: (Mock) -> None get_mock.return_value = Response(True, '[]', 200) request = TierAccountRequestResource(config=self.config) @@ -63,13 +61,13 @@ def test_get_tier_account_request_empty(self, get_mock): call( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-0000-0000-0000-000-000') + url=('http://localhost:8080/api/public/v1/' + 'tier/account-requests/TAR-0000-0000-0000-000-000')) ]) self.assertEqual(tier_account_request, [], msg=None) @patch('requests.get') def test_list_tier_account_request_ok(self, get_mock): - # type: (Mock) -> None get_mock.side_effect = [ Response(True, list_tier_account_request_contents, 200) ] @@ -87,10 +85,8 @@ def test_list_tier_account_request_ok(self, get_mock): @patch('requests.post') def test_create_tier_account_request(self, post_mock): - # type: (Mock) -> None post_mock.return_value = Response(True, create_tier_account_request_response, 200) body = create_tier_account_request_body - # print(body) request = TierAccountRequestResource(config=self.config) tier_account_request = request.create(body) post_mock.assert_called_with( @@ -102,7 +98,6 @@ def test_create_tier_account_request(self, post_mock): @patch('requests.post') def test_accept_tier_account_request(self, post_mock): - # type: (Mock) -> None post_mock.return_value = Response(True, accept_tier_account_request_response, 200) request = TierAccountRequestResource(config=self.config) id_tar = 'TAR-6458-9737-0065-004-001' @@ -111,13 +106,12 @@ def test_accept_tier_account_request(self, post_mock): post_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-6458-9737-0065-004-001/accept') - # print(tier_account_request) + url=('http://localhost:8080/api/public/v1/' + 'tier/account-requests/TAR-6458-9737-0065-004-001/accept')) assert tier_account_request.id == 'TAR-6458-9737-0065-004-001' @patch('requests.post') def test_ignore_tier_account_request(self, post_mock): - # type: (Mock) -> None post_mock.return_value = Response(True, ignore_tier_account_request_response, 200) request = TierAccountRequestResource(config=self.config) id_tar = 'TAR-6458-9737-0065-005-001' @@ -127,7 +121,8 @@ def test_ignore_tier_account_request(self, post_mock): headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, json={'reason': 'some reason'}, - url='http://localhost:8080/api/public/v1/tier/account-requests/TAR-6458-9737-0065-005-001/ignore') + url=('http://localhost:8080/api/public/v1/' + 'tier/account-requests/TAR-6458-9737-0065-005-001/ignore')) assert tier_account_request.id == 'TAR-6458-9737-0065-005-001' diff --git a/tests/test_tier_account_request_automation.py b/tests/test_tier_account_request_automation.py index 82d368e..275b11b 100644 --- a/tests/test_tier_account_request_automation.py +++ b/tests/test_tier_account_request_automation.py @@ -6,13 +6,13 @@ import os import unittest -from mock import MagicMock, call, mock, patch +from mock import MagicMock, patch from connect.config import Config from connect.resources.tier_account_request_automation import ( TierAccountRequestAction, TierAccountRequestAutomation) -from .common import Response, load_json, load_str +from .common import Response, load_str list_tier_account_request_contents = load_str( os.path.join(os.path.dirname(__file__), 'data', 'response_list_tier_account_request.json')) @@ -23,13 +23,14 @@ def _get_response_list(): return Response( ok=True, - text= list_tier_account_request_contents, + text=list_tier_account_request_contents, status_code=200) + def _get_response_get(): return Response( ok=True, - text= get_tier_account_request_contents, + text=get_tier_account_request_contents, status_code=200) @@ -39,23 +40,17 @@ def process_request(self, request): print(request.id, request.account.contact_info.country) print('====================================') if request.account.contact_info.country == 'ES': - stat = TierAccountRequestAction(TierAccountRequestAction.ACCEPT) - print(stat) - return stat + return TierAccountRequestAction(TierAccountRequestAction.ACCEPT) elif request.account.contact_info.country == 'IT': - stat = TierAccountRequestAction(TierAccountRequestAction.IGNORE, 'No data') - print(stat) - return stat + return TierAccountRequestAction(TierAccountRequestAction.IGNORE, 'No data') else: - stat = TierAccountRequestAction(TierAccountRequestAction.SKIP) - print(stat) - return stat + return TierAccountRequestAction(TierAccountRequestAction.SKIP) class TestTierAccountRequestAutomation(unittest.TestCase): def setUp(self): self.config = Config(file='tests/config.json') - + @patch('requests.post') @patch('requests.get', MagicMock(return_value=_get_response_list())) def test_request_automation(self, post_mock): @@ -63,4 +58,4 @@ def test_request_automation(self, post_mock): configuration = Config(file='examples/config.json') tier_account_example = MyExampleTARAutomation(config=configuration) tier_account_example.process() - assert post_mock.call_count == 2 + assert post_mock.call_count == 2 diff --git a/tests/test_tier_config_request.py b/tests/test_tier_config_request.py index ba680e3..e4692f2 100644 --- a/tests/test_tier_config_request.py +++ b/tests/test_tier_config_request.py @@ -21,13 +21,14 @@ create_tier_config_request_body = load_str( os.path.join(os.path.dirname(__file__), 'data', 'create_tier_config_request_body.json')) + class TestTierConfigRequest(unittest.TestCase): def setUp(self): self.config = Config(file='tests/config.json') - + @patch('requests.get') def test_get_tier_config_request_ok(self, get_mock): - # type: (Mock) -> None + get_mock.side_effect = [ Response(True, '[' + get_tier_config_request_contents + ']', 200), Response(True, get_tier_config_request_contents, 200) @@ -46,10 +47,9 @@ def test_get_tier_config_request_ok(self, get_mock): ) ]) assert isinstance(tier_config_request, TierConfigRequest) - + @patch('requests.get') def test_list_tier_config_request_ok(self, get_mock): - # type: (Mock) -> None get_mock.side_effect = [ Response(True, list_tier_config_request_contents, 200) ] @@ -67,10 +67,8 @@ def test_list_tier_config_request_ok(self, get_mock): @patch('requests.post') def test_create_tier_config_request(self, post_mock): - # type: (Mock) -> None body_return = get_tier_config_request_contents post_mock.return_value = Response(True, body_return, 201) - # print(body) request = TierConfigRequestResource(config=self.config) tier_config_request = request.create(create_tier_config_request_body) post_mock.assert_called_with( @@ -80,10 +78,8 @@ def test_create_tier_config_request(self, post_mock): url='http://localhost:8080/api/public/v1/tier/config-requests') assert tier_config_request.id == 'TCR-195-110-021-001' - @patch('requests.post') def test_inquire_tier_account_request(self, post_mock): - # type: (Mock) -> None post_mock.return_value = Response(True, '', 204) request = TierConfigRequestResource(config=self.config) id_tar = 'TAR-6458-9737-0065-004-001' @@ -92,12 +88,12 @@ def test_inquire_tier_account_request(self, post_mock): post_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/inquire') + url=('http://localhost:8080/api/public/v1/' + 'tier/config-requests/TAR-6458-9737-0065-004-001/inquire')) assert tier_config_request == ('', 204) @patch('requests.post') def test_pending_tier_account_request(self, post_mock): - # type: (Mock) -> None post_mock.return_value = Response(True, '', 200) request = TierConfigRequestResource(config=self.config) id_tar = 'TAR-6458-9737-0065-004-001' @@ -106,12 +102,12 @@ def test_pending_tier_account_request(self, post_mock): post_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/pend') + url=('http://localhost:8080/api/public/v1/' + 'tier/config-requests/TAR-6458-9737-0065-004-001/pend')) assert tier_config_request == ('', 200) @patch('requests.post') def test_assign_tier_account_request(self, post_mock): - # type: (Mock) -> None post_mock.return_value = Response(True, '', 200) request = TierConfigRequestResource(config=self.config) id_tar = 'TAR-6458-9737-0065-004-001' @@ -120,12 +116,12 @@ def test_assign_tier_account_request(self, post_mock): post_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/assign') + url=('http://localhost:8080/api/public/v1/' + 'tier/config-requests/TAR-6458-9737-0065-004-001/assign')) assert tier_config_request == ('', 200) @patch('requests.post') def test_unassign_tier_account_request(self, post_mock): - # type: (Mock) -> None post_mock.return_value = Response(True, '', 200) request = TierConfigRequestResource(config=self.config) id_tar = 'TAR-6458-9737-0065-004-001' @@ -134,14 +130,14 @@ def test_unassign_tier_account_request(self, post_mock): post_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/unassign') + url=('http://localhost:8080/api/public/v1/' + 'tier/config-requests/TAR-6458-9737-0065-004-001/unassign')) assert tier_config_request == ('', 200) @patch('requests.post') def test_approve_tier_account_request(self, post_mock): - # type: (Mock) -> None body_request = {"template": {"id": "TP-1234-123-123"}} - body_response = {"template": {"id": "TP-123-123-123", "representation": "Rendered template" }} + body_response = {"template": {"id": "TP-123-123-123", "representation": "Rendered"}} post_mock.return_value = Response(True, body_response, 200) request = TierConfigRequestResource(config=self.config) id_tar = 'TAR-6458-9737-0065-004-001' @@ -150,13 +146,13 @@ def test_approve_tier_account_request(self, post_mock): post_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - json=body_request, - url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/approve') + json=body_request, + url=('http://localhost:8080/api/public/v1/' + 'tier/config-requests/TAR-6458-9737-0065-004-001/approve')) assert tier_config_request == (body_response, 200) @patch('requests.post') def test_fail_tier_account_request(self, post_mock): - # type: (Mock) -> None body_request = {"reason": "some reason"} post_mock.return_value = Response(True, '', 204) request = TierConfigRequestResource(config=self.config) @@ -166,9 +162,11 @@ def test_fail_tier_account_request(self, post_mock): post_mock.assert_called_with( headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}, timeout=300, - json=body_request, - url='http://localhost:8080/api/public/v1/tier/config-requests/TAR-6458-9737-0065-004-001/fail') + json=body_request, + url=('http://localhost:8080/api/public/v1/' + 'tier/config-requests/TAR-6458-9737-0065-004-001/fail')) assert tier_config_request == ('', 204) + if __name__ == "__main__": unittest.main() From 4c250a0b3f7416365264cb767bb68a2807b50243 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Fri, 3 Apr 2020 19:05:40 +0200 Subject: [PATCH 12/20] Enable python 3.8 to test matrix --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 88dc7d9..44d43a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,10 @@ matrix: python: 3.7 dist: xenial sudo: true + - os: linux + python: 3.8 + dist: xenial + sudo: true install: - pip install -r requirements/test.txt From 91b9eea09b718eeefb860e91deb4398e0e7be6d3 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Mon, 6 Apr 2020 02:10:14 +0200 Subject: [PATCH 13/20] Fix PR feedback from Francesco Faraone. --- .coveragerc | 2 +- connect/__init__.py | 9 +----- connect/resources/__init__.py | 1 - connect/resources/base.py | 8 ++--- connect/resources/billing_request.py | 5 ++-- connect/resources/tier_account.py | 10 +++---- .../tier_account_request_automation.py | 4 ++- connect/resources/tier_config_request.py | 30 ++++++++----------- examples/config.json | 4 +-- examples/tier_account_request.py | 11 +++---- requirements/sdk.txt | 2 +- .../ignore_tier_account_request_response.json | 2 +- .../list_tier_config_request_response.json | 2 +- tests/data/response_add_billing_request.json | 2 +- tests/data/response_get_billing_request.json | 2 +- tests/data/response_get_recurring_asset.json | 2 +- .../response_get_tier_account_request.json | 2 +- tests/data/response_list_billing_request.json | 2 +- tests/data/response_list_recurring_asset.json | 2 +- .../response_list_tier_account_request.json | 2 +- tests/data/tier_configuration_request.json | 2 +- tests/test_tier_account_request_automation.py | 3 -- 22 files changed, 43 insertions(+), 66 deletions(-) diff --git a/.coveragerc b/.coveragerc index 38734a2..04ef031 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,3 @@ [run] omit = - connect/models/exception.py \ No newline at end of file + connect/models/exception.py diff --git a/connect/__init__.py b/connect/__init__.py index bb242fc..7e99098 100644 --- a/connect/__init__.py +++ b/connect/__init__.py @@ -37,13 +37,6 @@ def __init__(self, config=None): __all__ = [ - 'config', - 'exceptions', - 'logger', - 'models', - 'resources', - 'rql', 'FulfillmentAutomation', - 'TierConfigAutomation', - 'TierRequestAutomation', + 'TierConfigAutomation' ] diff --git a/connect/resources/__init__.py b/connect/resources/__init__.py index 75bdddb..9060e4c 100644 --- a/connect/resources/__init__.py +++ b/connect/resources/__init__.py @@ -24,5 +24,4 @@ 'Subscription', 'BillingRequest', 'RecurringAsset' - # 'DirectoryExample', ] diff --git a/connect/resources/base.py b/connect/resources/base.py index b636b66..ddb6532 100644 --- a/connect/resources/base.py +++ b/connect/resources/base.py @@ -53,7 +53,6 @@ def headers(self): def get_url(self, path=''): # type: (str) -> str url = self.urljoin(self.config.api_url, self.base_path, path) - print(url) return url @staticmethod @@ -182,13 +181,12 @@ def update(self, id_obj, body): """ Update Object :param str id_item: Primary key of the object request to update. :param str body: Object to update. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: Object updated. """ if not id_obj: - raise ValueError('Object Request not exist') + raise ValueError('ID not valid') response = self._api.put( - path='{}/attributes'.format(id_obj), + path='{}'.format(id_obj), json=body ) return response diff --git a/connect/resources/billing_request.py b/connect/resources/billing_request.py index d4fd515..a1d278a 100644 --- a/connect/resources/billing_request.py +++ b/connect/resources/billing_request.py @@ -16,11 +16,10 @@ def update_billing_request(self, id_billing_request, body): """ Update Billing Request Attribute :param str id_billing_request: Primary key of the billing request to update. :param str body: Obj to update. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: Billing Request Attributes Object. """ if not id_billing_request: - raise ValueError('Billing Request not exist') + raise ValueError('Invalid ID') response = self._api.put( path='{}/attributes'.format(id_billing_request), json=body diff --git a/connect/resources/tier_account.py b/connect/resources/tier_account.py index 7c50022..417b20c 100644 --- a/connect/resources/tier_account.py +++ b/connect/resources/tier_account.py @@ -24,22 +24,20 @@ class TierAccountRequestResource(BaseResource): def accept(self, id_tar): """ Accept a Tier Configuration Request. :param str id_tar: Primary key of the tier configuration request to accept. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: Tier Account Request object. """ if not id_tar: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response, _ = self._api.post(path='{}/accept'.format(id_tar)) return self.model_class.deserialize(response) def ignore(self, id_tar, reason): """ Ignore a Tier Configuration Request :param str id_tar: Primary key of the tier configuration request to ignore. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: Tier Account Request object. """ if not id_tar: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response, _ = self._api.post( path='{}/ignore'.format(id_tar), json={ diff --git a/connect/resources/tier_account_request_automation.py b/connect/resources/tier_account_request_automation.py index 714e3f2..5240b64 100644 --- a/connect/resources/tier_account_request_automation.py +++ b/connect/resources/tier_account_request_automation.py @@ -16,7 +16,9 @@ class TierAccountRequestAction: a collection of Tier Account Request Object, this is processed calling to method dispatch and redirect to proccess_request. Create an instance of your subclass and call its ``process`` method to begin processing. - + The method process_request implements the business logic and depending of the evaluation, + will invoque the methods ACCEPT, IGNORE or SKIP for each TAR. + For an example on how to use this class, see :ref:`tier_account_example`. """ ACCEPT = 'accept' diff --git a/connect/resources/tier_config_request.py b/connect/resources/tier_config_request.py index 610b8df..b05ae8e 100644 --- a/connect/resources/tier_config_request.py +++ b/connect/resources/tier_config_request.py @@ -23,22 +23,20 @@ class TierConfigRequestResource(BaseResource): def pend(self, id_tcr): """ Set a Tier Configuration Request to pend status. :param str id_tar: Primary key of the tier configuration request to set. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: 204, Empty response """ if not id_tcr: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response = self._api.post(path='{}/pend'.format(id_tcr)) return response def inquire(self, id_tcr): """ Set a Tier Configuration Request to inquire status. :param str id_tar: Primary key of the tier configuration request to set. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: 204, Empty response """ if not id_tcr: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response = self._api.post(path='{}/inquire'.format(id_tcr)) return response @@ -46,11 +44,10 @@ def approve(self, id_tcr, id_template): """ Approve a Tier Configuration Request :param str id_tcr: Primary key of the tier configuration request to approve. :param str id_template: Primary key of the template. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: Template object. """ if not id_tcr: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response = self._api.post( path='{}/approve'.format(id_tcr), json={ @@ -64,11 +61,10 @@ def fail(self, id_tcr, reason): """ Set fail a Tier Configuration Request :param str id_tar: Primary key of the tier configuration request to ignore. :param str reason: Reason of the fail. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: 204, Empty response """ if not id_tcr: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response = self._api.post( path='{}/fail'.format(id_tcr), json={ @@ -79,21 +75,19 @@ def fail(self, id_tcr, reason): def assign(self, id_tcr): """ Assign a Tier Configuration Request. :param str id_tar: Primary key of the tier configuration request to set. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: 204, Empty response """ if not id_tcr: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response = self._api.post(path='{}/assign'.format(id_tcr)) return response def unassign(self, id_tcr): """ Unassign a Tier Configuration Request. :param str id_tar: Primary key of the tier configuration request to set. - :return: ActivationTileResponse object with tile contents. - :rtype: ActivationTileResponse + :return: 204, Empty response """ if not id_tcr: - raise ValueError('Tier Configuration Request not exist') + raise ValueError('Invalid ID') response = self._api.post(path='{}/unassign'.format(id_tcr)) return response diff --git a/examples/config.json b/examples/config.json index ca96196..b68dfcf 100644 --- a/examples/config.json +++ b/examples/config.json @@ -1,5 +1,5 @@ { "apiEndpoint": "https://api.cnct.tech/public/v1", - "apiKey": "ApiKey SU-771-994-269:553158141b425b106f4099dc15c7fe6064789312", - "products": "PRD-226-811-341" + "apiKey": "ApiKey SU-XXX-XXX-XXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "products": "PRD-000-000-000" } diff --git a/examples/tier_account_request.py b/examples/tier_account_request.py index d43f812..e5bf388 100644 --- a/examples/tier_account_request.py +++ b/examples/tier_account_request.py @@ -18,25 +18,22 @@ def get_pending(self): def get_tier_account(self): tier = Directory(config=self.configuration) t_account = tier.get_tier_account('TA-6458-9737-0065') - print(t_account.id) - print(t_account.external_id) - print(t_account.external_uid) - print(t_account.contact_info.address_line1) + return t_account.id def accept_tier_account_request(self, id_tar): tier = Fulfillment(config=self.configuration) response = tier.accept_tier_account_request(id_tar) - print(response) + return response def ignore_tier_account_request(self, id_tar, reason): tier = Fulfillment(config=self.configuration) response = tier.ignore_tier_account_request(id_tar, reason) - print(response) + return response def create_tier_account_request(self, data): tier = Fulfillment(config=self.configuration) response = tier.create_tier_account_request(data) - print(response) + return response def main(): diff --git a/requirements/sdk.txt b/requirements/sdk.txt index a014e78..b84ed73 100644 --- a/requirements/sdk.txt +++ b/requirements/sdk.txt @@ -3,4 +3,4 @@ marshmallow==2.18.0 openpyxl==2.5.14 requests==2.21.0 six==1.12.0 -mock==2.0.0 + diff --git a/tests/data/ignore_tier_account_request_response.json b/tests/data/ignore_tier_account_request_response.json index 7a1a103..2f9449c 100644 --- a/tests/data/ignore_tier_account_request_response.json +++ b/tests/data/ignore_tier_account_request_response.json @@ -80,4 +80,4 @@ "at": "2020-03-31T18:39:06+00:00" } } -} \ No newline at end of file +} diff --git a/tests/data/list_tier_config_request_response.json b/tests/data/list_tier_config_request_response.json index 9d1a6db..63b5196 100644 --- a/tests/data/list_tier_config_request_response.json +++ b/tests/data/list_tier_config_request_response.json @@ -257,4 +257,4 @@ "tier2": null } } -] \ No newline at end of file +] diff --git a/tests/data/response_add_billing_request.json b/tests/data/response_add_billing_request.json index 1fb7051..568ef4a 100644 --- a/tests/data/response_add_billing_request.json +++ b/tests/data/response_add_billing_request.json @@ -148,4 +148,4 @@ "delta": 1.0, "uom": "monthly" } -} \ No newline at end of file +} diff --git a/tests/data/response_get_billing_request.json b/tests/data/response_get_billing_request.json index d8dd43e..843bae8 100644 --- a/tests/data/response_get_billing_request.json +++ b/tests/data/response_get_billing_request.json @@ -106,4 +106,4 @@ "delta": 1.0, "uom": "monthly" } -} \ No newline at end of file +} diff --git a/tests/data/response_get_recurring_asset.json b/tests/data/response_get_recurring_asset.json index 4f114dd..3e89b69 100644 --- a/tests/data/response_get_recurring_asset.json +++ b/tests/data/response_get_recurring_asset.json @@ -158,4 +158,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/data/response_get_tier_account_request.json b/tests/data/response_get_tier_account_request.json index c18cba6..f2da59f 100644 --- a/tests/data/response_get_tier_account_request.json +++ b/tests/data/response_get_tier_account_request.json @@ -83,4 +83,4 @@ "at": "2020-03-11T16:08:39+00:00" } } -} \ No newline at end of file +} diff --git a/tests/data/response_list_billing_request.json b/tests/data/response_list_billing_request.json index 62b53cf..1541d1b 100644 --- a/tests/data/response_list_billing_request.json +++ b/tests/data/response_list_billing_request.json @@ -297,4 +297,4 @@ "uom": "monthly" } } -] \ No newline at end of file +] diff --git a/tests/data/response_list_recurring_asset.json b/tests/data/response_list_recurring_asset.json index 182c744..c7bf7c8 100644 --- a/tests/data/response_list_recurring_asset.json +++ b/tests/data/response_list_recurring_asset.json @@ -257,4 +257,4 @@ } } } -] \ No newline at end of file +] diff --git a/tests/data/response_list_tier_account_request.json b/tests/data/response_list_tier_account_request.json index f837562..02df29d 100644 --- a/tests/data/response_list_tier_account_request.json +++ b/tests/data/response_list_tier_account_request.json @@ -257,4 +257,4 @@ } } } -] \ No newline at end of file +] diff --git a/tests/data/tier_configuration_request.json b/tests/data/tier_configuration_request.json index 7aa65c1..9c11126 100644 --- a/tests/data/tier_configuration_request.json +++ b/tests/data/tier_configuration_request.json @@ -25,4 +25,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/test_tier_account_request_automation.py b/tests/test_tier_account_request_automation.py index 275b11b..56b8777 100644 --- a/tests/test_tier_account_request_automation.py +++ b/tests/test_tier_account_request_automation.py @@ -36,9 +36,6 @@ def _get_response_get(): class MyExampleTARAutomation(TierAccountRequestAutomation): def process_request(self, request): - print('====================================') - print(request.id, request.account.contact_info.country) - print('====================================') if request.account.contact_info.country == 'ES': return TierAccountRequestAction(TierAccountRequestAction.ACCEPT) elif request.account.contact_info.country == 'IT': From 20226012fce2925c52a693f4c8dd9de44f119787 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Mon, 6 Apr 2020 02:11:50 +0200 Subject: [PATCH 14/20] Fix Flake8 Errors --- connect/resources/tier_account_request_automation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/connect/resources/tier_account_request_automation.py b/connect/resources/tier_account_request_automation.py index 5240b64..69cf1c5 100644 --- a/connect/resources/tier_account_request_automation.py +++ b/connect/resources/tier_account_request_automation.py @@ -16,9 +16,8 @@ class TierAccountRequestAction: a collection of Tier Account Request Object, this is processed calling to method dispatch and redirect to proccess_request. Create an instance of your subclass and call its ``process`` method to begin processing. - The method process_request implements the business logic and depending of the evaluation, - will invoque the methods ACCEPT, IGNORE or SKIP for each TAR. - + The method process_request implements the business logic and depending of the evaluation, + will invoque the methods ACCEPT, IGNORE or SKIP for each TAR. For an example on how to use this class, see :ref:`tier_account_example`. """ ACCEPT = 'accept' From 4dcf02b33d30f5700130609be765657d9d940239 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Mon, 6 Apr 2020 09:58:47 +0200 Subject: [PATCH 15/20] Change copyright text --- connect/__init__.py | 2 +- connect/config.py | 2 +- connect/exceptions.py | 2 +- connect/logger/__init__.py | 2 +- connect/logger/logger.py | 2 +- connect/models/__init__.py | 2 +- connect/models/activation.py | 2 +- connect/models/activation_template_response.py | 2 +- connect/models/activation_tile_response.py | 2 +- connect/models/agreement.py | 2 +- connect/models/agreement_stats.py | 2 +- connect/models/aniversary.py | 2 +- connect/models/asset.py | 2 +- connect/models/attributes.py | 2 +- connect/models/base.py | 2 +- connect/models/billing.py | 2 +- connect/models/billing_request.py | 2 +- connect/models/company.py | 2 +- connect/models/configuration.py | 2 +- connect/models/connection.py | 2 +- connect/models/constraints.py | 2 +- connect/models/contact.py | 2 +- connect/models/contact_info.py | 2 +- connect/models/contract.py | 2 +- connect/models/conversation.py | 2 +- connect/models/conversation_message.py | 2 +- connect/models/country.py | 2 +- connect/models/customer_ui_settings.py | 2 +- connect/models/document.py | 2 +- connect/models/download_link.py | 2 +- connect/models/event.py | 2 +- connect/models/events.py | 2 +- connect/models/exception.py | 2 +- connect/models/ext_id_hub.py | 2 +- connect/models/fulfillment.py | 2 +- connect/models/hub.py | 2 +- connect/models/hub_instance.py | 2 +- connect/models/hub_stats.py | 2 +- connect/models/item.py | 2 +- connect/models/last_request.py | 2 +- connect/models/marketplace.py | 2 +- connect/models/param.py | 2 +- connect/models/period.py | 2 +- connect/models/phone_number.py | 2 +- connect/models/product.py | 2 +- connect/models/product_category.py | 2 +- connect/models/product_configuration.py | 2 +- connect/models/product_configuration_parameter.py | 2 +- connect/models/product_family.py | 2 +- connect/models/product_stats.py | 2 +- connect/models/product_stats_info.py | 2 +- connect/models/recurring_asset.py | 2 +- connect/models/renewal.py | 2 +- connect/models/schemas.py | 2 +- connect/models/server_error_response.py | 2 +- connect/models/stat.py | 2 +- connect/models/stats.py | 2 +- connect/models/template.py | 2 +- connect/models/tier_account.py | 2 +- connect/models/tier_account_request.py | 2 +- connect/models/tier_accounts.py | 2 +- connect/models/tier_config.py | 2 +- connect/models/tier_config_request.py | 2 +- connect/models/usage_file.py | 2 +- connect/models/usage_listing.py | 2 +- connect/models/usage_record.py | 2 +- connect/models/usage_records.py | 2 +- connect/models/user.py | 2 +- connect/models/value_choice.py | 2 +- connect/resources/__init__.py | 2 +- connect/resources/automation_engine.py | 2 +- connect/resources/base.py | 2 +- connect/resources/billing_request.py | 2 +- connect/resources/directory.py | 2 +- connect/resources/fulfillment_automation.py | 2 +- connect/resources/recurring_asset.py | 2 +- connect/resources/template.py | 2 +- connect/resources/tier_account.py | 2 +- connect/resources/tier_account_request_automation.py | 2 +- connect/resources/tier_config_automation.py | 2 +- connect/resources/tier_config_request.py | 2 +- connect/resources/usage_automation.py | 2 +- connect/resources/usage_file_automation.py | 2 +- connect/rql/__init__.py | 2 +- connect/rql/query.py | 2 +- examples/billing_request.py | 2 +- examples/fulfillment.py | 2 +- examples/recurring_asset.py | 2 +- examples/tier_account_request.py | 2 +- examples/tier_account_request_automation.py | 2 +- examples/tier_config.py | 2 +- examples/usage.py | 2 +- examples/usage_file.py | 2 +- setup.py | 2 +- tests/__init__.py | 2 +- tests/common.py | 2 +- tests/test_billing_request.py | 2 +- tests/test_config.py | 2 +- tests/test_conversation.py | 2 +- tests/test_deprecated.py | 2 +- tests/test_directory.py | 2 +- tests/test_models.py | 2 +- tests/test_query.py | 2 +- tests/test_recurring_asset.py | 2 +- tests/test_server_error_response.py | 2 +- tests/test_tier_account_request.py | 2 +- tests/test_tier_account_request_automation.py | 2 +- tests/test_tier_config.py | 2 +- tests/test_tier_config_request.py | 2 +- tests/test_usage.py | 2 +- tests/test_usage_file.py | 2 +- 111 files changed, 111 insertions(+), 111 deletions(-) diff --git a/connect/__init__.py b/connect/__init__.py index 7e99098..21c4856 100644 --- a/connect/__init__.py +++ b/connect/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from abc import ABCMeta diff --git a/connect/config.py b/connect/config.py index b716661..f6f6092 100644 --- a/connect/config.py +++ b/connect/config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json import os diff --git a/connect/exceptions.py b/connect/exceptions.py index eb08dcb..c6ef40d 100644 --- a/connect/exceptions.py +++ b/connect/exceptions.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/logger/__init__.py b/connect/logger/__init__.py index c9bbd35..e5c9912 100644 --- a/connect/logger/__init__.py +++ b/connect/logger/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .logger import function_log, logger diff --git a/connect/logger/logger.py b/connect/logger/logger.py index af91ce5..f06a0bd 100644 --- a/connect/logger/logger.py +++ b/connect/logger/logger.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from functools import wraps import json diff --git a/connect/models/__init__.py b/connect/models/__init__.py index cb1b915..9ab6cac 100644 --- a/connect/models/__init__.py +++ b/connect/models/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .activation import Activation from .activation_template_response import ActivationTemplateResponse diff --git a/connect/models/activation.py b/connect/models/activation.py index 7addc80..4b24e87 100644 --- a/connect/models/activation.py +++ b/connect/models/activation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional diff --git a/connect/models/activation_template_response.py b/connect/models/activation_template_response.py index e3fff2a..84cc9ed 100644 --- a/connect/models/activation_template_response.py +++ b/connect/models/activation_template_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. class ActivationTemplateResponse(object): diff --git a/connect/models/activation_tile_response.py b/connect/models/activation_tile_response.py index 9789ecd..d9fc290 100644 --- a/connect/models/activation_tile_response.py +++ b/connect/models/activation_tile_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json diff --git a/connect/models/agreement.py b/connect/models/agreement.py index 12d12a0..706785f 100644 --- a/connect/models/agreement.py +++ b/connect/models/agreement.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional, List diff --git a/connect/models/agreement_stats.py b/connect/models/agreement_stats.py index e3b4022..7ac6af7 100644 --- a/connect/models/agreement_stats.py +++ b/connect/models/agreement_stats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/aniversary.py b/connect/models/aniversary.py index 30f0083..fbdc6b0 100644 --- a/connect/models/aniversary.py +++ b/connect/models/aniversary.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import AniversarySchema diff --git a/connect/models/asset.py b/connect/models/asset.py index c7a577e..affd5b3 100644 --- a/connect/models/asset.py +++ b/connect/models/asset.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List, Optional diff --git a/connect/models/attributes.py b/connect/models/attributes.py index 50d0a96..c4cc9ff 100644 --- a/connect/models/attributes.py +++ b/connect/models/attributes.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import AttributesSchema diff --git a/connect/models/base.py b/connect/models/base.py index 0ceb7cf..a045db7 100644 --- a/connect/models/base.py +++ b/connect/models/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json diff --git a/connect/models/billing.py b/connect/models/billing.py index d21366a..5c7f6ee 100644 --- a/connect/models/billing.py +++ b/connect/models/billing.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import BillingSchema diff --git a/connect/models/billing_request.py b/connect/models/billing_request.py index ee00478..bbfb36b 100644 --- a/connect/models/billing_request.py +++ b/connect/models/billing_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import BillingRequestSchema diff --git a/connect/models/company.py b/connect/models/company.py index 01a2338..402addf 100644 --- a/connect/models/company.py +++ b/connect/models/company.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import CompanySchema diff --git a/connect/models/configuration.py b/connect/models/configuration.py index 6f92eef..cea0a74 100644 --- a/connect/models/configuration.py +++ b/connect/models/configuration.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/connection.py b/connect/models/connection.py index e03cf9c..b8e5087 100644 --- a/connect/models/connection.py +++ b/connect/models/connection.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/constraints.py b/connect/models/constraints.py index 81ebb37..6d0e4ac 100644 --- a/connect/models/constraints.py +++ b/connect/models/constraints.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/contact.py b/connect/models/contact.py index 92b1e82..caffc75 100644 --- a/connect/models/contact.py +++ b/connect/models/contact.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/contact_info.py b/connect/models/contact_info.py index f489ab2..2f18c2f 100644 --- a/connect/models/contact_info.py +++ b/connect/models/contact_info.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/contract.py b/connect/models/contract.py index bf5362d..c808c80 100644 --- a/connect/models/contract.py +++ b/connect/models/contract.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional diff --git a/connect/models/conversation.py b/connect/models/conversation.py index 09c3923..a465cce 100644 --- a/connect/models/conversation.py +++ b/connect/models/conversation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/conversation_message.py b/connect/models/conversation_message.py index 721b44b..3ebe78d 100644 --- a/connect/models/conversation_message.py +++ b/connect/models/conversation_message.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/country.py b/connect/models/country.py index 3cbbea3..b27bce0 100644 --- a/connect/models/country.py +++ b/connect/models/country.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import CountrySchema diff --git a/connect/models/customer_ui_settings.py b/connect/models/customer_ui_settings.py index 66b0001..c904457 100644 --- a/connect/models/customer_ui_settings.py +++ b/connect/models/customer_ui_settings.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/document.py b/connect/models/document.py index 99de38b..4f002fe 100644 --- a/connect/models/document.py +++ b/connect/models/document.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import DocumentSchema diff --git a/connect/models/download_link.py b/connect/models/download_link.py index 834b2d4..77f0519 100644 --- a/connect/models/download_link.py +++ b/connect/models/download_link.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import DownloadLinkSchema diff --git a/connect/models/event.py b/connect/models/event.py index 93e5f0c..d634594 100644 --- a/connect/models/event.py +++ b/connect/models/event.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional diff --git a/connect/models/events.py b/connect/models/events.py index 80f6036..122bebf 100644 --- a/connect/models/events.py +++ b/connect/models/events.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .event import Event from .schemas import EventsSchema diff --git a/connect/models/exception.py b/connect/models/exception.py index 5e583a7..65d0510 100644 --- a/connect/models/exception.py +++ b/connect/models/exception.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. # This file provides backwards compatibility with the previous location # and names of exception classes diff --git a/connect/models/ext_id_hub.py b/connect/models/ext_id_hub.py index 791b893..ac7c253 100644 --- a/connect/models/ext_id_hub.py +++ b/connect/models/ext_id_hub.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .hub import Hub diff --git a/connect/models/fulfillment.py b/connect/models/fulfillment.py index c655ac2..b19a6bb 100644 --- a/connect/models/fulfillment.py +++ b/connect/models/fulfillment.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime from typing import Union diff --git a/connect/models/hub.py b/connect/models/hub.py index 82af7ae..8478ef2 100644 --- a/connect/models/hub.py +++ b/connect/models/hub.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/hub_instance.py b/connect/models/hub_instance.py index ee90e01..761b909 100644 --- a/connect/models/hub_instance.py +++ b/connect/models/hub_instance.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import HubInstanceSchema diff --git a/connect/models/hub_stats.py b/connect/models/hub_stats.py index fdfd7af..21da480 100644 --- a/connect/models/hub_stats.py +++ b/connect/models/hub_stats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import HubStatsSchema diff --git a/connect/models/item.py b/connect/models/item.py index fee4cc3..6f54166 100644 --- a/connect/models/item.py +++ b/connect/models/item.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List, Optional, Union diff --git a/connect/models/last_request.py b/connect/models/last_request.py index 7255355..0b9e411 100644 --- a/connect/models/last_request.py +++ b/connect/models/last_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import LastRequestSchema diff --git a/connect/models/marketplace.py b/connect/models/marketplace.py index 81d8b08..d574445 100644 --- a/connect/models/marketplace.py +++ b/connect/models/marketplace.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/param.py b/connect/models/param.py index 180a640..b7efc8c 100644 --- a/connect/models/param.py +++ b/connect/models/param.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List, Optional diff --git a/connect/models/period.py b/connect/models/period.py index 1d08409..54b274b 100644 --- a/connect/models/period.py +++ b/connect/models/period.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime from typing import Optional diff --git a/connect/models/phone_number.py b/connect/models/phone_number.py index 0469c28..094fb0f 100644 --- a/connect/models/phone_number.py +++ b/connect/models/phone_number.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/product.py b/connect/models/product.py index 94e468a..c496c40 100644 --- a/connect/models/product.py +++ b/connect/models/product.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from copy import copy import datetime diff --git a/connect/models/product_category.py b/connect/models/product_category.py index b1f5e94..bc0f32e 100644 --- a/connect/models/product_category.py +++ b/connect/models/product_category.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List, Optional diff --git a/connect/models/product_configuration.py b/connect/models/product_configuration.py index 9123d32..3733c0f 100644 --- a/connect/models/product_configuration.py +++ b/connect/models/product_configuration.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ProductConfigurationSchema diff --git a/connect/models/product_configuration_parameter.py b/connect/models/product_configuration_parameter.py index f53a6ea..f86165b 100644 --- a/connect/models/product_configuration_parameter.py +++ b/connect/models/product_configuration_parameter.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .constraints import Constraints diff --git a/connect/models/product_family.py b/connect/models/product_family.py index d1ff563..825b39e 100644 --- a/connect/models/product_family.py +++ b/connect/models/product_family.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ProductFamilySchema diff --git a/connect/models/product_stats.py b/connect/models/product_stats.py index 99cb396..8abc252 100644 --- a/connect/models/product_stats.py +++ b/connect/models/product_stats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .product_stats_info import ProductStatsInfo diff --git a/connect/models/product_stats_info.py b/connect/models/product_stats_info.py index 7e6c572..4681cdd 100644 --- a/connect/models/product_stats_info.py +++ b/connect/models/product_stats_info.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ProductStatsInfoSchema diff --git a/connect/models/recurring_asset.py b/connect/models/recurring_asset.py index 15270e9..6391eee 100644 --- a/connect/models/recurring_asset.py +++ b/connect/models/recurring_asset.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import RecurringAssetSchema diff --git a/connect/models/renewal.py b/connect/models/renewal.py index f65d4d1..544c747 100644 --- a/connect/models/renewal.py +++ b/connect/models/renewal.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime diff --git a/connect/models/schemas.py b/connect/models/schemas.py index b02d904..d5d2fe0 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from marshmallow import Schema, fields, post_load import six diff --git a/connect/models/server_error_response.py b/connect/models/server_error_response.py index 4867c4d..827f377 100644 --- a/connect/models/server_error_response.py +++ b/connect/models/server_error_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List diff --git a/connect/models/stat.py b/connect/models/stat.py index 4418564..36a6276 100644 --- a/connect/models/stat.py +++ b/connect/models/stat.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import StatSchema diff --git a/connect/models/stats.py b/connect/models/stats.py index 5a7bd2a..d8725d6 100644 --- a/connect/models/stats.py +++ b/connect/models/stats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import StatsSchema diff --git a/connect/models/template.py b/connect/models/template.py index 47edf9d..eda6fd8 100644 --- a/connect/models/template.py +++ b/connect/models/template.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import TemplateSchema diff --git a/connect/models/tier_account.py b/connect/models/tier_account.py index 7592158..61c5abd 100644 --- a/connect/models/tier_account.py +++ b/connect/models/tier_account.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import TierAccountSchema diff --git a/connect/models/tier_account_request.py b/connect/models/tier_account_request.py index dcb229a..661cd80 100644 --- a/connect/models/tier_account_request.py +++ b/connect/models/tier_account_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import TierAccountRequestSchema diff --git a/connect/models/tier_accounts.py b/connect/models/tier_accounts.py index a09acf0..0cde71d 100644 --- a/connect/models/tier_accounts.py +++ b/connect/models/tier_accounts.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional diff --git a/connect/models/tier_config.py b/connect/models/tier_config.py index b2e1e15..0046f31 100644 --- a/connect/models/tier_config.py +++ b/connect/models/tier_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional, List diff --git a/connect/models/tier_config_request.py b/connect/models/tier_config_request.py index 973f28e..cbeb19a 100644 --- a/connect/models/tier_config_request.py +++ b/connect/models/tier_config_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Optional, List diff --git a/connect/models/usage_file.py b/connect/models/usage_file.py index e4e0e5e..662a082 100644 --- a/connect/models/usage_file.py +++ b/connect/models/usage_file.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .company import Company diff --git a/connect/models/usage_listing.py b/connect/models/usage_listing.py index ad7b945..669a54e 100644 --- a/connect/models/usage_listing.py +++ b/connect/models/usage_listing.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .company import Company diff --git a/connect/models/usage_record.py b/connect/models/usage_record.py index 40ea644..46a09ca 100644 --- a/connect/models/usage_record.py +++ b/connect/models/usage_record.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import UsageRecordSchema diff --git a/connect/models/usage_records.py b/connect/models/usage_records.py index ea37443..861c4d8 100644 --- a/connect/models/usage_records.py +++ b/connect/models/usage_records.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import UsageRecordsSchema diff --git a/connect/models/user.py b/connect/models/user.py index 08a08fa..b7d3691 100644 --- a/connect/models/user.py +++ b/connect/models/user.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import UserSchema diff --git a/connect/models/value_choice.py b/connect/models/value_choice.py index 3827dd3..bd6da78 100644 --- a/connect/models/value_choice.py +++ b/connect/models/value_choice.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel from .schemas import ValueChoiceSchema diff --git a/connect/resources/__init__.py b/connect/resources/__init__.py index 9060e4c..685ec48 100644 --- a/connect/resources/__init__.py +++ b/connect/resources/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .directory import Directory from .fulfillment_automation import FulfillmentAutomation diff --git a/connect/resources/automation_engine.py b/connect/resources/automation_engine.py index 5448b2f..dfa955b 100644 --- a/connect/resources/automation_engine.py +++ b/connect/resources/automation_engine.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import copy import logging diff --git a/connect/resources/base.py b/connect/resources/base.py index ddb6532..eda73fc 100644 --- a/connect/resources/base.py +++ b/connect/resources/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import functools import logging diff --git a/connect/resources/billing_request.py b/connect/resources/billing_request.py index a1d278a..b8111b5 100644 --- a/connect/resources/billing_request.py +++ b/connect/resources/billing_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from connect.models.billing_request import BillingRequest from .base import BaseResource diff --git a/connect/resources/directory.py b/connect/resources/directory.py index 6fa92d2..0acc2a5 100644 --- a/connect/resources/directory.py +++ b/connect/resources/directory.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from copy import copy diff --git a/connect/resources/fulfillment_automation.py b/connect/resources/fulfillment_automation.py index 38ca7aa..e784342 100644 --- a/connect/resources/fulfillment_automation.py +++ b/connect/resources/fulfillment_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from abc import ABCMeta import logging diff --git a/connect/resources/recurring_asset.py b/connect/resources/recurring_asset.py index c3bf222..73c3758 100644 --- a/connect/resources/recurring_asset.py +++ b/connect/resources/recurring_asset.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from connect.models.recurring_asset import RecurringAsset from .base import BaseResource diff --git a/connect/resources/template.py b/connect/resources/template.py index acfedd9..230b760 100644 --- a/connect/resources/template.py +++ b/connect/resources/template.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import List, Any, Dict diff --git a/connect/resources/tier_account.py b/connect/resources/tier_account.py index 417b20c..464d64b 100644 --- a/connect/resources/tier_account.py +++ b/connect/resources/tier_account.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from connect.models.tier_account import TierAccount from connect.models.tier_account_request import TierAccountRequest diff --git a/connect/resources/tier_account_request_automation.py b/connect/resources/tier_account_request_automation.py index 69cf1c5..0faecfa 100644 --- a/connect/resources/tier_account_request_automation.py +++ b/connect/resources/tier_account_request_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import logging diff --git a/connect/resources/tier_config_automation.py b/connect/resources/tier_config_automation.py index c277c05..73b321b 100644 --- a/connect/resources/tier_config_automation.py +++ b/connect/resources/tier_config_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from abc import ABCMeta import logging diff --git a/connect/resources/tier_config_request.py b/connect/resources/tier_config_request.py index b05ae8e..ed96098 100644 --- a/connect/resources/tier_config_request.py +++ b/connect/resources/tier_config_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from connect.models.tier_config import TierConfig from connect.models.tier_config_request import TierConfigRequest diff --git a/connect/resources/usage_automation.py b/connect/resources/usage_automation.py index 2534d52..0e8ff16 100644 --- a/connect/resources/usage_automation.py +++ b/connect/resources/usage_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json import logging diff --git a/connect/resources/usage_file_automation.py b/connect/resources/usage_file_automation.py index 9a3b12b..a64ffc4 100644 --- a/connect/resources/usage_file_automation.py +++ b/connect/resources/usage_file_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json import logging diff --git a/connect/rql/__init__.py b/connect/rql/__init__.py index fadc4b6..63ba92d 100644 --- a/connect/rql/__init__.py +++ b/connect/rql/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .query import Query diff --git a/connect/rql/query.py b/connect/rql/query.py index c8ffc71..8254da9 100644 --- a/connect/rql/query.py +++ b/connect/rql/query.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from copy import copy from typing import Dict, List, Optional diff --git a/examples/billing_request.py b/examples/billing_request.py index e614cd1..9bbaa82 100644 --- a/examples/billing_request.py +++ b/examples/billing_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json from connect.config import Config from connect.resources.subscription import Subscription diff --git a/examples/fulfillment.py b/examples/fulfillment.py index f99f731..3606ce3 100644 --- a/examples/fulfillment.py +++ b/examples/fulfillment.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from typing import Union import warnings diff --git a/examples/recurring_asset.py b/examples/recurring_asset.py index b83ebc1..432bcc8 100644 --- a/examples/recurring_asset.py +++ b/examples/recurring_asset.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json from connect.config import Config from connect.resources.subscription import Subscription diff --git a/examples/tier_account_request.py b/examples/tier_account_request.py index e5bf388..c6f4b29 100644 --- a/examples/tier_account_request.py +++ b/examples/tier_account_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json from connect.config import Config from connect.resources.fulfillment import Fulfillment diff --git a/examples/tier_account_request_automation.py b/examples/tier_account_request_automation.py index 15d570b..324e4d7 100644 --- a/examples/tier_account_request_automation.py +++ b/examples/tier_account_request_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from connect.resources.tier_account_request_automation import ( TierAccountRequestAutomation, TierAccountRequestAction, diff --git a/examples/tier_config.py b/examples/tier_config.py index d1fa14a..a11367a 100644 --- a/examples/tier_config.py +++ b/examples/tier_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. # NOTE: This example development is in progress. This is just a skeleton. diff --git a/examples/usage.py b/examples/usage.py index a68a77f..0bcfa12 100644 --- a/examples/usage.py +++ b/examples/usage.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from datetime import datetime, timedelta import warnings diff --git a/examples/usage_file.py b/examples/usage_file.py index abfed25..65cc060 100644 --- a/examples/usage_file.py +++ b/examples/usage_file.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import warnings diff --git a/setup.py b/setup.py index ebf6ff4..9495e8f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from os.path import abspath, dirname, exists, join from setuptools import find_packages, setup diff --git a/tests/__init__.py b/tests/__init__.py index 7ee6406..3a7bbf7 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. diff --git a/tests/common.py b/tests/common.py index 136a9e5..571fdde 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from collections import namedtuple from typing import Optional diff --git a/tests/test_billing_request.py b/tests/test_billing_request.py index 1a1c837..14f2da2 100644 --- a/tests/test_billing_request.py +++ b/tests/test_billing_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os import unittest diff --git a/tests/test_config.py b/tests/test_config.py index 04210f4..d7c842f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os diff --git a/tests/test_conversation.py b/tests/test_conversation.py index af15142..8e620c4 100644 --- a/tests/test_conversation.py +++ b/tests/test_conversation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import datetime import os diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index edf96b6..aaee5c6 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import pytest diff --git a/tests/test_directory.py b/tests/test_directory.py index b5ab476..838b517 100644 --- a/tests/test_directory.py +++ b/tests/test_directory.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. # TODO: Assert received request data diff --git a/tests/test_models.py b/tests/test_models.py index 156bb81..a449e43 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import json import os diff --git a/tests/test_query.py b/tests/test_query.py index ce0611d..3fa9092 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from connect.rql import Query diff --git a/tests/test_recurring_asset.py b/tests/test_recurring_asset.py index 66cecd0..a4d0d31 100644 --- a/tests/test_recurring_asset.py +++ b/tests/test_recurring_asset.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os import unittest diff --git a/tests/test_server_error_response.py b/tests/test_server_error_response.py index d26028e..bf6643f 100644 --- a/tests/test_server_error_response.py +++ b/tests/test_server_error_response.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os diff --git a/tests/test_tier_account_request.py b/tests/test_tier_account_request.py index 1872af0..30d1037 100644 --- a/tests/test_tier_account_request.py +++ b/tests/test_tier_account_request.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os import unittest diff --git a/tests/test_tier_account_request_automation.py b/tests/test_tier_account_request_automation.py index 56b8777..4b60701 100644 --- a/tests/test_tier_account_request_automation.py +++ b/tests/test_tier_account_request_automation.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os import unittest diff --git a/tests/test_tier_config.py b/tests/test_tier_config.py index ed6e662..b3d0e24 100644 --- a/tests/test_tier_config.py +++ b/tests/test_tier_config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os from datetime import datetime diff --git a/tests/test_tier_config_request.py b/tests/test_tier_config_request.py index e4692f2..62ccc20 100644 --- a/tests/test_tier_config_request.py +++ b/tests/test_tier_config_request.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os import unittest diff --git a/tests/test_usage.py b/tests/test_usage.py index adfea0d..ab2679b 100644 --- a/tests/test_usage.py +++ b/tests/test_usage.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os import time diff --git a/tests/test_usage_file.py b/tests/test_usage_file.py index ee949d1..e421078 100644 --- a/tests/test_usage_file.py +++ b/tests/test_usage_file.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # This file is part of the Ingram Micro Cloud Blue Connect SDK. -# Copyright (c) 2020 Ingram Micro. All Rights Reserved. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. import os from datetime import datetime From 6cc86d2fd57676fb940948f047d090d4c816ded1 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Tue, 7 Apr 2020 20:06:02 +0200 Subject: [PATCH 16/20] Create and modify Usage Models & Statics generation --- connect/models/__init__.py | 2 + connect/models/billing.py | 2 +- connect/models/schemas.py | 34 +++++++++++++++- connect/models/tier_config.py | 4 +- connect/models/usage_file.py | 24 ++++++++++- connect/models/usage_record.py | 27 +++++++++++++ connect/models/usage_stats.py | 28 +++++++++++++ connect/resources/fulfillment_automation.py | 4 +- connect/resources/tier_config_automation.py | 14 +++---- connect/resources/usage_automation.py | 44 ++++++++++++++------- examples/config.json | 4 +- examples/tier_config.py | 3 +- tests/data/response_usage_file.json | 5 ++- tests/test_models.py | 4 +- tests/test_usage_file.py | 2 +- 15 files changed, 164 insertions(+), 37 deletions(-) create mode 100644 connect/models/usage_stats.py diff --git a/connect/models/__init__.py b/connect/models/__init__.py index 9ab6cac..431f6f4 100644 --- a/connect/models/__init__.py +++ b/connect/models/__init__.py @@ -58,6 +58,7 @@ from .usage_listing import UsageListing from .usage_record import UsageRecord from .usage_records import UsageRecords +from .usage_stats import UsageStats from .user import User from .value_choice import ValueChoice from .billing_request import BillingRequest @@ -126,6 +127,7 @@ 'UsageListing', 'UsageRecord', 'UsageRecords', + 'UsageStats', 'User', 'ValueChoice', ] diff --git a/connect/models/billing.py b/connect/models/billing.py index 5c7f6ee..353365c 100644 --- a/connect/models/billing.py +++ b/connect/models/billing.py @@ -13,7 +13,7 @@ class Billing(BaseModel): _schema = BillingSchema() stats = None # type: object - """ (:py:class:`.Stats`) Stats of companySchema. """ + """ (:py:class:`.Stats`) BillingStats of companySchema. """ period = None # type: object """ (:py:class:`.Period`) Period of the billing. """ diff --git a/connect/models/schemas.py b/connect/models/schemas.py index d5d2fe0..229c59b 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -693,6 +693,7 @@ def make_object(self, data): class UsageRecordsSchema(BaseSchema): valid = fields.Int() invalid = fields.Int() + closed = fields.Int() @post_load def make_object(self, data): @@ -700,14 +701,32 @@ def make_object(self, data): return UsageRecords(**data) +class UsageStatsSchema(BaseSchema): + uploaded = fields.Str() + validated = fields.Str() + pending = fields.Str() + accepted = fields.Str() + closed = fields.Str() + invalid = fields.Str() + + @post_load + def make_object(self, data): + from connect.models import UsageStats + return UsageStats(**data) + + class UsageFileSchema(BaseSchema): name = fields.Str() description = fields.Str() note = fields.Str() status = fields.Str() + period_from = fields.Str() + period_to = fields.Str() + currency = fields.Str() + schema = fields.Str() created_by = fields.Str() created_at = fields.Str() - upload_file_uri = fields.Str() + usage_file_uri = fields.Str() processed_file_uri = fields.Str() product = fields.Nested(ProductSchema) contract = fields.Nested(ContractSchema) @@ -717,6 +736,8 @@ class UsageFileSchema(BaseSchema): acceptance_note = fields.Str() rejection_note = fields.Str() error_details = fields.Str() + external_id = fields.Str() + stats = fields.Nested(UsageStatsSchema) records = fields.Nested(UsageRecordsSchema) events = fields.Nested(EventsSchema) @@ -744,13 +765,22 @@ def make_object(self, data): class UsageRecordSchema(BaseSchema): usage_record_id = fields.Str() + usage_record_note = fields.Str() item_search_criteria = fields.Str() item_search_value = fields.Str() - quantity = fields.Int() + amount = fields.Str() + quantity = fields.Str() start_time_utc = fields.Str() end_time_utc = fields.Str() asset_search_criteria = fields.Str() asset_search_value = fields.Str() + item_name = fields.Str() + item_npm = fields.Str() + item_unit = fields.Str() + item_precision = fields.Str() + category_id = fields.Str() + asset_recon_id = fields.Str() + tier = fields.Str() @post_load def make_object(self, data): diff --git a/connect/models/tier_config.py b/connect/models/tier_config.py index 0046f31..1b38581 100644 --- a/connect/models/tier_config.py +++ b/connect/models/tier_config.py @@ -90,8 +90,8 @@ def get(cls, account_id, product_id, config=None): response, _ = ApiClient(config, base_path='tier/config-requests').get( params={ 'status': 'approved', - 'configuration__product__id': product_id, - 'configuration__account__id': account_id, + 'configuration.product.id': product_id, + 'configuration.account.id': account_id, } ) objects = TierConfigRequest.deserialize(response) diff --git a/connect/models/usage_file.py b/connect/models/usage_file.py index 662a082..16ae942 100644 --- a/connect/models/usage_file.py +++ b/connect/models/usage_file.py @@ -10,6 +10,7 @@ from .marketplace import Marketplace from .product import Product from .usage_records import UsageRecords +from .usage_stats import UsageStats from .schemas import UsageFileSchema @@ -34,13 +35,25 @@ class UsageFile(BaseModel): pending, accepted, closed. """ + period_from = None # type: str + """ (str) Date & time from which usage records are considered in this usage file. """ + + period_to = None # type: str + """ (str) Date & time from which usage records are considered in this usage file. """ + + currency = None # type: str + """ (str) Currency of the amount included in usage file. """ + + schema = None # type: str + """ (str)Usage Scheme used for the usage file. """ + created_by = None # type: str """ (str) User ID who have created this UsageFile. """ created_at = None # type: str """ (str) Date of the creation of the UsageFile. """ - upload_file_uri = None # type: str + usage_file_uri = None # type: str """ (str) Google Storage shared location of the upload file. Only available in GET API and not included in list API (sharing timeout 600 sec). """ @@ -75,8 +88,17 @@ class UsageFile(BaseModel): """ (str) In case of invalid file, this field will contain errors related to the file. """ # TODO: In the docs it is error_details, on PHP SDK it appears as error_detail + external_id = None # type: str + """ (str) External ID of the file. """ + + stats = None # type: UsageStats + """ (:py:class:`.UsageStats`) UsageStats Object. """ + records = None # type: UsageRecords """ (:py:class:`.UsageRecords`) UsageRecords Object. """ events = None # type: Events """ (:py:class:`.Events`) Events occured on file. """ + + environment = None # type: str + """ (str) Environment. """ diff --git a/connect/models/usage_record.py b/connect/models/usage_record.py index 46a09ca..a617c2c 100644 --- a/connect/models/usage_record.py +++ b/connect/models/usage_record.py @@ -15,12 +15,18 @@ class UsageRecord(BaseModel): usage_record_id = None # type: str """ (str) Usage record id. """ + usage_record_note = None # type: str + """ (str) Usage record note. """ + item_search_criteria = None # type: str """ (str) Item search criteria. """ item_search_value = None # type: str """ (str) Item search value. """ + amount = None # type: float + """ (float) Amount. """ + quantity = None # type: int """ (int) Quantity. """ @@ -35,3 +41,24 @@ class UsageRecord(BaseModel): asset_search_value = None # type: str """ (str) Asset search value. """ + + item_name = None # type: str + """ (str) Item name. """ + + item_npm = None # type: str + """ (str) Item npm. """ + + item_unit = None # type: str + """ (str) Item unit. """ + + item_precision = None # type: str + """ (str) Item precision. """ + + category_id = None # type: str + """ (str) Category Id. """ + + asset_recon_id = None # type: str + """ (str) Asset recon Id. """ + + tier = None # type: str + """ (str) Tier. """ diff --git a/connect/models/usage_stats.py b/connect/models/usage_stats.py new file mode 100644 index 0000000..1d43e06 --- /dev/null +++ b/connect/models/usage_stats.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import UsageStatsSchema + + +class UsageStats(BaseModel): + """ Usage Stats object. """ + + _schema = UsageStatsSchema() + + uploaded = None # type: int + """ (Int) Uploaded. """ + + validated = None # type: int + """ (Int) Validated. """ + + pending = None # type: int + """ (Int) Pending. """ + + accepted = None # type: int + """ (Int) Accepted. """ + + closed = None # type: int + """ (Int) Closed. """ diff --git a/connect/resources/fulfillment_automation.py b/connect/resources/fulfillment_automation.py index e784342..80db414 100644 --- a/connect/resources/fulfillment_automation.py +++ b/connect/resources/fulfillment_automation.py @@ -159,8 +159,8 @@ def get_tier_config(self, tier_id, product_id): url = self._api.urljoin(self.config.api_url, 'tier/config-requests') params = { 'status': 'approved', - 'configuration__product__id': product_id, - 'configuration__account__id': tier_id, + 'configuration.product.id': product_id, + 'configuration.account.id': tier_id, } response, _ = self._api.get(url=url, params=params) objects = TierConfigRequest.deserialize(response) diff --git a/connect/resources/tier_config_automation.py b/connect/resources/tier_config_automation.py index 73b321b..769f72b 100644 --- a/connect/resources/tier_config_automation.py +++ b/connect/resources/tier_config_automation.py @@ -45,13 +45,13 @@ def filters(self, status='pending', **kwargs): - type - status - id - - configuration__id - - configuration__tier_level - - configuration__account__id - - configuration__product__id - - assignee__id + - configuration.id + - configuration.tier_level + - configuration.account.id + - configuration.product.id + - assignee.id - unassigned (bool) - - configuration__account__external_uid + - configuration.account.external_uid :param str status: Status of the requests. Default: ``'pending'``. :param dict[str,Any] kwargs: Additional filters to add to the default ones. @@ -60,7 +60,7 @@ def filters(self, status='pending', **kwargs): """ filters = super(TierConfigAutomation, self).filters(status=status, **kwargs) if self.config.products: - filters['configuration__product__id'] = ','.join(self.config.products) + filters['configuration.product.id'] = ','.join(self.config.products) return filters @function_log(custom_logger=logger) diff --git a/connect/resources/usage_automation.py b/connect/resources/usage_automation.py index 0e8ff16..2a4272a 100644 --- a/connect/resources/usage_automation.py +++ b/connect/resources/usage_automation.py @@ -154,23 +154,39 @@ def _create_spreadsheet(usage_records): sheet = book.active sheet.title = 'usage_records' sheet['A1'] = 'record_id' - sheet['B1'] = 'item_search_criteria' - sheet['C1'] = 'item_search_value' - sheet['D1'] = 'quantity' - sheet['E1'] = 'start_time_utc' - sheet['F1'] = 'end_time_utc' - sheet['G1'] = 'asset_search_criteria' - sheet['H1'] = 'asset_search_value' + sheet['B1'] = 'record_note' + sheet['C1'] = 'item_search_criteria' + sheet['D1'] = 'item_search_value' + sheet['E1'] = 'amount' + sheet['F1'] = 'quantity' + sheet['G1'] = 'start_time_utc' + sheet['H1'] = 'end_time_utc' + sheet['I1'] = 'asset_search_criteria' + sheet['J1'] = 'asset_search_value' + sheet['K1'] = 'item_name' + sheet['L1'] = 'item_mpn' + sheet['M1'] = 'item_precision' + sheet['N1'] = 'category_id' + sheet['O1'] = 'asset_recon_id' + sheet['P1'] = 'tier' for index, record in enumerate(usage_records): row = str(index + 2) sheet['A' + row] = record.usage_record_id - sheet['B' + row] = record.item_search_criteria - sheet['C' + row] = record.item_search_value - sheet['D' + row] = record.quantity - sheet['E' + row] = record.start_time_utc - sheet['F' + row] = record.end_time_utc - sheet['G' + row] = record.asset_search_criteria - sheet['H' + row] = record.asset_search_value + sheet['B' + row] = record.usage_record_note + sheet['C' + row] = record.item_search_criteria + sheet['D' + row] = record.item_search_value + sheet['E' + row] = record.amount + sheet['F' + row] = record.quantity + sheet['G' + row] = record.start_time_utc + sheet['H' + row] = record.end_time_utc + sheet['I' + row] = record.asset_search_criteria + sheet['J' + row] = record.asset_search_value + sheet['K' + row] = record.item_name + sheet['L' + row] = record.item_npm + sheet['M' + row] = record.item_precision + sheet['N' + row] = record.category_id + sheet['O' + row] = record.asset_recon_id + sheet['P' + row] = record.tier return book def _upload_spreadsheet(self, usage_file, spreadsheet): diff --git a/examples/config.json b/examples/config.json index b68dfcf..e6eac4a 100644 --- a/examples/config.json +++ b/examples/config.json @@ -1,5 +1,5 @@ { "apiEndpoint": "https://api.cnct.tech/public/v1", - "apiKey": "ApiKey SU-XXX-XXX-XXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - "products": "PRD-000-000-000" + "apiKey": "ApiKey SU-607-795-595:2fe65fd64b867fe2f81748726713c252ea183c48", + "products": "PRD-418-056-738" } diff --git a/examples/tier_config.py b/examples/tier_config.py index a11367a..b47f99e 100644 --- a/examples/tier_config.py +++ b/examples/tier_config.py @@ -20,10 +20,11 @@ logger.setLevel('DEBUG') # If we remove this line, it is done implicitly -Config(file='config.json') +Config(file='./examples/config.json') class TierConfigExample(TierConfigAutomation): + def process_request(self, request): # type: (TierConfigRequest) -> Union[ActivationTemplateResponse, ActivationTileResponse] pass diff --git a/tests/data/response_usage_file.json b/tests/data/response_usage_file.json index 24d113c..04e62a7 100644 --- a/tests/data/response_usage_file.json +++ b/tests/data/response_usage_file.json @@ -29,14 +29,15 @@ "id": "PA-587-127", "name": "ABC Corp" }, - "upload_file_uri": "", + "usage_file_uri": "", "processed_file_uri": "", "acceptance_note": "All usage data is correct", "rejection_note": "Rejected due to wrong usage for item 56", "error_details": "Error details in case of usage file is marked as invalid", "records": { "valid": 56, - "invalid": 0 + "invalid": 0, + "closed": 0 }, "events": { "uploaded": { diff --git a/tests/test_models.py b/tests/test_models.py index a449e43..21bb7a5 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -224,8 +224,8 @@ def test_get_tier_config(get_mock): timeout=300, params={ 'status': 'approved', - 'configuration__product__id': 'product_id', - 'configuration__account__id': 'account_id'}) + 'configuration.product.id': 'product_id', + 'configuration.account.id': 'account_id'}) @patch('requests.get', MagicMock(return_value=Response(ok=True, text='[]', status_code=200))) diff --git a/tests/test_usage_file.py b/tests/test_usage_file.py index e421078..ae5533f 100644 --- a/tests/test_usage_file.py +++ b/tests/test_usage_file.py @@ -70,7 +70,7 @@ def test_create_resource(): assert provider.id == 'PA-587-127' assert provider.name == 'ABC Corp' - assert request.upload_file_uri == '' + assert request.usage_file_uri == '' assert request.processed_file_uri == '' assert request.acceptance_note == 'All usage data is correct' assert request.rejection_note == 'Rejected due to wrong usage for item 56' From f9247521cff27ea35cc7cb37c39599b65815d2d3 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Wed, 8 Apr 2020 10:51:57 +0200 Subject: [PATCH 17/20] Fix Francesco Faraone feedback --- connect/models/schemas.py | 4 ++-- examples/config.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/connect/models/schemas.py b/connect/models/schemas.py index 229c59b..d5be53c 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -768,8 +768,8 @@ class UsageRecordSchema(BaseSchema): usage_record_note = fields.Str() item_search_criteria = fields.Str() item_search_value = fields.Str() - amount = fields.Str() - quantity = fields.Str() + amount = fields.Int() + quantity = fields.Int() start_time_utc = fields.Str() end_time_utc = fields.Str() asset_search_criteria = fields.Str() diff --git a/examples/config.json b/examples/config.json index e6eac4a..fdde622 100644 --- a/examples/config.json +++ b/examples/config.json @@ -1,5 +1,5 @@ { "apiEndpoint": "https://api.cnct.tech/public/v1", - "apiKey": "ApiKey SU-607-795-595:2fe65fd64b867fe2f81748726713c252ea183c48", - "products": "PRD-418-056-738" + "apiKey": "ApiKey SU-000-000-000:0000000000000000000000000000000000000000", + "products": "PRD-000-000-000" } From 39f58ef9b6c8e995bbaeae5727fe90547134ef33 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Tue, 14 Apr 2020 16:22:15 +0200 Subject: [PATCH 18/20] Fix JaviCerveraIngram Feedback --- connect/models/__init__.py | 4 ++-- connect/models/billing.py | 4 ++-- connect/models/schemas.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/connect/models/__init__.py b/connect/models/__init__.py index 431f6f4..799e19e 100644 --- a/connect/models/__init__.py +++ b/connect/models/__init__.py @@ -8,7 +8,7 @@ from .activation_tile_response import ActivationTileResponse from .agreement import Agreement from .agreement_stats import AgreementStats -from .aniversary import Aniversary +from .anniversary import Anniversary from .asset import Asset from .base import BaseModel from .billing import Billing @@ -73,7 +73,7 @@ 'ActivationTileResponse', 'Agreement', 'AgreementStats', - 'Aniversary', + 'Anniversary', 'Asset', 'Attributes', 'BaseModel', diff --git a/connect/models/billing.py b/connect/models/billing.py index 353365c..992a4e8 100644 --- a/connect/models/billing.py +++ b/connect/models/billing.py @@ -21,5 +21,5 @@ class Billing(BaseModel): next_date = None # type: str """ (str) Next date of the billing. """ - aniversary = None # type: object - """ (:py:class:`.Aniversary`) Aniversary. """ + anniversary = None # type: object + """ (:py:class:`.Anniversary`) Anniversary. """ diff --git a/connect/models/schemas.py b/connect/models/schemas.py index d5be53c..a56bba4 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -823,14 +823,14 @@ def make_object(self, data): return Attributes(**data) -class AniversarySchema(BaseSchema): +class AnniversarySchema(BaseSchema): day = fields.Integer() month = fields.Integer() @post_load def make_object(self, data): - from connect.models import Aniversary - return Aniversary(**data) + from connect.models import Anniversary + return Anniversary(**data) class StatSchema(BaseSchema): @@ -857,7 +857,7 @@ class BillingSchema(BaseSchema): stats = fields.Nested(StatsSchema) period = fields.Nested(PeriodSchema) next_date = fields.DateTime() - aniversary = fields.Nested(AniversarySchema) + anniversary = fields.Nested(AnniversarySchema) @post_load def make_object(self, data): From f554ca4609c5a5bc31414767133a77a46ca47f45 Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Tue, 14 Apr 2020 16:22:48 +0200 Subject: [PATCH 19/20] Fix JaviCerveraIngram --- connect/models/{aniversary.py => anniversary.py} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename connect/models/{aniversary.py => anniversary.py} (52%) diff --git a/connect/models/aniversary.py b/connect/models/anniversary.py similarity index 52% rename from connect/models/aniversary.py rename to connect/models/anniversary.py index fbdc6b0..12b4db0 100644 --- a/connect/models/aniversary.py +++ b/connect/models/anniversary.py @@ -4,16 +4,16 @@ # Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. from .base import BaseModel -from .schemas import AniversarySchema +from .schemas import AnniversarySchema -class Aniversary(BaseModel): - """ An Aniversary object. """ +class Anniversary(BaseModel): + """ An Anniversary object. """ - _schema = AniversarySchema() + _schema = AnniversarySchema() day = None # type: str - """ (str) Day of the aniversay. """ + """ (str) Day of the anniversay. """ month = None # type: str - """ (str) Month of the aniversary. """ + """ (str) Month of the anniversary. """ From 782c5fed04f457e5a21e8b55da26f175b842343f Mon Sep 17 00:00:00 2001 From: Martin Constante Date: Thu, 16 Apr 2020 12:50:11 +0200 Subject: [PATCH 20/20] Fix Pavel and Vova feedback --- connect/models/billing_request.py | 4 ++-- connect/models/schemas.py | 3 +-- connect/resources/automation_engine.py | 1 - connect/resources/subscription.py | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/connect/models/billing_request.py b/connect/models/billing_request.py index bbfb36b..0f90a81 100644 --- a/connect/models/billing_request.py +++ b/connect/models/billing_request.py @@ -24,8 +24,8 @@ class BillingRequest(BaseModel): item = None # type: object """ (object) Billing Request Item. """ - asset = None # type: object - """ (object) Billing Request Asset. """ + attrubutes = None # type: object + """ (object) Billing Request Attributes. """ period = None # type: object """ (object) Billing Request Period. """ diff --git a/connect/models/schemas.py b/connect/models/schemas.py index a56bba4..49ab20d 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -66,7 +66,6 @@ def make_object(self, data): class CompanySchema(BaseSchema): name = fields.Str() - last_request = fields.Nested(LastRequestSchema, many=True) count = fields.Integer() @post_load @@ -376,7 +375,7 @@ def make_object(self, data): class ContractSchema(BaseSchema): - name = fields.String() + name = fields.Str() version = fields.Int() type = fields.Str() status = fields.Str() diff --git a/connect/resources/automation_engine.py b/connect/resources/automation_engine.py index dfa955b..d7ac7b3 100644 --- a/connect/resources/automation_engine.py +++ b/connect/resources/automation_engine.py @@ -24,7 +24,6 @@ def filters(self, status='pending', **kwargs): @function_log(custom_logger=logger) def process(self, filters=None): - self.logger.info('We are here!!!!') ''' # type: (Dict[str, Any]) -> None ''' diff --git a/connect/resources/subscription.py b/connect/resources/subscription.py index 3e83405..597ea45 100644 --- a/connect/resources/subscription.py +++ b/connect/resources/subscription.py @@ -4,8 +4,7 @@ class Subscription(object): - """ Allows listing and obtaining several types of objects. - + """ This class allows manage billing request and recurring asset, :param Config config: Config object or ``None`` to use environment config (default). """