From ee04acea48775d55870a487d04b80e24b74f596b Mon Sep 17 00:00:00 2001 From: Javier San Juan Cervera Date: Fri, 20 Sep 2019 11:14:01 +0200 Subject: [PATCH] Put each model in its own Python file, to reduce the chance of having circular references on imports. --- connect/exceptions.py | 2 +- connect/models/__init__.py | 59 ++++-- connect/models/activation.py | 25 +++ .../models/activation_template_response.py | 21 ++ ...esponse.py => activation_tile_response.py} | 17 -- connect/models/agreement.py | 76 +++++++ connect/models/agreement_stats.py | 21 ++ connect/models/asset.py | 9 +- connect/models/company.py | 11 +- connect/models/configuration.py | 27 +++ connect/models/connection.py | 2 +- connect/models/constraints.py | 28 +++ connect/models/contact.py | 48 +---- connect/models/contact_info.py | 37 ++++ connect/models/contract.py | 67 +++++++ connect/models/conversation.py | 23 +-- connect/models/conversation_message.py | 28 +++ connect/models/customer_ui_settings.py | 29 +++ connect/models/document.py | 19 ++ connect/models/download_link.py | 22 +++ connect/models/event.py | 47 +---- connect/models/events.py | 46 +++++ connect/models/ext_id_hub.py | 20 ++ connect/models/fulfillment.py | 5 +- connect/models/hub.py | 39 +--- connect/models/hub_instance.py | 16 ++ connect/models/hub_stats.py | 19 ++ connect/models/item.py | 56 ++++++ connect/models/marketplace.py | 151 +------------- connect/models/{parameters.py => param.py} | 41 +--- connect/models/phone_number.py | 27 +++ connect/models/product.py | 186 +----------------- connect/models/product_category.py | 28 +++ connect/models/product_configuration.py | 19 ++ connect/models/product_family.py | 16 ++ connect/models/product_stats.py | 23 +++ connect/models/product_stats_info.py | 17 ++ connect/models/renewal.py | 27 +++ connect/models/schemas.py | 28 +-- connect/models/server_error_response.py | 2 +- connect/models/template.py | 19 ++ connect/models/tier_account.py | 28 +++ connect/models/tier_accounts.py | 23 +++ connect/models/tier_config.py | 148 ++------------ connect/models/tier_config_request.py | 82 ++++++++ connect/models/{usage.py => usage_file.py} | 78 +------- connect/models/usage_listing.py | 35 ++++ connect/models/usage_record.py | 37 ++++ connect/models/usage_records.py | 20 ++ connect/models/user.py | 16 ++ connect/models/value_choice.py | 19 ++ tests/test_tier_config.py | 12 +- 52 files changed, 1119 insertions(+), 782 deletions(-) create mode 100644 connect/models/activation.py create mode 100644 connect/models/activation_template_response.py rename connect/models/{activation_response.py => activation_tile_response.py} (56%) create mode 100644 connect/models/agreement.py create mode 100644 connect/models/agreement_stats.py create mode 100644 connect/models/configuration.py create mode 100644 connect/models/constraints.py create mode 100644 connect/models/contact_info.py create mode 100644 connect/models/contract.py create mode 100644 connect/models/conversation_message.py create mode 100644 connect/models/customer_ui_settings.py create mode 100644 connect/models/document.py create mode 100644 connect/models/download_link.py create mode 100644 connect/models/events.py create mode 100644 connect/models/ext_id_hub.py create mode 100644 connect/models/hub_instance.py create mode 100644 connect/models/hub_stats.py create mode 100644 connect/models/item.py rename connect/models/{parameters.py => param.py} (62%) create mode 100644 connect/models/phone_number.py create mode 100644 connect/models/product_category.py create mode 100644 connect/models/product_configuration.py create mode 100644 connect/models/product_family.py create mode 100644 connect/models/product_stats.py create mode 100644 connect/models/product_stats_info.py create mode 100644 connect/models/renewal.py create mode 100644 connect/models/template.py create mode 100644 connect/models/tier_account.py create mode 100644 connect/models/tier_accounts.py create mode 100644 connect/models/tier_config_request.py rename connect/models/{usage.py => usage_file.py} (58%) create mode 100644 connect/models/usage_listing.py create mode 100644 connect/models/usage_record.py create mode 100644 connect/models/usage_records.py create mode 100644 connect/models/user.py create mode 100644 connect/models/value_choice.py diff --git a/connect/exceptions.py b/connect/exceptions.py index 5f9f3dd..75f3e50 100644 --- a/connect/exceptions.py +++ b/connect/exceptions.py @@ -8,7 +8,7 @@ from deprecation import deprecated import six -from .models.parameters import Param +from .models.param import Param class Message(Exception): diff --git a/connect/models/__init__.py b/connect/models/__init__.py index 8213d6f..b2d4878 100644 --- a/connect/models/__init__.py +++ b/connect/models/__init__.py @@ -3,24 +3,55 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2019 Ingram Micro. All Rights Reserved. -from .activation_response import ActivationTemplateResponse, ActivationTileResponse +from .activation import Activation +from .activation_template_response import ActivationTemplateResponse +from .activation_tile_response import ActivationTileResponse +from .agreement import Agreement +from .agreement_stats import AgreementStats from .asset import Asset from .base import BaseModel -from .company import Company, User +from .company import Company +from .configuration import Configuration from .connection import Connection -from .contact import Contact, ContactInfo, PhoneNumber -from .conversation import Conversation, ConversationMessage -from .event import EventInfo, Events +from .constraints import Constraints +from .contact import Contact +from .contact_info import ContactInfo +from .contract import Contract +from .conversation import Conversation +from .conversation_message import ConversationMessage +from .customer_ui_settings import CustomerUiSettings +from .document import Document +from .download_link import DownloadLink +from .event import Event +from .events import Events +from .ext_id_hub import ExtIdHub from .fulfillment import Fulfillment -from .hub import Hub, HubInstance, ExtIdHub, HubStats -from .marketplace import Activation, Agreement, AgreementStats, Contract, Marketplace -from .parameters import Constraints, Param, ValueChoice -from .product import CustomerUiSettings, Document, DownloadLink, Item, Product, \ - ProductCategory, ProductConfiguration, ProductFamily, ProductStats, ProductStatsInfo, Renewal +from .hub import Hub +from .hub_instance import HubInstance +from .hub_stats import HubStats +from .item import Item +from .marketplace import Marketplace +from .param import Param +from .phone_number import PhoneNumber +from .product import Product +from .product_category import ProductCategory +from .product_configuration import ProductConfiguration +from .product_family import ProductFamily +from .product_stats import ProductStats +from .product_stats_info import ProductStatsInfo +from .renewal import Renewal from .server_error_response import ServerErrorResponse -from .tier_config import Configuration, Template, TierAccount, TierAccounts, TierConfig, \ - TierConfigRequest -from .usage import UsageFile, UsageListing, UsageRecord, UsageRecords +from .template import Template +from .tier_account import TierAccount +from .tier_accounts import TierAccounts +from .tier_config import TierConfig +from .tier_config_request import TierConfigRequest +from .usage_file import UsageFile +from .usage_listing import UsageListing +from .usage_record import UsageRecord +from .usage_records import UsageRecords +from .user import User +from .value_choice import ValueChoice __all__ = [ 'Activation', @@ -42,7 +73,7 @@ 'CustomerUiSettings', 'Document', 'DownloadLink', - 'EventInfo', + 'Event', 'Events', 'ExtIdHub', 'Fulfillment', diff --git a/connect/models/activation.py b/connect/models/activation.py new file mode 100644 index 0000000..0e73633 --- /dev/null +++ b/connect/models/activation.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 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/activation_template_response.py b/connect/models/activation_template_response.py new file mode 100644 index 0000000..310b92a --- /dev/null +++ b/connect/models/activation_template_response.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + + +class ActivationTemplateResponse(object): + """ An instance of this class might the returned by the overriden ``process_request`` method + of your :py:class:`connect.resources.FulfillmentAutomation` or + :py:class:`connect.resources.TierConfigAutomation` subclass to approve the request being + processed, showing a tile with the specified template id. + + :param str template_id: Id of the template od the tile to be shown in the Vendor Portal. + The template must have been defined in the Vendor Portal. + :rtype: None + """ + + template_id = None # type: str + + def __init__(self, template_id): + self.template_id = template_id diff --git a/connect/models/activation_response.py b/connect/models/activation_tile_response.py similarity index 56% rename from connect/models/activation_response.py rename to connect/models/activation_tile_response.py index cbbfb4c..cec94c9 100644 --- a/connect/models/activation_response.py +++ b/connect/models/activation_tile_response.py @@ -23,20 +23,3 @@ def __init__(self, markdown=''): self.tile = json.loads(markdown) except ValueError: self.tile = markdown or self.__class__.tile - - -class ActivationTemplateResponse(object): - """ An instance of this class might the returned by the overriden ``process_request`` method - of your :py:class:`connect.resources.FulfillmentAutomation` or - :py:class:`connect.resources.TierConfigAutomation` subclass to approve the request being - processed, showing a tile with the specified template id. - - :param str template_id: Id of the template od the tile to be shown in the Vendor Portal. - The template must have been defined in the Vendor Portal. - :rtype: None - """ - - template_id = None # type: str - - def __init__(self, template_id): - self.template_id = template_id diff --git a/connect/models/agreement.py b/connect/models/agreement.py new file mode 100644 index 0000000..45c8c96 --- /dev/null +++ b/connect/models/agreement.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional, List + +from .agreement_stats import AgreementStats +from .base import BaseModel +from .company import Company +from .marketplace import Marketplace +from .user import User +from .schemas import AgreementSchema + + +class Agreement(BaseModel): + """ An Agreement object. """ + + _schema = AgreementSchema() + + type = None # type: str + """ (str) Type of the agreement. One of: distribution, program, service. """ + + title = None # type: str + """ (str) Title of the agreement. """ + + description = None # type: str + """ (str) Agreement details (Markdown). """ + + created = None # type: datetime.datetime + """ (datetime.datetime) Date of creation of the agreement. """ + + updated = None # type: datetime.datetime + """ (datetime.datetime) Date of the update of the agreement. It can be creation + of the new version, change of the field, etc. (any change). + """ + + owner = None # type: Company + """ (:py:class:`.Company`) Reference to the owner account object. """ + + stats = None # type: Optional[AgreementStats] + """ (:py:class:`.AgreementStats` | None) Agreement stats. """ + + author = None # type: Optional[User] + """ (:py:class:`.User` | None) Reference to the user who created the version. """ + + version = None # type: int + """ (int) Chronological number of the version. """ + + active = None # type: bool + """ (bool) State of the version. """ + + link = None # type: str + """ (str) Url to the document. """ + + version_created = None # type: datetime.datetime + """ (datetime.datetime) Date of the creation of the version. """ + + version_contracts = None # type: int + """ (int) Number of contracts this version has. """ + + agreements = None # type: List[Agreement] + """ (List[:py:class:`.Agreement`]) Program agreements can have distribution agreements + associated with them. + """ + + parent = None # type: Optional[Agreement] + """ (:py:class:`.Agreement` | None) Reference to the parent program agreement + (for distribution agreement). + """ + + marketplace = None # type: Optional[Marketplace] + """ (:py:class:`.Marketplace` | None) Reference to marketplace object + (for distribution agreement). + """ diff --git a/connect/models/agreement_stats.py b/connect/models/agreement_stats.py new file mode 100644 index 0000000..ec86fc3 --- /dev/null +++ b/connect/models/agreement_stats.py @@ -0,0 +1,21 @@ +# -*- 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 + +from .base import BaseModel +from .schemas import AgreementStatsSchema + + +class AgreementStats(BaseModel): + """ Agreement stats. """ + + _schema = AgreementStatsSchema() + + contracts = None # type: Optional[int] + """ (int|None) Number of contracts this agreement has. """ + + versions = None # type: int + """ (int) Number of versions in the agreement. """ diff --git a/connect/models/asset.py b/connect/models/asset.py index a5dd869..c2cdba7 100644 --- a/connect/models/asset.py +++ b/connect/models/asset.py @@ -7,10 +7,11 @@ from .base import BaseModel from .connection import Connection -from .parameters import Param -from .product import Item, Product -from .tier_config import TierAccounts -from connect.models.schemas import AssetSchema +from .item import Item +from .param import Param +from .product import Product +from .tier_accounts import TierAccounts +from .schemas import AssetSchema class Asset(BaseModel): diff --git a/connect/models/company.py b/connect/models/company.py index 8452ad0..a09f563 100644 --- a/connect/models/company.py +++ b/connect/models/company.py @@ -4,7 +4,7 @@ # Copyright (c) 2019 Ingram Micro. All Rights Reserved. from .base import BaseModel -from connect.models.schemas import CompanySchema, UserSchema +from .schemas import CompanySchema class Company(BaseModel): @@ -14,12 +14,3 @@ class Company(BaseModel): name = None # type: str """ (str) Company name. """ - - -class User(BaseModel): - """ Represents a user within the platform. """ - - _schema = UserSchema() - - name = None # type: str - """ (str) User name. """ diff --git a/connect/models/configuration.py b/connect/models/configuration.py new file mode 100644 index 0000000..82e372b --- /dev/null +++ b/connect/models/configuration.py @@ -0,0 +1,27 @@ +# -*- 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 List + +from .base import BaseModel +from .param import Param +from .schemas import ConfigurationSchema + + +class Configuration(BaseModel): + """ Configuration Phase Parameter Context-Bound Data Object. + + To be used in parameter contexts: + + - Asset. + - Fulfillment Request. + - TierConfig. + - TierConfig Requests. + """ + + _schema = ConfigurationSchema() + + params = None # type: List[Param] + """ (List[:py:class:`.Param`]) """ diff --git a/connect/models/connection.py b/connect/models/connection.py index f2bca7c..11502e7 100644 --- a/connect/models/connection.py +++ b/connect/models/connection.py @@ -7,7 +7,7 @@ from .company import Company from .hub import Hub from .product import Product -from connect.models.schemas import ConnectionSchema +from .schemas import ConnectionSchema class Connection(BaseModel): diff --git a/connect/models/constraints.py b/connect/models/constraints.py new file mode 100644 index 0000000..69fa8f1 --- /dev/null +++ b/connect/models/constraints.py @@ -0,0 +1,28 @@ +# -*- 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 List + +from .base import BaseModel +from .value_choice import ValueChoice +from .schemas import ConstraintsSchema + + +class Constraints(BaseModel): + """ Parameter constraints. """ + + _schema = ConstraintsSchema() + + hidden = None # type: bool + """ (bool) Is the parameter hidden? """ + + required = None # type: bool + """ (bool) Is the parameter required? """ + + choices = None # type: List[ValueChoice] + """ (List[:py:class:`.ValueChoice`]) Parameter value choices. """ + + unique = None # type: bool + """ (bool) Is the constraint unique? """ diff --git a/connect/models/contact.py b/connect/models/contact.py index 72f94a1..b47d5a7 100644 --- a/connect/models/contact.py +++ b/connect/models/contact.py @@ -6,25 +6,8 @@ from typing import Optional from .base import BaseModel -from connect.models.schemas import PhoneNumberSchema, ContactSchema, ContactInfoSchema - - -class PhoneNumber(BaseModel): - """ Phone number. """ - - _schema = PhoneNumberSchema() - - country_code = None # type: Optional[str] - """ (str|None) Country code. """ - - area_code = None # type: Optional[str] - """ (str|None) Area code. """ - - phone_number = None # type: Optional[str] - """ (str|None) Phone number. """ - - extension = None # type: Optional[str] - """ (str|None) Phone extension. """ +from .phone_number import PhoneNumber +from .schemas import ContactSchema class Contact(BaseModel): @@ -43,30 +26,3 @@ class Contact(BaseModel): phone_number = None # type: PhoneNumber """ (:py:class:`.PhoneNumber`) Phone number.""" - - -class ContactInfo(BaseModel): - """ Represents the information of a contact. """ - - _schema = ContactInfoSchema() - - address_line1 = None # type: str - """ (str) Street address, first line. """ - - address_line2 = None # type: Optional[str] - """ (str|None) Street address, second line. """ - - country = None # type: str - """ (str) Country code. """ - - state = None # type: str - """ (str) State name. """ - - city = None # type: str - """ (str) City name. """ - - postal_code = None # type: str - """ (str) Postal ZIP code. """ - - contact = None # type: Contact - """ (:py:class:`.Contact`) Person of contact. """ diff --git a/connect/models/contact_info.py b/connect/models/contact_info.py new file mode 100644 index 0000000..13f1223 --- /dev/null +++ b/connect/models/contact_info.py @@ -0,0 +1,37 @@ +# -*- 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 + +from .base import BaseModel +from .contact import Contact +from .schemas import ContactInfoSchema + + +class ContactInfo(BaseModel): + """ Represents the information of a contact. """ + + _schema = ContactInfoSchema() + + address_line1 = None # type: str + """ (str) Street address, first line. """ + + address_line2 = None # type: Optional[str] + """ (str|None) Street address, second line. """ + + country = None # type: str + """ (str) Country code. """ + + state = None # type: str + """ (str) State name. """ + + city = None # type: str + """ (str) City name. """ + + postal_code = None # type: str + """ (str) Postal ZIP code. """ + + contact = None # type: Contact + """ (:py:class:`.Contact`) Person of contact. """ diff --git a/connect/models/contract.py b/connect/models/contract.py new file mode 100644 index 0000000..078690c --- /dev/null +++ b/connect/models/contract.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +import datetime +from typing import Optional + +from .activation import Activation +from .agreement import Agreement +from .base import BaseModel +from .company import Company +from .marketplace import Marketplace +from .user import User +from .schemas import ContractSchema + + +class Contract(BaseModel): + """ Contract object. """ + + _schema = ContractSchema() + + name = None # type: str + """ (str) Contract name. """ + + version = None # type: int + """ (int) Version of the contract (same as associated agreement version). """ + + type = None # type: str + """ (str) Type of the contract (same as agreement type). One of: + distribution, program, service. + """ + + status = None # type: str + """ (str) Contract Status. One of: enrolling, pending, active, terminated, rejected """ + + agreement = None # type: Agreement + """ (:py:class:`.Agreement`) Reference object to the agreement. """ + + marketplace = None # type: Optional[Marketplace] + """ (:py:class:`.Marketplace` | None) Reference object to the agreement marketplace. """ + + owner = None # type: Optional[Company] + """ (:py:class:`.Company` | None) Reference object to the owner company. """ + + creator = None # type: User + """ (:py:class:`.User`) Reference object to the creator. """ + + created = None # type: datetime.datetime + """ (datetime.datetime) Contract creation date. """ + + updated = None # type: datetime.datetime + """ (datetime.datetime) Date of contract status update. """ + + enrolled = None # type: Optional[datetime.datetime] + """ (datetime.datetime|None) Date when contract was enrolled. """ + + version_created = None # type: datetime.datetime + """ (datetime.datetime) Contract version creation date. """ + + activation = None # type: Activation + """ (:py:class:`.Activation`) Activation information. """ + + signee = None # type: Optional[User] + """ (:py:class:`.User` | None) Reference object to the user of the owner company, + who signed the contract. + """ diff --git a/connect/models/conversation.py b/connect/models/conversation.py index 5422065..9b11e12 100644 --- a/connect/models/conversation.py +++ b/connect/models/conversation.py @@ -8,26 +8,9 @@ from typing import List from .base import BaseModel -from .company import User -from connect.models.schemas import ConversationMessageSchema, ConversationSchema - - -class ConversationMessage(BaseModel): - """ Message in a :py:class:`.Conversation`. """ - - _schema = ConversationMessageSchema() - - conversation = None # type: str - """ (str) Primary ID of Conversation object. """ - - created = None # type: datetime.datetime - """ (datetime.datetime) Date of the Message creation. """ - - creator = None # type: User - """ (:py:class:`.User`) :py:class:`.User` that created the message. """ - - text = None # type: str - """ (str) Actual message. """ +from .conversation_message import ConversationMessage +from .user import User +from .schemas import ConversationSchema class Conversation(BaseModel): diff --git a/connect/models/conversation_message.py b/connect/models/conversation_message.py new file mode 100644 index 0000000..12e2f5a --- /dev/null +++ b/connect/models/conversation_message.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +import datetime + +from .base import BaseModel +from .user import User +from .schemas import ConversationMessageSchema + + +class ConversationMessage(BaseModel): + """ Message in a :py:class:`.Conversation`. """ + + _schema = ConversationMessageSchema() + + conversation = None # type: str + """ (str) Primary ID of Conversation object. """ + + created = None # type: datetime.datetime + """ (datetime.datetime) Date of the Message creation. """ + + creator = None # type: User + """ (:py:class:`.User`) :py:class:`.User` that created the message. """ + + text = None # type: str + """ (str) Actual message. """ diff --git a/connect/models/customer_ui_settings.py b/connect/models/customer_ui_settings.py new file mode 100644 index 0000000..cb409e8 --- /dev/null +++ b/connect/models/customer_ui_settings.py @@ -0,0 +1,29 @@ +# -*- 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 List + +from .base import BaseModel +from .document import Document +from .download_link import DownloadLink +from .schemas import CustomerUiSettingsSchema + + +class CustomerUiSettings(BaseModel): + """ Customer Ui Settings for a product. """ + + _schema = CustomerUiSettingsSchema() + + description = None # type: str + """ (str) Description. """ + + getting_started = None # type: str + """ (str) Getting started. """ + + download_links = None # type: List[DownloadLink] + """ (List[:py:class:`.DownloadLink`]) Download links. """ + + documents = None # type: List[Document] + """ (List[:py:class:`.Document`]) Documents. """ diff --git a/connect/models/document.py b/connect/models/document.py new file mode 100644 index 0000000..6feb09c --- /dev/null +++ b/connect/models/document.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import DocumentSchema + + +class Document(BaseModel): + """ Document for a product. """ + + _schema = DocumentSchema() + + title = None # title: str + """ (str) Document title. """ + + url = None # title: str + """ (str) Document URL. """ diff --git a/connect/models/download_link.py b/connect/models/download_link.py new file mode 100644 index 0000000..cccbd6d --- /dev/null +++ b/connect/models/download_link.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import DownloadLinkSchema + + +class DownloadLink(BaseModel): + """ Download link for a product. """ + + _schema = DownloadLinkSchema() + + title = None # type: str + """ (str) Link title. """ + + url = None # type: str + """ (str) Link URL. """ + + visible_for = None # title: str + """ (str) Link visibility. One of: admin, user. """ diff --git a/connect/models/event.py b/connect/models/event.py index 17ae9ec..463cd59 100644 --- a/connect/models/event.py +++ b/connect/models/event.py @@ -7,56 +7,17 @@ from typing import Optional from .base import BaseModel -from .company import User -from connect.models.schemas import EventInfoSchema, EventsSchema +from .user import User +from .schemas import EventSchema -class EventInfo(BaseModel): +class Event(BaseModel): """ Represents the date and user that caused an event. """ - _schema = EventInfoSchema() + _schema = EventSchema() at = None # type: Optional[datetime.datetime] """ (datetime.datetime|None) Date when the event occurred. """ by = None # type: Optional[User] """ (:py:class:`.User`) User that caused the event. """ - - -class Events(BaseModel): - """ Represents a set of events that can take place on an object. """ - - _schema = EventsSchema() - - created = None # type: EventInfo - """ (:py:class:`.EventInfo`) Creation event. """ - - inquired = None # type: EventInfo - """ (:py:class:`.EventInfo`) Inquire event. """ - - pended = None # type: EventInfo - """ (:py:class:`.EventInfo`) Pending event. """ - - validated = None # type: EventInfo - """ (:py:class:`.EventInfo`) Validation event. """ - - updated = None # type: EventInfo - """ (:py:class:`.EventInfo`) Update event. """ - - approved = None # type: EventInfo - """ (:py:class:`.EventInfo`) Approve event. """ - - uploaded = None # type: EventInfo - """ (:py:class:`.EventInfo`) Uploaded event. """ - - submitted = None # type: EventInfo - """ (:py:class:`.EventInfo`) Submit event. """ - - accepted = None # type: EventInfo - """ (:py:class:`.EventInfo`) Accept event. """ - - rejected = None # type: EventInfo - """ (:py:class:`.EventInfo`) Reject event. """ - - closed = None # type: EventInfo - """ (:py:class:`.EventInfo`) Close event. """ diff --git a/connect/models/events.py b/connect/models/events.py new file mode 100644 index 0000000..f340a36 --- /dev/null +++ b/connect/models/events.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. +from .base import BaseModel +from .event import Event +from .schemas import EventsSchema + + +class Events(BaseModel): + """ Represents a set of events that can take place on an object. """ + + _schema = EventsSchema() + + created = None # type: Event + """ (:py:class:`.EventInfo`) Creation event. """ + + inquired = None # type: Event + """ (:py:class:`.EventInfo`) Inquire event. """ + + pended = None # type: Event + """ (:py:class:`.EventInfo`) Pending event. """ + + validated = None # type: Event + """ (:py:class:`.EventInfo`) Validation event. """ + + updated = None # type: Event + """ (:py:class:`.EventInfo`) Update event. """ + + approved = None # type: Event + """ (:py:class:`.EventInfo`) Approve event. """ + + uploaded = None # type: Event + """ (:py:class:`.EventInfo`) Uploaded event. """ + + submitted = None # type: Event + """ (:py:class:`.EventInfo`) Submit event. """ + + accepted = None # type: Event + """ (:py:class:`.EventInfo`) Accept event. """ + + rejected = None # type: Event + """ (:py:class:`.EventInfo`) Reject event. """ + + closed = None # type: Event + """ (:py:class:`.EventInfo`) Close event. """ diff --git a/connect/models/ext_id_hub.py b/connect/models/ext_id_hub.py new file mode 100644 index 0000000..4799ada --- /dev/null +++ b/connect/models/ext_id_hub.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .hub import Hub +from .schemas import ExtIdHubSchema + + +class ExtIdHub(BaseModel): + """ Associates a :py:class:`.Hub` with an external id. """ + + _schema = ExtIdHubSchema() + + hub = None # type: Hub + """ (:py:class:`.Hub`) Hub. """ + + external_id = None # type: str + """ (str) External id. """ diff --git a/connect/models/fulfillment.py b/connect/models/fulfillment.py index 2d2c3eb..591b619 100644 --- a/connect/models/fulfillment.py +++ b/connect/models/fulfillment.py @@ -7,9 +7,10 @@ from .asset import Asset from .base import BaseModel +from .contract import Contract from .conversation import Conversation -from .marketplace import Contract, Marketplace -from connect.models.schemas import FulfillmentSchema +from .marketplace import Marketplace +from .schemas import FulfillmentSchema class Fulfillment(BaseModel): diff --git a/connect/models/hub.py b/connect/models/hub.py index cbf0892..a1e5031 100644 --- a/connect/models/hub.py +++ b/connect/models/hub.py @@ -7,29 +7,10 @@ from .base import BaseModel from .company import Company -from .event import Events -from connect.models.schemas import HubInstanceSchema, HubStatsSchema, HubSchema, ExtIdHubSchema - - -class HubInstance(BaseModel): - """ An instance of a hub. """ - - _schema = HubInstanceSchema() - - type = None # type: str - """ (str) E-Commerce system type. """ - - -class HubStats(BaseModel): - """ Hub stats. """ - - _schema = HubStatsSchema() - - connections = None # type: int - """ (int) Number of connections active for this Hub. """ - - marketplaces = None # type: int - """ (int) Number of marketplaces for this Hub. """ +from .events import Events +from .hub_instance import HubInstance +from .hub_stats import HubStats +from .schemas import HubSchema class Hub(BaseModel): @@ -54,15 +35,3 @@ class Hub(BaseModel): stats = None # type: HubStats """ (:py:class:`.HubStats`) Hub stats. """ - - -class ExtIdHub(BaseModel): - """ Associates a :py:class:`.Hub` with an external id. """ - - _schema = ExtIdHubSchema() - - hub = None # type: Hub - """ (:py:class:`.Hub`) Hub. """ - - external_id = None # type: str - """ (str) External id. """ diff --git a/connect/models/hub_instance.py b/connect/models/hub_instance.py new file mode 100644 index 0000000..0984491 --- /dev/null +++ b/connect/models/hub_instance.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import HubInstanceSchema + + +class HubInstance(BaseModel): + """ An instance of a hub. """ + + _schema = HubInstanceSchema() + + type = None # type: str + """ (str) E-Commerce system type. """ diff --git a/connect/models/hub_stats.py b/connect/models/hub_stats.py new file mode 100644 index 0000000..17e9d10 --- /dev/null +++ b/connect/models/hub_stats.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import HubStatsSchema + + +class HubStats(BaseModel): + """ Hub stats. """ + + _schema = HubStatsSchema() + + connections = None # type: int + """ (int) Number of connections active for this Hub. """ + + marketplaces = None # type: int + """ (int) Number of marketplaces for this Hub. """ diff --git a/connect/models/item.py b/connect/models/item.py new file mode 100644 index 0000000..368f5dd --- /dev/null +++ b/connect/models/item.py @@ -0,0 +1,56 @@ +# -*- 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 List, Optional, Union + +from .base import BaseModel +from .param import Param +from .renewal import Renewal +from .schemas import ItemSchema + + +class Item(BaseModel): + """ A product item. """ + + _schema = ItemSchema() + + mpn = None # type: str + """ (str) Item manufacture part number. """ + + quantity = None # type: Union[int,float] + """ (int|float) Number of items of the type in the asset (-1 if unlimited) """ + + old_quantity = None # type: Union[int,float,None] + """ (int|float|None) Previous value of quantity. """ + + renewal = None # type: Optional[Renewal] + """ (:py:class:`.Renewal` | None) Parameters of renewal request + (empty for all other types). + """ + + params = None # type: List[Param] + """ (List[:py:class:`.Param` | None] List of Item and Item x Marketplace Configuration Phase + Parameter Context-Bound Object + """ + + # Undocumented fields (they appear in PHP SDK) + + display_name = None # type: str + """ (str) Display name. """ + + global_id = None # type: str + """ (str) Global id. """ + + item_type = None # type: str + """ (str) Item type. """ + + period = None # type: str + """ (str) Period. """ + + type = None # type: str + """ (str) Type. """ + + name = None # type: str + """ (str) Name. """ diff --git a/connect/models/marketplace.py b/connect/models/marketplace.py index 4dbc83a..6a4e518 100644 --- a/connect/models/marketplace.py +++ b/connect/models/marketplace.py @@ -3,14 +3,12 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2019 Ingram Micro. All Rights Reserved. -import datetime -from typing import Optional, List +from typing import List from .base import BaseModel -from .company import Company, User -from .hub import ExtIdHub -from connect.models.schemas import MarketplaceSchema, AgreementStatsSchema, AgreementSchema, \ - ActivationSchema, ContractSchema +from .company import Company +from .ext_id_hub import ExtIdHub +from .schemas import MarketplaceSchema class Marketplace(BaseModel): @@ -46,144 +44,3 @@ class Marketplace(BaseModel): zone = None # type: str """ (str) Zone where the marketplace is located, there can be following zones: AF, NA, OC, AS, EU, SA (It is continents). """ - - -class AgreementStats(BaseModel): - """ Agreement stats. """ - - _schema = AgreementStatsSchema() - - contracts = None # type: Optional[int] - """ (int|None) Number of contracts this agreement has. """ - - versions = None # type: int - """ (int) Number of versions in the agreement. """ - - -class Agreement(BaseModel): - """ An Agreement object. """ - - _schema = AgreementSchema() - - type = None # type: str - """ (str) Type of the agreement. One of: distribution, program, service. """ - - title = None # type: str - """ (str) Title of the agreement. """ - - description = None # type: str - """ (str) Agreement details (Markdown). """ - - created = None # type: datetime.datetime - """ (datetime.datetime) Date of creation of the agreement. """ - - updated = None # type: datetime.datetime - """ (datetime.datetime) Date of the update of the agreement. It can be creation - of the new version, change of the field, etc. (any change). - """ - - owner = None # type: Company - """ (:py:class:`.Company`) Reference to the owner account object. """ - - stats = None # type: Optional[AgreementStats] - """ (:py:class:`.AgreementStats` | None) Agreement stats. """ - - author = None # type: Optional[User] - """ (:py:class:`.User` | None) Reference to the user who created the version. """ - - version = None # type: int - """ (int) Chronological number of the version. """ - - active = None # type: bool - """ (bool) State of the version. """ - - link = None # type: str - """ (str) Url to the document. """ - - version_created = None # type: datetime.datetime - """ (datetime.datetime) Date of the creation of the version. """ - - version_contracts = None # type: int - """ (int) Number of contracts this version has. """ - - agreements = None # type: List[Agreement] - """ (List[:py:class:`.Agreement`]) Program agreements can have distribution agreements - associated with them. - """ - - parent = None # type: Optional[Agreement] - """ (:py:class:`.Agreement` | None) Reference to the parent program agreement - (for distribution agreement). - """ - - marketplace = None # type: Optional[Marketplace] - """ (:py:class:`.Marketplace` | None) Reference to marketplace object - (for distribution agreement). - """ - - -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. """ - - -class Contract(BaseModel): - """ Contract object. """ - - _schema = ContractSchema() - - name = None # type: str - """ (str) Contract name. """ - - version = None # type: int - """ (int) Version of the contract (same as associated agreement version). """ - - type = None # type: str - """ (str) Type of the contract (same as agreement type). One of: - distribution, program, service. - """ - - status = None # type: str - """ (str) Contract Status. One of: enrolling, pending, active, terminated, rejected """ - - agreement = None # type: Agreement - """ (:py:class:`.Agreement`) Reference object to the agreement. """ - - marketplace = None # type: Optional[Marketplace] - """ (:py:class:`.Marketplace` | None) Reference object to the agreement marketplace. """ - - owner = None # type: Optional[Company] - """ (:py:class:`.Company` | None) Reference object to the owner company. """ - - creator = None # type: User - """ (:py:class:`.User`) Reference object to the creator. """ - - created = None # type: datetime.datetime - """ (datetime.datetime) Contract creation date. """ - - updated = None # type: datetime.datetime - """ (datetime.datetime) Date of contract status update. """ - - enrolled = None # type: Optional[datetime.datetime] - """ (datetime.datetime|None) Date when contract was enrolled. """ - - version_created = None # type: datetime.datetime - """ (datetime.datetime) Contract version creation date. """ - - activation = None # type: Activation - """ (:py:class:`.Activation`) Activation information. """ - - signee = None # type: Optional[User] - """ (:py:class:`.User` | None) Reference object to the user of the owner company, - who signed the contract. - """ diff --git a/connect/models/parameters.py b/connect/models/param.py similarity index 62% rename from connect/models/parameters.py rename to connect/models/param.py index 9b15324..5fd7881 100644 --- a/connect/models/parameters.py +++ b/connect/models/param.py @@ -5,39 +5,12 @@ from typing import List, Optional -import connect.models from .base import BaseModel -from connect.models.schemas import ValueChoiceSchema, ConstraintsSchema, ParamSchema - - -class ValueChoice(BaseModel): - """ A value choice for a parameter. """ - - _schema = ValueChoiceSchema() - - value = None # type: str - """ (str) Value. """ - - label = None # type: str - """ (str) Label. """ - - -class Constraints(BaseModel): - """ Parameter constraints. """ - - _schema = ConstraintsSchema() - - hidden = None # type: bool - """ (bool) Is the parameter hidden? """ - - required = None # type: bool - """ (bool) Is the parameter required? """ - - choices = None # type: List[ValueChoice] - """ (List[:py:class:`.ValueChoice`]) Parameter value choices. """ - - unique = None # type: bool - """ (bool) Is the constraint unique? """ +from .constraints import Constraints +from .events import Events +from .marketplace import Marketplace +from .value_choice import ValueChoice +from .schemas import ParamSchema class Param(BaseModel): @@ -80,8 +53,8 @@ class Param(BaseModel): phase = None # type: Optional[str] """ (str|None) Param phase. """ - events = None # type: Optional[connect.models.Events] + events = None # type: Optional[Events] """ (:py:class:`.Events` | None) Events. """ - marketplace = None # type: Optional[connect.models.Marketplace] + marketplace = None # type: Optional[Marketplace] """ (:py:class:`.Marketplace` | None) Marketplace. """ diff --git a/connect/models/phone_number.py b/connect/models/phone_number.py new file mode 100644 index 0000000..990d917 --- /dev/null +++ b/connect/models/phone_number.py @@ -0,0 +1,27 @@ +# -*- 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 + +from .base import BaseModel +from .schemas import PhoneNumberSchema + + +class PhoneNumber(BaseModel): + """ Phone number. """ + + _schema = PhoneNumberSchema() + + country_code = None # type: Optional[str] + """ (str|None) Country code. """ + + area_code = None # type: Optional[str] + """ (str|None) Area code. """ + + phone_number = None # type: Optional[str] + """ (str|None) Phone number. """ + + extension = None # type: Optional[str] + """ (str|None) Phone extension. """ diff --git a/connect/models/product.py b/connect/models/product.py index 0341138..2043cdd 100644 --- a/connect/models/product.py +++ b/connect/models/product.py @@ -4,122 +4,15 @@ # Copyright (c) 2019 Ingram Micro. All Rights Reserved. import datetime -from typing import List, Optional, Union +from typing import Optional -import connect.models from .base import BaseModel -from connect.models.schemas import ProductConfigurationSchema, DownloadLinkSchema, DocumentSchema, \ - CustomerUiSettingsSchema, ProductSchema, RenewalSchema, ItemSchema, ProductFamilySchema, \ - ProductCategorySchema, ProductStatsInfoSchema, ProductStatsSchema - - -class ProductConfiguration(BaseModel): - """ Product configurations. """ - - _schema = ProductConfigurationSchema() - - suspend_resume_supported = None # type: bool - """ (bool) Is suspend and resume supported for the product? """ - - requires_reseller_information = None # type: bool - """ (bool) Does the product require reseller information? """ - - -class DownloadLink(BaseModel): - """ Download link for a product. """ - - _schema = DownloadLinkSchema() - - title = None # type: str - """ (str) Link title. """ - - url = None # type: str - """ (str) Link URL. """ - - visible_for = None # title: str - """ (str) Link visibility. One of: admin, user. """ - - -class Document(BaseModel): - """ Document for a product. """ - - _schema = DocumentSchema() - - title = None # title: str - """ (str) Document title. """ - - url = None # title: str - """ (str) Document URL. """ - - -class CustomerUiSettings(BaseModel): - """ Customer Ui Settings for a product. """ - - _schema = CustomerUiSettingsSchema() - - description = None # type: str - """ (str) Description. """ - - getting_started = None # type: str - """ (str) Getting started. """ - - download_links = None # type: List[DownloadLink] - """ (List[:py:class:`.DownloadLink`]) Download links. """ - - documents = None # type: List[Document] - """ (List[:py:class:`.Document`]) Documents. """ - - -class ProductFamily(BaseModel): - """ Represents a family of products """ - - _schema = ProductFamilySchema() - - name = None # type: str - """ (str) Family name. """ - - -class ProductCategory(BaseModel): - """ Represents a product category. """ - - _schema = ProductCategorySchema() - - name = None # type: str - """ (str) Category name. """ - - parent = None # type: Optional[ProductCategory] - """ (:py:class:`.ProductCategory` | None) Reference to parent category. """ - - children = None # type: Optional[List[ProductCategory]] - """ (List[:py:class:`.ProductCategory`] | None) List of children categories. """ - - family = None # type: Optional[ProductFamily] - """ (:py:class:`.ProductFamily` | None) Product family. """ - - -class ProductStatsInfo(BaseModel): - _schema = ProductStatsInfoSchema() - - distribution = None # type: int - """ (int) Number of distributions related to the product. """ - - sourcing = None # type: int - """ (int) Number of sourcings related to the product. """ - - -class ProductStats(BaseModel): - """ Statistics of product use. """ - - _schema = ProductStatsSchema() - - listing = None # type: int - """ (int) Number of listings (direct use of product by provider). """ - - agreements = None # type: ProductStatsInfo - """ (:py:class:`.ProductStatsInfo`) Agreements related to the product. """ - - contracts = None # type: ProductStatsInfo - """ (:py:class:`.ProductStatsInfo`) Contracts related to the product """ +from .company import Company +from .customer_ui_settings import CustomerUiSettings +from .product_category import ProductCategory +from .product_configuration import ProductConfiguration +from .product_stats import ProductStats +from .schemas import ProductSchema class Product(BaseModel): @@ -160,7 +53,7 @@ class Product(BaseModel): category = None # type: Optional[ProductCategory] """ (:py:class:`.ProductCategory` | None) Reference to ProductCategory Object. """ - owner = None # type: Optional[connect.models.Company] + owner = None # type: Optional[Company] """ (:py:class:`.Company` | None) """ latest = None # type: Optional[bool] @@ -170,66 +63,3 @@ class Product(BaseModel): stats = None # type: Optional[ProductStats] """ (:py:class:``.ProductStats) Statistics of product use, depends on account of callee. """ - - -class Renewal(BaseModel): - """ Item renewal data. """ - - _schema = RenewalSchema() - - from_ = None # type: datetime.datetime - """ (datetime.datetime) Date of renewal beginning. """ - - to = None # type: datetime.datetime - """ (datetime.datetime) Date of renewal end. """ - - period_delta = None # type: int - """ (int) Size of renewal period. """ - - period_uom = None # type: str - """ (str) Unit of measure for renewal period. One of: year, month, day, hour. """ - - -class Item(BaseModel): - """ A product item. """ - - _schema = ItemSchema() - - mpn = None # type: str - """ (str) Item manufacture part number. """ - - quantity = None # type: Union[int,float] - """ (int|float) Number of items of the type in the asset (-1 if unlimited) """ - - old_quantity = None # type: Union[int,float,None] - """ (int|float|None) Previous value of quantity. """ - - renewal = None # type: Optional[Renewal] - """ (:py:class:`.Renewal` | None) Parameters of renewal request - (empty for all other types). - """ - - params = None # type: List[connect.models.Param] - """ (List[:py:class:`.Param` | None] List of Item and Item x Marketplace Configuration Phase - Parameter Context-Bound Object - """ - - # Undocumented fields (they appear in PHP SDK) - - display_name = None # type: str - """ (str) Display name. """ - - global_id = None # type: str - """ (str) Global id. """ - - item_type = None # type: str - """ (str) Item type. """ - - period = None # type: str - """ (str) Period. """ - - type = None # type: str - """ (str) Type. """ - - name = None # type: str - """ (str) Name. """ diff --git a/connect/models/product_category.py b/connect/models/product_category.py new file mode 100644 index 0000000..ac4e5b4 --- /dev/null +++ b/connect/models/product_category.py @@ -0,0 +1,28 @@ +# -*- 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 List, Optional + +from .base import BaseModel +from .product_family import ProductFamily +from .schemas import ProductCategorySchema + + +class ProductCategory(BaseModel): + """ Represents a product category. """ + + _schema = ProductCategorySchema() + + name = None # type: str + """ (str) Category name. """ + + parent = None # type: Optional[ProductCategory] + """ (:py:class:`.ProductCategory` | None) Reference to parent category. """ + + children = None # type: Optional[List[ProductCategory]] + """ (List[:py:class:`.ProductCategory`] | None) List of children categories. """ + + family = None # type: Optional[ProductFamily] + """ (:py:class:`.ProductFamily` | None) Product family. """ diff --git a/connect/models/product_configuration.py b/connect/models/product_configuration.py new file mode 100644 index 0000000..b667496 --- /dev/null +++ b/connect/models/product_configuration.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import ProductConfigurationSchema + + +class ProductConfiguration(BaseModel): + """ Product configurations. """ + + _schema = ProductConfigurationSchema() + + suspend_resume_supported = None # type: bool + """ (bool) Is suspend and resume supported for the product? """ + + requires_reseller_information = None # type: bool + """ (bool) Does the product require reseller information? """ diff --git a/connect/models/product_family.py b/connect/models/product_family.py new file mode 100644 index 0000000..89466d8 --- /dev/null +++ b/connect/models/product_family.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import ProductFamilySchema + + +class ProductFamily(BaseModel): + """ Represents a family of products """ + + _schema = ProductFamilySchema() + + name = None # type: str + """ (str) Family name. """ diff --git a/connect/models/product_stats.py b/connect/models/product_stats.py new file mode 100644 index 0000000..2da7e8d --- /dev/null +++ b/connect/models/product_stats.py @@ -0,0 +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 .base import BaseModel +from .product_stats_info import ProductStatsInfo +from .schemas import ProductStatsSchema + + +class ProductStats(BaseModel): + """ Statistics of product use. """ + + _schema = ProductStatsSchema() + + listing = None # type: int + """ (int) Number of listings (direct use of product by provider). """ + + agreements = None # type: ProductStatsInfo + """ (:py:class:`.ProductStatsInfo`) Agreements related to the product. """ + + contracts = None # type: ProductStatsInfo + """ (:py:class:`.ProductStatsInfo`) Contracts related to the product """ diff --git a/connect/models/product_stats_info.py b/connect/models/product_stats_info.py new file mode 100644 index 0000000..8db1d53 --- /dev/null +++ b/connect/models/product_stats_info.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import ProductStatsInfoSchema + + +class ProductStatsInfo(BaseModel): + _schema = ProductStatsInfoSchema() + + distribution = None # type: int + """ (int) Number of distributions related to the product. """ + + sourcing = None # type: int + """ (int) Number of sourcings related to the product. """ diff --git a/connect/models/renewal.py b/connect/models/renewal.py new file mode 100644 index 0000000..5be94c7 --- /dev/null +++ b/connect/models/renewal.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +import datetime + +from .base import BaseModel +from .schemas import RenewalSchema + + +class Renewal(BaseModel): + """ Item renewal data. """ + + _schema = RenewalSchema() + + from_ = None # type: datetime.datetime + """ (datetime.datetime) Date of renewal beginning. """ + + to = None # type: datetime.datetime + """ (datetime.datetime) Date of renewal end. """ + + period_delta = None # type: int + """ (int) Size of renewal period. """ + + period_uom = None # type: str + """ (str) Unit of measure for renewal period. One of: year, month, day, hour. """ diff --git a/connect/models/schemas.py b/connect/models/schemas.py index c4782f9..d3a8b35 100644 --- a/connect/models/schemas.py +++ b/connect/models/schemas.py @@ -137,28 +137,28 @@ def make_object(self, data): return User(**data) -class EventInfoSchema(BaseSchema): +class EventSchema(BaseSchema): at = fields.DateTime(allow_none=True) by = fields.Nested(UserSchema, allow_none=True) @post_load def make_object(self, data): - from connect.models import EventInfo - return EventInfo(**data) + from connect.models import Event + return Event(**data) class EventsSchema(BaseSchema): - created = fields.Nested(EventInfoSchema) - inquired = fields.Nested(EventInfoSchema) - pended = fields.Nested(EventInfoSchema) - validated = fields.Nested(EventInfoSchema) - updated = fields.Nested(EventInfoSchema) - approved = fields.Nested(EventInfoSchema) - uploaded = fields.Nested(EventInfoSchema) - submitted = fields.Nested(EventInfoSchema) - accepted = fields.Nested(EventInfoSchema) - rejected = fields.Nested(EventInfoSchema) - closed = fields.Nested(EventInfoSchema) + created = fields.Nested(EventSchema) + inquired = fields.Nested(EventSchema) + pended = fields.Nested(EventSchema) + validated = fields.Nested(EventSchema) + updated = fields.Nested(EventSchema) + approved = fields.Nested(EventSchema) + uploaded = fields.Nested(EventSchema) + submitted = fields.Nested(EventSchema) + accepted = fields.Nested(EventSchema) + rejected = fields.Nested(EventSchema) + closed = fields.Nested(EventSchema) @post_load def make_object(self, data): diff --git a/connect/models/server_error_response.py b/connect/models/server_error_response.py index 4915605..7c0d616 100644 --- a/connect/models/server_error_response.py +++ b/connect/models/server_error_response.py @@ -6,7 +6,7 @@ from typing import List from .base import BaseModel -from connect.models.schemas import ServerErrorResponseSchema +from .schemas import ServerErrorResponseSchema class ServerErrorResponse(BaseModel): diff --git a/connect/models/template.py b/connect/models/template.py new file mode 100644 index 0000000..c3501c4 --- /dev/null +++ b/connect/models/template.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import TemplateSchema + + +class Template(BaseModel): + """ Tier Template """ + + _schema = TemplateSchema() + + name = None # type: str + """ (str) Template name. """ + + representation = None # type: str + """ (str) Template representation. """ diff --git a/connect/models/tier_account.py b/connect/models/tier_account.py new file mode 100644 index 0000000..31272c0 --- /dev/null +++ b/connect/models/tier_account.py @@ -0,0 +1,28 @@ +# -*- 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 + +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. """ diff --git a/connect/models/tier_accounts.py b/connect/models/tier_accounts.py new file mode 100644 index 0000000..bca21e6 --- /dev/null +++ b/connect/models/tier_accounts.py @@ -0,0 +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 .base import BaseModel +from .tier_account import TierAccount +from .schemas import TierAccountsSchema + + +class TierAccounts(BaseModel): + """ TierAccounts object. """ + + _schema = TierAccountsSchema() + + customer = None # type: TierAccount + """ (:py:class:`.TierAccount`) Customer Level TierAccount Object. """ + + tier1 = None # type: TierAccount + """ (:py:class:`.TierAccount`) Level 1 TierAccount Object. """ + + tier2 = None # type: TierAccount + """ (:py:class:`.TierAccount`) Level 2 TierAccount Object. """ diff --git a/connect/models/tier_config.py b/connect/models/tier_config.py index a4ddcba..14e44b5 100644 --- a/connect/models/tier_config.py +++ b/connect/models/tier_config.py @@ -5,79 +5,17 @@ from typing import Optional, List -import connect.models from .base import BaseModel -from .company import User +from .configuration import Configuration from .connection import Connection -from .contact import ContactInfo -from .event import Events -from .marketplace import Activation -from .parameters import Param +from .contract import Contract +from .events import Events +from .marketplace import Marketplace +from .param import Param from .product import Product -from connect.models.schemas import TemplateSchema, TierAccountSchema, \ - TierAccountsSchema, TierConfigSchema, TierConfigRequestSchema, ConfigurationSchema - - -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. """ - - -class TierAccounts(BaseModel): - """ TierAccounts object. """ - - _schema = TierAccountsSchema() - - customer = None # type: TierAccount - """ (:py:class:`.TierAccount`) Customer Level TierAccount Object. """ - - tier1 = None # type: TierAccount - """ (:py:class:`.TierAccount`) Level 1 TierAccount Object. """ - - tier2 = None # type: TierAccount - """ (:py:class:`.TierAccount`) Level 2 TierAccount Object. """ - - -class Template(BaseModel): - """ Tier Template """ - - _schema = TemplateSchema() - - name = None # type: str - """ (str) Template name. """ - - representation = None # type: str - """ (str) Template representation. """ - - -class Configuration(BaseModel): - """ Configuration Phase Parameter Context-Bound Data Object. - - To be used in parameter contexts: - - - Asset. - - Fulfillment Request. - - TierConfig. - - TierConfig Requests. - """ - - _schema = ConfigurationSchema() - - params = None # type: List[Param] - """ (List[:py:class:`.Param`]) """ +from .template import Template +from .tier_account import TierAccount +from .schemas import TierConfigSchema class TierConfig(BaseModel): @@ -113,10 +51,10 @@ class TierConfig(BaseModel): template = None # type: Template """ (:py:class:`.Template`) Template Object. """ - contract = None # type: connect.models.Contract + contract = None # type: Contract """ (:py:class:`.Contract`) Contract Object reference. """ - marketplace = None # type: connect.models.Marketplace + marketplace = None # type: Marketplace """ (:py:class:`.Marketplace`) Marketplace Object reference. """ configuration = None # type: Configuration @@ -141,6 +79,7 @@ def get(cls, account_id, product_id, config=None): :return: The requested Tier Config, or ``None`` if it was not found. :rtype: Optional[TierConfig] """ + from .tier_config_request import TierConfigRequest from connect.resources.base import ApiClient response, _ = ApiClient(config, base_path='tier/config-requests').get( @@ -168,68 +107,3 @@ def get_param_by_id(self, id_): return list(filter(lambda param: param.id == id_, self.params))[0] except IndexError: return None - - -class TierConfigRequest(BaseModel): - _schema = TierConfigRequestSchema() - - type = None # type: str - """ (str) TCR type. One of: setup, update. """ - - status = None # type: str - """ (str) TCR current status. One of: tiers_setup, pending, inquiring, approved, failed. """ - - configuration = None # type: TierConfig - """ (:py:class:`.TierConfig`) Full representation of TierConfig Object. """ - - parent_configuration = None # type: Optional[TierConfig] - """ (:py:class:`.TierConfig` | None) Full representation of parent TierConfig. """ - - account = None # type: TierAccount - """ (:py:class:`.TierAccount`) Reference object to TierAccount. """ - - product = None # type: Product - """ (:py:class:`.Product`) Reference object to product (application). """ - - tier_level = None # type: int - """ (int) Tier level for product from customer perspective (1 or 2). """ - - params = None # type: List[Param] - """ (List[:py:class:`.Param`]) List of parameter data objects as in Asset Object. - Params can be modified only in Pending state. - """ - - environment = None # type: str - """ (str) TCR environment (test, prod or preview) """ - - assignee = None # type: Optional[User] - """ (:py:class:`.User` | None) TCR environment. One of: test, prod, preview. """ - - template = None # type: Optional[Template] - """ (:py:class:`.Template` | None) Template Object. This is filled only if TCR is approved. """ - - reason = None # type: Optional[str] - """ (str|None) Failing reason. This is filled only if TCR is failed. """ - - activation = None # type: Optional[Activation] - """ (:py:class:`.Activation` | None) Activation object. This is created only if TCR - has ordering parameters and seen in inquiring state of the TCR. - """ - - notes = None # type: Optional[str] - """ (str) TCR pending notes. Notes can be modified only in Pending state. """ - - events = None # type: Optional[Events] - """ (:py:class:`.Events` | None) Tier Config request Events. """ - - def get_param_by_id(self, id_): - """ Get a Tier Config Request parameter. - - :param str id_: Parameter id. - :return: The requested parameter, or ``None`` if it was not found. - :rtype: Param - """ - try: - return list(filter(lambda param: param.id == id_, self.params))[0] - except IndexError: - return None diff --git a/connect/models/tier_config_request.py b/connect/models/tier_config_request.py new file mode 100644 index 0000000..ac112a0 --- /dev/null +++ b/connect/models/tier_config_request.py @@ -0,0 +1,82 @@ +# -*- 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, List + +from .activation import Activation +from .base import BaseModel +from .events import Events +from .param import Param +from .product import Product +from .template import Template +from .tier_account import TierAccount +from .tier_config import TierConfig +from .user import User +from .schemas import TierConfigRequestSchema + + +class TierConfigRequest(BaseModel): + _schema = TierConfigRequestSchema() + + type = None # type: str + """ (str) TCR type. One of: setup, update. """ + + status = None # type: str + """ (str) TCR current status. One of: tiers_setup, pending, inquiring, approved, failed. """ + + configuration = None # type: TierConfig + """ (:py:class:`.TierConfig`) Full representation of TierConfig Object. """ + + parent_configuration = None # type: Optional[TierConfig] + """ (:py:class:`.TierConfig` | None) Full representation of parent TierConfig. """ + + account = None # type: TierAccount + """ (:py:class:`.TierAccount`) Reference object to TierAccount. """ + + product = None # type: Product + """ (:py:class:`.Product`) Reference object to product (application). """ + + tier_level = None # type: int + """ (int) Tier level for product from customer perspective (1 or 2). """ + + params = None # type: List[Param] + """ (List[:py:class:`.Param`]) List of parameter data objects as in Asset Object. + Params can be modified only in Pending state. + """ + + environment = None # type: str + """ (str) TCR environment (test, prod or preview) """ + + assignee = None # type: Optional[User] + """ (:py:class:`.User` | None) TCR environment. One of: test, prod, preview. """ + + template = None # type: Optional[Template] + """ (:py:class:`.Template` | None) Template Object. This is filled only if TCR is approved. """ + + reason = None # type: Optional[str] + """ (str|None) Failing reason. This is filled only if TCR is failed. """ + + activation = None # type: Optional[Activation] + """ (:py:class:`.Activation` | None) Activation object. This is created only if TCR + has ordering parameters and seen in inquiring state of the TCR. + """ + + notes = None # type: Optional[str] + """ (str) TCR pending notes. Notes can be modified only in Pending state. """ + + events = None # type: Optional[Events] + """ (:py:class:`.Events` | None) Tier Config request Events. """ + + def get_param_by_id(self, id_): + """ Get a Tier Config Request parameter. + + :param str id_: Parameter id. + :return: The requested parameter, or ``None`` if it was not found. + :rtype: Param + """ + try: + return list(filter(lambda param: param.id == id_, self.params))[0] + except IndexError: + return None diff --git a/connect/models/usage.py b/connect/models/usage_file.py similarity index 58% rename from connect/models/usage.py rename to connect/models/usage_file.py index 8033828..310dce9 100644 --- a/connect/models/usage.py +++ b/connect/models/usage_file.py @@ -2,26 +2,15 @@ # This file is part of the Ingram Micro Cloud Blue Connect SDK. # Copyright (c) 2019 Ingram Micro. All Rights Reserved. -from connect.models import Events + from .base import BaseModel from .company import Company -from .marketplace import Contract, Marketplace +from .contract import Contract +from .events import Events +from .marketplace import Marketplace from .product import Product -from connect.models.schemas import UsageRecordsSchema, UsageFileSchema, UsageListingSchema, \ - UsageRecordSchema - - -class UsageRecords(BaseModel): - """ Usage Records Object. """ - # TODO: Verify that this data is correct. - - _schema = UsageRecordsSchema() - - valid = None # type: int - """ (int) Valid. """ - - invalid = None # type: int - """ (int) Invalid. """ +from .usage_records import UsageRecords +from .schemas import UsageFileSchema class UsageFile(BaseModel): @@ -90,58 +79,3 @@ class UsageFile(BaseModel): events = None # type: Events """ (:py:class:`.Events`) Events occured on file. """ - - -class UsageListing(BaseModel): - """ Usage Listing Object. """ - - _schema = UsageListingSchema() - - status = None # type: str - """ (str) Status. """ - - contract = None # type: Contract - """ (:py:class:`.Contract`) Contract Object. """ - - product = None # type: Product - """ (:py:class:`.Product`) Product Object. """ - - created = None # type: str - """ (str) Creation time. """ - - # Undocumented fields (they appear in PHP SDK) - vendor = None # type: Company - """ (:py:class:`.Company`) Vendor Object. """ - - provider = None # type: Company - """ (:py:class:`.Company`) Provider Object. """ - - -class UsageRecord(BaseModel): - """ Usage Record Object. """ - - _schema = UsageRecordSchema() - - usage_record_id = None # type: str - """ (str) Usage record id. """ - - item_search_criteria = None # type: str - """ (str) Item search criteria. """ - - item_search_value = None # type: str - """ (str) Item search value. """ - - quantity = None # type: int - """ (int) Quantity. """ - - start_time_utc = None # type: str - """ (str) Start Time in UTC. """ - - end_time_utc = None # type: str - """ (str) End Time in UTC. """ - - asset_search_criteria = None # type: str - """ (str) Asset search criteria. """ - - asset_search_value = None # type: str - """ (str) Asset search value. """ diff --git a/connect/models/usage_listing.py b/connect/models/usage_listing.py new file mode 100644 index 0000000..e6b44b9 --- /dev/null +++ b/connect/models/usage_listing.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .company import Company +from .contract import Contract +from .product import Product +from .schemas import UsageListingSchema + + +class UsageListing(BaseModel): + """ Usage Listing Object. """ + + _schema = UsageListingSchema() + + status = None # type: str + """ (str) Status. """ + + contract = None # type: Contract + """ (:py:class:`.Contract`) Contract Object. """ + + product = None # type: Product + """ (:py:class:`.Product`) Product Object. """ + + created = None # type: str + """ (str) Creation time. """ + + # Undocumented fields (they appear in PHP SDK) + vendor = None # type: Company + """ (:py:class:`.Company`) Vendor Object. """ + + provider = None # type: Company + """ (:py:class:`.Company`) Provider Object. """ diff --git a/connect/models/usage_record.py b/connect/models/usage_record.py new file mode 100644 index 0000000..2bfc35b --- /dev/null +++ b/connect/models/usage_record.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import UsageRecordSchema + + +class UsageRecord(BaseModel): + """ Usage Record Object. """ + + _schema = UsageRecordSchema() + + usage_record_id = None # type: str + """ (str) Usage record id. """ + + item_search_criteria = None # type: str + """ (str) Item search criteria. """ + + item_search_value = None # type: str + """ (str) Item search value. """ + + quantity = None # type: int + """ (int) Quantity. """ + + start_time_utc = None # type: str + """ (str) Start Time in UTC. """ + + end_time_utc = None # type: str + """ (str) End Time in UTC. """ + + asset_search_criteria = None # type: str + """ (str) Asset search criteria. """ + + asset_search_value = None # type: str + """ (str) Asset search value. """ diff --git a/connect/models/usage_records.py b/connect/models/usage_records.py new file mode 100644 index 0000000..fecd7fe --- /dev/null +++ b/connect/models/usage_records.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import UsageRecordsSchema + + +class UsageRecords(BaseModel): + """ Usage Records Object. """ + # TODO: Verify that this data is correct. + + _schema = UsageRecordsSchema() + + valid = None # type: int + """ (int) Valid. """ + + invalid = None # type: int + """ (int) Invalid. """ diff --git a/connect/models/user.py b/connect/models/user.py new file mode 100644 index 0000000..36b74ce --- /dev/null +++ b/connect/models/user.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import UserSchema + + +class User(BaseModel): + """ Represents a user within the platform. """ + + _schema = UserSchema() + + name = None # type: str + """ (str) User name. """ diff --git a/connect/models/value_choice.py b/connect/models/value_choice.py new file mode 100644 index 0000000..d6ac899 --- /dev/null +++ b/connect/models/value_choice.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# This file is part of the Ingram Micro Cloud Blue Connect SDK. +# Copyright (c) 2019 Ingram Micro. All Rights Reserved. + +from .base import BaseModel +from .schemas import ValueChoiceSchema + + +class ValueChoice(BaseModel): + """ A value choice for a parameter. """ + + _schema = ValueChoiceSchema() + + value = None # type: str + """ (str) Value. """ + + label = None # type: str + """ (str) Label. """ diff --git a/tests/test_tier_config.py b/tests/test_tier_config.py index 1d44537..f1cd124 100644 --- a/tests/test_tier_config.py +++ b/tests/test_tier_config.py @@ -12,7 +12,7 @@ from connect.exceptions import FailRequest, InquireRequest, SkipRequest from connect.models import Param, ActivationTileResponse, ActivationTemplateResponse, BaseModel, \ - Company, Connection, EventInfo, Hub, Product, TierConfigRequest, TierConfig, Events, \ + Company, Connection, Event, Hub, Product, TierConfigRequest, TierConfig, Events, \ Template, Activation, User, TierAccount from connect.resources import TierConfigAutomation from .common import Response, load_str @@ -85,14 +85,14 @@ def test_create_resource(): events = configuration.events assert isinstance(events, Events) - assert isinstance(events.created, EventInfo) + assert isinstance(events.created, Event) assert isinstance(events.created.at, datetime) assert str(events.created.at) == '2018-11-21 11:10:29' assert not events.created.by assert not events.inquired assert not events.pended assert not events.validated - assert isinstance(events.updated, EventInfo) + assert isinstance(events.updated, Event) assert isinstance(events.updated.at, datetime) assert str(events.updated.at) == '2018-11-21 11:10:29' assert isinstance(events.updated.by, User) @@ -117,17 +117,17 @@ def test_create_resource(): events = request.events assert isinstance(events, Events) - assert isinstance(events.created, EventInfo) + assert isinstance(events.created, Event) assert isinstance(events.created.at, datetime) assert str(events.created.at) == '2018-11-21 11:10:29' assert not events.created.by - assert isinstance(events.inquired, EventInfo) + assert isinstance(events.inquired, Event) assert isinstance(events.inquired.at, datetime) assert str(events.inquired.at) == '2018-11-21 11:10:29' assert isinstance(events.inquired.by, User) assert events.inquired.by.id == 'PA-000-000' assert events.inquired.by.name == 'Username' - assert isinstance(events.pended, EventInfo) + assert isinstance(events.pended, Event) assert isinstance(events.pended.at, datetime) assert str(events.pended.at) == '2018-11-21 11:10:29' assert isinstance(events.pended.by, User)