Skip to content

Commit 7fab284

Browse files
Merge pull request #66 from JaviCerveraIngram/CPS-46-refactor-models
CPS-46 Refactor imports
2 parents bbaf3e5 + ee04ace commit 7fab284

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1119
-782
lines changed

connect/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from deprecation import deprecated
99
import six
1010

11-
from .models.parameters import Param
11+
from .models.param import Param
1212

1313

1414
class Message(Exception):

connect/models/__init__.py

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,55 @@
33
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
44
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.
55

6-
from .activation_response import ActivationTemplateResponse, ActivationTileResponse
6+
from .activation import Activation
7+
from .activation_template_response import ActivationTemplateResponse
8+
from .activation_tile_response import ActivationTileResponse
9+
from .agreement import Agreement
10+
from .agreement_stats import AgreementStats
711
from .asset import Asset
812
from .base import BaseModel
9-
from .company import Company, User
13+
from .company import Company
14+
from .configuration import Configuration
1015
from .connection import Connection
11-
from .contact import Contact, ContactInfo, PhoneNumber
12-
from .conversation import Conversation, ConversationMessage
13-
from .event import EventInfo, Events
16+
from .constraints import Constraints
17+
from .contact import Contact
18+
from .contact_info import ContactInfo
19+
from .contract import Contract
20+
from .conversation import Conversation
21+
from .conversation_message import ConversationMessage
22+
from .customer_ui_settings import CustomerUiSettings
23+
from .document import Document
24+
from .download_link import DownloadLink
25+
from .event import Event
26+
from .events import Events
27+
from .ext_id_hub import ExtIdHub
1428
from .fulfillment import Fulfillment
15-
from .hub import Hub, HubInstance, ExtIdHub, HubStats
16-
from .marketplace import Activation, Agreement, AgreementStats, Contract, Marketplace
17-
from .parameters import Constraints, Param, ValueChoice
18-
from .product import CustomerUiSettings, Document, DownloadLink, Item, Product, \
19-
ProductCategory, ProductConfiguration, ProductFamily, ProductStats, ProductStatsInfo, Renewal
29+
from .hub import Hub
30+
from .hub_instance import HubInstance
31+
from .hub_stats import HubStats
32+
from .item import Item
33+
from .marketplace import Marketplace
34+
from .param import Param
35+
from .phone_number import PhoneNumber
36+
from .product import Product
37+
from .product_category import ProductCategory
38+
from .product_configuration import ProductConfiguration
39+
from .product_family import ProductFamily
40+
from .product_stats import ProductStats
41+
from .product_stats_info import ProductStatsInfo
42+
from .renewal import Renewal
2043
from .server_error_response import ServerErrorResponse
21-
from .tier_config import Configuration, Template, TierAccount, TierAccounts, TierConfig, \
22-
TierConfigRequest
23-
from .usage import UsageFile, UsageListing, UsageRecord, UsageRecords
44+
from .template import Template
45+
from .tier_account import TierAccount
46+
from .tier_accounts import TierAccounts
47+
from .tier_config import TierConfig
48+
from .tier_config_request import TierConfigRequest
49+
from .usage_file import UsageFile
50+
from .usage_listing import UsageListing
51+
from .usage_record import UsageRecord
52+
from .usage_records import UsageRecords
53+
from .user import User
54+
from .value_choice import ValueChoice
2455

