Skip to content

Commit abc6f55

Browse files
authored
Merge pull request #468 from NHSDigital/apm-4807-remove-api-catalogue-functionality
APM-4807: Remove anything to do with the API Catalogue
2 parents e915d00 + 0e2498e commit abc6f55

12 files changed

Lines changed: 378 additions & 561 deletions

File tree

ansible/collections/ansible_collections/nhsd/apigee/plugins/action/deploy_api_catalog_item.py

Lines changed: 0 additions & 179 deletions
This file was deleted.
Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import typing
2-
31
APIGEE_BASE_URL = "https://api.enterprise.apigee.com/v1/"
42
APIGEE_DAPI_URL = "https://apigee.com/dapi/api/"
53

@@ -13,16 +11,3 @@
1311
],
1412
"nhsd-prod": ["dev", "int", "sandbox", "prod"],
1513
}
16-
17-
18-
def portal_uri(org: typing.Literal["nhsd-nonprod", "nhsd-prod"]) -> str:
19-
portal_ids = {
20-
"nhsd-nonprod": "nhsd-nonprod-developerportal",
21-
"nhsd-prod": "nhsd-prod-developerportal",
22-
}
23-
if org not in portal_ids:
24-
raise ValueError(f"Invalid organization name {org}")
25-
return f"https://apigee.com/portals/api/sites/{portal_ids[org]}/apidocs"
26-
27-
28-

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/models/ansible/apply_pull_request_namespace.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,4 @@ def apply_namespace(cls, manifest, values):
5959
for spec in env.specs:
6060
spec.name = spec.name.replace(old, new, 1)
6161

62-
for entry in env.api_catalog:
63-
entry.edgeAPIProductName = entry.edgeAPIProductName.replace(
64-
old, new, 1
65-
)
66-
entry.title = f"[{display}] {entry.title}"
67-
entry.specId = entry.specId.replace(old, new, 1)
68-
6962
return manifest

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/models/ansible/deploy_api_catalog_item.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/models/apigee/apidoc.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/models/manifest/apigee_environment.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import typing
22
import pydantic
3-
from ansible_collections.nhsd.apigee.plugins.module_utils.models.apigee.apidoc import (
4-
ApigeeApidoc,
5-
)
63
from ansible_collections.nhsd.apigee.plugins.module_utils.models.apigee.spec import (
74
ApigeeSpec,
85
)
@@ -16,7 +13,6 @@ class ManifestApigeeEnvironment(pydantic.BaseModel):
1613
name: LITERAL_APIGEE_ENVIRONMENTS
1714
products: typing.List[ApigeeProduct] = []
1815
specs: typing.List[ApigeeSpec] = []
19-
api_catalog: typing.List[ApigeeApidoc] = []
2016

2117
@pydantic.validator("products", "specs")
2218
def names_unique(cls, values):
@@ -25,22 +21,6 @@ def names_unique(cls, values):
2521
raise ValueError("Names are not unique")
2622
return values
2723

28-
@pydantic.validator("api_catalog")
29-
def catalog_references(cls, api_catalog, values):
30-
spec_names = [spec.name for spec in values.get("specs", [])]
31-
product_names = [product.name for product in values.get("products", [])]
32-
33-
for item in api_catalog:
34-
if item.edgeAPIProductName not in product_names:
35-
raise ValueError(
36-
f"edgeAPIProductName {item.edgeAPIProductName} not in list of products in this environment"
37-
)
38-
if item.specId and item.specId not in spec_names:
39-
raise ValueError(
40-
f"specId {item.specId} not in list of specs in this environment"
41-
)
42-
return api_catalog
43-
4424
@pydantic.validator("products", pre=True)
4525
def set_single_environment(cls, products, values):
4626
"""

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/models/manifest/meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from ansible_collections.nhsd.apigee.plugins.module_utils.paas import api_registry
66

7-
SCHEMA_VERSION = "1.1.6"
7+
SCHEMA_VERSION = "1.1.8"
88

99
_REGISTRY_DATA = {}
1010

ansible/collections/ansible_collections/nhsd/apigee/plugins/module_utils/utils.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -74,56 +74,6 @@ def put(url, access_token, **kwargs):
7474
return request("PUT", url, access_token, **kwargs)
7575

7676

77-
def select_unique(
78-
items: typing.List[typing.Dict[str, typing.Any]],
79-
key: str,
80-
value: str,
81-
valid_lengths: typing.Optional[typing.List[int]] = None,
82-
) -> typing.List[typing.Dict[str, typing.Any]]:
83-
84-
selected = [item for item in items if item.get(key) == value]
85-
if not valid_lengths:
86-
valid_lengths = [0, 1]
87-
if len(selected) not in valid_lengths:
88-
raise ValueError(f"{JSON.dumps(selected)}")
89-
return selected
90-
91-
92-
def get_all_apidocs(organization, access_token, task_vars=None, refresh=False):
93-
"""
94-
Get all apidocs for organization. Requires valid apigee acess_token.
95-
96-
If task_vars is passed in, will search in there for the apidocs.
97-
If task_vars is included, will update the task_vars with APIGEE_APIDOCS.
98-
"""
99-
if task_vars is None:
100-
task_vars = {}
101-
apidocs = task_vars.get("APIGEE_APIDOCS")
102-
if refresh or not apidocs:
103-
all_results = []
104-
105-
params = {
106-
"pageSize" : 100
107-
}
108-
scan = True
109-
110-
while scan:
111-
apidocs_request = get(constants.portal_uri(organization), access_token, params=params)
112-
if apidocs_request.get("failed"):
113-
return apidocs_request
114-
115-
next_page_token = apidocs_request["response"]["body"]["next_page_token"]
116-
all_results += apidocs_request["response"]["body"]["data"]
117-
118-
if next_page_token != "":
119-
params["pageToken"] = next_page_token
120-
else:
121-
scan = False
122-
123-
task_vars.update({"APIGEE_APIDOCS": all_results})
124-
return task_vars
125-
126-
12777
def get_all_spec_resources(organization, access_token, task_vars=None, refresh=False):
12878
"""
12979
Get all spec_resources for organization. Requires valid apigee

ansible/collections/ansible_collections/nhsd/apigee/roles/deploy_manifest/tasks/main.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,3 @@
6262
organization: "{{ APIGEE_ORGANIZATION }}"
6363
access_token: "{{ APIGEE_ACCESS_TOKEN }}"
6464
loop: "{{ apigee_environment.specs }}"
65-
66-
- name: deploy api catalog
67-
nhsd.apigee.deploy_api_catalog_item:
68-
api_catalog_item: "{{ item }}"
69-
organization: "{{ APIGEE_ORGANIZATION }}"
70-
access_token: "{{ APIGEE_ACCESS_TOKEN }}"
71-
loop: "{{ apigee_environment.api_catalog }}"
72-
# See comment on product loop control. (I believe APIDocs
73-
# actually can reference products that don't exist. But this is
74-
# cleaner.)
75-
when: APIGEE_ORGANIZATION == 'nhsd-prod' and item.edgeAPIProductName | regex_search('^' + SERVICE_NAME + '-' + PULL_REQUEST | default(APIGEE_ENVIRONMENT))

0 commit comments

Comments
 (0)