Skip to content

Commit

Permalink
wip: adding docs workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored May 6, 2024
1 parent 2405bd8 commit 5cd0904
Show file tree
Hide file tree
Showing 8 changed files with 320 additions and 75 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# .github/workflows/docs.yml

name: Docs

on:
workflow_call:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "14"
- run: npx @redocly/cli build-docs api/api.yml --o docs/index.html
- uses: actions/upload-artifact@v2
if: github.ref == 'refs/heads/main'
with:
path: docs

deploy:
if: github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/download-artifact@v2
with:
name: docs
- uses: actions/deploy-pages@v4
id: deployment
24 changes: 22 additions & 2 deletions api/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,14 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Operator"
"401":
$ref: "#/components/responses/Unauthorized"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalError"
put:
summary: Updates the operator for a system
operationId: updateSystemOperator
Expand All @@ -897,12 +905,18 @@ paths:
requestBody:
$ref: "#/components/requestBodies/UpdateSystemOperator"
responses:
"200":
"201":
description: Successful
content:
application/json:
schema:
$ref: "#/components/schemas/Operator"
"401":
$ref: "#/components/responses/Unauthorized"
"400":
$ref: "#/components/responses/BadRequest"
"404":
$ref: "#/components/responses/NotFound"
delete:
summary: Deletes the operator for a system
operationId: deleteSystemOperator
Expand All @@ -911,6 +925,12 @@ paths:
responses:
"204":
description: Successful
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalError"

components:
parameters:
Expand Down Expand Up @@ -1097,7 +1117,7 @@ components:
type: string
claims:
$ref: "#/components/schemas/JWTAccountClaims"

# Body for creating an operator account user
CreateOperatorAccountUser:
content:
application/json:
Expand Down
10 changes: 0 additions & 10 deletions internal/api/services/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ func (a *ApiHandlers) GetSystem(ctx context.Context, req openapi.GetSystemReques
return openapi.GetSystem200JSONResponse(openapi.System{Id: &system.ID, Name: system.Name, Description: utils.StrPtr(system.Description), Operator: &openapi.Operator{Id: system.OperatorID}}), nil
}

// GetSystemOperator ...
func (a *ApiHandlers) GetSystemOperator(ctx context.Context, req openapi.GetSystemOperatorRequestObject) (openapi.GetSystemOperatorResponseObject, error) {
system, err := a.systems.GetSystem(ctx, req.SystemId)
if err != nil {
return nil, err
}

return openapi.GetSystemOperator200JSONResponse(openapi.Operator{Id: utils.PtrUUID(system.Operator.ID), Name: system.Operator.Name}), nil
}

// DeleteSystem ...
func (a *ApiHandlers) DeleteSystem(ctx context.Context, req openapi.DeleteSystemRequestObject) (openapi.DeleteSystemResponseObject, error) {
err := a.systems.DeleteSystem(ctx, req.SystemId)
Expand Down
14 changes: 14 additions & 0 deletions internal/api/services/systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,17 @@ func (a *ApiHandlers) CreateSystem(ctx context.Context, req openapi.CreateSystem

return openapi.CreateSystem201JSONResponse(res), nil
}

// GetSystemOperator ...
func (a *ApiHandlers) GetSystemOperator(ctx context.Context, req openapi.GetSystemOperatorRequestObject) (openapi.GetSystemOperatorResponseObject, error) {
system, err := a.systems.GetSystem(ctx, req.SystemId)
if err != nil {
return nil, err
}

if system.OperatorID == nil {
return openapi.GetSystemOperator404JSONResponse(openapi.GetSystemOperator404JSONResponse{openapi.NotFoundJSONResponse(openapi.ErrorNotFound("no operator found"))}), nil

Check failure on line 82 in internal/api/services/systems.go

View workflow job for this annotation

GitHub Actions / test

github.com/zeiss/typhoon/pkg/apis.GetSystemOperator404JSONResponse struct literal uses unkeyed fields
}

return openapi.GetSystemOperator200JSONResponse(openapi.Operator{Id: utils.PtrUUID(system.Operator.ID), Name: system.Operator.Name}), nil
}
89 changes: 86 additions & 3 deletions pkg/apis/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion pkg/apis/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ func (e Error) Error() error {
return fmt.Errorf("code: %d, message: %s", e.Code, e.Message)
}

// Unimplemented is a struct that implements the StrictServerInterface interface
// NotImplemented is a helper function to create a new Error with a 501 status code.
func NotImplemented(message string, args ...interface{}) Error {
return Error{
Code: http.StatusNotImplemented,
Message: fmt.Sprintf(message, args...),
}
}

// ErrorNotFound is a helper function to create a new Error with a 404 status code.
func ErrorNotFound(message string, args ...interface{}) Error {
return Error{
Code: http.StatusNotFound,
Message: fmt.Sprintf(message, args...),
}
}
Loading

0 comments on commit 5cd0904

Please sign in to comment.