diff options
Diffstat (limited to 'onap-client/onap_client/aai')
-rw-r--r-- | onap-client/onap_client/aai/__init__.py | 40 | ||||
-rw-r--r-- | onap-client/onap_client/aai/catalog/__init__.py | 36 | ||||
-rw-r--r-- | onap-client/onap_client/aai/catalog/business_catalog.py | 274 | ||||
-rw-r--r-- | onap-client/onap_client/aai/catalog/cloud_infrastructure_catalog.py | 132 | ||||
-rw-r--r-- | onap-client/onap_client/aai/client.py | 77 | ||||
-rw-r--r-- | onap-client/onap_client/aai/tests/__init__.py | 36 |
6 files changed, 595 insertions, 0 deletions
diff --git a/onap-client/onap_client/aai/__init__.py b/onap-client/onap_client/aai/__init__.py new file mode 100644 index 0000000..a67037c --- /dev/null +++ b/onap-client/onap_client/aai/__init__.py @@ -0,0 +1,40 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ + +from onap_client.config import APP_CONFIG + +AAI_PROPERTIES = APP_CONFIG.aai diff --git a/onap-client/onap_client/aai/catalog/__init__.py b/onap-client/onap_client/aai/catalog/__init__.py new file mode 100644 index 0000000..5519a84 --- /dev/null +++ b/onap-client/onap_client/aai/catalog/__init__.py @@ -0,0 +1,36 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ diff --git a/onap-client/onap_client/aai/catalog/business_catalog.py b/onap-client/onap_client/aai/catalog/business_catalog.py new file mode 100644 index 0000000..2b9af21 --- /dev/null +++ b/onap-client/onap_client/aai/catalog/business_catalog.py @@ -0,0 +1,274 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ + +import uuid +from functools import partial + +from onap_client import aai +from onap_client import config +from onap_client.aai.client import AAIClient + +PAYLOADS_DIR = config.PAYLOADS_DIR +aai_properties = aai.AAI_PROPERTIES +application_id = config.APPLICATION_ID + + +class BusinessClient(AAIClient): + @property + def catalog_resources(self): + return CATALOG_RESOURCES + + @property + def namespace(self): + return "business" + + +CATALOG_RESOURCES = { + "GET_OWNING_ENTITY": { + "verb": "GET", + "description": "Queries AAI for an owning entity", + "uri": partial( + "{endpoint}{service_path}/owning-entities?owning-entity-name={name}".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "uri-parameters": ["name"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_OWNING_ENTITIES": { + "verb": "GET", + "description": "Queries AAI for all owning entities", + "uri": partial( + "{endpoint}{service_path}/owning-entities".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_CUSTOMER": { + "verb": "GET", + "description": "Queries AAI for a customer", + "uri": partial( + "{endpoint}{service_path}/customers?global-customer-id={name}".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "uri-parameters": ["name"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_CUSTOMERS": { + "verb": "GET", + "description": "Queries AAI for all customers", + "uri": partial( + "{endpoint}{service_path}/customers".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_PLATFORM": { + "verb": "GET", + "description": "Queries AAI for a platform", + "uri": partial( + "{endpoint}{service_path}/platforms?platform-name={name}".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "uri-parameters": ["name"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_PLATFORMS": { + "verb": "GET", + "description": "Queries AAI for all platforms", + "uri": partial( + "{endpoint}{service_path}/platforms".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_PROJECT": { + "verb": "GET", + "description": "Queries AAI for a project", + "uri": partial( + "{endpoint}{service_path}/projects/project/{name}".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "uri-parameters": ["name"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_PROJECTS": { + "verb": "GET", + "description": "Queries AAI for all projects", + "uri": partial( + "{endpoint}{service_path}/projects".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_LINES_OF_BUSINESS": { + "verb": "GET", + "description": "Queries AAI for all lobs", + "uri": partial( + "{endpoint}{service_path}/lines-of-business".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "CREATE_CUSTOMER": { + "verb": "PUT", + "description": "Creates a customer in AAI", + "uri": partial( + "{endpoint}{service_path}/customers/customer/{customer_name}".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "uri-parameters": ["customer_name"], + "payload-parameters": ["customer_name", "subscriber_name"], + "payload": "{}/aai_create_customer.jinja".format(PAYLOADS_DIR), + "success_code": 201, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_CUSTOMER_SUBSCRIPTIONS": { + "verb": "GET", + "description": "Queries AAI the subscriptions for a customer", + "uri": partial( + "{endpoint}{service_path}/customers/customer/{customer_name}/service-subscriptions".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "uri-parameters": ["customer_name"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_SERVICE_INSTANCES": { + "verb": "GET", + "description": "Queries AAI the service instances for a customer subscription", + "uri": partial( + "{endpoint}{service_path}/customers/customer/{customer_name}/service-subscriptions/service-subscription/{subscription_name}/service-instances".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_BUSINESS_PATH, + ), + "uri-parameters": ["customer_name", "subscription_name"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, +} diff --git a/onap-client/onap_client/aai/catalog/cloud_infrastructure_catalog.py b/onap-client/onap_client/aai/catalog/cloud_infrastructure_catalog.py new file mode 100644 index 0000000..b2570a0 --- /dev/null +++ b/onap-client/onap_client/aai/catalog/cloud_infrastructure_catalog.py @@ -0,0 +1,132 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ + +import uuid +from functools import partial + +from onap_client import aai +from onap_client import config +from onap_client.aai.client import AAIClient + +PAYLOADS_DIR = config.PAYLOADS_DIR +aai_properties = aai.AAI_PROPERTIES +application_id = config.APPLICATION_ID + + +class CloudInfrastructureClient(AAIClient): + @property + def catalog_resources(self): + return CATALOG_RESOURCES + + @property + def namespace(self): + return "cloud_infrastructure" + + +CATALOG_RESOURCES = { + "GET_CLOUD_REGIONS": { + "verb": "GET", + "description": "Queries AAI for all cloud regions", + "uri": partial( + "{endpoint}{service_path}/cloud-regions".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_CLOUD_INFRASTRUCTURE_PATH, + ), + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_CLOUD_REGION": { + "verb": "GET", + "description": "Queries AAI for a cloud region", + "uri": partial( + "{endpoint}{service_path}/cloud-regions/cloud-region/{cloud_owner}/{cloud_region}".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_CLOUD_INFRASTRUCTURE_PATH, + ), + "uri-parameters": ["cloud_region", "cloud_owner"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_CLOUD_REGION_TENANTS": { + "verb": "GET", + "description": "Queries AAI for a cloud region's tenants", + "uri": partial( + "{endpoint}{service_path}/cloud-regions/cloud-region/{cloud_owner}/{cloud_region}/tenants".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_CLOUD_INFRASTRUCTURE_PATH, + ), + "uri-parameters": ["cloud_region", "cloud_owner"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, + "GET_ESR_LIST": { + "verb": "GET", + "description": "Queries AAI for a esr info", + "uri": partial( + "{endpoint}{service_path}/cloud-regions/cloud-region/{cloud_owner}/{cloud_region}/esr-system-info-list".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_CLOUD_INFRASTRUCTURE_PATH, + ), + "uri-parameters": ["cloud_region", "cloud_owner"], + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, +} diff --git a/onap-client/onap_client/aai/client.py b/onap-client/onap_client/aai/client.py new file mode 100644 index 0000000..5a2ddb1 --- /dev/null +++ b/onap-client/onap_client/aai/client.py @@ -0,0 +1,77 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ + +import uuid + +from functools import partial +from onap_client import aai +from onap_client.client.clients import Client +from onap_client import config + +aai_properties = aai.AAI_PROPERTIES +application_id = config.APPLICATION_ID + + +class AAIClient(Client): + @property + def namespace(self): + return "aai" + + @property + def catalog_resources(self): + return CATALOG_RESOURCES + + +CATALOG_RESOURCES = { + "HEALTH_CHECK": { + "verb": "GET", + "description": "Queries AAI health check endpoint", + "uri": partial( + "{endpoint}{service_path}".format, + endpoint=aai_properties.AAI_BE_ENDPOINT, + service_path=aai_properties.AAI_HEALTH_CHECK_PATH, + ), + "success_code": 200, + "headers": { + "Accept": "application/json", + "Content-Type": "application/json", + "X-TransactionId": str(uuid.uuid4()), + "X-FromAppId": application_id, + }, + "auth": (aai_properties.AAI_USERNAME, aai_properties.AAI_PASSWORD,), + }, +} diff --git a/onap-client/onap_client/aai/tests/__init__.py b/onap-client/onap_client/aai/tests/__init__.py new file mode 100644 index 0000000..5519a84 --- /dev/null +++ b/onap-client/onap_client/aai/tests/__init__.py @@ -0,0 +1,36 @@ +# -*- coding: utf8 -*- +# ============LICENSE_START======================================================= +# org.onap.vvp/validation-scripts +# =================================================================== +# Copyright © 2020 AT&T Intellectual Property. All rights reserved. +# =================================================================== +# +# Unless otherwise specified, all software contained herein is licensed +# under the Apache License, Version 2.0 (the "License"); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +# +# Unless otherwise specified, all documentation contained herein is licensed +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); +# you may not use this documentation except in compliance with the License. +# You may obtain a copy of the License at +# +# https://creativecommons.org/licenses/by/4.0/ +# +# Unless required by applicable law or agreed to in writing, documentation +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============LICENSE_END============================================ |