Skip to content

Commit 97fb781

Browse files
Merge pull request #69 from JaviCerveraIngram/CPS-51-tcr-filters
Cps 51 TCR filters
2 parents e071bda + 2791728 commit 97fb781

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

connect/models/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def make_object(self, data):
502502
class TierAccountsSchema(Schema):
503503
customer = fields.Nested(TierAccountSchema)
504504
tier1 = fields.Nested(TierAccountSchema)
505-
tier2 = fields.Nested(TierAccountSchema)
505+
tier2 = fields.Nested(TierAccountSchema, allow_none=True)
506506

507507
@post_load
508508
def make_object(self, data):

connect/models/tier_accounts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
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 typing import Optional
7+
68
from .base import BaseModel
79
from .tier_account import TierAccount
810
from .schemas import TierAccountsSchema
@@ -19,5 +21,5 @@ class TierAccounts(BaseModel):
1921
tier1 = None # type: TierAccount
2022
""" (:py:class:`.TierAccount`) Level 1 TierAccount Object. """
2123

22-
tier2 = None # type: TierAccount
23-
""" (:py:class:`.TierAccount`) Level 2 TierAccount Object. """
24+
tier2 = None # type: Optional[TierAccount]
25+
""" (:py:class:`.TierAccount` | None) Level 2 TierAccount Object. """

connect/resources/tier_config_automation.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ class TierConfigAutomation(AutomationEngine):
3636
resource = 'tier/config-requests'
3737
model_class = TierConfigRequest
3838

39+
def filters(self, status='pending', **kwargs):
40+
""" Returns the default set of filters for Tier Config request, plus any others that you
41+
might specify. The allowed filters are:
42+
43+
- type
44+
- status
45+
- id
46+
- configuration__id
47+
- configuration__tier_level
48+
- configuration__account__id
49+
- configuration__product__id
50+
- assignee__id
51+
- unassigned (bool)
52+
- configuration__account__external_uid
53+
54+
:param str status: Status of the requests. Default: ``'pending'``.
55+
:param dict[str,Any] kwargs: Additional filters to add to the default ones.
56+
:return: The set of filters for this resource.
57+
:rtype: dict[str,Any]
58+
"""
59+
filters = super(TierConfigAutomation, self).filters(status=status, **kwargs)
60+
if self.config.products:
61+
filters['configuration__product__id'] = ','.join(self.config.products)
62+
return filters
63+
3964
@function_log
4065
def dispatch(self, request):
4166
# type: (TierConfigRequest) -> str

0 commit comments

Comments
 (0)