2556
__all__ = [
2657
'Activation',
@@ -42,7 +73,7 @@
4273
'CustomerUiSettings',
4374
'Document',
4475
'DownloadLink',
45-
'EventInfo',
76+
'Event',
4677
'Events',
4778
'ExtIdHub',
4879
'Fulfillment',

connect/models/activation.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
4+
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.
5+
6+
import datetime
7+
from typing import Optional
8+
9+
from .base import BaseModel
10+
from .schemas import ActivationSchema
11+
12+
13+
class Activation(BaseModel):
14+
""" Activation object. """
15+
16+
_schema = ActivationSchema()
17+
18+
link = None # type: Optional[str]
19+
""" (str|None) Activation link. """
20+
21+
message = None # type: str
22+
""" (str) Activation message. """
23+
24+
date = None # type: Optional[datetime.datetime]
25+
""" (datetime.datetime|None) Activation date. """
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
4+
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.
5+
6+
7+
class ActivationTemplateResponse(object):
8+
""" An instance of this class might the returned by the overriden ``process_request`` method
9+
of your :py:class:`connect.resources.FulfillmentAutomation` or
10+
:py:class:`connect.resources.TierConfigAutomation` subclass to approve the request being
11+
processed, showing a tile with the specified template id.
12+
13+
:param str template_id: Id of the template od the tile to be shown in the Vendor Portal.
14+
The template must have been defined in the Vendor Portal.
15+
:rtype: None
16+
"""
17+
18+
template_id = None # type: str
19+
20+
def __init__(self, template_id):
21+
self.template_id = template_id

connect/models/activation_response.py renamed to connect/models/activation_tile_response.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,3 @@ def __init__(self, markdown=''):
2323
self.tile = json.loads(markdown)
2424
except ValueError:
2525
self.tile = markdown or self.__class__.tile
26-
27-
28-
class ActivationTemplateResponse(object):
29-
""" An instance of this class might the returned by the overriden ``process_request`` method
30-
of your :py:class:`connect.resources.FulfillmentAutomation` or
31-
:py:class:`connect.resources.TierConfigAutomation` subclass to approve the request being
32-
processed, showing a tile with the specified template id.
33-
34-
:param str template_id: Id of the template od the tile to be shown in the Vendor Portal.
35-
The template must have been defined in the Vendor Portal.
36-
:rtype: None
37-
"""
38-
39-
template_id = None # type: str
40-
41-
def __init__(self, template_id):
42-
self.template_id = template_id

connect/models/agreement.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
4+
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.
5+
6+
import datetime
7+
from typing import Optional, List
8+
9+
from .agreement_stats import AgreementStats
10+
from .base import BaseModel
11+
from .company import Company
12+
from .marketplace import Marketplace
13+
from .user import User
14+
from .schemas import AgreementSchema
15+
16+
17+
class Agreement(BaseModel):
18+
""" An Agreement object. """
19+
20+
_schema = AgreementSchema()
21+
22+
type = None # type: str
23+
""" (str) Type of the agreement. One of: distribution, program, service. """
24+
25+
title = None # type: str
26+
""" (str) Title of the agreement. """
27+
28+
description = None # type: str
29+
""" (str) Agreement details (Markdown). """
30+
31+
created = None # type: datetime.datetime
32+
""" (datetime.datetime) Date of creation of the agreement. """
33+
34+
updated = None # type: datetime.datetime
35+
""" (datetime.datetime) Date of the update of the agreement. It can be creation
36+
of the new version, change of the field, etc. (any change).
37+
"""
38+
39+
owner = None # type: Company
40+
""" (:py:class:`.Company`) Reference to the owner account object. """
41+
42+
stats = None # type: Optional[AgreementStats]
43+
""" (:py:class:`.AgreementStats` | None) Agreement stats. """
44+
45+
author = None # type: Optional[User]
46+
""" (:py:class:`.User` | None) Reference to the user who created the version. """
47+
48+
version = None # type: int
49+
""" (int) Chronological number of the version. """
50+
51+
active = None # type: bool
52+
""" (bool) State of the version. """
53+
54+
link = None # type: str
55+
""" (str) Url to the document. """
56+
57+
version_created = None # type: datetime.datetime
58+
""" (datetime.datetime) Date of the creation of the version. """
59+
60+
version_contracts = None # type: int
61+
""" (int) Number of contracts this version has. """
62+
63+
agreements = None # type: List[Agreement]
64+
""" (List[:py:class:`.Agreement`]) Program agreements can have distribution agreements
65+
associated with them.
66+
"""
67+
68+
parent = None # type: Optional[Agreement]
69+
""" (:py:class:`.Agreement` | None) Reference to the parent program agreement
70+
(for distribution agreement).
71+
"""
72+
73+
marketplace = None # type: Optional[Marketplace]
74+
""" (:py:class:`.Marketplace` | None) Reference to marketplace object
75+
(for distribution agreement).
76+
"""

connect/models/agreement_stats.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
4+
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.
5+
6+
from typing import Optional
7+
8+
from .base import BaseModel
9+
from .schemas import AgreementStatsSchema
10+
11+
12+
class AgreementStats(BaseModel):
13+
""" Agreement stats. """
14+
15+
_schema = AgreementStatsSchema()
16+
17+
contracts = None # type: Optional[int]
18+
""" (int|None) Number of contracts this agreement has. """
19+
20+
versions = None # type: int
21+
""" (int) Number of versions in the agreement. """

connect/models/asset.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
from .base import BaseModel
99
from .connection import Connection
10-
from .parameters import Param
11-
from .product import Item, Product
12-
from .tier_config import TierAccounts
13-
from connect.models.schemas import AssetSchema
10+
from .item import Item
11+
from .param import Param
12+
from .product import Product
13+
from .tier_accounts import TierAccounts
14+
from .schemas import AssetSchema
1415

1516

1617
class Asset(BaseModel):

connect/models/company.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.
55

66
from .base import BaseModel
7-
from connect.models.schemas import CompanySchema, UserSchema
7+
from .schemas import CompanySchema
88

99

1010
class Company(BaseModel):
@@ -14,12 +14,3 @@ class Company(BaseModel):
1414

1515
name = None # type: str
1616
""" (str) Company name. """
17-
18-
19-
class User(BaseModel):
20-
""" Represents a user within the platform. """
21-
22-
_schema = UserSchema()
23-
24-
name = None # type: str
25-
""" (str) User name. """

connect/models/configuration.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
4+
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.
5+
6+
from typing import List
7+
8+
from .base import BaseModel
9+
from .param import Param
10+
from .schemas import ConfigurationSchema
11+
12+
13+
class Configuration(BaseModel):
14+
""" Configuration Phase Parameter Context-Bound Data Object.
15+
16+
To be used in parameter contexts:
17+
18+
- Asset.
19+
- Fulfillment Request.
20+
- TierConfig.
21+
- TierConfig Requests.
22+
"""
23+
24+
_schema = ConfigurationSchema()
25+
26+
params = None # type: List[Param]
27+
""" (List[:py:class:`.Param`]) """

0 commit comments

Comments
 (0)