Skip to content

Commit 37e3b3c

Browse files
authored
Merge pull request #42 from NHSDigital/feature/eja-eli-161-adding-proxygen-capabilities
Feature/eja eli 161 adding proxygen capabilities
2 parents ba0acfd + 4a94a8a commit 37e3b3c

26 files changed

+2832
-74
lines changed

Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,69 @@ config:: # Configure development environment (main) @Configuration
6262
precommit: test-unit build test-integration lint ## Pre-commit tasks
6363
python -m this
6464

65+
##################
66+
#### Proxygen ####
67+
##################
68+
69+
retrieve-proxygen-key: # Obtain the 'machine user' credentials from AWS SSM (Development environment)
70+
mkdir -p ~/.proxygen && \
71+
aws ssm get-parameter --name /proxygen/private_key_temp --with-decryption | jq ".Parameter.Value" --raw-output \
72+
> ~/.proxygen/eligibility-signposting-api.pem
73+
74+
setup-proxygen-credentials: # Copy Proxygen templated credentials to where it expected them
75+
cd specification && cp -r .proxygen ~
76+
77+
get-spec: # Get the most recent specification live in proxygen
78+
$(MAKE) setup-proxygen-credentials
79+
proxygen spec get
80+
81+
# Specification
82+
83+
guard-%:
84+
@ if [ "${${*}}" = "" ]; then \
85+
echo "Variable $* not set"; \
86+
exit 1; \
87+
fi
88+
89+
set-target: guard-APIM_ENV
90+
@ TARGET=target-$$APIM_ENV.yaml \
91+
envsubst '$${TARGET}' \
92+
< specification/x-nhsd-apim/target-template.yaml > specification/x-nhsd-apim/target.yaml
93+
94+
set-access: guard-APIM_ENV
95+
@ ACCESS=access-$$APIM_ENV.yaml \
96+
envsubst '$${ACCESS}' \
97+
< specification/x-nhsd-apim/access-template.yaml > specification/x-nhsd-apim/access.yaml
98+
99+
set-security: guard-APIM_ENV
100+
@ SECURITY=security-$$APIM_ENV.yaml \
101+
envsubst '$${SECURITY}' \
102+
< specification/components/security/security-template.yaml > specification/components/security/security.yaml
103+
104+
set-ratelimit: guard-APIM_ENV
105+
@ RATELIMIT=ratelimit-$$APIM_ENV.yaml \
106+
envsubst '$${RATELIMIT}' \
107+
< specification/x-nhsd-apim/ratelimit-template.yaml > specification/x-nhsd-apim/ratelimit.yaml
108+
109+
update-spec-template: guard-APIM_ENV
110+
ifeq ($(APIM_ENV), $(filter $(APIM_ENV), sandbox internal-dev int ref prod ))
111+
@ $(MAKE) set-target APIM_ENV=$$APIM_ENV
112+
@ $(MAKE) set-access APIM_ENV=$$APIM_ENV
113+
@ $(MAKE) set-security APIM_ENV=$$APIM_ENV
114+
@ $(MAKE) set-ratelimit APIM_ENV=$$APIM_ENV
115+
else
116+
@ echo ERROR: $$APIM_ENV is not a valid environment. Please use one of [sandbox, internal-dev, int, ref, prod]
117+
@ exit 1;
118+
endif
119+
120+
construct-spec: guard-APIM_ENV
121+
@ $(MAKE) update-spec-template APIM_ENV=$$APIM_ENV
122+
mkdir -p build/specification && \
123+
npx redocly bundle specification/eligibility-signposting-api.yaml --remove-unused-components --keep-url-references --ext yaml \
124+
> build/specification/eligibility-signposting-api.yaml
125+
ifeq ($(APIM_ENV), sandbox)
126+
@ $(MAKE) publish
127+
endif
65128
SPEC_DIR := $(CURDIR)/specification
66129
POSTMAN_DIR := $(SPEC_DIR)/postman
67130

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The software will only be used for signposting an individual to an appropriate s
2020
- [Usage](#usage)
2121
- [Testing](#testing)
2222
- [Sandbox](#sandbox)
23+
- [Specification](#specification)
2324
- [Conflict with yanai](#conflict-with-yanai)
2425
- [Creating a Postman collection](#creating-a-postman-collection)
2526
- [Design](#design)
@@ -96,6 +97,11 @@ There are `make` tasks for you to configure to run your tests. Run `make test`
9697

9798
There is a minimalist sandbox environment in `/sandbox` with an accompanying README with instructions on how to run it locally.
9899

100+
## Specification
101+
102+
The OpenAPI specification is stored in `specification`. In that folder, there is an accompanying README with instructions on how to produce an environment-specification specification and publish
103+
it using Proxygen CLI.
104+
99105
## Conflict with yanai
100106

101107
If you have previously built [yanai](https://nhsd-confluence.digital.nhs.uk/pages/viewpage.action?pageId=48826732), which is the platform we use to supply data to this project, that uses an old version of localstack that does not support our Python version. We have pinned the correct version here and yanai have their version pinned as well so it should work fine, but sometimes issues can arise - if so then removing the docker image can solve that, before then rebuilding.

0 commit comments

Comments
 (0)