Skip to content

Commit

Permalink
ref: Consistent fill and error handling (#57)
Browse files Browse the repository at this point in the history
* ref: consistent fill methods

* ref: api patches

* ref: consistent error handling

* fix: mark optional project rate limit attributes as computed

* feat: add sponsorship
  • Loading branch information
jianyuan authored Dec 21, 2024
1 parent cca4a0b commit f8f998e
Show file tree
Hide file tree
Showing 25 changed files with 335 additions and 351 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ jobs:
- "1.5.*"
- "1.6.*"
- "1.7.*"
- "1.8.*"
- "1.9.*"
- "1.10.*"
is-pr:
- ${{ github.event_name == 'pull_request' }}
# Only run the latest version of Terraform on pull requests
exclude:
- terraform: "1.4.*"
is-pr: true
- terraform: "1.5.*"
is-pr: true
- terraform: "1.6.*"
is-pr: true
- terraform: "1.7.*"
is-pr: true
- terraform: "1.8.*"
is-pr: true
- terraform: "1.9.*"
is-pr: true
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Unofficial Terraform provider for OpenAI.

If you find this provider useful, please consider supporting me through GitHub Sponsorship or Ko-Fi to help with its development.

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/L3L71DQEL)
[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/jianyuan)
[![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/L3L71DQEL)

## Requirements

Expand Down
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ page_title: "openai Provider"
subcategory: ""
description: |-
The OpenAI provider enables you to configure resources and data sources for your OpenAI organization. It utilizes the official Administration API https://platform.openai.com/docs/api-reference/administration to interact with the OpenAI platform.
If you find this provider useful, please consider supporting me through GitHub Sponsorship or Ko-Fi to help with its development.
Github-sponsors https://github.com/sponsors/jianyuan
Ko-Fi https://ko-fi.com/L3L71DQEL
---

# openai Provider

The OpenAI provider enables you to configure resources and data sources for your OpenAI organization. It utilizes the official [Administration API](https://platform.openai.com/docs/api-reference/administration) to interact with the OpenAI platform.

If you find this provider useful, please consider supporting me through GitHub Sponsorship or Ko-Fi to help with its development.

[![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge&logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/jianyuan)
[![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/L3L71DQEL)

## Example Usage

```terraform
Expand Down
58 changes: 49 additions & 9 deletions internal/apiclient/api-patches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,76 @@

#@overlay/match by=overlay.all
---
#@ def rename_property(m, old, new):
#@ m = dict(m)
#@ if old in m:
#@ m[new] = m.pop(old)
#@ end
#@ return m
#@ end

#@ def fix_property(p):
#@ p = dict(p)
#@ if "type" in p and p["type"] == "integer":
#@ p["format"] = "int64"
#@ end
#@ return p
#@ end

#@ def fix_properties(m):
#@ m = dict(m)
#@ return {k: fix_property(dict(v)) for k, v in m.items()}
#@ end

paths:
/organization/admin_api_keys:
post:
requestBody:
content:
application/json:
#@overlay/replace
schema:
type: object
required:
- name
- type
properties:
name:
type: string
#@overlay/match missing_ok=True
type:
type: string
/organization/invites:
post:
#@overlay/replace via=lambda left, right: {"201": left["200"]}
#@overlay/replace via=lambda left, right: rename_property(left, "200", "201")
responses:
/organization/projects:
post:
#@overlay/replace via=lambda left, right: {"201": left["200"]}
#@overlay/replace via=lambda left, right: rename_property(left, "200", "201")
responses:
/organization/projects/{project_id}/users:
post:
#@overlay/replace via=lambda left, right: {"201": left["200"]}
#@overlay/replace via=lambda left, right: rename_property(left, "200", "201")
responses:
/organization/projects/{project_id}/service_accounts:
post:
#@overlay/replace via=lambda left, right: {"201": left["200"]}
#@overlay/replace via=lambda left, right: rename_property(left, "200", "201")
responses:
components:
schemas:
Invite:
#@overlay/replace via=lambda left, right: fix_properties(dict(left))
properties:
Project:
#@overlay/replace via=lambda left, right: fix_properties(dict(left))
properties:
ProjectRateLimitUpdateRequest:
#@overlay/replace via=lambda left, right: fix_properties(dict(left))
properties:
ProjectRateLimit:
#@overlay/replace via=lambda left, right: fix_properties(dict(left))
properties:
ProjectServiceAccount:
#@overlay/replace via=lambda left, right: fix_properties(dict(left))
properties:
ProjectServiceAccountCreateResponse:
#@overlay/replace via=lambda left, right: fix_properties(dict(left))
properties:
User:
#@overlay/replace via=lambda left, right: fix_properties(dict(left))
properties:
33 changes: 33 additions & 0 deletions internal/apiclient/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,7 @@ paths:
properties:
name:
type: string
example: New Admin Key
type:
type: string
responses:
Expand Down Expand Up @@ -5103,6 +5104,12 @@ paths:
schema:
$ref: '#/components/schemas/ProjectServiceAccountCreateRequest'
responses:
"400":
description: Error response when project is archived.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
"201":
description: Project service account created successfully.
content:
Expand Down Expand Up @@ -5320,6 +5327,12 @@ paths:
schema:
$ref: '#/components/schemas/ProjectUserCreateRequest'
responses:
"400":
description: Error response for various conditions.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
"201":
description: User added to project successfully.
content:
Expand Down Expand Up @@ -16142,12 +16155,15 @@ components:
invited_at:
type: integer
description: The Unix timestamp (in seconds) of when the invite was sent.
format: int64
expires_at:
type: integer
description: The Unix timestamp (in seconds) of when the invite expires.
format: int64
accepted_at:
type: integer
description: The Unix timestamp (in seconds) of when the invite was accepted.
format: int64
projects:
type: array
description: The projects that were granted membership upon acceptance of the invite.
Expand Down Expand Up @@ -17570,10 +17586,12 @@ components:
created_at:
type: integer
description: The Unix timestamp (in seconds) of when the project was created.
format: int64
archived_at:
type: integer
nullable: true
description: The Unix timestamp (in seconds) of when the project was archived or `null`.
format: int64
status:
type: string
enum:
Expand Down Expand Up @@ -17746,21 +17764,27 @@ components:
max_requests_per_1_minute:
type: integer
description: The maximum requests per minute.
format: int64
max_tokens_per_1_minute:
type: integer
description: The maximum tokens per minute.
format: int64
max_images_per_1_minute:
type: integer
description: The maximum images per minute. Only present for relevant models.
format: int64
max_audio_megabytes_per_1_minute:
type: integer
description: The maximum audio megabytes per minute. Only present for relevant models.
format: int64
max_requests_per_1_day:
type: integer
description: The maximum requests per day. Only present for relevant models.
format: int64
batch_1_day_max_input_tokens:
type: integer
description: The maximum batch input tokens per day. Only present for relevant models.
format: int64
required:
- object
- id
Expand Down Expand Up @@ -17807,21 +17831,27 @@ components:
max_requests_per_1_minute:
type: integer
description: The maximum requests per minute.
format: int64
max_tokens_per_1_minute:
type: integer
description: The maximum tokens per minute.
format: int64
max_images_per_1_minute:
type: integer
description: The maximum images per minute. Only relevant for certain models.
format: int64
max_audio_megabytes_per_1_minute:
type: integer
description: The maximum audio megabytes per minute. Only relevant for certain models.
format: int64
max_requests_per_1_day:
type: integer
description: The maximum requests per day. Only relevant for certain models.
format: int64
batch_1_day_max_input_tokens:
type: integer
description: The maximum batch input tokens per day. Only relevant for certain models.
format: int64
ProjectServiceAccount:
type: object
description: Represents an individual service account in a project.
Expand All @@ -17846,6 +17876,7 @@ components:
created_at:
type: integer
description: The Unix timestamp (in seconds) of when the service account was created
format: int64
required:
- object
- id
Expand Down Expand Up @@ -17910,6 +17941,7 @@ components:
description: Service accounts can only have one role of type `member`
created_at:
type: integer
format: int64
api_key:
$ref: '#/components/schemas/ProjectServiceAccountApiKey'
required:
Expand Down Expand Up @@ -22313,6 +22345,7 @@ components:
added_at:
type: integer
description: The Unix timestamp (in seconds) of when the user was added.
format: int64
required:
- object
- id
Expand Down
Loading

0 comments on commit f8f998e

Please sign in to comment.