Skip to content

Commit

Permalink
feat(next): update generated core and public clients from Katapult 2.…
Browse files Browse the repository at this point in the history
…68.0 schemas (#179)

Also update the generate.sh script to print some basic information about
what it is doing.
  • Loading branch information
jimehk authored Nov 29, 2024
1 parent 7af4d65 commit 4c8efb9
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 18 deletions.
2 changes: 2 additions & 0 deletions next/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/krystal/go-katapult/next/public"
)

//go:generate ./generate.sh

type Client struct {
Core core.ClientInterface
Public public.ClientInterface
Expand Down
52 changes: 42 additions & 10 deletions next/core/core.go

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

16 changes: 12 additions & 4 deletions next/generate.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/bash

echo "Generating Core and Public clients using OpenAPI specs"

go_version=$(grep goVersion generator-config.yml | cut -d':' -f2 | tr -d '[:space:]')
generator_version=$(grep generatorVersion generator-config.yml | cut -d':' -f2 | tr -d '[:space:]')
go_version="$(grep goVersion generator-config.yml | cut -d':' -f2 | tr -d '[:space:]')"
generator_version="$(grep generatorVersion generator-config.yml | cut -d':' -f2 | tr -d '[:space:]')"
core_api_version="$(jq -r '.info."x-katapult-version"' katapult-core-openapi.json)"
public_api_version="$(jq -r '.info."x-katapult-version"' katapult-public-openapi.json)"

echo " -> Using Go version: $go_version"
echo " -> Using OpenAPI generator version: $generator_version"

echo " -> Generating Core client (Katapult version: ${core_api_version})..."
docker run \
--user "$(id -u):$(id -g)" \
-v "$(pwd):/local" \
Expand All @@ -12,8 +19,9 @@ docker run \
-generate types,client \
-package core \
-templates /local/templates \
/local/katapult-core-openapi.json > "./core/core.go"
/local/katapult-core-openapi.json > "./core/core.go"

echo " -> Generating Public client (Katapult version: ${public_api_version})..."
docker run \
--user "$(id -u):$(id -g)" \
-v "$(pwd):/local" \
Expand All @@ -22,4 +30,4 @@ docker run \
-generate types,client \
-package public \
-templates /local/templates \
/local/katapult-public-openapi.json > "./public/public.go"
/local/katapult-public-openapi.json > "./public/public.go"
45 changes: 43 additions & 2 deletions next/katapult-core-openapi.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"openapi": "3.0.0",
"info": {
"x-katapult-version": "2.64.0",
"x-katapult-version": "2.68.0",
"version": "1.0.0",
"title": "Katapult Core API",
"description": "Welcome to the documentation for the Katapult Core API"
},
"externalDocs": {
"description": "Katapult API Documentation",
"url": "https://developers.katapult.io/docs/category/core-api"
"url": "https://docs.katapult.io/docs/category/core-api"
},
"servers": [
{
Expand Down Expand Up @@ -15943,6 +15943,9 @@
"404": {
"$ref": "#/components/responses/NoVirtualMachineForAPITokenResponse"
},
"409": {
"$ref": "#/components/responses/ContinuousManagementDisabledResponse"
},
"429": {
"$ref": "#/components/responses/APIAuthenticator429Response"
},
Expand Down Expand Up @@ -16300,6 +16303,10 @@
"type": "string",
"nullable": true
},
"default": {
"type": "boolean",
"description": "Indicates if this network is the default network for the data center."
},
"data_center": {
"$ref": "#/components/schemas/GetDataCenterDefaultNetworkPartDataCenter"
}
Expand Down Expand Up @@ -19976,6 +19983,10 @@
"type": "string",
"nullable": true
},
"default": {
"type": "boolean",
"description": "Indicates if this network is the default network for the data center."
},
"data_center": {
"$ref": "#/components/schemas/DataCenter"
}
Expand Down Expand Up @@ -20518,6 +20529,12 @@
"no_virtual_machine_for_api_token"
]
},
"ContinuousManagementDisabledEnum": {
"type": "string",
"enum": [
"continuous_management_disabled"
]
},
"ZoneLookup": {
"description": "All 'zone[]' params are mutually exclusive, only one can be provided.",
"type": "object",
Expand Down Expand Up @@ -22955,6 +22972,10 @@
"type": "string",
"nullable": true
},
"default": {
"type": "boolean",
"description": "Indicates if this network is the default network for the data center."
},
"data_center": {
"$ref": "#/components/schemas/GetOrganizationAvailableNetworksPartDataCenter"
}
Expand Down Expand Up @@ -26713,6 +26734,26 @@
}
}
},
"ContinuousManagementDisabledResponse": {
"description": "SSH Key Continuous management is not enabled for this virtual machine",
"content": {
"application/json": {
"schema": {
"properties": {
"code": {
"$ref": "#/components/schemas/ContinuousManagementDisabledEnum"
},
"description": {
"type": "string"
},
"detail": {
"type": "object"
}
}
}
}
}
},
"OrganizationNotActivatedPermissionDeniedResourceCreationRestricted403Res": {
"description": "403 error response",
"content": {
Expand Down
4 changes: 2 additions & 2 deletions next/katapult-public-openapi.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"openapi": "3.0.0",
"info": {
"x-katapult-version": "2.64.0",
"x-katapult-version": "2.68.0",
"version": "1.0.0",
"title": "Katapult Public API",
"description": "Welcome to the documentation for the Katapult Public API"
},
"externalDocs": {
"description": "Katapult API Documentation",
"url": "https://developers.katapult.io/docs/category/public-api"
"url": "https://docs.katapult.io/docs/category/public-api"
},
"servers": [
{
Expand Down

0 comments on commit 4c8efb9

Please sign in to comment.