Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add domain registration token #4

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ jobs:
touch *.yaml
make generate-json
git diff --exit-code

oapi_codegen:
runs-on: "ubuntu-latest"
container: registry.access.redhat.com/ubi9/go-toolset:1.18
steps:
- uses: "actions/checkout@v3"
- run: make oapi-codegen
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/.venv
/node_modules
/bin
/tmp
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ VENV = $(srcdir)/.venv
PYTHON_VENV = $(VENV)/bin/python
VALIDATOR = $(VENV)/bin/openapi-spec-validator
NODE_BIN = node_modules/.bin
BIN = bin
TMP = tmp
OAPI_CODEGEN = $(BIN)/oapi-codegen
OAPI_CODEGEN_VERSION ?= v1.12.4

SWAGGER_CONTAINER = swagger-editor

.PHONY: all
all:
$(MAKE) openapi-sort
$(MAKE) validate
$(MAKE) oapi-codegen
$(MAKE) vacuum
$(MAKE) generate-json

.PHONY: clean
clean:
rm -rf $(VENV)
rm -rf $(VENV) $(BIN) $(TMP)


$(PYTHON_VENV):
$(PYTHON) -m venv $(VENV)
Expand All @@ -30,6 +36,27 @@ $(NODE_BIN)/%: package.json package-lock.json
npm install
touch $(NODE_BIN)/*

$(OAPI_CODEGEN):
GOBIN=$(CURDIR)/$(BIN) go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION)

.PHONY: oapi-codegen
oapi-codegen: \
$(TMP)/public/spec.gen.go $(TMP)/public/server.gen.go $(TMP)/public/types.gen.go \
$(TMP)/internal/spec.gen.go $(TMP)/internal/server.gen.go $(TMP)/internal/types.gen.go \
$(TMP)/metrics/spec.gen.go $(TMP)/metrics/server.gen.go $(TMP)/metrics/types.gen.go

$(TMP)/%/spec.gen.go: %.openapi.yaml $(OAPI_CODEGEN)
@mkdir -p $(dir $@)
$(OAPI_CODEGEN) -generate spec -package $* -o $(TMP)/$*/spec.gen.go $<

$(TMP)/%/server.gen.go: %.openapi.yaml $(OAPI_CODEGEN)
@mkdir -p $(dir $@)
$(OAPI_CODEGEN) -generate server -package $* -o $(TMP)/$*/server.gen.go $<

$(TMP)/%/types.gen.go: %.openapi.yaml $(OAPI_CODEGEN)
@mkdir -p $(dir $@)
$(OAPI_CODEGEN) -generate types -package $* -o $(TMP)/$*/types.gen.go $<

