Skip to content

Commit

Permalink
Merge pull request #48 from cloudblue/LITE-18826-new-capabilities-sync
Browse files Browse the repository at this point in the history
LITE-18826: Add support for new capabilities
  • Loading branch information
marcserrat authored Jun 17, 2021
2 parents 5d2bffc + 5b10775 commit f620664
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 2 deletions.
31 changes: 31 additions & 0 deletions connect/cli/plugins/product/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ def _dump_capabilities(ws, product, silent): # noqa: CCR001
ppu = product['capabilities']['ppu']
capabilities = product['capabilities']
tiers = capabilities['tiers']
subscription = capabilities['subscription']
change = subscription['change']

action_validation = DataValidation(
type='list',
Expand Down Expand Up @@ -639,6 +641,10 @@ def _dump_capabilities(ws, product, silent): # noqa: CCR001
disabled_enabled.add(ws['C4'])
ws['A5'].value = 'Consumption reporting for Reservation Items'
ws['B5'].value = '-'
ws['C5'].value = (
'Enabled' if capabilities['reservation']['consumption'] else 'Disabled'
)
disabled_enabled.add(ws['C5'])

progress.update(1)
progress.close()
Expand Down Expand Up @@ -689,6 +695,31 @@ def _get_reseller_authorization_level(tiers):
ws['A10'].value = 'Administrative Hold'
ws['B10'].value = '-'

ws['A11'].value = 'Dynamic Validation of Tier Requests'
ws['B11'].value = '-'
ws['C11'].value = (
'Enabled' if capabilities['tiers']['validation'] else 'Disabled'
)
disabled_enabled.add(ws['C11'])
ws['A12'].value = 'Editable Ordering Parameters in Change Request'
ws['B12'].value = '-'
ws['C12'].value = (
'Enabled' if subscription['change']['editable_ordering_parameters'] else 'Disabled'
)
disabled_enabled.add(ws['C12'])
ws['A13'].value = 'Validation of Draft Change Request'
ws['B13'].value = '-'
ws['C13'].value = (
'Enabled' if 'validation' in change and change['validation'] else 'Disabled'
)
disabled_enabled.add(ws['C13'])
ws['A14'].value = 'Validation of inquiring form for Change Requests'
ws['B14'].value = '-'
ws['C14'].value = (
'Enabled' if 'inquiring_validation' in change and change['inquiring_validation'] else 'Disabled'
)
disabled_enabled.add(ws['C14'])

def _get_administrative_hold(capabilities):
if 'hold' in capabilities['subscription'] and capabilities['subscription']['hold']:
return 'Enabled'
Expand Down
68 changes: 68 additions & 0 deletions connect/cli/plugins/product/sync/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,74 @@ def sync(self): # noqa: CCR001
product['capabilities']['subscription']['hold'] = True
else:
product['capabilities']['subscription']['hold'] = False
if data.capability == 'Dynamic Validation of Tier Requests':
if data.value == 'Enabled':
product['capabilities']['tiers']['validation'] = True
else:
product['capabilities']['tiers']['validation'] = False
if data.capability == 'Editable Ordering Parameters in Change Request':
if data.value == 'Enabled':
product[
'capabilities'
][
'subscription'
][
'change'
][
'editable_ordering_parameters'
] = True
else:
product[
'capabilities'
][
'subscription'
][
'change'
][
'editable_ordering_parameters'
] = False
if data.capability == 'Validation of Draft Change Request':
if data.value == 'Enabled':
product[
'capabilities'
][
'subscription'
][
'change'
][
'validation'
] = True
else:
product[
'capabilities'
][
'subscription'
][
'change'
][
'validation'
] = False
if data.capability == 'Validation of inquiring form for Change Requests':
if data.value == 'Enabled':
product[
'capabilities'
][
'subscription'
][
'change'
][
'inquiring_validation'
] = True
else:
product[
'capabilities'
][
'subscription'
][
'change'
][
'inquiring_validation'
] = False
if update:
self._client.products[self._product_id].update(product)
updated_items.append(data.capability)
Expand Down
10 changes: 8 additions & 2 deletions tests/fixtures/product_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@
"updates": false,
"configs": {
"level": 2
}
},
"validation":false
},
"subscription": {
"hold": false,
"schema": "evergreen"
"schema": "evergreen",
"change":{
"editable_ordering_parameters":false,
"validation":false,
"inquiring_validation":false
}
}
},
"visibility": {
Expand Down

0 comments on commit f620664

Please sign in to comment.