Skip to content

Commit 3f5edc1

Browse files
authored
Merge branch 'master' into APM-000-fix-version-parsing
2 parents 002d158 + 8b69562 commit 3f5edc1

27 files changed

Lines changed: 1883 additions & 1548 deletions

File tree

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

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import requests
2-
import json
3-
import bisect
41
import copy
52

63
from ansible_collections.nhsd.apigee.plugins.module_utils.models.ansible.add_jwks_resource_url import (
@@ -13,7 +10,6 @@
1310
from ansible_collections.nhsd.apigee.plugins.module_utils import constants
1411

1512
ATTRIBUTE_NAME = "jwks-resource-url"
16-
DEVELOPER_DETAILS = "APIGEE_DEVELOPER_DETAILS"
1713

1814

1915
class ActionModule(ApigeeAction):
@@ -39,49 +35,24 @@ def run(self, tmp=None, task_vars=None):
3935
after["attributes"].append(jwks_attribute)
4036
after["attributes"] = sorted(after["attributes"], key=lambda attr: attr["name"])
4137

42-
developer_details = task_vars.get(DEVELOPER_DETAILS)
43-
if not developer_details:
44-
developer_details = []
45-
params = {"expand": True}
46-
url = (
47-
constants.APIGEE_BASE_URL
48-
+ f"organizations/{args.organization}/developers"
49-
)
50-
while True:
51-
resp = utils.get(url, args.access_token, params=params)
52-
if resp.get("failed"):
53-
return resp
54-
devs = resp["response"]["body"]["developer"]
55-
developer_details.extend(devs)
56-
if len(devs) == 1000:
57-
# last developer's ID as startKey will be included
58-
# in next request, so pop now to de-dupe.
59-
last_dev = developer_details.pop()
60-
params["startKey"] = last_dev["developerId"]
61-
else:
62-
break
63-
64-
try:
65-
developer_id = args._app_data["developerId"]
66-
developer_ids = [d["developerId"] for d in developer_details]
67-
i = bisect.bisect_left(developer_ids, developer_id)
68-
if i == len(developer_details):
69-
raise RuntimeError(f"Unable to find developer with id {developer_id}")
70-
except RuntimeError as e:
71-
return {"failed": True, "error": str(e)}
72-
73-
developer = developer_details[i]
74-
7538
delta = utils.delta(before, after)
7639
result = {
7740
"changed": bool(delta),
78-
"app": after,
79-
"developer": developer,
80-
"ansible_facts": {DEVELOPER_DETAILS: developer_details},
41+
"app": after
8142
}
8243

44+
company_exists = "companyName" in args._app_data.keys()
45+
developer_exists = "developerId" in args._app_data.keys()
46+
if developer_exists and not company_exists:
47+
owner = args._app_data["developerId"]
48+
elif company_exists and not developer_exists:
49+
owner = args._app_data["companyName"]
50+
else:
51+
return {"failed": True, "error": f"Invalid owner for app {args._app_data['appId']}"}
52+
53+
owner_endpoint = "companies" if company_exists else "developers"
8354
app_name = args._app_data["name"]
84-
app_path = f"organizations/{args.organization}/developers/{developer['email']}/apps/{app_name}/attributes"
55+
app_path = f"organizations/{args.organization}/{owner_endpoint}/{owner}/apps/{app_name}/attributes"
8556

8657
if diff_mode:
8758
result["diff"] = [

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

0 commit comments

Comments
 (0)