.PHONY: validate
validate: $(VALIDATOR)
$(VALIDATOR) public.openapi.yaml
Expand Down
119 changes: 119 additions & 0 deletions public.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,56 @@
]
}
},
"/domains/token": {
"description": "Request a domain registration token",
"summary": "Domain registration token",
"parameters": [
{
"name": "X-Rh-Insights-Request-Id",
"description": "Request id",
"required": true,
"schema": {
"type": "string"
},
"in": "header"
}
],
"post": {
"description": "Request a domain registration token",
"summary": "Domain registration token request",
"operationId": "createDomainToken",
"requestBody": {
"description": "Domain registration request",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DomainRegTokenRequest"
}
}
}
},
"responses": {
"201": {
"$ref": "#/components/responses/DomainRegTokenResponse"
},
"400": {
"$ref": "#/components/responses/ErrorResponse"
},
"404": {
"$ref": "#/components/responses/ErrorResponse"
}
},
"security": [
{
"x-rh-identity": []
}
],
"tags": [
"resources"
]
}
},
"/domains/{uuid}": {
"description": "Specific operations on an existing domain to read, update or delete it.",
"summary": "Operations on a specific domain",
Expand Down Expand Up @@ -459,6 +509,16 @@
}
}
},
"DomainRegTokenResponse": {
"description": "Response with domain registration token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DomainRegToken"
}
}
}
},
"ErrorResponse": {
"description": "Error response for some operation.",
"content": {
Expand Down Expand Up @@ -904,6 +964,65 @@
},
"example": "domain.example"
},
"DomainRegToken": {
"title": "Root Type for domain registration token response",
"description": "A domain registration response",
"type": "object",
"required": [
"domain_id",
"domain_token",
"domain_type",
"expiration"
],
"additionalProperties": false,
"properties": {
"domain_id": {
"$ref": "#/components/schemas/DomainId"
},
"domain_token": {
"description": "A domain registration token string",
"type": "string"
},
"domain_type": {
"$ref": "#/components/schemas/DomainType"
},
"expiration": {
"description": "Expiration time stamp (Unix timestamp)",
"type": "integer"
}
},
"x-rh-ipa-hcc": {
"name": "DomainRegTokenResponse",
"type": "response"
},
"example": {
"domain_id": "681abfd7-18ce-51b3-a9cc-10d386c8dc35",
"domain_token": "F3kVxQP4sIs.cjbtH-GB8JuszfqrQnnudLoLzJH3zkw5jnhmTgKP_HU",
"domain_type": "rhel-idm",
"expiration": 1691407070
}
},
"DomainRegTokenRequest": {
"title": "Root Type for domain registration token request",
"description": "A domain registration request",
"type": "object",
"required": [
"domain_type"
],
"additionalProperties": false,
"properties": {
"domain_type": {
"$ref": "#/components/schemas/DomainType"
}
},
"x-rh-ipa-hcc": {
"name": "DomainRegTokenRequest",
"type": "request"
},
"example": {
"domain_type": "rhel-idm"
}
},
"DomainType": {
"title": "Domain Type",
"description": "Type of domain (currently only rhel-idm)",
Expand Down
82 changes: 82 additions & 0 deletions public.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,38 @@ paths:
- x-rh-identity: []
tags:
- resources
/domains/token:
description: Request a domain registration token
summary: Domain registration token
parameters:
- name: X-Rh-Insights-Request-Id
description: Request id
required: true
schema:
type: string
in: header
post:
description: Request a domain registration token
summary: Domain registration token request
operationId: createDomainToken
requestBody:
description: Domain registration request
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DomainRegTokenRequest'
responses:
'201':
$ref: '#/components/responses/DomainRegTokenResponse'
'400':
$ref: '#/components/responses/ErrorResponse'
'404':
$ref: '#/components/responses/ErrorResponse'
security:
- x-rh-identity: []
tags:
- resources
/domains/{uuid}:
description: Specific operations on an existing domain to read, update or delete it.
summary: Operations on a specific domain
Expand Down Expand Up @@ -297,6 +329,12 @@ components:
X-Rh-Idm-Rhel-Idm-Token:
schema:
type: string
DomainRegTokenResponse:
description: Response with domain registration token
content:
application/json:
schema:
$ref: '#/components/schemas/DomainRegToken'
ErrorResponse:
description: Error response for some operation.
content:
Expand Down Expand Up @@ -655,6 +693,50 @@ components:
x-rh-ipa-hcc:
type: defs
example: domain.example
DomainRegToken:
title: Root Type for domain registration token response
description: A domain registration response
type: object
required:
- domain_id
- domain_token
- domain_type
- expiration
additionalProperties: false
properties:
domain_id:
$ref: '#/components/schemas/DomainId'
domain_token:
description: A domain registration token string
type: string
domain_type:
$ref: '#/components/schemas/DomainType'
expiration:
description: Expiration time stamp (Unix timestamp)
type: integer
x-rh-ipa-hcc:
name: DomainRegTokenResponse
type: response
example:
domain_id: 681abfd7-18ce-51b3-a9cc-10d386c8dc35
domain_token: F3kVxQP4sIs.cjbtH-GB8JuszfqrQnnudLoLzJH3zkw5jnhmTgKP_HU
domain_type: rhel-idm
expiration: 1691407070
DomainRegTokenRequest:
title: Root Type for domain registration token request
description: A domain registration request
type: object
required:
- domain_type
additionalProperties: false
properties:
domain_type:
$ref: '#/components/schemas/DomainType'
x-rh-ipa-hcc:
name: DomainRegTokenRequest
type: request
example:
domain_type: rhel-idm
DomainType:
title: Domain Type
description: Type of domain (currently only rhel-idm)
Expand Down