-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from cloudblue/LITE-13315-changes-to-support-…
…different-parameter-types Parameter with new types
- Loading branch information
Showing
19 changed files
with
552 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import json | ||
from .base import BaseResource | ||
|
||
|
||
class ProductsResource(BaseResource): | ||
""" Allows listing and obtaining several types of objects. | ||
:param Config config: Config object or ``None`` to use environment config (default). | ||
""" | ||
resource = 'products' | ||
|
||
def list_parameters(self, product_id): | ||
""" List parameters for a product. | ||
:param str product_id: Primary key of the product to search for. | ||
:return: response object with templates contents. | ||
""" | ||
""" | ||
# type: (Dict[str, Any]) -> List[Any] | ||
""" | ||
response, _ = self._api.get( | ||
'/public/v1/products/' + product_id + '/parameters/' | ||
) | ||
response = json.loads(response) | ||
return response | ||
|
||
def create_parameter(self, product_id, body): | ||
""" Create parameter for a product. | ||
:param str product_id: Primary key of the product to create parameter. | ||
:param str body: Body of the parameter to create. | ||
:return: response object with templates contents. | ||
""" | ||
""" | ||
# type: (Dict[str, Any]) -> List[Any] | ||
""" | ||
if not product_id: | ||
raise ValueError('Invalid ID') | ||
path = '/public/v1/products/' + product_id + '/parameters/' | ||
response = self._api.post( | ||
path=path, | ||
json=body | ||
) | ||
return response | ||
|
||
def update_parameter(self, product_id, parameter_id, body): | ||
""" Update parameter for a product. | ||
:param str product_id: Primary key of the product to update parameter. | ||
:param str parameter_id: Primary key of the parameter to update. | ||
:param str body: Body of the parameter to update. | ||
:return: response object with templates contents. | ||
""" | ||
""" | ||
# type: (Dict[str, Any]) -> List[Any] | ||
""" | ||
if not product_id: | ||
raise ValueError('Invalid ID') | ||
path = '/public/v1/products/' + product_id + '/parameters/' + parameter_id | ||
response = self._api.put( | ||
path=path, | ||
json=body | ||
) | ||
return response | ||
|
||
def delete_parameter(self, product_id, parameter_id): | ||
""" Delete parameter for a product. | ||
:param str product_id: Primary key of the product to delete parameter. | ||
:param str parameter_id: Primary key of the parameter to delete. | ||
:return: response object with templates contents. | ||
""" | ||
""" | ||
# type: (Dict[str, Any]) -> List[Any] | ||
""" | ||
if not product_id: | ||
raise ValueError('Invalid ID') | ||
path = '/public/v1/products/' + product_id + '/parameters/' + parameter_id | ||
response = self._api.delete( | ||
path=path | ||
) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"apiEndpoint": "https://api.cnct.tech/public/v1", | ||
"apiKey": "ApiKey SU-000-000-000:0000000000000000000000000000000000000000", | ||
"apiEndpoint": "https://api.cnct.info/public/v1", | ||
"apiKey": "ApiKey SU-000-000-000:0000000000000000000000000000000000000", | ||
"products": "PRD-000-000-000" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of the Ingram Micro Cloud Blue Connect SDK. | ||
# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. | ||
import json | ||
from connect.config import Config | ||
from connect.resources.fulfillment import FulfillmentResource | ||
|
||
|
||
class AssetRequest(): | ||
configuration = Config(file='examples/config.json') | ||
|
||
def list_asset_request(self): | ||
asset_request = FulfillmentResource(config=self.configuration) | ||
return asset_request.search_asset_request() | ||
|
||
def create_asset_request(self, body): | ||
asset_request = FulfillmentResource(config=self.configuration) | ||
return asset_request.create_purchase_request(body) | ||
|
||
|
||
def main(): | ||
asset_request_example = AssetRequest() | ||
with open('./tests/data/create_purchase_request_body_param.json') as json_file: | ||
body = json.load(json_file) | ||
result = asset_request_example.create_asset_request(body) | ||
for asset in result: | ||
print(asset.id) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of the Ingram Micro Cloud Blue Connect SDK. | ||
# Copyright (c) 2019-2020 Ingram Micro. All Rights Reserved. | ||
import json | ||
from connect.config import Config | ||
from connect.resources.product import ProductsResource | ||
|
||
|
||
class Parameters(): | ||
configuration = Config(file='examples/config.json') | ||
|
||
def list_parameters(self, product_id): | ||
product = ProductsResource(config=self.configuration) | ||
return product.list_parameters(product_id) | ||
|
||
def create_parameter(self, product_id, body): | ||
product = ProductsResource(config=self.configuration) | ||
return product.create_parameter(product_id, body) | ||
|
||
def update_parameter(self, product_id, parameter_id, body): | ||
product = ProductsResource(config=self.configuration) | ||
return product.update_parameter(product_id, parameter_id, body) | ||
|
||
def delete_parameter(self, product_id, param_id): | ||
product = ProductsResource(config=self.configuration) | ||
return product.delete_parameter(product_id, param_id) | ||
|
||
|
||
def main(): | ||
parameters_example = Parameters() | ||
with open('./tests/data/create_parameter_request.json') as json_file: | ||
body = json.load(json_file) | ||
parameters_example.create_parameter('PRD-075-401-854', body) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "magic_param_c", | ||
"title": "Title of the Magic Parameter C", | ||
"description": "This is a backup email for emergency", | ||
"type": "checkbox", | ||
"scope": "asset", | ||
"phase": "ordering", | ||
"constraints": { | ||
"required": false, | ||
"hidden": false, | ||
"unique": false, | ||
"choices": [ | ||
{ | ||
"label": "val1", | ||
"value": "test1", | ||
"default": true | ||
}, | ||
{ | ||
"label": "val2", | ||
"value": "test2" | ||
}, | ||
{ | ||
"label": "val3", | ||
"value": "test3" | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.