Skip to content

Commit 9d3553e

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): OpenAPI spec update via Stainless API (#402)
1 parent 4f30fd4 commit 9d3553e

File tree

27 files changed

+390
-189
lines changed

27 files changed

+390
-189
lines changed

.github/workflows/ci.yml

+19
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,26 @@ jobs:
3939
- name: Ensure importable
4040
run: |
4141
rye run python -c 'import cloudflare'
42+
test:
43+
name: test
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Install Rye
50+
run: |
51+
curl -sSf https://rye-up.com/get | bash
52+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
53+
env:
54+
RYE_VERSION: 0.24.0
55+
RYE_INSTALL_OPTION: '--yes'
56+
57+
- name: Bootstrap
58+
run: ./scripts/bootstrap
4259

60+
- name: Run tests
61+
run: ./scripts/test
4362
examples:
4463
name: examples
4564
runs-on: ubuntu-latest

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dist
1212
.env
1313
.envrc
1414
codegen.log
15+
Brewfile.lock.json

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1258
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-b3772775d2fb2b6a241272ee7e25947401f425c5f89ba33c11dabd434a060aa7.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5f1479806ff9a382d425b33f45765681c248cf0895cd4fb79eec5b51a55ea23a.yml

Brewfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
brew "rye"
2+

api.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -2559,16 +2559,22 @@ Methods:
25592559
Types:
25602560

25612561
```python
2562-
from cloudflare.types.web3 import Hostname, HostnameDeleteResponse
2562+
from cloudflare.types.web3 import (
2563+
HostnameCreateResponse,
2564+
HostnameListResponse,
2565+
HostnameDeleteResponse,
2566+
HostnameEditResponse,
2567+
HostnameGetResponse,
2568+
)
25632569
```
25642570

25652571
Methods:
25662572

2567-
- <code title="post /zones/{zone_identifier}/web3/hostnames">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">create</a>(zone_identifier, \*\*<a href="src/cloudflare/types/web3/hostname_create_params.py">params</a>) -> <a href="./src/cloudflare/types/web3/hostname.py">Hostname</a></code>
2568-
- <code title="get /zones/{zone_identifier}/web3/hostnames">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">list</a>(zone_identifier) -> <a href="./src/cloudflare/types/web3/hostname.py">SyncSinglePage[Hostname]</a></code>
2573+
- <code title="post /zones/{zone_identifier}/web3/hostnames">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">create</a>(zone_identifier, \*\*<a href="src/cloudflare/types/web3/hostname_create_params.py">params</a>) -> <a href="./src/cloudflare/types/web3/hostname_create_response.py">HostnameCreateResponse</a></code>
2574+
- <code title="get /zones/{zone_identifier}/web3/hostnames">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">list</a>(zone_identifier) -> <a href="./src/cloudflare/types/web3/hostname_list_response.py">SyncSinglePage[HostnameListResponse]</a></code>
25692575
- <code title="delete /zones/{zone_identifier}/web3/hostnames/{identifier}">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">delete</a>(identifier, \*, zone_identifier) -> <a href="./src/cloudflare/types/web3/hostname_delete_response.py">Optional</a></code>
2570-
- <code title="patch /zones/{zone_identifier}/web3/hostnames/{identifier}">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">edit</a>(identifier, \*, zone_identifier, \*\*<a href="src/cloudflare/types/web3/hostname_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/web3/hostname.py">Hostname</a></code>
2571-
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">get</a>(identifier, \*, zone_identifier) -> <a href="./src/cloudflare/types/web3/hostname.py">Hostname</a></code>
2576+
- <code title="patch /zones/{zone_identifier}/web3/hostnames/{identifier}">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">edit</a>(identifier, \*, zone_identifier, \*\*<a href="src/cloudflare/types/web3/hostname_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/web3/hostname_edit_response.py">HostnameEditResponse</a></code>
2577+
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}">client.web3.hostnames.<a href="./src/cloudflare/resources/web3/hostnames/hostnames.py">get</a>(identifier, \*, zone_identifier) -> <a href="./src/cloudflare/types/web3/hostname_get_response.py">HostnameGetResponse</a></code>
25722578

25732579
### IPFSUniversalPaths
25742580

@@ -2577,13 +2583,16 @@ Methods:
25772583
Types:
25782584

25792585
```python
2580-
from cloudflare.types.web3.hostnames.ipfs_universal_paths import ContentList
2586+
from cloudflare.types.web3.hostnames.ipfs_universal_paths import (
2587+
ContentListUpdateResponse,
2588+
ContentListGetResponse,
2589+
)
25812590
```
25822591

25832592
Methods:
25842593

