Skip to content

Commit ef994b6

Browse files
chrisdengsogithub-actions[bot]
authored andcommitted
feat: regenerate from the OpenAPI spec
1 parent 7ceaf20 commit ef994b6

1,130 files changed

Lines changed: 14222 additions & 25352 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/release-notes/v3.0.0.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## moderation_api 3.0.0
2+
3+
A new major version of the Ruby SDK. Read the breaking changes before you upgrade.
4+
5+
```bash
6+
gem install moderation_api -v "~> 3.0"
7+
```
8+
9+
### Ruby-specific changes
10+
11+
- The module is `ModerationApi` (was `ModerationAPI`). Create the client with `ModerationApi::ModerationApi.new(secret_key: ENV.fetch("MODAPI_SECRET_KEY"))`.
12+
- Requests are typed objects, for example `Operations::SubmitContentRequest.new(content: Operations::TextRequest.new(text: "..."))`, and responses carry the result in `.object`. Sorbet type signatures are included.
13+
- Verify webhooks with `require "moderation_api/webhook_signature"` and `ModerationApi::WebhookSignature.construct_event(payload, signature)`.
14+
### What's new
15+
16+
- **Covers the whole API**, including the management API (`projects`, `channels`), wordlists and the review queue.
17+
- **Automatic pagination.** List methods return an iterator that fetches the next page for you.
18+
- **Clear errors.** One error class per HTTP status (`BadRequestError`, `NotFoundError`, `RateLimitError`, ...). Every error has a specific `code` (for example `invalid_api_key`, `quota_exceeded` or `author_not_found`), a `request_id` and a `doc_url`. See [Errors](https://docs.moderationapi.com/api-reference/errors).
19+
- **Retries** with exponential backoff on `429` and `5xx`, and timeouts per client or per request.
20+
- **Webhook verification** that reads the secret from `MODAPI_WEBHOOK_SECRET`.
21+
22+
### Breaking changes
23+
24+
The SDK is now generated from our OpenAPI spec with a new generator. Most calls keep their names, but check these:
25+
26+
- **List responses** are `{ data, pagination }` instead of a plain array or a resource-specific shape, and list methods take `page` and `pageSize`.
27+
- **Errors** have a new body: `code` is the specific error code, not the HTTP category. The old `data` field is gone.
28+
- **Renamed:** `account.list` is now `account.retrieve`, and `actions.execute.execute` is now `actions.execute`.
29+
- **Removed:** `actions.execute.executeByID` (use `actions.execute` with `actionId` or `actionKey`), `auth.*`, and `content.stream` (see [Real-time voice](https://docs.moderationapi.com/content-moderation/real-time-voice)).
30+
- **Organization keys** work only with `projects` and `channels`; project keys work with everything else. Use one client per key. See the README.
31+
32+
The license is unchanged: Apache-2.0.

‎.github/workflows/publish-gem.yml‎

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Maintained in moderation-api/sdk-generator (custom/ruby). Edits here are overwritten.
2+
# Every push to main whose package version has no release tag yet publishes
3+
# that version and creates the GitHub release (notes: .github/release-notes/vX.Y.Z.md
4+
# if present, otherwise generated from the merged pull requests).
25
name: Publish Gem
36
on:
4-
release:
5-
types: [published]
7+
push:
8+
branches: [main]
69
workflow_dispatch:
710

11+
concurrency: release
12+
813
permissions:
9-
contents: read
14+
contents: write
1015

1116
jobs:
1217
publish:
@@ -16,15 +21,32 @@ jobs:
1621
- uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
1722
with:
1823
ruby-version: "3.2"
19-
- name: Check the release tag matches the gem version
20-
if: github.event_name == 'release'
24+
- name: Read the version
25+
run: echo "VERSION=$(ruby -e 'puts Gem::Specification.load("moderation_api.gemspec").version')" >> "$GITHUB_ENV"
26+
- name: Check for an unreleased version
27+
id: version
2128
run: |
22-
version=$(ruby -e 'puts Gem::Specification.load("moderation_api.gemspec").version')
23-
if [ "${GITHUB_REF_NAME#v}" != "$version" ]; then
24-
echo "::error::Release tag $GITHUB_REF_NAME does not match gem version $version"
25-
exit 1
29+
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
30+
if git ls-remote --exit-code --tags origin "refs/tags/v${VERSION}" >/dev/null; then
31+
echo "v${VERSION} is already released."
32+
echo "release=false" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "release=true" >> "$GITHUB_OUTPUT"
2635
fi
27-
- run: gem build moderation_api.gemspec
28-
- run: gem push moderation_api-*.gem
36+
- if: steps.version.outputs.release == 'true'
37+
run: gem build moderation_api.gemspec
38+
- if: steps.version.outputs.release == 'true'
39+
run: gem push moderation_api-${VERSION}.gem
2940
env:
3041
GEM_HOST_API_KEY: ${{ secrets.MODERATION_API_GEM_HOST_API_KEY || secrets.GEM_HOST_API_KEY }}
42+
- name: Create the GitHub release
43+
if: steps.version.outputs.release == 'true'
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
run: |
47+
notes=".github/release-notes/v${VERSION}.md"
48+
if [ -f "$notes" ]; then
49+
gh release create "v${VERSION}" --target "$GITHUB_SHA" --title "v${VERSION}" --notes-file "$notes"
50+
else
51+
gh release create "v${VERSION}" --target "$GITHUB_SHA" --title "v${VERSION}" --generate-notes
52+
fi

0 commit comments

Comments
 (0)