Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1885)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 7, 2024
1 parent 59cd9f9 commit a436f5e
Show file tree
Hide file tree
Showing 10 changed files with 462 additions and 59 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,16 @@ jobs:

- run: |
go build ./...
test:
name: test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Bootstrap
run: ./scripts/bootstrap

- name: Run tests
run: ./scripts/test

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
codegen.log
Brewfile.lock.json
.idea/
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1258
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b3772775d2fb2b6a241272ee7e25947401f425c5f89ba33c11dabd434a060aa7.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f1479806ff9a382d425b33f45765681c248cf0895cd4fb79eec5b51a55ea23a.yml
20 changes: 12 additions & 8 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2354,29 +2354,33 @@ Methods:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#Hostname">Hostname</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameNewResponse">HostnameNewResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameListResponse">HostnameListResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameDeleteResponse">HostnameDeleteResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameEditResponse">HostnameEditResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameGetResponse">HostnameGetResponse</a>

Methods:

- <code title="post /zones/{zone_identifier}/web3/hostnames">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameNewParams">HostnameNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#Hostname">Hostname</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_identifier}/web3/hostnames">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#Hostname">Hostname</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /zones/{zone_identifier}/web3/hostnames">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameNewParams">HostnameNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameNewResponse">HostnameNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_identifier}/web3/hostnames">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameListResponse">HostnameListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /zones/{zone_identifier}/web3/hostnames/{identifier}">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameDeleteResponse">HostnameDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /zones/{zone_identifier}/web3/hostnames/{identifier}">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.Edit">Edit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameEditParams">HostnameEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#Hostname">Hostname</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#Hostname">Hostname</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /zones/{zone_identifier}/web3/hostnames/{identifier}">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.Edit">Edit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameEditParams">HostnameEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameEditResponse">HostnameEditResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}">client.Web3.Hostnames.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameGetResponse">HostnameGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

### IPFSUniversalPaths

#### ContentLists

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#ContentList">ContentList</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListUpdateResponse">HostnameIPFSUniversalPathContentListUpdateResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListGetResponse">HostnameIPFSUniversalPathContentListGetResponse</a>

Methods:

- <code title="put /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListUpdateParams">HostnameIPFSUniversalPathContentListUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#ContentList">ContentList</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#ContentList">ContentList</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListUpdateParams">HostnameIPFSUniversalPathContentListUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListUpdateResponse">HostnameIPFSUniversalPathContentListUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, zoneIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, identifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3">web3</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/web3#HostnameIPFSUniversalPathContentListGetResponse">HostnameIPFSUniversalPathContentListGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

##### Entries

Expand Down
16 changes: 16 additions & 0 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
}
fi

echo "==> Installing Go dependencies…"

go mod install
8 changes: 8 additions & 0 deletions scripts/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

gofmt ./...

41 changes: 41 additions & 0 deletions scripts/mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

if [[ -n "$1" && "$1" != '--'* ]]; then
URL="$1"
shift
else
URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)"
fi

# Check if the URL is empty
if [ -z "$URL" ]; then
echo "Error: No OpenAPI spec path/url provided or found in .stats.yml"
exit 1
fi

echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
echo -n "."
sleep 0.1
done

if grep -q "✖ fatal" ".prism.log"; then
cat .prism.log
exit 1
fi

echo
else
npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL"
fi
57 changes: 57 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
}

kill_server_on_port() {
pids=$(lsof -t -i tcp:"$1" || echo "")
if [ "$pids" != "" ]; then
kill "$pids"
echo "Stopped $pids."
fi
}

function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

# Start the dev server
./scripts/mock --daemon
fi

if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo
fi

# Run tests
echo "==> Running tests"
go test ./... "$@"
Loading

0 comments on commit a436f5e

Please sign in to comment.