2585-
- <code title="put /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.web3.hostnames.ipfs_universal_paths.content_lists.<a href="./src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py">update</a>(identifier, \*, zone_identifier, \*\*<a href="src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_params.py">params</a>) -> <a href="./src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py">ContentList</a></code>
2586-
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.web3.hostnames.ipfs_universal_paths.content_lists.<a href="./src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py">get</a>(identifier, \*, zone_identifier) -> <a href="./src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list.py">ContentList</a></code>
2594+
- <code title="put /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.web3.hostnames.ipfs_universal_paths.content_lists.<a href="./src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py">update</a>(identifier, \*, zone_identifier, \*\*<a href="src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_params.py">params</a>) -> <a href="./src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_update_response.py">ContentListUpdateResponse</a></code>
2595+
- <code title="get /zones/{zone_identifier}/web3/hostnames/{identifier}/ipfs_universal_path/content_list">client.web3.hostnames.ipfs_universal_paths.content_lists.<a href="./src/cloudflare/resources/web3/hostnames/ipfs_universal_paths/content_lists/content_lists.py">get</a>(identifier, \*, zone_identifier) -> <a href="./src/cloudflare/types/web3/hostnames/ipfs_universal_paths/content_list_get_response.py">ContentListGetResponse</a></code>
25872596

25882597
##### Entries
25892598

bin/check-env-state.py

-40
This file was deleted.

bin/check-test-server

-50
This file was deleted.

bin/test

-3
This file was deleted.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ format = { chain = [
6868
"fix:ruff",
6969
]}
7070
"format:black" = "black ."
71-
"format:docs" = "python bin/ruffen-docs.py README.md api.md"
71+
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
7272
"format:ruff" = "ruff format"
7373
"format:isort" = "isort ."
7474

@@ -192,5 +192,6 @@ known-first-party = ["cloudflare", "tests"]
192192

193193
[tool.ruff.per-file-ignores]
194194
"bin/**.py" = ["T201", "T203"]
195+
"scripts/**.py" = ["T201", "T203"]
195196
"tests/**.py" = ["T201", "T203"]
196197
"examples/**.py" = ["T201", "T203"]

scripts/bootstrap

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
8+
brew bundle check >/dev/null 2>&1 || {
9+
echo "==> Installing Homebrew dependencies…"
10+
brew bundle
11+
}
12+
fi
13+
14+
echo "==> Installing Python dependencies…"
15+
16+
# experimental uv support makes installations significantly faster
17+
rye config --set-bool behavior.use-uv=true
18+
19+
rye sync

scripts/format

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
rye run format
8+

scripts/lint

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
rye run lint
8+

scripts/mock

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
if [[ -n "$1" && "$1" != '--'* ]]; then
8+
URL="$1"
9+
shift
10+
else
11+
URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)"
12+
fi
13+
14+
# Check if the URL is empty
15+
if [ -z "$URL" ]; then
16+
echo "Error: No OpenAPI spec path/url provided or found in .stats.yml"
17+
exit 1
18+
fi
19+
20+
echo "==> Starting mock server with URL ${URL}"
21+
22+
# Run prism mock on the given spec
23+
if [ "$1" == "--daemon" ]; then
24+
npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log &
25+
26+
# Wait for server to come online
27+
echo -n "Waiting for server"
28+
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
29+
echo -n "."
30+
sleep 0.1
31+
done
32+
33+
if grep -q "✖ fatal" ".prism.log"; then
34+
cat .prism.log
35+
exit 1
36+
fi
37+
38+
echo
39+
else
40+
npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL"
41+
fi

scripts/test

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
RED='\033[0;31m'
8+
GREEN='\033[0;32m'
9+
YELLOW='\033[0;33m'
10+
NC='\033[0m' # No Color
11+
12+
function prism_is_running() {
13+
curl --silent "http://localhost:4010" >/dev/null 2>&1
14+
}
15+
16+
kill_server_on_port() {
17+
pids=$(lsof -t -i tcp:"$1" || echo "")
18+
if [ "$pids" != "" ]; then
19+
kill "$pids"
20+
echo "Stopped $pids."
21+
fi
22+
}
23+
24+
function is_overriding_api_base_url() {
25+
[ -n "$TEST_API_BASE_URL" ]
26+
}
27+
28+
if ! is_overriding_api_base_url && ! prism_is_running ; then
29+
# When we exit this script, make sure to kill the background mock server process
30+
trap 'kill_server_on_port 4010' EXIT
31+
32+
# Start the dev server
33+
./scripts/mock --daemon
34+
fi
35+
36+
if is_overriding_api_base_url ; then
37+
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
38+
echo
39+
elif ! prism_is_running ; then
40+
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
41+
echo -e "running against your OpenAPI spec."
42+
echo
43+
echo -e "To run the server, pass in the path or url of your OpenAPI"
44+
echo -e "spec to the prism command:"
45+
echo
46+
echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}"
47+
echo
48+
49+
exit 1
50+
else
51+
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
52+
echo
53+
fi
54+
55+
# Run tests
56+
echo "==> Running tests"
57+
rye run pytest "$@"
File renamed without changes.

0 commit comments

Comments
 (0)