Skip to content
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
6 changes: 4 additions & 2 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"generatorName": "fernapi/fern-python-sdk",
"generatorVersion": "5.26.0",
"generatorConfig": {
"package_name": "cloudpdf"
"package_name": "cloudpdf",
"client_class_name": "CloudPDFClient",
"environment_class_name": "CloudPDFEnvironment"
},
"originGitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"originGitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "3.0.0a1",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
with:
python-version: '3.12'
- run: python -m pip install --disable-pip-version-check build
- run: python -m build --wheel
- run: python -m build
132 changes: 132 additions & 0 deletions .github/workflows/sdk-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: SDK Release

on:
push:
branches: [main]
paths-ignore:
- '.github/**'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: sdk-release
cancel-in-progress: false

jobs:
release:
name: Publish cloudpdf
if: github.event_name == 'workflow_dispatch' || vars.SDK_AUTO_PUBLISH_ENABLED == 'true'
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Verify generated release version
id: version
run: |
python - <<'PY'
import json
import os
import tomllib

with open('pyproject.toml', 'rb') as file:
manifest = tomllib.load(file)
with open('cloudpdf-generation.json', encoding='utf-8') as file:
generation = json.load(file)
name = manifest['tool']['poetry']['name']
version = manifest['tool']['poetry']['version']
if generation['language'] != 'python':
raise RuntimeError('generation language is not python')
if name != 'cloudpdf':
raise RuntimeError(f'unexpected PyPI project {name}')
if version != generation['sdkVersion']:
raise RuntimeError(f'package version {version} does not match generated version {generation["sdkVersion"]}')
prerelease = '-' in generation['canonicalVersion']
with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:
output.write(f'version={version}\n')
output.write(f'tag=v{version}\n')
output.write(f'prerelease={str(prerelease).lower()}\n')
PY

- name: Build and inspect distributions
run: |
python -m pip install --disable-pip-version-check build
python -m build --outdir dist
python -m zipfile --list dist/*.whl >/dev/null

- name: Protect immutable release tag
id: release-tag
env:
RELEASE_TAG: ${{ steps.version.outputs.tag }}
run: |
git fetch --force --tags origin
if git rev-parse --quiet --verify "refs/tags/$RELEASE_TAG" >/dev/null; then
tagged_commit="$(git rev-list -n 1 "$RELEASE_TAG")"
if [ "$tagged_commit" != "$GITHUB_SHA" ]; then
if git diff --quiet "$RELEASE_TAG" "$GITHUB_SHA" -- . ':(exclude).github/**'; then
echo "::notice::Reusing $RELEASE_TAG after a workflow-only change."
else
echo "::error::Release tag $RELEASE_TAG already points to different package source at $tagged_commit; bump the SDK version."
exit 1
fi
fi
echo "existed=true" >> "$GITHUB_OUTPUT"
else
git config user.name cloudpdf-sdk-bot
git config user.email hello@cloudpdf.com
git tag -a "$RELEASE_TAG" -m "CloudPDF Python SDK $RELEASE_TAG"
git push origin "refs/tags/$RELEASE_TAG"
echo "existed=false" >> "$GITHUB_OUTPUT"
fi

- name: Check PyPI publication state
id: registry
env:
VERSION: ${{ steps.version.outputs.version }}
TAG_EXISTED: ${{ steps.release-tag.outputs.existed }}
run: |
http_status="$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' "https://pypi.org/pypi/cloudpdf/$VERSION/json")"
case "$http_status" in
200)
if [ "$TAG_EXISTED" != 'true' ]; then
echo "::error::cloudpdf==$VERSION already exists on PyPI but its release tag did not exist."
exit 1
fi
echo "publish=false" >> "$GITHUB_OUTPUT"
;;
404)
echo "publish=true" >> "$GITHUB_OUTPUT"
;;
*)
echo "::error::PyPI returned HTTP $http_status while checking cloudpdf==$VERSION."
exit 1
;;
esac

- name: Publish to PyPI
if: steps.registry.outputs.publish == 'true'
uses: pypa/gh-action-pypi-publish@release/v1

- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.version.outputs.tag }}
PRERELEASE: ${{ steps.version.outputs.prerelease }}
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
exit 0
fi
args=(--verify-tag --generate-notes --title "CloudPDF Python SDK $RELEASE_TAG")
if [ "$PRERELEASE" = 'true' ]; then args+=(--prerelease); fi
gh release create "$RELEASE_TAG" "${args[@]}"
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Cloudpdf Python Library
# CloudPDF Python SDK

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Cloudpdf%2FPython)
[![pypi](https://img.shields.io/pypi/v/cloudpdf)](https://pypi.python.org/pypi/cloudpdf)

The Cloudpdf Python library provides convenient access to the Cloudpdf APIs from Python.
The official Python SDK for the CloudPDF API.

## Table of Contents

Expand Down Expand Up @@ -34,9 +34,9 @@ A full reference for this library is available [here](./reference.md).
Instantiate and use the client with the following:

```python
from cloudpdf import CloudpdfApi
from cloudpdf import CloudPDFClient

client = CloudpdfApi(
client = CloudPDFClient(
token="<token>",
base_url="https://yourhost.com/path/to/api",
)
Expand All @@ -53,9 +53,9 @@ The SDK also exports an `async` client so that you can make non-blocking calls t
```python
import asyncio

from cloudpdf import AsyncCloudpdfApi
from cloudpdf import AsyncCloudPDFClient

client = AsyncCloudpdfApi(
client = AsyncCloudPDFClient(
token="<token>",
base_url="https://yourhost.com/path/to/api",
)
Expand Down Expand Up @@ -93,9 +93,9 @@ The SDK provides access to raw response data, including headers, through the `.w
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.

```python
from cloudpdf import CloudpdfApi
from cloudpdf import CloudPDFClient

client = CloudpdfApi(...)
client = CloudPDFClient(...)
response = client.tenants.with_raw_response.create(...)
print(response.headers) # access the response headers
print(response.status_code) # access the response status code
Expand Down Expand Up @@ -137,9 +137,9 @@ client.tenants.create(..., request_options={
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

```python
from cloudpdf import CloudpdfApi
from cloudpdf import CloudPDFClient

client = CloudpdfApi(..., timeout=20.0)
client = CloudPDFClient(..., timeout=20.0)

# Override timeout for a specific method
client.tenants.create(..., request_options={
Expand All @@ -154,9 +154,9 @@ and transports.

```python
import httpx
from cloudpdf import CloudpdfApi
from cloudpdf import CloudPDFClient

client = CloudpdfApi(
client = CloudPDFClient(
...,
httpx_client=httpx.Client(
proxy="http://my.test.proxy.example.com",
Expand Down
2 changes: 1 addition & 1 deletion cloudpdf-generation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repository": "embedpdf/embed-pdf-viewer",
"openapi": "cloudpdf/contract/openapi.json",
"openapiSha256": "6858ce7912e9063d8fb171ade95fc473db01c5971a3af241a612dda79cc05100",
"gitCommit": "232d5e0240d5673a73c9ea7c7ae9e7b937fdd5b3",
"gitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
"gitCommitIsDirty": false
},
"fern": {
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ dynamic = ["version"]
[tool.poetry]
name = "cloudpdf"
version = "3.0.0a1"
description = ""
description = "The official Python SDK for the CloudPDF API."
readme = "README.md"
authors = []
authors = ["CloudPDF <hello@cloudpdf.com>"]
keywords = []
license = "Apache-2.0"
classifiers = [
Expand Down
Loading
Loading