├── .gitattributes ├── .github └── workflows │ ├── release.yml │ └── speakeasy_sdk_generation.yml ├── .gitignore ├── .goreleaser.yml ├── .speakeasy └── gen.lock ├── CONTRIBUTING.md ├── LICENSE ├── LICENSE.md ├── README.md ├── RELEASES.md ├── USAGE.md ├── docs ├── index.md └── resources │ ├── chat_completion.md │ ├── completion.md │ ├── embedding.md │ └── image.md ├── examples ├── README.md ├── provider │ └── provider.tf └── resources │ ├── openai_chat_completion │ └── resource.tf │ ├── openai_completion │ └── resource.tf │ ├── openai_embedding │ └── resource.tf │ └── openai_image │ └── resource.tf ├── files.gen ├── gen.yaml ├── go.mod ├── go.sum ├── internal ├── planmodifiers │ ├── boolplanmodifier │ │ └── suppress_diff.go │ ├── float64planmodifier │ │ └── suppress_diff.go │ ├── int64planmodifier │ │ └── suppress_diff.go │ ├── listplanmodifier │ │ └── suppress_diff.go │ ├── mapplanmodifier │ │ └── suppress_diff.go │ ├── numberplanmodifier │ │ └── suppress_diff.go │ ├── objectplanmodifier │ │ └── suppress_diff.go │ ├── setplanmodifier │ │ └── suppress_diff.go │ ├── stringplanmodifier │ │ └── suppress_diff.go │ └── utils │ │ └── state_check.go ├── provider │ ├── chatcompletion_resource.go │ ├── chatcompletion_resource_sdk.go │ ├── completion_resource.go │ ├── completion_resource_sdk.go │ ├── embedding_resource.go │ ├── embedding_resource_sdk.go │ ├── image_resource.go │ ├── image_resource_sdk.go │ ├── provider.go │ ├── reflect │ │ ├── diags.go │ │ ├── doc.go │ │ ├── generic_attr_value.go │ │ ├── helpers.go │ │ ├── interfaces.go │ │ ├── into.go │ │ ├── map.go │ │ ├── number.go │ │ ├── options.go │ │ ├── outof.go │ │ ├── pointer.go │ │ ├── primitive.go │ │ ├── slice.go │ │ └── struct.go │ ├── types │ │ ├── chat_completion_functions.go │ │ ├── chat_completion_request_message.go │ │ ├── chat_completion_response_message.go │ │ ├── chat_completion_response_message_function_call.go │ │ ├── choices.go │ │ ├── create_chat_completion_request_function_call.go │ │ ├── create_completion_response_choices.go │ │ ├── create_embedding_response_usage.go │ │ ├── data.go │ │ ├── function_call.go │ │ ├── images_response_data.go │ │ ├── logprobs.go │ │ ├── prompt.go │ │ ├── stop.go │ │ ├── two.go │ │ └── usage.go │ └── utils.go ├── sdk │ ├── .gitattributes │ ├── .gitignore │ ├── CONTRIBUTING.md │ ├── internal │ │ ├── hooks │ │ │ └── hooks.go │ │ └── utils │ │ │ ├── contenttype.go │ │ │ ├── form.go │ │ │ ├── headers.go │ │ │ ├── json.go │ │ │ ├── pathparams.go │ │ │ ├── queryparams.go │ │ │ ├── requestbody.go │ │ │ ├── retries.go │ │ │ ├── security.go │ │ │ └── utils.go │ ├── models │ │ ├── errors │ │ │ └── sdkerror.go │ │ ├── operations │ │ │ ├── cancelfinetune.go │ │ │ ├── createchatcompletion.go │ │ │ ├── createcompletion.go │ │ │ ├── createedit.go │ │ │ ├── createembedding.go │ │ │ ├── createfile.go │ │ │ ├── createfinetune.go │ │ │ ├── createimage.go │ │ │ ├── createimageedit.go │ │ │ ├── createimagevariation.go │ │ │ ├── createmoderation.go │ │ │ ├── createtranscription.go │ │ │ ├── createtranslation.go │ │ │ ├── deletefile.go │ │ │ ├── deletemodel.go │ │ │ ├── downloadfile.go │ │ │ ├── listfiles.go │ │ │ ├── listfinetuneevents.go │ │ │ ├── listfinetunes.go │ │ │ ├── listmodels.go │ │ │ ├── options.go │ │ │ ├── retrievefile.go │ │ │ ├── retrievefinetune.go │ │ │ └── retrievemodel.go │ │ └── shared │ │ │ ├── chatcompletionfunctions.go │ │ │ ├── chatcompletionrequestmessage.go │ │ │ ├── chatcompletionresponsemessage.go │ │ │ ├── createchatcompletionrequest.go │ │ │ ├── createchatcompletionresponse.go │ │ │ ├── createcompletionrequest.go │ │ │ ├── createcompletionresponse.go │ │ │ ├── createeditrequest.go │ │ │ ├── createeditresponse.go │ │ │ ├── createembeddingrequest.go │ │ │ ├── createembeddingresponse.go │ │ │ ├── createfilerequest.go │ │ │ ├── createfinetunerequest.go │ │ │ ├── createimageeditrequest.go │ │ │ ├── createimagerequest.go │ │ │ ├── createimagevariationrequest.go │ │ │ ├── createmoderationrequest.go │ │ │ ├── createmoderationresponse.go │ │ │ ├── createtranscriptionrequest.go │ │ │ ├── createtranscriptionresponse.go │ │ │ ├── createtranslationrequest.go │ │ │ ├── createtranslationresponse.go │ │ │ ├── deletefileresponse.go │ │ │ ├── deletemodelresponse.go │ │ │ ├── finetune.go │ │ │ ├── finetuneevent.go │ │ │ ├── imagesresponse.go │ │ │ ├── listfilesresponse.go │ │ │ ├── listfinetuneeventsresponse.go │ │ │ ├── listfinetunesresponse.go │ │ │ ├── listmodelsresponse.go │ │ │ ├── model.go │ │ │ ├── openaifile.go │ │ │ └── security.go │ ├── oai.go │ ├── openai.go │ ├── retry │ │ └── config.go │ └── types │ │ ├── bigint.go │ │ ├── date.go │ │ ├── datetime.go │ │ ├── decimal.go │ │ └── pointers.go └── validators │ ├── DateValidator.go │ ├── ExactlyOneChild.go │ ├── JSONParseValidator.go │ ├── RFC3339Validator.go │ ├── boolvalidators │ └── not_null.go │ ├── float64validators │ └── not_null.go │ ├── int64validators │ └── not_null.go │ ├── listvalidators │ └── not_null.go │ ├── mapvalidators │ └── not_null.go │ ├── numbervalidators │ └── not_null.go │ ├── objectvalidators │ └── not_null.go │ ├── setvalidators │ └── not_null.go │ └── stringvalidators │ └── not_null.go ├── main.go ├── openai.yml ├── renovate.json5 ├── terraform-registry-manifest.json └── tools └── tools.go /.gitattributes: -------------------------------------------------------------------------------- 1 | # This allows generated code to be indexed correctly 2 | *.go linguist-generated=false -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # Terraform Provider release workflow. 2 | name: Release 3 | 4 | # This GitHub action creates a release when a tag that matches the pattern 5 | # "v*" (e.g. v0.1.0) is created. 6 | on: 7 | push: 8 | tags: 9 | - 'v*' 10 | 11 | # Releases need permissions to read and write the repository contents. 12 | # GitHub considers creating releases and uploading assets as writing contents. 13 | permissions: 14 | contents: write 15 | 16 | jobs: 17 | goreleaser: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 21 | with: 22 | # Allow goreleaser to access older tag information. 23 | fetch-depth: 0 24 | - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 25 | with: 26 | go-version-file: 'go.mod' 27 | cache: true 28 | - name: Import GPG key 29 | uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0 30 | id: import_gpg 31 | with: 32 | gpg_private_key: ${{ secrets.TERRAFORM_GPG_PRIVATE_KEY }} 33 | passphrase: ${{ secrets.TERRAFORM_GPG_PASSPHRASE }} 34 | - name: Run GoReleaser 35 | uses: goreleaser/goreleaser-action@3fa32b8bb5620a2c1afe798654bbad59f9da4906 # v4.4.0 36 | with: 37 | args: release --clean 38 | env: 39 | # GitHub sets the GITHUB_TOKEN secret automatically. 40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 41 | GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} -------------------------------------------------------------------------------- /.github/workflows/speakeasy_sdk_generation.yml: -------------------------------------------------------------------------------- 1 | name: Generate 2 | permissions: 3 | checks: write 4 | contents: write 5 | statuses: write 6 | "on": 7 | workflow_dispatch: 8 | inputs: 9 | force: 10 | description: Force generation of SDKs 11 | type: boolean 12 | default: false 13 | schedule: 14 | - cron: 0 0 * * * 15 | jobs: 16 | generate: 17 | uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-generation.yaml@v14 18 | with: 19 | force: ${{ github.event.inputs.force }} 20 | languages: | 21 | - terraform 22 | mode: direct 23 | openapi_docs: | 24 | - ./openai.yml 25 | speakeasy_version: latest 26 | secrets: 27 | github_access_token: ${{ secrets.GITHUB_TOKEN }} 28 | speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }} 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .terraform 2 | .terraform* 3 | *.tfstate* 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # Visit https://goreleaser.com for documentation on how to customize this 2 | # behavior. 3 | before: 4 | hooks: 5 | # this is just an example and not a requirement for provider building/publishing 6 | - go mod tidy 7 | builds: 8 | - env: 9 | # goreleaser does not work with CGO, it could also complicate 10 | # usage by users in CI/CD systems like Terraform Cloud where 11 | # they are unable to install libraries. 12 | - CGO_ENABLED=0 13 | mod_timestamp: '{{ .CommitTimestamp }}' 14 | flags: 15 | - -trimpath 16 | ldflags: 17 | - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' 18 | goos: 19 | - freebsd 20 | - windows 21 | - linux 22 | - darwin 23 | goarch: 24 | - amd64 25 | - '386' 26 | - arm 27 | - arm64 28 | ignore: 29 | - goos: darwin 30 | goarch: '386' 31 | binary: '{{ .ProjectName }}_v{{ .Version }}' 32 | archives: 33 | - format: zip 34 | name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' 35 | checksum: 36 | extra_files: 37 | - glob: 'terraform-registry-manifest.json' 38 | name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' 39 | name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' 40 | algorithm: sha256 41 | signs: 42 | - artifacts: checksum 43 | args: 44 | # if you are using this in a GitHub action or some other automated pipeline, you 45 | # need to pass the batch flag to indicate its not interactive. 46 | - "--batch" 47 | - "--local-user" 48 | - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key 49 | - "--output" 50 | - "${signature}" 51 | - "--detach-sign" 52 | - "${artifact}" 53 | release: 54 | extra_files: 55 | - glob: 'terraform-registry-manifest.json' 56 | name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' 57 | # If you want to manually examine the release before its live, uncomment this line: 58 | # draft: true 59 | changelog: 60 | skip: true -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to This Repository 2 | 3 | Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. 4 | 5 | ## How to Report Issues 6 | 7 | If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: 8 | 9 | - A clear and descriptive title 10 | - Steps to reproduce the issue 11 | - Expected and actual behavior 12 | - Any relevant logs, screenshots, or error messages 13 | - Information about your environment (e.g., operating system, software versions) 14 | - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed 15 | 16 | ## Issue Triage and Upstream Fixes 17 | 18 | We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. 19 | 20 | ## Contact 21 | 22 | If you have any questions or need further assistance, please feel free to reach out by opening an issue. 23 | 24 | Thank you for your understanding and cooperation! 25 | 26 | The Maintainers 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Anton Babenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 antonbabenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |

Programmatically control resources in the OpenAI API.

6 | 7 | 8 |
9 | 10 | ## Authentication 11 | 12 | Developers will need to create an API Key within their OpenAI [organisation](https://platform.openai.com/) to make API requests. 13 | 14 | 15 | ## SDK Installation 16 | 17 | To install this provider, copy and paste this code into your Terraform configuration. Then, run `terraform init`. 18 | 19 | ```hcl 20 | terraform { 21 | required_providers { 22 | openai = { 23 | source = "antonbabenko/openai" 24 | version = "2.3.2" 25 | } 26 | } 27 | } 28 | 29 | provider "openai" { 30 | # Configuration options 31 | } 32 | ``` 33 | 34 | 35 | 36 | ## SDK Example Usage 37 | 38 | ### Testing the provider locally 39 | 40 | Should you want to validate a change locally, the `--debug` flag allows you to execute the provider against a terraform instance locally. 41 | 42 | This also allows for debuggers (e.g. delve) to be attached to the provider. 43 | 44 | ### Example 45 | 46 | ```sh 47 | go run main.go --debug 48 | # Copy the TF_REATTACH_PROVIDERS env var 49 | # In a new terminal 50 | cd examples/your-example 51 | TF_REATTACH_PROVIDERS=... terraform init 52 | TF_REATTACH_PROVIDERS=... terraform apply 53 | ``` 54 | 55 | 56 | 57 | ## Available Resources and Operations 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Terraform allows you to use local provider builds by setting a `dev_overrides` block in a configuration file called `.terraformrc`. This block overrides all other configured installation methods. 69 | 70 | Terraform searches for the `.terraformrc` file in your home directory and applies any configuration settings you set. 71 | 72 | ``` 73 | provider_installation { 74 | 75 | dev_overrides { 76 | "registry.terraform.io/openai/scaffolding" = "" 77 | } 78 | 79 | # For all other providers, install them directly from their origin provider 80 | # registries as normal. If you omit this, Terraform will _only_ use 81 | # the dev_overrides block, and so no other providers will be available. 82 | direct {} 83 | } 84 | ``` 85 | 86 | Your `` may vary depending on how your Go environment variables are configured. Execute `go env GOBIN` to set it, then set the `` to the value returned. If nothing is returned, set it to the default location, `$HOME/go/bin`. 87 | 88 | ### Contributions 89 | 90 | While we value open-source contributions to this SDK, this library is generated programmatically. 91 | Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release! 92 | 93 | ### Provider Created by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks) 94 | -------------------------------------------------------------------------------- /USAGE.md: -------------------------------------------------------------------------------- 1 | 2 | ```sh 3 | go run main.go --debug 4 | # Copy the TF_REATTACH_PROVIDERS env var 5 | # In a new terminal 6 | cd examples/your-example 7 | TF_REATTACH_PROVIDERS=... terraform init 8 | TF_REATTACH_PROVIDERS=... terraform apply 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "openai Provider" 4 | subcategory: "" 5 | description: |- 6 | OpenAI API: APIs for sampling from and fine-tuning language models. Hello World! 7 | --- 8 | 9 | # openai Provider 10 | 11 | OpenAI API: APIs for sampling from and fine-tuning language models. Hello World! 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | terraform { 17 | required_providers { 18 | openai = { 19 | source = "antonbabenko/openai" 20 | version = "2.3.2" 21 | } 22 | } 23 | } 24 | 25 | provider "openai" { 26 | # Configuration options 27 | } 28 | ``` 29 | 30 | 31 | ## Schema 32 | 33 | ### Optional 34 | 35 | - `api_key` (String, Sensitive) 36 | - `server_url` (String) Server URL (defaults to https://api.openai.com/v1) 37 | -------------------------------------------------------------------------------- /docs/resources/embedding.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "openai_embedding Resource - terraform-provider-openai" 4 | subcategory: "" 5 | description: |- 6 | Embedding Resource 7 | --- 8 | 9 | # openai_embedding (Resource) 10 | 11 | Embedding Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | resource "openai_embedding" "my_embedding" { 17 | input = { 18 | str = "The quick brown fox jumped over the lazy dog" 19 | } 20 | model = "text-embedding-ada-002" 21 | user = "user-1234" 22 | } 23 | ``` 24 | 25 | 26 | ## Schema 27 | 28 | ### Required 29 | 30 | - `input` (Attributes) Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed the max input tokens for the model (8191 tokens for `text-embedding-ada-002`). [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens. 31 | 32 | Requires replacement if changed. (see [below for nested schema](#nestedatt--input)) 33 | - `model` (String) ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. 34 | 35 | Requires replacement if changed. ; must be one of ["text-embedding-ada-002"] 36 | 37 | ### Optional 38 | 39 | - `user` (String) A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 40 | 41 | Requires replacement if changed. 42 | 43 | ### Read-Only 44 | 45 | - `data` (Attributes List) (see [below for nested schema](#nestedatt--data)) 46 | - `object` (String) 47 | - `usage` (Attributes) (see [below for nested schema](#nestedatt--usage)) 48 | 49 | 50 | ### Nested Schema for `input` 51 | 52 | Optional: 53 | 54 | - `array_of_array_of_integer` (List of List of Number) Requires replacement if changed. 55 | - `array_of_integer` (List of Number) Requires replacement if changed. 56 | - `array_of_str` (List of String) Requires replacement if changed. 57 | - `str` (String) Requires replacement if changed. 58 | 59 | 60 | 61 | ### Nested Schema for `data` 62 | 63 | Read-Only: 64 | 65 | - `embedding` (List of Number) 66 | - `index` (Number) 67 | - `object` (String) 68 | 69 | 70 | 71 | ### Nested Schema for `usage` 72 | 73 | Read-Only: 74 | 75 | - `prompt_tokens` (Number) 76 | - `total_tokens` (Number) 77 | -------------------------------------------------------------------------------- /docs/resources/image.md: -------------------------------------------------------------------------------- 1 | --- 2 | # generated by https://github.com/hashicorp/terraform-plugin-docs 3 | page_title: "openai_image Resource - terraform-provider-openai" 4 | subcategory: "" 5 | description: |- 6 | Image Resource 7 | --- 8 | 9 | # openai_image (Resource) 10 | 11 | Image Resource 12 | 13 | ## Example Usage 14 | 15 | ```terraform 16 | resource "openai_image" "my_image" { 17 | n = 1 18 | prompt = "A cute baby sea otter" 19 | response_format = "url" 20 | size = "1024x1024" 21 | user = "user-1234" 22 | } 23 | ``` 24 | 25 | 26 | ## Schema 27 | 28 | ### Required 29 | 30 | - `prompt` (String) A text description of the desired image(s). The maximum length is 1000 characters. Requires replacement if changed. 31 | 32 | ### Optional 33 | 34 | - `n` (Number) The number of images to generate. Must be between 1 and 10. Requires replacement if changed. ; Default: 1 35 | - `response_format` (String) The format in which the generated images are returned. Must be one of `url` or `b64_json`. Requires replacement if changed. ; must be one of ["url", "b64_json"]; Default: "url" 36 | - `size` (String) The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. Requires replacement if changed. ; must be one of ["256x256", "512x512", "1024x1024"]; Default: "1024x1024" 37 | - `user` (String) A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 38 | 39 | Requires replacement if changed. 40 | 41 | ### Read-Only 42 | 43 | - `created` (Number) 44 | - `data` (Attributes List) (see [below for nested schema](#nestedatt--data)) 45 | 46 | 47 | ### Nested Schema for `data` 48 | 49 | Read-Only: 50 | 51 | - `b64_json` (String) 52 | - `url` (String) 53 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # TODO -------------------------------------------------------------------------------- /examples/provider/provider.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | openai = { 4 | source = "antonbabenko/openai" 5 | version = "2.3.2" 6 | } 7 | } 8 | } 9 | 10 | provider "openai" { 11 | # Configuration options 12 | } -------------------------------------------------------------------------------- /examples/resources/openai_chat_completion/resource.tf: -------------------------------------------------------------------------------- 1 | resource "openai_chat_completion" "my_chatcompletion" { 2 | frequency_penalty = 5 3 | function_call = { 4 | one = "none" 5 | } 6 | functions = [ 7 | { 8 | description = "...my_description..." 9 | name = "Carlos Halvorson" 10 | parameters = { 11 | "Granite" = "{ \"see\": \"documentation\" }" 12 | "DNS" = "{ \"see\": \"documentation\" }" 13 | } 14 | }, 15 | ] 16 | logit_bias = { 17 | "copying" = 2 18 | "transmitting" = 9 19 | } 20 | max_tokens = 9 21 | messages = [ 22 | { 23 | content = "...my_content..." 24 | function_call = { 25 | arguments = "...my_arguments..." 26 | name = "Mae VonRueden" 27 | } 28 | name = "Rick Gottlieb" 29 | role = "user" 30 | }, 31 | ] 32 | model = "gpt-3.5-turbo" 33 | n = 1 34 | presence_penalty = 48.05 35 | stop = { 36 | str = "..." 37 | } 38 | stream = false 39 | temperature = 1 40 | top_p = 1 41 | user = "user-1234" 42 | } -------------------------------------------------------------------------------- /examples/resources/openai_completion/resource.tf: -------------------------------------------------------------------------------- 1 | resource "openai_completion" "my_completion" { 2 | best_of = 4 3 | echo = false 4 | frequency_penalty = 26.31 5 | logit_bias = { 6 | "invoice" = 1 7 | "Future" = 7 8 | } 9 | logprobs = 3 10 | max_tokens = 16 11 | model = "text-davinci-003" 12 | n = 1 13 | presence_penalty = 69.43 14 | prompt = { 15 | str = "This is a test." 16 | } 17 | stop = { 18 | str = "\n" 19 | } 20 | stream = false 21 | suffix = "test." 22 | temperature = 1 23 | top_p = 1 24 | user = "user-1234" 25 | } -------------------------------------------------------------------------------- /examples/resources/openai_embedding/resource.tf: -------------------------------------------------------------------------------- 1 | resource "openai_embedding" "my_embedding" { 2 | input = { 3 | str = "The quick brown fox jumped over the lazy dog" 4 | } 5 | model = "text-embedding-ada-002" 6 | user = "user-1234" 7 | } -------------------------------------------------------------------------------- /examples/resources/openai_image/resource.tf: -------------------------------------------------------------------------------- 1 | resource "openai_image" "my_image" { 2 | n = 1 3 | prompt = "A cute baby sea otter" 4 | response_format = "url" 5 | size = "1024x1024" 6 | user = "user-1234" 7 | } -------------------------------------------------------------------------------- /gen.yaml: -------------------------------------------------------------------------------- 1 | configVersion: 2.0.0 2 | generation: 3 | sdkClassName: oai 4 | usageSnippets: 5 | optionalPropertyRendering: withExample 6 | fixes: 7 | nameResolutionDec2023: false 8 | parameterOrderingFeb2024: false 9 | requestResponseComponentNamesFeb2024: false 10 | auth: 11 | oAuth2ClientCredentialsEnabled: false 12 | terraform: 13 | version: 2.3.2 14 | additionalDataSources: [] 15 | additionalDependencies: {} 16 | additionalResources: [] 17 | allowUnknownFieldsInWeakUnions: false 18 | author: antonbabenko 19 | environmentVariables: [] 20 | imports: 21 | option: openapi 22 | paths: 23 | callbacks: callbacks 24 | errors: sdkerrors 25 | operations: operations 26 | shared: shared 27 | webhooks: webhooks 28 | packageName: openai 29 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/antonbabenko/terraform-provider-openai/v2 2 | 3 | go 1.21 4 | 5 | require ( 6 | github.com/cenkalti/backoff/v4 v4.2.0 7 | github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 8 | github.com/hashicorp/terraform-plugin-docs v0.19.4 9 | github.com/hashicorp/terraform-plugin-framework v1.10.0 10 | github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 11 | github.com/hashicorp/terraform-plugin-go v0.23.0 12 | ) 13 | 14 | require ( 15 | github.com/BurntSushi/toml v1.2.1 // indirect 16 | github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect 17 | github.com/Masterminds/goutils v1.1.1 // indirect 18 | github.com/Masterminds/semver/v3 v3.2.0 // indirect 19 | github.com/Masterminds/sprig/v3 v3.2.3 // indirect 20 | github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect 21 | github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect 22 | github.com/armon/go-radix v1.0.0 // indirect 23 | github.com/bgentry/speakeasy v0.1.0 // indirect 24 | github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect 25 | github.com/cloudflare/circl v1.3.7 // indirect 26 | github.com/fatih/color v1.16.0 // indirect 27 | github.com/golang/protobuf v1.5.4 // indirect 28 | github.com/google/uuid v1.6.0 // indirect 29 | github.com/hashicorp/cli v1.1.6 // indirect 30 | github.com/hashicorp/errwrap v1.1.0 // indirect 31 | github.com/hashicorp/go-checkpoint v0.5.0 // indirect 32 | github.com/hashicorp/go-cleanhttp v0.5.2 // indirect 33 | github.com/hashicorp/go-hclog v1.5.0 // indirect 34 | github.com/hashicorp/go-multierror v1.1.1 // indirect 35 | github.com/hashicorp/go-plugin v1.6.0 // indirect 36 | github.com/hashicorp/go-uuid v1.0.3 // indirect 37 | github.com/hashicorp/go-version v1.7.0 // indirect 38 | github.com/hashicorp/hc-install v0.7.0 // indirect 39 | github.com/hashicorp/terraform-exec v0.21.0 // indirect 40 | github.com/hashicorp/terraform-json v0.22.1 // indirect 41 | github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect 42 | github.com/hashicorp/terraform-registry-address v0.2.3 // indirect 43 | github.com/hashicorp/terraform-svchost v0.1.1 // indirect 44 | github.com/hashicorp/yamux v0.1.1 // indirect 45 | github.com/huandu/xstrings v1.3.3 // indirect 46 | github.com/imdario/mergo v0.3.15 // indirect 47 | github.com/mattn/go-colorable v0.1.13 // indirect 48 | github.com/mattn/go-isatty v0.0.20 // indirect 49 | github.com/mattn/go-runewidth v0.0.9 // indirect 50 | github.com/mitchellh/copystructure v1.2.0 // indirect 51 | github.com/mitchellh/go-testing-interface v1.14.1 // indirect 52 | github.com/mitchellh/reflectwalk v1.0.2 // indirect 53 | github.com/oklog/run v1.0.0 // indirect 54 | github.com/posener/complete v1.2.3 // indirect 55 | github.com/shopspring/decimal v1.3.1 // indirect 56 | github.com/spf13/cast v1.5.0 // indirect 57 | github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect 58 | github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect 59 | github.com/yuin/goldmark v1.7.1 // indirect 60 | github.com/yuin/goldmark-meta v1.1.0 // indirect 61 | github.com/zclconf/go-cty v1.14.4 // indirect 62 | go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect 63 | golang.org/x/crypto v0.21.0 // indirect 64 | golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect 65 | golang.org/x/mod v0.17.0 // indirect 66 | golang.org/x/net v0.23.0 // indirect 67 | golang.org/x/sys v0.18.0 // indirect 68 | golang.org/x/text v0.15.0 // indirect 69 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect 70 | google.golang.org/grpc v1.63.2 // indirect 71 | google.golang.org/protobuf v1.34.0 // indirect 72 | gopkg.in/yaml.v2 v2.3.0 // indirect 73 | gopkg.in/yaml.v3 v3.0.1 // indirect 74 | ) 75 | -------------------------------------------------------------------------------- /internal/planmodifiers/boolplanmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package boolplanmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.Bool { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyBool implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyBool(ctx context.Context, req planmodifier.BoolRequest, resp *planmodifier.BoolResponse) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/float64planmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package float64planmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.Float64 { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyFloat64 implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyFloat64(ctx context.Context, req planmodifier.Float64Request, resp *planmodifier.Float64Response) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/int64planmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package int64planmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.Int64 { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyInt64 implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyInt64(ctx context.Context, req planmodifier.Int64Request, resp *planmodifier.Int64Response) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/listplanmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package listplanmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.List { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyList implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyList(ctx context.Context, req planmodifier.ListRequest, resp *planmodifier.ListResponse) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/mapplanmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package mapplanmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.Map { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyMap implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyMap(ctx context.Context, req planmodifier.MapRequest, resp *planmodifier.MapResponse) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/numberplanmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package numberplanmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.Number { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyNumber implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyNumber(ctx context.Context, req planmodifier.NumberRequest, resp *planmodifier.NumberResponse) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/objectplanmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package objectplanmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.Object { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyObject implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyObject(ctx context.Context, req planmodifier.ObjectRequest, resp *planmodifier.ObjectResponse) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/setplanmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package setplanmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.Set { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifySet implements the plan modification logic. 40 | func (m suppressDiff) PlanModifySet(ctx context.Context, req planmodifier.SetRequest, resp *planmodifier.SetResponse) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/stringplanmodifier/suppress_diff.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package stringplanmodifier 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/planmodifiers/utils" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" 10 | ) 11 | 12 | const ( 13 | // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation 14 | ExplicitSuppress = iota 15 | ) 16 | 17 | // SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown 18 | func SuppressDiff(strategy int) planmodifier.String { 19 | return suppressDiff{ 20 | strategy: strategy, 21 | } 22 | } 23 | 24 | // suppressDiff implements the plan modifier. 25 | type suppressDiff struct { 26 | strategy int 27 | } 28 | 29 | // Description returns a human-readable description of the plan modifier. 30 | func (m suppressDiff) Description(_ context.Context) string { 31 | return "Once set, the value of this attribute in state will not change." 32 | } 33 | 34 | // MarkdownDescription returns a markdown description of the plan modifier. 35 | func (m suppressDiff) MarkdownDescription(_ context.Context) string { 36 | return "Once set, the value of this attribute in state will not change." 37 | } 38 | 39 | // PlanModifyString implements the plan modification logic. 40 | func (m suppressDiff) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse) { 41 | // Do nothing if there is a known planned value. 42 | if !req.PlanValue.IsUnknown() { 43 | return 44 | } 45 | 46 | // Do nothing if there is an unknown configuration value 47 | if req.ConfigValue.IsUnknown() { 48 | return 49 | } 50 | 51 | if utils.IsAllStateUnknown(ctx, req.State) { 52 | return 53 | } 54 | 55 | resp.PlanValue = req.StateValue 56 | } 57 | -------------------------------------------------------------------------------- /internal/planmodifiers/utils/state_check.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package utils 4 | 5 | import ( 6 | "context" 7 | "github.com/hashicorp/terraform-plugin-framework/attr" 8 | "github.com/hashicorp/terraform-plugin-framework/path" 9 | "github.com/hashicorp/terraform-plugin-framework/tfsdk" 10 | ) 11 | 12 | func IsAllStateUnknown(ctx context.Context, state tfsdk.State) bool { 13 | attrs := state.Schema.GetAttributes() 14 | anyFound := false 15 | for k, _ := range attrs { 16 | attrValue := new(attr.Value) 17 | state.GetAttribute(ctx, path.Root(k), attrValue) 18 | if attrValue != nil && !(*attrValue).IsUnknown() && !(*attrValue).IsNull() { 19 | anyFound = true 20 | break 21 | } 22 | } 23 | 24 | return !anyFound 25 | } 26 | -------------------------------------------------------------------------------- /internal/provider/embedding_resource_sdk.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package provider 4 | 5 | import ( 6 | tfTypes "github.com/antonbabenko/terraform-provider-openai/v2/internal/provider/types" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 8 | "github.com/hashicorp/terraform-plugin-framework/types" 9 | "math/big" 10 | ) 11 | 12 | func (r *EmbeddingResourceModel) ToSharedCreateEmbeddingRequest() *shared.CreateEmbeddingRequest { 13 | var input shared.Input 14 | str := new(string) 15 | if !r.Input.Str.IsUnknown() && !r.Input.Str.IsNull() { 16 | *str = r.Input.Str.ValueString() 17 | } else { 18 | str = nil 19 | } 20 | if str != nil { 21 | input = shared.Input{ 22 | Str: str, 23 | } 24 | } 25 | var arrayOfStr []string = []string{} 26 | for _, arrayOfStrItem := range r.Input.ArrayOfStr { 27 | arrayOfStr = append(arrayOfStr, arrayOfStrItem.ValueString()) 28 | } 29 | if arrayOfStr != nil { 30 | input = shared.Input{ 31 | ArrayOfStr: arrayOfStr, 32 | } 33 | } 34 | var arrayOfInteger []int64 = []int64{} 35 | for _, arrayOfIntegerItem := range r.Input.ArrayOfInteger { 36 | arrayOfInteger = append(arrayOfInteger, arrayOfIntegerItem.ValueInt64()) 37 | } 38 | if arrayOfInteger != nil { 39 | input = shared.Input{ 40 | ArrayOfInteger: arrayOfInteger, 41 | } 42 | } 43 | var arrayOfArrayOfInteger [][]int64 = [][]int64{} 44 | for _, arrayOfArrayOfIntegerItem := range r.Input.ArrayOfArrayOfInteger { 45 | var arrayOfArrayOfIntegerTmp []int64 = []int64{} 46 | for _, item := range arrayOfArrayOfIntegerItem { 47 | arrayOfArrayOfIntegerTmp = append(arrayOfArrayOfIntegerTmp, item.ValueInt64()) 48 | } 49 | arrayOfArrayOfInteger = append(arrayOfArrayOfInteger, arrayOfArrayOfIntegerTmp) 50 | } 51 | if arrayOfArrayOfInteger != nil { 52 | input = shared.Input{ 53 | ArrayOfArrayOfInteger: arrayOfArrayOfInteger, 54 | } 55 | } 56 | model := shared.CreateEmbeddingRequestModel(r.Model.ValueString()) 57 | user := new(string) 58 | if !r.User.IsUnknown() && !r.User.IsNull() { 59 | *user = r.User.ValueString() 60 | } else { 61 | user = nil 62 | } 63 | out := shared.CreateEmbeddingRequest{ 64 | Input: input, 65 | Model: model, 66 | User: user, 67 | } 68 | return &out 69 | } 70 | 71 | func (r *EmbeddingResourceModel) RefreshFromSharedCreateEmbeddingResponse(resp *shared.CreateEmbeddingResponse) { 72 | if resp != nil { 73 | r.Data = []tfTypes.Data{} 74 | if len(r.Data) > len(resp.Data) { 75 | r.Data = r.Data[:len(resp.Data)] 76 | } 77 | for dataCount, dataItem := range resp.Data { 78 | var data1 tfTypes.Data 79 | data1.Embedding = []types.Number{} 80 | for _, v := range dataItem.Embedding { 81 | data1.Embedding = append(data1.Embedding, types.NumberValue(big.NewFloat(float64(v)))) 82 | } 83 | data1.Index = types.Int64Value(dataItem.Index) 84 | data1.Object = types.StringValue(dataItem.Object) 85 | if dataCount+1 > len(r.Data) { 86 | r.Data = append(r.Data, data1) 87 | } else { 88 | r.Data[dataCount].Embedding = data1.Embedding 89 | r.Data[dataCount].Index = data1.Index 90 | r.Data[dataCount].Object = data1.Object 91 | } 92 | } 93 | r.Object = types.StringValue(resp.Object) 94 | r.Usage.PromptTokens = types.Int64Value(resp.Usage.PromptTokens) 95 | r.Usage.TotalTokens = types.Int64Value(resp.Usage.TotalTokens) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /internal/provider/image_resource_sdk.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package provider 4 | 5 | import ( 6 | tfTypes "github.com/antonbabenko/terraform-provider-openai/v2/internal/provider/types" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 8 | "github.com/hashicorp/terraform-plugin-framework/types" 9 | ) 10 | 11 | func (r *ImageResourceModel) ToSharedCreateImageRequest() *shared.CreateImageRequest { 12 | n := new(int64) 13 | if !r.N.IsUnknown() && !r.N.IsNull() { 14 | *n = r.N.ValueInt64() 15 | } else { 16 | n = nil 17 | } 18 | var prompt string 19 | prompt = r.Prompt.ValueString() 20 | 21 | responseFormat := new(shared.CreateImageRequestResponseFormat) 22 | if !r.ResponseFormat.IsUnknown() && !r.ResponseFormat.IsNull() { 23 | *responseFormat = shared.CreateImageRequestResponseFormat(r.ResponseFormat.ValueString()) 24 | } else { 25 | responseFormat = nil 26 | } 27 | size := new(shared.CreateImageRequestSize) 28 | if !r.Size.IsUnknown() && !r.Size.IsNull() { 29 | *size = shared.CreateImageRequestSize(r.Size.ValueString()) 30 | } else { 31 | size = nil 32 | } 33 | user := new(string) 34 | if !r.User.IsUnknown() && !r.User.IsNull() { 35 | *user = r.User.ValueString() 36 | } else { 37 | user = nil 38 | } 39 | out := shared.CreateImageRequest{ 40 | N: n, 41 | Prompt: prompt, 42 | ResponseFormat: responseFormat, 43 | Size: size, 44 | User: user, 45 | } 46 | return &out 47 | } 48 | 49 | func (r *ImageResourceModel) RefreshFromSharedImagesResponse(resp *shared.ImagesResponse) { 50 | if resp != nil { 51 | r.Created = types.Int64Value(resp.Created) 52 | r.Data = []tfTypes.ImagesResponseData{} 53 | if len(r.Data) > len(resp.Data) { 54 | r.Data = r.Data[:len(resp.Data)] 55 | } 56 | for dataCount, dataItem := range resp.Data { 57 | var data1 tfTypes.ImagesResponseData 58 | data1.B64JSON = types.StringPointerValue(dataItem.B64JSON) 59 | data1.URL = types.StringPointerValue(dataItem.URL) 60 | if dataCount+1 > len(r.Data) { 61 | r.Data = append(r.Data, data1) 62 | } else { 63 | r.Data[dataCount].B64JSON = data1.B64JSON 64 | r.Data[dataCount].URL = data1.URL 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /internal/provider/provider.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package provider 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk" 8 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 9 | "github.com/hashicorp/terraform-plugin-framework/datasource" 10 | "github.com/hashicorp/terraform-plugin-framework/provider" 11 | "github.com/hashicorp/terraform-plugin-framework/provider/schema" 12 | "github.com/hashicorp/terraform-plugin-framework/resource" 13 | "github.com/hashicorp/terraform-plugin-framework/types" 14 | "net/http" 15 | ) 16 | 17 | var _ provider.Provider = &OpenaiProvider{} 18 | 19 | type OpenaiProvider struct { 20 | // version is set to the provider version on release, "dev" when the 21 | // provider is built and ran locally, and "test" when running acceptance 22 | // testing. 23 | version string 24 | } 25 | 26 | // OpenaiProviderModel describes the provider data model. 27 | type OpenaiProviderModel struct { 28 | ServerURL types.String `tfsdk:"server_url"` 29 | APIKey types.String `tfsdk:"api_key"` 30 | } 31 | 32 | func (p *OpenaiProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { 33 | resp.TypeName = "openai" 34 | resp.Version = p.version 35 | } 36 | 37 | func (p *OpenaiProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { 38 | resp.Schema = schema.Schema{ 39 | MarkdownDescription: `OpenAI API: APIs for sampling from and fine-tuning language models. Hello World!` + "\n" + 40 | ``, 41 | Attributes: map[string]schema.Attribute{ 42 | "server_url": schema.StringAttribute{ 43 | MarkdownDescription: "Server URL (defaults to https://api.openai.com/v1)", 44 | Optional: true, 45 | Required: false, 46 | }, 47 | "api_key": schema.StringAttribute{ 48 | Sensitive: true, 49 | Optional: true, 50 | }, 51 | }, 52 | } 53 | } 54 | 55 | func (p *OpenaiProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { 56 | var data OpenaiProviderModel 57 | 58 | resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) 59 | 60 | if resp.Diagnostics.HasError() { 61 | return 62 | } 63 | 64 | ServerURL := data.ServerURL.ValueString() 65 | 66 | if ServerURL == "" { 67 | ServerURL = "https://api.openai.com/v1" 68 | } 69 | 70 | apiKey := new(string) 71 | if !data.APIKey.IsUnknown() && !data.APIKey.IsNull() { 72 | *apiKey = data.APIKey.ValueString() 73 | } else { 74 | apiKey = nil 75 | } 76 | security := shared.Security{ 77 | APIKey: apiKey, 78 | } 79 | 80 | opts := []sdk.SDKOption{ 81 | sdk.WithServerURL(ServerURL), 82 | sdk.WithSecurity(security), 83 | sdk.WithClient(http.DefaultClient), 84 | } 85 | client := sdk.New(opts...) 86 | 87 | resp.DataSourceData = client 88 | resp.ResourceData = client 89 | } 90 | 91 | func (p *OpenaiProvider) Resources(ctx context.Context) []func() resource.Resource { 92 | return []func() resource.Resource{ 93 | NewChatCompletionResource, 94 | NewCompletionResource, 95 | NewEmbeddingResource, 96 | NewImageResource, 97 | } 98 | } 99 | 100 | func (p *OpenaiProvider) DataSources(ctx context.Context) []func() datasource.DataSource { 101 | return []func() datasource.DataSource{} 102 | } 103 | 104 | func New(version string) func() provider.Provider { 105 | return func() provider.Provider { 106 | return &OpenaiProvider{ 107 | version: version, 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /internal/provider/reflect/diags.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package reflect 4 | 5 | import ( 6 | "fmt" 7 | "reflect" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/attr" 10 | "github.com/hashicorp/terraform-plugin-framework/diag" 11 | "github.com/hashicorp/terraform-plugin-framework/path" 12 | "github.com/hashicorp/terraform-plugin-go/tftypes" 13 | ) 14 | 15 | func toTerraform5ValueErrorDiag(err error, path path.Path) diag.DiagnosticWithPath { 16 | return diag.NewAttributeErrorDiagnostic( 17 | path, 18 | "Value Conversion Error", 19 | "An unexpected error was encountered trying to convert into a Terraform value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), 20 | ) 21 | } 22 | 23 | func toTerraformValueErrorDiag(err error, path path.Path) diag.DiagnosticWithPath { 24 | return diag.NewAttributeErrorDiagnostic( 25 | path, 26 | "Value Conversion Error", 27 | "An unexpected error was encountered trying to convert the Attribute value into a Terraform value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), 28 | ) 29 | } 30 | 31 | func validateValueErrorDiag(err error, path path.Path) diag.DiagnosticWithPath { 32 | return diag.NewAttributeErrorDiagnostic( 33 | path, 34 | "Value Conversion Error", 35 | "An unexpected error was encountered trying to validate the Terraform value type. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), 36 | ) 37 | } 38 | 39 | func valueFromTerraformErrorDiag(err error, path path.Path) diag.DiagnosticWithPath { 40 | return diag.NewAttributeErrorDiagnostic( 41 | path, 42 | "Value Conversion Error", 43 | "An unexpected error was encountered trying to convert the Terraform value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), 44 | ) 45 | } 46 | 47 | type DiagIntoIncompatibleType struct { 48 | Val tftypes.Value 49 | TargetType reflect.Type 50 | Err error 51 | } 52 | 53 | func (d DiagIntoIncompatibleType) Severity() diag.Severity { 54 | return diag.SeverityError 55 | } 56 | 57 | func (d DiagIntoIncompatibleType) Summary() string { 58 | return "Value Conversion Error" 59 | } 60 | 61 | func (d DiagIntoIncompatibleType) Detail() string { 62 | return fmt.Sprintf("An unexpected error was encountered trying to convert %T into %s. This is always an error in the provider. Please report the following to the provider developer:\n\n%s", d.Val, d.TargetType, d.Err.Error()) 63 | } 64 | 65 | func (d DiagIntoIncompatibleType) Equal(o diag.Diagnostic) bool { 66 | od, ok := o.(DiagIntoIncompatibleType) 67 | if !ok { 68 | return false 69 | } 70 | if !d.Val.Equal(od.Val) { 71 | return false 72 | } 73 | if d.TargetType != od.TargetType { 74 | return false 75 | } 76 | if d.Err.Error() != od.Err.Error() { 77 | return false 78 | } 79 | return true 80 | } 81 | 82 | type DiagNewAttributeValueIntoWrongType struct { 83 | ValType reflect.Type 84 | TargetType reflect.Type 85 | SchemaType attr.Type 86 | } 87 | 88 | func (d DiagNewAttributeValueIntoWrongType) Severity() diag.Severity { 89 | return diag.SeverityError 90 | } 91 | 92 | func (d DiagNewAttributeValueIntoWrongType) Summary() string { 93 | return "Value Conversion Error" 94 | } 95 | 96 | func (d DiagNewAttributeValueIntoWrongType) Detail() string { 97 | return fmt.Sprintf("An unexpected error was encountered trying to convert into a Terraform value. This is always an error in the provider. Please report the following to the provider developer:\n\nCannot use attr.Value %s, only %s is supported because %T is the type in the schema", d.TargetType, d.ValType, d.SchemaType) 98 | } 99 | 100 | func (d DiagNewAttributeValueIntoWrongType) Equal(o diag.Diagnostic) bool { 101 | od, ok := o.(DiagNewAttributeValueIntoWrongType) 102 | if !ok { 103 | return false 104 | } 105 | if d.ValType != od.ValType { 106 | return false 107 | } 108 | if d.TargetType != od.TargetType { 109 | return false 110 | } 111 | if !d.SchemaType.Equal(od.SchemaType) { 112 | return false 113 | } 114 | return true 115 | } 116 | -------------------------------------------------------------------------------- /internal/provider/reflect/doc.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | // Package reflect is a forked version of https://github.com/hashicorp/terraform-plugin-framework/tree/main/internal/reflect 4 | // that has been modified to support speakeasy's terraform generator. 5 | // In particular, behaviour differs in that it is intended to support merging Terraform State and Terraform Plan structures 6 | // into a single data structure, with Known Plan values overriding State values. This allows for code to be written 7 | // that drives API calls from a single point of truth. 8 | // Fork Commit hash is 99f28445b60580b6e39afda88a4bb469461f9bbb 9 | package reflect 10 | -------------------------------------------------------------------------------- /internal/provider/reflect/generic_attr_value.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package reflect 4 | 5 | import ( 6 | "context" 7 | "reflect" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework/attr" 10 | ) 11 | 12 | func IsGenericAttrValue(ctx context.Context, target interface{}) bool { 13 | return reflect.TypeOf((*attr.Value)(nil)) == reflect.TypeOf(target) 14 | } 15 | -------------------------------------------------------------------------------- /internal/provider/reflect/helpers.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package reflect 4 | 5 | import ( 6 | "context" 7 | "fmt" 8 | "reflect" 9 | "regexp" 10 | "strings" 11 | 12 | "github.com/hashicorp/terraform-plugin-framework/path" 13 | ) 14 | 15 | // trueReflectValue returns the reflect.Value for `in` after derefencing all 16 | // the pointers and unwrapping all the interfaces. It's the concrete value 17 | // beneath it all. 18 | func trueReflectValue(val reflect.Value) reflect.Value { 19 | kind := val.Type().Kind() 20 | for kind == reflect.Interface || kind == reflect.Ptr { 21 | innerVal := val.Elem() 22 | if !innerVal.IsValid() { 23 | break 24 | } 25 | val = innerVal 26 | kind = val.Type().Kind() 27 | } 28 | return val 29 | } 30 | 31 | // commaSeparatedString returns an English joining of the strings in `in`, 32 | // using "and" and commas as appropriate. 33 | func commaSeparatedString(in []string) string { 34 | switch len(in) { 35 | case 0: 36 | return "" 37 | case 1: 38 | return in[0] 39 | case 2: 40 | return strings.Join(in, " and ") 41 | default: 42 | in[len(in)-1] = "and " + in[len(in)-1] 43 | return strings.Join(in, ", ") 44 | } 45 | } 46 | 47 | // getStructTags returns a map of Terraform field names to their position in 48 | // the tags of the struct `in`. `in` must be a struct. 49 | func getStructTags(_ context.Context, in reflect.Value, path path.Path, opts Options) (map[string]int, error) { 50 | tags := map[string]int{} 51 | typ := trueReflectValue(in).Type() 52 | if typ.Kind() != reflect.Struct { 53 | return nil, fmt.Errorf("%s: can't get struct tags of %s, is not a struct", path, in.Type()) 54 | } 55 | for i := 0; i < typ.NumField(); i++ { 56 | field := typ.Field(i) 57 | if field.PkgPath != "" { 58 | // skip unexported fields 59 | continue 60 | } 61 | tag := field.Tag.Get(`tfsdk`) 62 | if tag == "-" { 63 | // skip explicitly excluded fields 64 | continue 65 | } 66 | if tag == "" { 67 | return nil, fmt.Errorf(`%s: need a struct tag for "tfsdk" on %s`, path, field.Name) 68 | } 69 | path := path.AtName(tag) 70 | if !isValidFieldName(tag) { 71 | return nil, fmt.Errorf("%s: invalid field name, must only use lowercase letters, underscores, and numbers, and must start with a letter", path) 72 | } 73 | if other, ok := tags[tag]; ok { 74 | return nil, fmt.Errorf("%s: can't use field name for both %s and %s", path, typ.Field(other).Name, field.Name) 75 | } 76 | tags[tag] = i 77 | } 78 | return tags, nil 79 | } 80 | 81 | // isValidFieldName returns true if `name` can be used as a field name in a 82 | // Terraform resource or data source. 83 | func isValidFieldName(name string) bool { 84 | re := regexp.MustCompile("^[a-z][a-z0-9_]*$") 85 | return re.MatchString(name) 86 | } 87 | 88 | // canBeNil returns true if `target`'s type can hold a nil value 89 | func canBeNil(target reflect.Value) bool { 90 | switch target.Kind() { 91 | case reflect.Ptr, reflect.Slice, reflect.Map, reflect.Interface: 92 | // these types can all hold nils 93 | return true 94 | default: 95 | // nothing else can be set to nil 96 | return false 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /internal/provider/reflect/options.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package reflect 4 | 5 | const ( 6 | SourceTypeState = iota 7 | SourceTypePlan 8 | ) 9 | 10 | // Options provides configuration settings for how the reflection behavior 11 | // works, letting callers tweak different behaviors based on their needs. 12 | type Options struct { 13 | // UnhandledNullAsEmpty controls whether null values should be 14 | // translated into empty values without provider interaction, or if 15 | // they must be explicitly handled. 16 | UnhandledNullAsEmpty bool 17 | 18 | // UnhandledUnknownAsEmpty controls whether null values should be 19 | // translated into empty values without provider interaction, or if 20 | // they must be explicitly handled. 21 | UnhandledUnknownAsEmpty bool 22 | 23 | // SourceType informs the reflection system what the source is 24 | // such that it can make decisions based on the tfPlanOnly annotation 25 | // The default is SourceTypeState 26 | SourceType int 27 | } 28 | -------------------------------------------------------------------------------- /internal/provider/reflect/outof.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package reflect 4 | 5 | import ( 6 | "context" 7 | "fmt" 8 | "math/big" 9 | "reflect" 10 | 11 | "github.com/hashicorp/terraform-plugin-framework/attr" 12 | "github.com/hashicorp/terraform-plugin-framework/diag" 13 | "github.com/hashicorp/terraform-plugin-framework/path" 14 | "github.com/hashicorp/terraform-plugin-go/tftypes" 15 | ) 16 | 17 | // FromValue is the inverse of Into, taking a Go value (`val`) and transforming it 18 | // into an attr.Value using the attr.Type supplied. `val` will first be 19 | // transformed into a tftypes.Value, then passed to `typ`'s ValueFromTerraform 20 | // method. 21 | func FromValue(ctx context.Context, typ attr.Type, val interface{}, path path.Path) (attr.Value, diag.Diagnostics) { 22 | var diags diag.Diagnostics 23 | 24 | if v, ok := val.(attr.Value); ok { 25 | return FromAttributeValue(ctx, typ, v, path) 26 | } 27 | if v, ok := val.(tftypes.ValueCreator); ok { 28 | return FromValueCreator(ctx, typ, v, path) 29 | } 30 | if v, ok := val.(Unknownable); ok { 31 | return FromUnknownable(ctx, typ, v, path) 32 | } 33 | if v, ok := val.(Nullable); ok { 34 | return FromNullable(ctx, typ, v, path) 35 | } 36 | if bf, ok := val.(*big.Float); ok { 37 | return FromBigFloat(ctx, typ, bf, path) 38 | } 39 | if bi, ok := val.(*big.Int); ok { 40 | return FromBigInt(ctx, typ, bi, path) 41 | } 42 | value := reflect.ValueOf(val) 43 | kind := value.Kind() 44 | switch kind { 45 | case reflect.Struct: 46 | t, ok := typ.(attr.TypeWithAttributeTypes) 47 | if !ok { 48 | err := fmt.Errorf("cannot use type %T as schema type %T; %T must be an attr.TypeWithAttributeTypes to hold %T", val, typ, typ, val) 49 | diags.AddAttributeError( 50 | path, 51 | "Value Conversion Error", 52 | "An unexpected error was encountered trying to convert from value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), 53 | ) 54 | return nil, diags 55 | } 56 | return FromStruct(ctx, t, value, path) 57 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, 58 | reflect.Int64: 59 | return FromInt(ctx, typ, value.Int(), path) 60 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, 61 | reflect.Uint64: 62 | return FromUint(ctx, typ, value.Uint(), path) 63 | case reflect.Float32, reflect.Float64: 64 | return FromFloat(ctx, typ, value.Float(), path) 65 | case reflect.Bool: 66 | return FromBool(ctx, typ, value.Bool(), path) 67 | case reflect.String: 68 | return FromString(ctx, typ, value.String(), path) 69 | case reflect.Slice: 70 | return FromSlice(ctx, typ, value, path) 71 | case reflect.Map: 72 | t, ok := typ.(attr.TypeWithElementType) 73 | if !ok { 74 | err := fmt.Errorf("cannot use type %T as schema type %T; %T must be an attr.TypeWithElementType to hold %T", val, typ, typ, val) 75 | diags.AddAttributeError( 76 | path, 77 | "Value Conversion Error", 78 | "An unexpected error was encountered trying to convert from value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), 79 | ) 80 | return nil, diags 81 | } 82 | return FromMap(ctx, t, value, path) 83 | case reflect.Ptr: 84 | return FromPointer(ctx, typ, value, path) 85 | default: 86 | err := fmt.Errorf("cannot construct attr.Type from %T (%s)", val, kind) 87 | diags.AddAttributeError( 88 | path, 89 | "Value Conversion Error", 90 | "An unexpected error was encountered trying to convert from value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), 91 | ) 92 | return nil, diags 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /internal/provider/reflect/primitive.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package reflect 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "reflect" 9 | 10 | "github.com/hashicorp/terraform-plugin-framework/attr" 11 | "github.com/hashicorp/terraform-plugin-framework/attr/xattr" 12 | "github.com/hashicorp/terraform-plugin-framework/diag" 13 | "github.com/hashicorp/terraform-plugin-framework/path" 14 | "github.com/hashicorp/terraform-plugin-go/tftypes" 15 | ) 16 | 17 | // Primitive builds a string or boolean, depending on the type of `target`, and 18 | // populates it with the data in `val`. 19 | // 20 | // It is meant to be called through `Into`, not directly. 21 | func Primitive(ctx context.Context, typ attr.Type, val tftypes.Value, target reflect.Value, path path.Path) (reflect.Value, diag.Diagnostics) { 22 | var diags diag.Diagnostics 23 | 24 | switch target.Kind() { 25 | case reflect.Bool: 26 | var b bool 27 | err := val.As(&b) 28 | if err != nil { 29 | diags.Append(diag.WithPath(path, DiagIntoIncompatibleType{ 30 | Val: val, 31 | TargetType: target.Type(), 32 | Err: err, 33 | })) 34 | return target, diags 35 | } 36 | return reflect.ValueOf(b).Convert(target.Type()), nil 37 | case reflect.String: 38 | var s string 39 | err := val.As(&s) 40 | if err != nil { 41 | diags.Append(diag.WithPath(path, DiagIntoIncompatibleType{ 42 | Val: val, 43 | TargetType: target.Type(), 44 | Err: err, 45 | })) 46 | return target, diags 47 | } 48 | return reflect.ValueOf(s).Convert(target.Type()), nil 49 | default: 50 | diags.Append(diag.WithPath(path, DiagIntoIncompatibleType{ 51 | Val: val, 52 | TargetType: target.Type(), 53 | Err: errors.New("unknown type"), 54 | })) 55 | return target, diags 56 | } 57 | } 58 | 59 | // FromString returns an attr.Value as produced by `typ` from a string. 60 | // 61 | // It is meant to be called through FromValue, not directly. 62 | func FromString(ctx context.Context, typ attr.Type, val string, path path.Path) (attr.Value, diag.Diagnostics) { 63 | var diags diag.Diagnostics 64 | err := tftypes.ValidateValue(tftypes.String, val) 65 | if err != nil { 66 | return nil, append(diags, validateValueErrorDiag(err, path)) 67 | } 68 | tfStr := tftypes.NewValue(tftypes.String, val) 69 | 70 | str, err := typ.ValueFromTerraform(ctx, tfStr) 71 | if err != nil { 72 | return nil, append(diags, valueFromTerraformErrorDiag(err, path)) 73 | } 74 | 75 | switch t := str.(type) { 76 | case xattr.ValidateableAttribute: 77 | resp := xattr.ValidateAttributeResponse{} 78 | 79 | t.ValidateAttribute(ctx, 80 | xattr.ValidateAttributeRequest{ 81 | Path: path, 82 | }, 83 | &resp, 84 | ) 85 | 86 | diags.Append(resp.Diagnostics...) 87 | 88 | if diags.HasError() { 89 | return nil, diags 90 | } 91 | default: 92 | //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. 93 | if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { 94 | diags.Append(typeWithValidate.Validate(ctx, tfStr, path)...) 95 | 96 | if diags.HasError() { 97 | return nil, diags 98 | } 99 | } 100 | } 101 | 102 | return str, diags 103 | } 104 | 105 | // FromBool returns an attr.Value as produced by `typ` from a bool. 106 | // 107 | // It is meant to be called through FromValue, not directly. 108 | func FromBool(ctx context.Context, typ attr.Type, val bool, path path.Path) (attr.Value, diag.Diagnostics) { 109 | var diags diag.Diagnostics 110 | err := tftypes.ValidateValue(tftypes.Bool, val) 111 | if err != nil { 112 | return nil, append(diags, validateValueErrorDiag(err, path)) 113 | } 114 | tfBool := tftypes.NewValue(tftypes.Bool, val) 115 | 116 | b, err := typ.ValueFromTerraform(ctx, tfBool) 117 | if err != nil { 118 | return nil, append(diags, valueFromTerraformErrorDiag(err, path)) 119 | } 120 | 121 | switch t := b.(type) { 122 | case xattr.ValidateableAttribute: 123 | resp := xattr.ValidateAttributeResponse{} 124 | 125 | t.ValidateAttribute(ctx, 126 | xattr.ValidateAttributeRequest{ 127 | Path: path, 128 | }, 129 | &resp, 130 | ) 131 | 132 | diags.Append(resp.Diagnostics...) 133 | 134 | if diags.HasError() { 135 | return nil, diags 136 | } 137 | default: 138 | //lint:ignore SA1019 xattr.TypeWithValidate is deprecated, but we still need to support it. 139 | if typeWithValidate, ok := typ.(xattr.TypeWithValidate); ok { 140 | diags.Append(typeWithValidate.Validate(ctx, tfBool, path)...) 141 | 142 | if diags.HasError() { 143 | return nil, diags 144 | } 145 | } 146 | } 147 | 148 | return b, diags 149 | } 150 | -------------------------------------------------------------------------------- /internal/provider/types/chat_completion_functions.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type ChatCompletionFunctions struct { 8 | Description types.String `tfsdk:"description"` 9 | Name types.String `tfsdk:"name"` 10 | Parameters map[string]types.String `tfsdk:"parameters"` 11 | } 12 | -------------------------------------------------------------------------------- /internal/provider/types/chat_completion_request_message.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type ChatCompletionRequestMessage struct { 8 | Content types.String `tfsdk:"content"` 9 | FunctionCall *FunctionCall `tfsdk:"function_call"` 10 | Name types.String `tfsdk:"name"` 11 | Role types.String `tfsdk:"role"` 12 | } 13 | -------------------------------------------------------------------------------- /internal/provider/types/chat_completion_response_message.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type ChatCompletionResponseMessage struct { 8 | Content types.String `tfsdk:"content"` 9 | FunctionCall *ChatCompletionResponseMessageFunctionCall `tfsdk:"function_call"` 10 | Role types.String `tfsdk:"role"` 11 | } 12 | -------------------------------------------------------------------------------- /internal/provider/types/chat_completion_response_message_function_call.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type ChatCompletionResponseMessageFunctionCall struct { 8 | Arguments types.String `tfsdk:"arguments"` 9 | Name types.String `tfsdk:"name"` 10 | } 11 | -------------------------------------------------------------------------------- /internal/provider/types/choices.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type Choices struct { 8 | FinishReason types.String `tfsdk:"finish_reason"` 9 | Index types.Int64 `tfsdk:"index"` 10 | Message ChatCompletionResponseMessage `tfsdk:"message"` 11 | } 12 | -------------------------------------------------------------------------------- /internal/provider/types/create_chat_completion_request_function_call.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type CreateChatCompletionRequestFunctionCall struct { 8 | One types.String `tfsdk:"one" tfPlanOnly:"true"` 9 | Two *Two `tfsdk:"two" tfPlanOnly:"true"` 10 | } 11 | -------------------------------------------------------------------------------- /internal/provider/types/create_completion_response_choices.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type CreateCompletionResponseChoices struct { 8 | FinishReason types.String `tfsdk:"finish_reason"` 9 | Index types.Int64 `tfsdk:"index"` 10 | Logprobs *Logprobs `tfsdk:"logprobs"` 11 | Text types.String `tfsdk:"text"` 12 | } 13 | -------------------------------------------------------------------------------- /internal/provider/types/create_embedding_response_usage.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type CreateEmbeddingResponseUsage struct { 8 | PromptTokens types.Int64 `tfsdk:"prompt_tokens"` 9 | TotalTokens types.Int64 `tfsdk:"total_tokens"` 10 | } 11 | -------------------------------------------------------------------------------- /internal/provider/types/data.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type Data struct { 8 | Embedding []types.Number `tfsdk:"embedding"` 9 | Index types.Int64 `tfsdk:"index"` 10 | Object types.String `tfsdk:"object"` 11 | } 12 | -------------------------------------------------------------------------------- /internal/provider/types/function_call.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type FunctionCall struct { 8 | Arguments types.String `tfsdk:"arguments"` 9 | Name types.String `tfsdk:"name"` 10 | } 11 | -------------------------------------------------------------------------------- /internal/provider/types/images_response_data.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type ImagesResponseData struct { 8 | B64JSON types.String `tfsdk:"b64_json"` 9 | URL types.String `tfsdk:"url"` 10 | } 11 | -------------------------------------------------------------------------------- /internal/provider/types/logprobs.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type Logprobs struct { 8 | TextOffset []types.Int64 `tfsdk:"text_offset"` 9 | TokenLogprobs []types.Number `tfsdk:"token_logprobs"` 10 | Tokens []types.String `tfsdk:"tokens"` 11 | TopLogprobs types.String `tfsdk:"top_logprobs"` 12 | } 13 | -------------------------------------------------------------------------------- /internal/provider/types/prompt.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type Prompt struct { 8 | Str types.String `tfsdk:"str" tfPlanOnly:"true"` 9 | ArrayOfStr []types.String `tfsdk:"array_of_str" tfPlanOnly:"true"` 10 | ArrayOfInteger []types.Int64 `tfsdk:"array_of_integer" tfPlanOnly:"true"` 11 | ArrayOfArrayOfInteger [][]types.Int64 `tfsdk:"array_of_array_of_integer" tfPlanOnly:"true"` 12 | } 13 | -------------------------------------------------------------------------------- /internal/provider/types/stop.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type Stop struct { 8 | Str types.String `tfsdk:"str" tfPlanOnly:"true"` 9 | ArrayOfStr []types.String `tfsdk:"array_of_str" tfPlanOnly:"true"` 10 | } 11 | -------------------------------------------------------------------------------- /internal/provider/types/two.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type Two struct { 8 | Name types.String `tfsdk:"name"` 9 | } 10 | -------------------------------------------------------------------------------- /internal/provider/types/usage.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "github.com/hashicorp/terraform-plugin-framework/types" 6 | 7 | type Usage struct { 8 | CompletionTokens types.Int64 `tfsdk:"completion_tokens"` 9 | PromptTokens types.Int64 `tfsdk:"prompt_tokens"` 10 | TotalTokens types.Int64 `tfsdk:"total_tokens"` 11 | } 12 | -------------------------------------------------------------------------------- /internal/provider/utils.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package provider 4 | 5 | import ( 6 | "context" 7 | "encoding/json" 8 | "fmt" 9 | tfReflect "github.com/antonbabenko/terraform-provider-openai/v2/internal/provider/reflect" 10 | "github.com/hashicorp/terraform-plugin-framework/diag" 11 | "github.com/hashicorp/terraform-plugin-framework/path" 12 | "github.com/hashicorp/terraform-plugin-framework/resource" 13 | "github.com/hashicorp/terraform-plugin-framework/types" 14 | "net/http" 15 | "net/http/httputil" 16 | "reflect" 17 | ) 18 | 19 | func debugResponse(response *http.Response) string { 20 | if v := response.Request.Header.Get("Authorization"); v != "" { 21 | response.Request.Header.Set("Authorization", "(sensitive)") 22 | } 23 | dumpReq, err := httputil.DumpRequest(response.Request, true) 24 | if err != nil { 25 | dumpReq, err = httputil.DumpRequest(response.Request, false) 26 | if err != nil { 27 | return err.Error() 28 | } 29 | } 30 | dumpRes, err := httputil.DumpResponse(response, true) 31 | if err != nil { 32 | dumpRes, err = httputil.DumpResponse(response, false) 33 | if err != nil { 34 | return err.Error() 35 | } 36 | } 37 | return fmt.Sprintf("**Request**:\n%s\n**Response**:\n%s", string(dumpReq), string(dumpRes)) 38 | } 39 | 40 | func reflectJSONKey(data any, key string) reflect.Value { 41 | jsonIfied, err := json.Marshal(data) 42 | if err != nil { 43 | panic(fmt.Errorf("failed to marshal data: %w", err)) 44 | } 45 | var jsonMap map[string]interface{} 46 | err = json.Unmarshal(jsonIfied, &jsonMap) 47 | if err != nil { 48 | panic(fmt.Errorf("failed to unmarshal data: %w", err)) 49 | } 50 | return reflect.ValueOf(jsonMap[key]) 51 | } 52 | 53 | func merge(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse, target interface{}) { 54 | var plan types.Object 55 | var state types.Object 56 | 57 | resp.Diagnostics.Append(req.State.Get(ctx, &state)...) 58 | if resp.Diagnostics.HasError() { 59 | return 60 | } 61 | resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) 62 | if resp.Diagnostics.HasError() { 63 | return 64 | } 65 | val, err := state.ToTerraformValue(ctx) 66 | if err != nil { 67 | resp.Diagnostics.Append(diag.NewErrorDiagnostic("Object Conversion Error", "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error())) 68 | return 69 | } 70 | resp.Diagnostics.Append(tfReflect.Into(ctx, types.ObjectType{AttrTypes: state.AttributeTypes(ctx)}, val, target, tfReflect.Options{ 71 | UnhandledNullAsEmpty: true, 72 | UnhandledUnknownAsEmpty: true, 73 | }, path.Empty())...) 74 | if resp.Diagnostics.HasError() { 75 | return 76 | } 77 | 78 | refreshPlan(ctx, plan, target, resp.Diagnostics) 79 | } 80 | 81 | func refreshPlan(ctx context.Context, plan types.Object, target interface{}, diagnostics diag.Diagnostics) { 82 | obj := types.ObjectType{AttrTypes: plan.AttributeTypes(ctx)} 83 | val, err := plan.ToTerraformValue(ctx) 84 | if err != nil { 85 | diagnostics.Append(diag.NewErrorDiagnostic("Object Conversion Error", "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error())) 86 | return 87 | } 88 | diagnostics.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{ 89 | UnhandledNullAsEmpty: true, 90 | UnhandledUnknownAsEmpty: true, 91 | SourceType: tfReflect.SourceTypePlan, 92 | }, path.Empty())...) 93 | } 94 | -------------------------------------------------------------------------------- /internal/sdk/.gitattributes: -------------------------------------------------------------------------------- 1 | # This allows generated code to be indexed correctly 2 | *.go linguist-generated=false -------------------------------------------------------------------------------- /internal/sdk/.gitignore: -------------------------------------------------------------------------------- 1 | # .gitignore 2 | -------------------------------------------------------------------------------- /internal/sdk/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to This Repository 2 | 3 | Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. 4 | 5 | ## How to Report Issues 6 | 7 | If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: 8 | 9 | - A clear and descriptive title 10 | - Steps to reproduce the issue 11 | - Expected and actual behavior 12 | - Any relevant logs, screenshots, or error messages 13 | - Information about your environment (e.g., operating system, software versions) 14 | - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed 15 | 16 | ## Issue Triage and Upstream Fixes 17 | 18 | We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. 19 | 20 | ## Contact 21 | 22 | If you have any questions or need further assistance, please feel free to reach out by opening an issue. 23 | 24 | Thank you for your understanding and cooperation! 25 | 26 | The Maintainers 27 | -------------------------------------------------------------------------------- /internal/sdk/internal/hooks/hooks.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package hooks 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "net/http" 9 | ) 10 | 11 | type FailEarly struct { 12 | Cause error 13 | } 14 | 15 | var _ error = (*FailEarly)(nil) 16 | 17 | func (f *FailEarly) Error() string { 18 | return f.Cause.Error() 19 | } 20 | 21 | // HTTPClient provides an interface for supplying the SDK with a custom HTTP client 22 | type HTTPClient interface { 23 | Do(req *http.Request) (*http.Response, error) 24 | } 25 | 26 | type HookContext struct { 27 | Context context.Context 28 | OperationID string 29 | OAuth2Scopes []string 30 | SecuritySource func(context.Context) (interface{}, error) 31 | } 32 | 33 | type BeforeRequestContext struct { 34 | HookContext 35 | } 36 | 37 | type AfterSuccessContext struct { 38 | HookContext 39 | } 40 | 41 | type AfterErrorContext struct { 42 | HookContext 43 | } 44 | 45 | // sdkInitHook is called when the SDK is initializing. The hook can modify and return a new baseURL and HTTP client to be used by the SDK. 46 | type sdkInitHook interface { 47 | SDKInit(baseURL string, client HTTPClient) (string, HTTPClient) 48 | } 49 | 50 | // beforeRequestHook is called before the SDK sends a request. The hook can modify the request before it is sent or return an error to stop the request from being sent. 51 | type beforeRequestHook interface { 52 | BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) 53 | } 54 | 55 | // afterSuccessHook is called after the SDK receives a response. The hook can modify the response before it is handled or return an error to stop the response from being handled. 56 | type afterSuccessHook interface { 57 | AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) 58 | } 59 | 60 | // afterErrorHook is called after the SDK encounters an error, or a non-successful response. The hook can modify the response if available otherwise modify the error. 61 | // All afterErrorHook hooks are called and returning an error won't stop the other hooks from being called. But if you want to stop the other hooks from being called, you can return a FailEarly error wrapping your error. 62 | type afterErrorHook interface { 63 | AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) 64 | } 65 | 66 | type Hooks struct { 67 | sdkInitHooks []sdkInitHook 68 | beforeRequestHook []beforeRequestHook 69 | afterSuccessHook []afterSuccessHook 70 | afterErrorHook []afterErrorHook 71 | } 72 | 73 | func New() *Hooks { 74 | h := &Hooks{ 75 | sdkInitHooks: []sdkInitHook{}, 76 | beforeRequestHook: []beforeRequestHook{}, 77 | afterSuccessHook: []afterSuccessHook{}, 78 | afterErrorHook: []afterErrorHook{}, 79 | } 80 | 81 | return h 82 | } 83 | 84 | // registerSDKInitHook registers a hook to be used by the SDK for the initialization event. 85 | func (h *Hooks) registerSDKInitHook(hook sdkInitHook) { 86 | h.sdkInitHooks = append(h.sdkInitHooks, hook) 87 | } 88 | 89 | // registerBeforeRequestHook registers a hook to be used by the SDK for the before request event. 90 | func (h *Hooks) registerBeforeRequestHook(hook beforeRequestHook) { 91 | h.beforeRequestHook = append(h.beforeRequestHook, hook) 92 | } 93 | 94 | // registerAfterSuccessHook registers a hook to be used by the SDK for the after success event. 95 | func (h *Hooks) registerAfterSuccessHook(hook afterSuccessHook) { 96 | h.afterSuccessHook = append(h.afterSuccessHook, hook) 97 | } 98 | 99 | // registerAfterErrorHook registers a hook to be used by the SDK for the after error event. 100 | func (h *Hooks) registerAfterErrorHook(hook afterErrorHook) { 101 | h.afterErrorHook = append(h.afterErrorHook, hook) 102 | } 103 | 104 | func (h *Hooks) SDKInit(baseURL string, client HTTPClient) (string, HTTPClient) { 105 | for _, hook := range h.sdkInitHooks { 106 | baseURL, client = hook.SDKInit(baseURL, client) 107 | } 108 | return baseURL, client 109 | } 110 | 111 | func (h *Hooks) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) { 112 | for _, hook := range h.beforeRequestHook { 113 | var err error 114 | req, err = hook.BeforeRequest(hookCtx, req) 115 | if err != nil { 116 | return req, err 117 | } 118 | } 119 | return req, nil 120 | } 121 | 122 | func (h *Hooks) AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) { 123 | for _, hook := range h.afterSuccessHook { 124 | var err error 125 | res, err = hook.AfterSuccess(hookCtx, res) 126 | if err != nil { 127 | return res, err 128 | } 129 | } 130 | return res, nil 131 | } 132 | 133 | func (h *Hooks) AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) { 134 | for _, hook := range h.afterErrorHook { 135 | res, err = hook.AfterError(hookCtx, res, err) 136 | var fe *FailEarly 137 | if errors.As(err, &fe) { 138 | return nil, fe.Cause 139 | } 140 | } 141 | return res, err 142 | } 143 | -------------------------------------------------------------------------------- /internal/sdk/internal/utils/contenttype.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package utils 4 | 5 | import ( 6 | "fmt" 7 | "mime" 8 | "strings" 9 | ) 10 | 11 | func MatchContentType(contentType string, pattern string) bool { 12 | if contentType == "" { 13 | contentType = "application/octet-stream" 14 | } 15 | 16 | if contentType == pattern || pattern == "*" || pattern == "*/*" { 17 | return true 18 | } 19 | 20 | mediaType, _, err := mime.ParseMediaType(contentType) 21 | if err != nil { 22 | return false 23 | } 24 | 25 | if mediaType == pattern { 26 | return true 27 | } 28 | 29 | parts := strings.Split(mediaType, "/") 30 | if len(parts) == 2 { 31 | if fmt.Sprintf("%s/*", parts[0]) == pattern || fmt.Sprintf("*/%s", parts[1]) == pattern { 32 | return true 33 | } 34 | } 35 | 36 | return false 37 | } 38 | -------------------------------------------------------------------------------- /internal/sdk/internal/utils/form.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package utils 4 | 5 | import ( 6 | "fmt" 7 | "math/big" 8 | "net/url" 9 | "reflect" 10 | "strings" 11 | "time" 12 | 13 | "github.com/ericlagergren/decimal" 14 | 15 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/types" 16 | ) 17 | 18 | func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { 19 | 20 | formValues := url.Values{} 21 | 22 | if isNil(objType, objValue) { 23 | return formValues 24 | } 25 | 26 | if objType.Kind() == reflect.Pointer { 27 | objType = objType.Elem() 28 | objValue = objValue.Elem() 29 | } 30 | 31 | switch objType.Kind() { 32 | case reflect.Struct: 33 | switch objValue.Interface().(type) { 34 | case time.Time: 35 | formValues.Add(paramName, valToString(objValue.Interface())) 36 | case types.Date: 37 | formValues.Add(paramName, valToString(objValue.Interface())) 38 | case big.Int: 39 | formValues.Add(paramName, valToString(objValue.Interface())) 40 | case decimal.Big: 41 | formValues.Add(paramName, valToString(objValue.Interface())) 42 | default: 43 | var items []string 44 | 45 | for i := 0; i < objType.NumField(); i++ { 46 | fieldType := objType.Field(i) 47 | valType := objValue.Field(i) 48 | 49 | if isNil(fieldType.Type, valType) { 50 | continue 51 | } 52 | 53 | if valType.Kind() == reflect.Pointer { 54 | valType = valType.Elem() 55 | } 56 | 57 | fieldName := getFieldName(fieldType) 58 | if fieldName == "" { 59 | continue 60 | } 61 | 62 | if explode { 63 | formValues.Add(fieldName, valToString(valType.Interface())) 64 | } else { 65 | items = append(items, fmt.Sprintf("%s%s%s", fieldName, delimiter, valToString(valType.Interface()))) 66 | } 67 | } 68 | 69 | if len(items) > 0 { 70 | formValues.Add(paramName, strings.Join(items, delimiter)) 71 | } 72 | } 73 | case reflect.Map: 74 | items := []string{} 75 | 76 | iter := objValue.MapRange() 77 | for iter.Next() { 78 | if explode { 79 | formValues.Add(iter.Key().String(), valToString(iter.Value().Interface())) 80 | } else { 81 | items = append(items, fmt.Sprintf("%s%s%s", iter.Key().String(), delimiter, valToString(iter.Value().Interface()))) 82 | } 83 | } 84 | 85 | if len(items) > 0 { 86 | formValues.Add(paramName, strings.Join(items, delimiter)) 87 | } 88 | case reflect.Slice, reflect.Array: 89 | values := parseDelimitedArray(explode, objValue, delimiter) 90 | for _, v := range values { 91 | formValues.Add(paramName, v) 92 | } 93 | default: 94 | formValues.Add(paramName, valToString(objValue.Interface())) 95 | } 96 | 97 | return formValues 98 | } 99 | 100 | func parseDelimitedArray(explode bool, objValue reflect.Value, delimiter string) []string { 101 | values := []string{} 102 | items := []string{} 103 | 104 | for i := 0; i < objValue.Len(); i++ { 105 | if explode { 106 | values = append(values, valToString(objValue.Index(i).Interface())) 107 | } else { 108 | items = append(items, valToString(objValue.Index(i).Interface())) 109 | } 110 | } 111 | 112 | if len(items) > 0 { 113 | values = append(values, strings.Join(items, delimiter)) 114 | } 115 | 116 | return values 117 | } 118 | -------------------------------------------------------------------------------- /internal/sdk/internal/utils/headers.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package utils 4 | 5 | import ( 6 | "context" 7 | "fmt" 8 | "net/http" 9 | "reflect" 10 | "strings" 11 | ) 12 | 13 | func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) { 14 | globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{}) 15 | if globals != nil { 16 | _ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated) 17 | } 18 | } 19 | 20 | func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string { 21 | headerParamsStructType, headerParamsValType := dereferencePointers(reflect.TypeOf(headers), reflect.ValueOf(headers)) 22 | 23 | globalsAlreadyPopulated := []string{} 24 | 25 | for i := 0; i < headerParamsStructType.NumField(); i++ { 26 | fieldType := headerParamsStructType.Field(i) 27 | valType := headerParamsValType.Field(i) 28 | 29 | if contains(skipFields, fieldType.Name) { 30 | continue 31 | } 32 | 33 | if globals != nil { 34 | var globalFound bool 35 | fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals) 36 | if globalFound { 37 | globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) 38 | } 39 | } 40 | 41 | tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) 42 | if tag == nil { 43 | continue 44 | } 45 | 46 | value := serializeHeader(fieldType.Type, valType, tag.Explode) 47 | if value != "" { 48 | reqHeaders.Add(tag.ParamName, value) 49 | } 50 | } 51 | 52 | return globalsAlreadyPopulated 53 | } 54 | 55 | func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string { 56 | if isNil(objType, objValue) { 57 | return "" 58 | } 59 | 60 | if objType.Kind() == reflect.Pointer { 61 | objType = objType.Elem() 62 | objValue = objValue.Elem() 63 | } 64 | 65 | switch objType.Kind() { 66 | case reflect.Struct: 67 | items := []string{} 68 | 69 | for i := 0; i < objType.NumField(); i++ { 70 | fieldType := objType.Field(i) 71 | valType := objValue.Field(i) 72 | 73 | if isNil(fieldType.Type, valType) { 74 | continue 75 | } 76 | 77 | if fieldType.Type.Kind() == reflect.Pointer { 78 | valType = valType.Elem() 79 | } 80 | 81 | tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) 82 | if tag == nil { 83 | continue 84 | } 85 | 86 | fieldName := tag.ParamName 87 | 88 | if fieldName == "" { 89 | continue 90 | } 91 | 92 | if explode { 93 | items = append(items, fmt.Sprintf("%s=%s", fieldName, valToString(valType.Interface()))) 94 | } else { 95 | items = append(items, fieldName, valToString(valType.Interface())) 96 | } 97 | } 98 | 99 | return strings.Join(items, ",") 100 | case reflect.Map: 101 | items := []string{} 102 | 103 | iter := objValue.MapRange() 104 | for iter.Next() { 105 | if explode { 106 | items = append(items, fmt.Sprintf("%s=%s", iter.Key().String(), valToString(iter.Value().Interface()))) 107 | } else { 108 | items = append(items, iter.Key().String(), valToString(iter.Value().Interface())) 109 | } 110 | } 111 | 112 | return strings.Join(items, ",") 113 | case reflect.Slice, reflect.Array: 114 | items := []string{} 115 | 116 | for i := 0; i < objValue.Len(); i++ { 117 | items = append(items, valToString(objValue.Index(i).Interface())) 118 | } 119 | 120 | return strings.Join(items, ",") 121 | default: 122 | return valToString(objValue.Interface()) 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /internal/sdk/internal/utils/retries.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package utils 4 | 5 | import ( 6 | "context" 7 | "errors" 8 | "fmt" 9 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/retry" 10 | "github.com/cenkalti/backoff/v4" 11 | "net/http" 12 | "net/url" 13 | "strconv" 14 | "strings" 15 | "time" 16 | ) 17 | 18 | var errRequestFailed = errors.New("request failed") 19 | 20 | // Deprecated: Use retry.BackoffStrategy instead. 21 | type BackoffStrategy = retry.BackoffStrategy 22 | 23 | // Deprecated: Use retry.Config instead. 24 | type RetryConfig = retry.Config 25 | 26 | type Retries struct { 27 | Config *retry.Config 28 | StatusCodes []string 29 | } 30 | 31 | func Retry(ctx context.Context, r Retries, action func() (*http.Response, error)) (*http.Response, error) { 32 | switch r.Config.Strategy { 33 | case "backoff": 34 | if r.Config.Backoff == nil { 35 | return action() 36 | } 37 | 38 | config := backoff.NewExponentialBackOff() 39 | config.InitialInterval = time.Duration(r.Config.Backoff.InitialInterval) * time.Millisecond 40 | config.MaxInterval = time.Duration(r.Config.Backoff.MaxInterval) * time.Millisecond 41 | config.Multiplier = r.Config.Backoff.Exponent 42 | config.MaxElapsedTime = time.Duration(r.Config.Backoff.MaxElapsedTime) * time.Millisecond 43 | config.Reset() 44 | 45 | var resp *http.Response 46 | 47 | err := backoff.Retry(func() error { 48 | if resp != nil { 49 | resp.Body.Close() 50 | } 51 | 52 | select { 53 | case <-ctx.Done(): 54 | return backoff.Permanent(ctx.Err()) 55 | default: 56 | } 57 | 58 | res, err := action() 59 | if err != nil { 60 | urlError := new(url.Error) 61 | if errors.As(err, &urlError) { 62 | if (urlError.Temporary() || urlError.Timeout()) && r.Config.RetryConnectionErrors { 63 | return err 64 | } 65 | } 66 | 67 | return backoff.Permanent(err) 68 | } 69 | resp = res 70 | if res == nil { 71 | return fmt.Errorf("no response") 72 | } 73 | 74 | for _, code := range r.StatusCodes { 75 | if strings.Contains(strings.ToUpper(code), "X") { 76 | codeRange, err := strconv.Atoi(code[:1]) 77 | if err != nil { 78 | continue 79 | } 80 | 81 | s := res.StatusCode / 100 82 | 83 | if s >= codeRange && s < codeRange+1 { 84 | return errRequestFailed 85 | } 86 | } else { 87 | parsedCode, err := strconv.Atoi(code) 88 | if err != nil { 89 | continue 90 | } 91 | 92 | if res.StatusCode == parsedCode { 93 | return errRequestFailed 94 | } 95 | } 96 | } 97 | 98 | resp = res 99 | 100 | return nil 101 | }, config) 102 | if err != nil && !errors.Is(err, errRequestFailed) { 103 | return nil, err 104 | } 105 | 106 | return resp, nil 107 | default: 108 | return action() 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /internal/sdk/models/errors/sdkerror.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package errors 4 | 5 | import ( 6 | "fmt" 7 | "net/http" 8 | ) 9 | 10 | type SDKError struct { 11 | Message string 12 | StatusCode int 13 | Body string 14 | RawResponse *http.Response 15 | } 16 | 17 | var _ error = &SDKError{} 18 | 19 | func NewSDKError(message string, statusCode int, body string, httpRes *http.Response) *SDKError { 20 | return &SDKError{ 21 | Message: message, 22 | StatusCode: statusCode, 23 | Body: body, 24 | RawResponse: httpRes, 25 | } 26 | } 27 | 28 | func (e *SDKError) Error() string { 29 | body := "" 30 | if len(e.Body) > 0 { 31 | body = fmt.Sprintf("\n%s", e.Body) 32 | } 33 | 34 | return fmt.Sprintf("%s: Status %d%s", e.Message, e.StatusCode, body) 35 | } 36 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/cancelfinetune.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CancelFineTuneRequest struct { 11 | // The ID of the fine-tune job to cancel 12 | // 13 | FineTuneID string `pathParam:"style=simple,explode=false,name=fine_tune_id"` 14 | } 15 | 16 | func (o *CancelFineTuneRequest) GetFineTuneID() string { 17 | if o == nil { 18 | return "" 19 | } 20 | return o.FineTuneID 21 | } 22 | 23 | type CancelFineTuneResponse struct { 24 | // HTTP response content type for this operation 25 | ContentType string 26 | // OK 27 | FineTune *shared.FineTune 28 | // HTTP response status code for this operation 29 | StatusCode int 30 | // Raw HTTP response; suitable for custom response parsing 31 | RawResponse *http.Response 32 | } 33 | 34 | func (o *CancelFineTuneResponse) GetContentType() string { 35 | if o == nil { 36 | return "" 37 | } 38 | return o.ContentType 39 | } 40 | 41 | func (o *CancelFineTuneResponse) GetFineTune() *shared.FineTune { 42 | if o == nil { 43 | return nil 44 | } 45 | return o.FineTune 46 | } 47 | 48 | func (o *CancelFineTuneResponse) GetStatusCode() int { 49 | if o == nil { 50 | return 0 51 | } 52 | return o.StatusCode 53 | } 54 | 55 | func (o *CancelFineTuneResponse) GetRawResponse() *http.Response { 56 | if o == nil { 57 | return nil 58 | } 59 | return o.RawResponse 60 | } 61 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createchatcompletion.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateChatCompletionResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | CreateChatCompletionResponse *shared.CreateChatCompletionResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateChatCompletionResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateChatCompletionResponse) GetCreateChatCompletionResponse() *shared.CreateChatCompletionResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.CreateChatCompletionResponse 33 | } 34 | 35 | func (o *CreateChatCompletionResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateChatCompletionResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createcompletion.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateCompletionResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | CreateCompletionResponse *shared.CreateCompletionResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateCompletionResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateCompletionResponse) GetCreateCompletionResponse() *shared.CreateCompletionResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.CreateCompletionResponse 33 | } 34 | 35 | func (o *CreateCompletionResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateCompletionResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createedit.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateEditResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | CreateEditResponse *shared.CreateEditResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateEditResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateEditResponse) GetCreateEditResponse() *shared.CreateEditResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.CreateEditResponse 33 | } 34 | 35 | func (o *CreateEditResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateEditResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createembedding.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateEmbeddingResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | CreateEmbeddingResponse *shared.CreateEmbeddingResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateEmbeddingResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateEmbeddingResponse) GetCreateEmbeddingResponse() *shared.CreateEmbeddingResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.CreateEmbeddingResponse 33 | } 34 | 35 | func (o *CreateEmbeddingResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateEmbeddingResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createfile.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateFileResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | OpenAIFile *shared.OpenAIFile 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateFileResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateFileResponse) GetOpenAIFile() *shared.OpenAIFile { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.OpenAIFile 33 | } 34 | 35 | func (o *CreateFileResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateFileResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createfinetune.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateFineTuneResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | FineTune *shared.FineTune 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateFineTuneResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateFineTuneResponse) GetFineTune() *shared.FineTune { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.FineTune 33 | } 34 | 35 | func (o *CreateFineTuneResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateFineTuneResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createimage.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateImageResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | ImagesResponse *shared.ImagesResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateImageResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateImageResponse) GetImagesResponse() *shared.ImagesResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.ImagesResponse 33 | } 34 | 35 | func (o *CreateImageResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateImageResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createimageedit.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateImageEditResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | ImagesResponse *shared.ImagesResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateImageEditResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateImageEditResponse) GetImagesResponse() *shared.ImagesResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.ImagesResponse 33 | } 34 | 35 | func (o *CreateImageEditResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateImageEditResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createimagevariation.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateImageVariationResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | ImagesResponse *shared.ImagesResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateImageVariationResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateImageVariationResponse) GetImagesResponse() *shared.ImagesResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.ImagesResponse 33 | } 34 | 35 | func (o *CreateImageVariationResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateImageVariationResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createmoderation.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateModerationResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | CreateModerationResponse *shared.CreateModerationResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateModerationResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateModerationResponse) GetCreateModerationResponse() *shared.CreateModerationResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.CreateModerationResponse 33 | } 34 | 35 | func (o *CreateModerationResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateModerationResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createtranscription.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateTranscriptionResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | CreateTranscriptionResponse *shared.CreateTranscriptionResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateTranscriptionResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateTranscriptionResponse) GetCreateTranscriptionResponse() *shared.CreateTranscriptionResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.CreateTranscriptionResponse 33 | } 34 | 35 | func (o *CreateTranscriptionResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateTranscriptionResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/createtranslation.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type CreateTranslationResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | CreateTranslationResponse *shared.CreateTranslationResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *CreateTranslationResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *CreateTranslationResponse) GetCreateTranslationResponse() *shared.CreateTranslationResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.CreateTranslationResponse 33 | } 34 | 35 | func (o *CreateTranslationResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *CreateTranslationResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/deletefile.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type DeleteFileRequest struct { 11 | // The ID of the file to use for this request 12 | FileID string `pathParam:"style=simple,explode=false,name=file_id"` 13 | } 14 | 15 | func (o *DeleteFileRequest) GetFileID() string { 16 | if o == nil { 17 | return "" 18 | } 19 | return o.FileID 20 | } 21 | 22 | type DeleteFileResponse struct { 23 | // HTTP response content type for this operation 24 | ContentType string 25 | // OK 26 | DeleteFileResponse *shared.DeleteFileResponse 27 | // HTTP response status code for this operation 28 | StatusCode int 29 | // Raw HTTP response; suitable for custom response parsing 30 | RawResponse *http.Response 31 | } 32 | 33 | func (o *DeleteFileResponse) GetContentType() string { 34 | if o == nil { 35 | return "" 36 | } 37 | return o.ContentType 38 | } 39 | 40 | func (o *DeleteFileResponse) GetDeleteFileResponse() *shared.DeleteFileResponse { 41 | if o == nil { 42 | return nil 43 | } 44 | return o.DeleteFileResponse 45 | } 46 | 47 | func (o *DeleteFileResponse) GetStatusCode() int { 48 | if o == nil { 49 | return 0 50 | } 51 | return o.StatusCode 52 | } 53 | 54 | func (o *DeleteFileResponse) GetRawResponse() *http.Response { 55 | if o == nil { 56 | return nil 57 | } 58 | return o.RawResponse 59 | } 60 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/deletemodel.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type DeleteModelRequest struct { 11 | // The model to delete 12 | Model string `pathParam:"style=simple,explode=false,name=model"` 13 | } 14 | 15 | func (o *DeleteModelRequest) GetModel() string { 16 | if o == nil { 17 | return "" 18 | } 19 | return o.Model 20 | } 21 | 22 | type DeleteModelResponse struct { 23 | // HTTP response content type for this operation 24 | ContentType string 25 | // OK 26 | DeleteModelResponse *shared.DeleteModelResponse 27 | // HTTP response status code for this operation 28 | StatusCode int 29 | // Raw HTTP response; suitable for custom response parsing 30 | RawResponse *http.Response 31 | } 32 | 33 | func (o *DeleteModelResponse) GetContentType() string { 34 | if o == nil { 35 | return "" 36 | } 37 | return o.ContentType 38 | } 39 | 40 | func (o *DeleteModelResponse) GetDeleteModelResponse() *shared.DeleteModelResponse { 41 | if o == nil { 42 | return nil 43 | } 44 | return o.DeleteModelResponse 45 | } 46 | 47 | func (o *DeleteModelResponse) GetStatusCode() int { 48 | if o == nil { 49 | return 0 50 | } 51 | return o.StatusCode 52 | } 53 | 54 | func (o *DeleteModelResponse) GetRawResponse() *http.Response { 55 | if o == nil { 56 | return nil 57 | } 58 | return o.RawResponse 59 | } 60 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/downloadfile.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "net/http" 7 | ) 8 | 9 | type DownloadFileRequest struct { 10 | // The ID of the file to use for this request 11 | FileID string `pathParam:"style=simple,explode=false,name=file_id"` 12 | } 13 | 14 | func (o *DownloadFileRequest) GetFileID() string { 15 | if o == nil { 16 | return "" 17 | } 18 | return o.FileID 19 | } 20 | 21 | type DownloadFileResponse struct { 22 | // HTTP response content type for this operation 23 | ContentType string 24 | // HTTP response status code for this operation 25 | StatusCode int 26 | // Raw HTTP response; suitable for custom response parsing 27 | RawResponse *http.Response 28 | // OK 29 | String *string 30 | } 31 | 32 | func (o *DownloadFileResponse) GetContentType() string { 33 | if o == nil { 34 | return "" 35 | } 36 | return o.ContentType 37 | } 38 | 39 | func (o *DownloadFileResponse) GetStatusCode() int { 40 | if o == nil { 41 | return 0 42 | } 43 | return o.StatusCode 44 | } 45 | 46 | func (o *DownloadFileResponse) GetRawResponse() *http.Response { 47 | if o == nil { 48 | return nil 49 | } 50 | return o.RawResponse 51 | } 52 | 53 | func (o *DownloadFileResponse) GetString() *string { 54 | if o == nil { 55 | return nil 56 | } 57 | return o.String 58 | } 59 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/listfiles.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type ListFilesResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | ListFilesResponse *shared.ListFilesResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *ListFilesResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *ListFilesResponse) GetListFilesResponse() *shared.ListFilesResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.ListFilesResponse 33 | } 34 | 35 | func (o *ListFilesResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *ListFilesResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/listfinetuneevents.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/internal/utils" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 8 | "net/http" 9 | ) 10 | 11 | type ListFineTuneEventsRequest struct { 12 | // The ID of the fine-tune job to get events for. 13 | // 14 | FineTuneID string `pathParam:"style=simple,explode=false,name=fine_tune_id"` 15 | // Whether to stream events for the fine-tune job. If set to true, 16 | // events will be sent as data-only 17 | // [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) 18 | // as they become available. The stream will terminate with a 19 | // `data: [DONE]` message when the job is finished (succeeded, cancelled, 20 | // or failed). 21 | // 22 | // If set to false, only events generated so far will be returned. 23 | // 24 | Stream *bool `default:"false" queryParam:"style=form,explode=true,name=stream"` 25 | } 26 | 27 | func (l ListFineTuneEventsRequest) MarshalJSON() ([]byte, error) { 28 | return utils.MarshalJSON(l, "", false) 29 | } 30 | 31 | func (l *ListFineTuneEventsRequest) UnmarshalJSON(data []byte) error { 32 | if err := utils.UnmarshalJSON(data, &l, "", false, false); err != nil { 33 | return err 34 | } 35 | return nil 36 | } 37 | 38 | func (o *ListFineTuneEventsRequest) GetFineTuneID() string { 39 | if o == nil { 40 | return "" 41 | } 42 | return o.FineTuneID 43 | } 44 | 45 | func (o *ListFineTuneEventsRequest) GetStream() *bool { 46 | if o == nil { 47 | return nil 48 | } 49 | return o.Stream 50 | } 51 | 52 | type ListFineTuneEventsResponse struct { 53 | // HTTP response content type for this operation 54 | ContentType string 55 | // OK 56 | ListFineTuneEventsResponse *shared.ListFineTuneEventsResponse 57 | // HTTP response status code for this operation 58 | StatusCode int 59 | // Raw HTTP response; suitable for custom response parsing 60 | RawResponse *http.Response 61 | } 62 | 63 | func (o *ListFineTuneEventsResponse) GetContentType() string { 64 | if o == nil { 65 | return "" 66 | } 67 | return o.ContentType 68 | } 69 | 70 | func (o *ListFineTuneEventsResponse) GetListFineTuneEventsResponse() *shared.ListFineTuneEventsResponse { 71 | if o == nil { 72 | return nil 73 | } 74 | return o.ListFineTuneEventsResponse 75 | } 76 | 77 | func (o *ListFineTuneEventsResponse) GetStatusCode() int { 78 | if o == nil { 79 | return 0 80 | } 81 | return o.StatusCode 82 | } 83 | 84 | func (o *ListFineTuneEventsResponse) GetRawResponse() *http.Response { 85 | if o == nil { 86 | return nil 87 | } 88 | return o.RawResponse 89 | } 90 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/listfinetunes.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type ListFineTunesResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | ListFineTunesResponse *shared.ListFineTunesResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *ListFineTunesResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *ListFineTunesResponse) GetListFineTunesResponse() *shared.ListFineTunesResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.ListFineTunesResponse 33 | } 34 | 35 | func (o *ListFineTunesResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *ListFineTunesResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/listmodels.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type ListModelsResponse struct { 11 | // HTTP response content type for this operation 12 | ContentType string 13 | // OK 14 | ListModelsResponse *shared.ListModelsResponse 15 | // HTTP response status code for this operation 16 | StatusCode int 17 | // Raw HTTP response; suitable for custom response parsing 18 | RawResponse *http.Response 19 | } 20 | 21 | func (o *ListModelsResponse) GetContentType() string { 22 | if o == nil { 23 | return "" 24 | } 25 | return o.ContentType 26 | } 27 | 28 | func (o *ListModelsResponse) GetListModelsResponse() *shared.ListModelsResponse { 29 | if o == nil { 30 | return nil 31 | } 32 | return o.ListModelsResponse 33 | } 34 | 35 | func (o *ListModelsResponse) GetStatusCode() int { 36 | if o == nil { 37 | return 0 38 | } 39 | return o.StatusCode 40 | } 41 | 42 | func (o *ListModelsResponse) GetRawResponse() *http.Response { 43 | if o == nil { 44 | return nil 45 | } 46 | return o.RawResponse 47 | } 48 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/options.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "errors" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/internal/utils" 8 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/retry" 9 | "time" 10 | ) 11 | 12 | var ErrUnsupportedOption = errors.New("unsupported option") 13 | 14 | const ( 15 | SupportedOptionServerURL = "serverURL" 16 | SupportedOptionRetries = "retries" 17 | SupportedOptionTimeout = "timeout" 18 | SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride" 19 | SupportedOptionURLOverride = "urlOverride" 20 | ) 21 | 22 | type Options struct { 23 | ServerURL *string 24 | Retries *retry.Config 25 | Timeout *time.Duration 26 | URLOverride *string 27 | } 28 | 29 | type Option func(*Options, ...string) error 30 | 31 | // WithServerURL allows providing an alternative server URL. 32 | func WithServerURL(serverURL string) Option { 33 | return func(opts *Options, supportedOptions ...string) error { 34 | if !utils.Contains(supportedOptions, SupportedOptionServerURL) { 35 | return ErrUnsupportedOption 36 | } 37 | 38 | opts.ServerURL = &serverURL 39 | return nil 40 | } 41 | } 42 | 43 | // WithTemplatedServerURL allows providing an alternative server URL with templated parameters. 44 | func WithTemplatedServerURL(serverURL string, params map[string]string) Option { 45 | return func(opts *Options, supportedOptions ...string) error { 46 | if !utils.Contains(supportedOptions, SupportedOptionServerURL) { 47 | return ErrUnsupportedOption 48 | } 49 | 50 | if params != nil { 51 | serverURL = utils.ReplaceParameters(serverURL, params) 52 | } 53 | 54 | opts.ServerURL = &serverURL 55 | return nil 56 | } 57 | } 58 | 59 | // WithRetries allows customizing the default retry configuration. 60 | func WithRetries(config retry.Config) Option { 61 | return func(opts *Options, supportedOptions ...string) error { 62 | if !utils.Contains(supportedOptions, SupportedOptionRetries) { 63 | return ErrUnsupportedOption 64 | } 65 | 66 | opts.Retries = &config 67 | return nil 68 | } 69 | } 70 | 71 | // WithOperationTimeout allows setting the request timeout applied for an operation. 72 | func WithOperationTimeout(timeout time.Duration) Option { 73 | return func(opts *Options, supportedOptions ...string) error { 74 | if !utils.Contains(supportedOptions, SupportedOptionRetries) { 75 | return ErrUnsupportedOption 76 | } 77 | 78 | opts.Timeout = &timeout 79 | return nil 80 | } 81 | } 82 | 83 | // WithURLOverride allows overriding the URL. 84 | func WithURLOverride(urlOverride string) Option { 85 | return func(opts *Options, supportedOptions ...string) error { 86 | if !utils.Contains(supportedOptions, SupportedOptionURLOverride) { 87 | return ErrUnsupportedOption 88 | } 89 | 90 | opts.URLOverride = &urlOverride 91 | return nil 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/retrievefile.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type RetrieveFileRequest struct { 11 | // The ID of the file to use for this request 12 | FileID string `pathParam:"style=simple,explode=false,name=file_id"` 13 | } 14 | 15 | func (o *RetrieveFileRequest) GetFileID() string { 16 | if o == nil { 17 | return "" 18 | } 19 | return o.FileID 20 | } 21 | 22 | type RetrieveFileResponse struct { 23 | // HTTP response content type for this operation 24 | ContentType string 25 | // OK 26 | OpenAIFile *shared.OpenAIFile 27 | // HTTP response status code for this operation 28 | StatusCode int 29 | // Raw HTTP response; suitable for custom response parsing 30 | RawResponse *http.Response 31 | } 32 | 33 | func (o *RetrieveFileResponse) GetContentType() string { 34 | if o == nil { 35 | return "" 36 | } 37 | return o.ContentType 38 | } 39 | 40 | func (o *RetrieveFileResponse) GetOpenAIFile() *shared.OpenAIFile { 41 | if o == nil { 42 | return nil 43 | } 44 | return o.OpenAIFile 45 | } 46 | 47 | func (o *RetrieveFileResponse) GetStatusCode() int { 48 | if o == nil { 49 | return 0 50 | } 51 | return o.StatusCode 52 | } 53 | 54 | func (o *RetrieveFileResponse) GetRawResponse() *http.Response { 55 | if o == nil { 56 | return nil 57 | } 58 | return o.RawResponse 59 | } 60 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/retrievefinetune.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type RetrieveFineTuneRequest struct { 11 | // The ID of the fine-tune job 12 | // 13 | FineTuneID string `pathParam:"style=simple,explode=false,name=fine_tune_id"` 14 | } 15 | 16 | func (o *RetrieveFineTuneRequest) GetFineTuneID() string { 17 | if o == nil { 18 | return "" 19 | } 20 | return o.FineTuneID 21 | } 22 | 23 | type RetrieveFineTuneResponse struct { 24 | // HTTP response content type for this operation 25 | ContentType string 26 | // OK 27 | FineTune *shared.FineTune 28 | // HTTP response status code for this operation 29 | StatusCode int 30 | // Raw HTTP response; suitable for custom response parsing 31 | RawResponse *http.Response 32 | } 33 | 34 | func (o *RetrieveFineTuneResponse) GetContentType() string { 35 | if o == nil { 36 | return "" 37 | } 38 | return o.ContentType 39 | } 40 | 41 | func (o *RetrieveFineTuneResponse) GetFineTune() *shared.FineTune { 42 | if o == nil { 43 | return nil 44 | } 45 | return o.FineTune 46 | } 47 | 48 | func (o *RetrieveFineTuneResponse) GetStatusCode() int { 49 | if o == nil { 50 | return 0 51 | } 52 | return o.StatusCode 53 | } 54 | 55 | func (o *RetrieveFineTuneResponse) GetRawResponse() *http.Response { 56 | if o == nil { 57 | return nil 58 | } 59 | return o.RawResponse 60 | } 61 | -------------------------------------------------------------------------------- /internal/sdk/models/operations/retrievemodel.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package operations 4 | 5 | import ( 6 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/models/shared" 7 | "net/http" 8 | ) 9 | 10 | type RetrieveModelRequest struct { 11 | // The ID of the model to use for this request 12 | Model string `pathParam:"style=simple,explode=false,name=model"` 13 | } 14 | 15 | func (o *RetrieveModelRequest) GetModel() string { 16 | if o == nil { 17 | return "" 18 | } 19 | return o.Model 20 | } 21 | 22 | type RetrieveModelResponse struct { 23 | // HTTP response content type for this operation 24 | ContentType string 25 | // OK 26 | Model *shared.Model 27 | // HTTP response status code for this operation 28 | StatusCode int 29 | // Raw HTTP response; suitable for custom response parsing 30 | RawResponse *http.Response 31 | } 32 | 33 | func (o *RetrieveModelResponse) GetContentType() string { 34 | if o == nil { 35 | return "" 36 | } 37 | return o.ContentType 38 | } 39 | 40 | func (o *RetrieveModelResponse) GetModel() *shared.Model { 41 | if o == nil { 42 | return nil 43 | } 44 | return o.Model 45 | } 46 | 47 | func (o *RetrieveModelResponse) GetStatusCode() int { 48 | if o == nil { 49 | return 0 50 | } 51 | return o.StatusCode 52 | } 53 | 54 | func (o *RetrieveModelResponse) GetRawResponse() *http.Response { 55 | if o == nil { 56 | return nil 57 | } 58 | return o.RawResponse 59 | } 60 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/chatcompletionfunctions.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type ChatCompletionFunctions struct { 6 | // A description of what the function does, used by the model to choose when and how to call the function. 7 | Description *string `json:"description,omitempty"` 8 | // The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. 9 | Name string `json:"name"` 10 | // The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. 11 | // 12 | // To describe a function that accepts no parameters, provide the value `{"type": "object", "properties": {}}`. 13 | Parameters map[string]any `json:"parameters"` 14 | } 15 | 16 | func (o *ChatCompletionFunctions) GetDescription() *string { 17 | if o == nil { 18 | return nil 19 | } 20 | return o.Description 21 | } 22 | 23 | func (o *ChatCompletionFunctions) GetName() string { 24 | if o == nil { 25 | return "" 26 | } 27 | return o.Name 28 | } 29 | 30 | func (o *ChatCompletionFunctions) GetParameters() map[string]any { 31 | if o == nil { 32 | return map[string]any{} 33 | } 34 | return o.Parameters 35 | } 36 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/chatcompletionrequestmessage.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | ) 9 | 10 | // FunctionCall - The name and arguments of a function that should be called, as generated by the model. 11 | type FunctionCall struct { 12 | // The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. 13 | Arguments string `json:"arguments"` 14 | // The name of the function to call. 15 | Name string `json:"name"` 16 | } 17 | 18 | func (o *FunctionCall) GetArguments() string { 19 | if o == nil { 20 | return "" 21 | } 22 | return o.Arguments 23 | } 24 | 25 | func (o *FunctionCall) GetName() string { 26 | if o == nil { 27 | return "" 28 | } 29 | return o.Name 30 | } 31 | 32 | // Role - The role of the messages author. One of `system`, `user`, `assistant`, or `function`. 33 | type Role string 34 | 35 | const ( 36 | RoleSystem Role = "system" 37 | RoleUser Role = "user" 38 | RoleAssistant Role = "assistant" 39 | RoleFunction Role = "function" 40 | ) 41 | 42 | func (e Role) ToPointer() *Role { 43 | return &e 44 | } 45 | func (e *Role) UnmarshalJSON(data []byte) error { 46 | var v string 47 | if err := json.Unmarshal(data, &v); err != nil { 48 | return err 49 | } 50 | switch v { 51 | case "system": 52 | fallthrough 53 | case "user": 54 | fallthrough 55 | case "assistant": 56 | fallthrough 57 | case "function": 58 | *e = Role(v) 59 | return nil 60 | default: 61 | return fmt.Errorf("invalid value for Role: %v", v) 62 | } 63 | } 64 | 65 | type ChatCompletionRequestMessage struct { 66 | // The contents of the message. `content` is required for all messages, and may be null for assistant messages with function calls. 67 | Content *string `json:"content"` 68 | // The name and arguments of a function that should be called, as generated by the model. 69 | FunctionCall *FunctionCall `json:"function_call,omitempty"` 70 | // The name of the author of this message. `name` is required if role is `function`, and it should be the name of the function whose response is in the `content`. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters. 71 | Name *string `json:"name,omitempty"` 72 | // The role of the messages author. One of `system`, `user`, `assistant`, or `function`. 73 | Role Role `json:"role"` 74 | } 75 | 76 | func (o *ChatCompletionRequestMessage) GetContent() *string { 77 | if o == nil { 78 | return nil 79 | } 80 | return o.Content 81 | } 82 | 83 | func (o *ChatCompletionRequestMessage) GetFunctionCall() *FunctionCall { 84 | if o == nil { 85 | return nil 86 | } 87 | return o.FunctionCall 88 | } 89 | 90 | func (o *ChatCompletionRequestMessage) GetName() *string { 91 | if o == nil { 92 | return nil 93 | } 94 | return o.Name 95 | } 96 | 97 | func (o *ChatCompletionRequestMessage) GetRole() Role { 98 | if o == nil { 99 | return Role("") 100 | } 101 | return o.Role 102 | } 103 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/chatcompletionresponsemessage.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | ) 9 | 10 | // ChatCompletionResponseMessageFunctionCall - The name and arguments of a function that should be called, as generated by the model. 11 | type ChatCompletionResponseMessageFunctionCall struct { 12 | // The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. 13 | Arguments *string `json:"arguments,omitempty"` 14 | // The name of the function to call. 15 | Name *string `json:"name,omitempty"` 16 | } 17 | 18 | func (o *ChatCompletionResponseMessageFunctionCall) GetArguments() *string { 19 | if o == nil { 20 | return nil 21 | } 22 | return o.Arguments 23 | } 24 | 25 | func (o *ChatCompletionResponseMessageFunctionCall) GetName() *string { 26 | if o == nil { 27 | return nil 28 | } 29 | return o.Name 30 | } 31 | 32 | // ChatCompletionResponseMessageRole - The role of the author of this message. 33 | type ChatCompletionResponseMessageRole string 34 | 35 | const ( 36 | ChatCompletionResponseMessageRoleSystem ChatCompletionResponseMessageRole = "system" 37 | ChatCompletionResponseMessageRoleUser ChatCompletionResponseMessageRole = "user" 38 | ChatCompletionResponseMessageRoleAssistant ChatCompletionResponseMessageRole = "assistant" 39 | ChatCompletionResponseMessageRoleFunction ChatCompletionResponseMessageRole = "function" 40 | ) 41 | 42 | func (e ChatCompletionResponseMessageRole) ToPointer() *ChatCompletionResponseMessageRole { 43 | return &e 44 | } 45 | func (e *ChatCompletionResponseMessageRole) UnmarshalJSON(data []byte) error { 46 | var v string 47 | if err := json.Unmarshal(data, &v); err != nil { 48 | return err 49 | } 50 | switch v { 51 | case "system": 52 | fallthrough 53 | case "user": 54 | fallthrough 55 | case "assistant": 56 | fallthrough 57 | case "function": 58 | *e = ChatCompletionResponseMessageRole(v) 59 | return nil 60 | default: 61 | return fmt.Errorf("invalid value for ChatCompletionResponseMessageRole: %v", v) 62 | } 63 | } 64 | 65 | type ChatCompletionResponseMessage struct { 66 | // The contents of the message. 67 | Content *string `json:"content,omitempty"` 68 | // The name and arguments of a function that should be called, as generated by the model. 69 | FunctionCall *ChatCompletionResponseMessageFunctionCall `json:"function_call,omitempty"` 70 | // The role of the author of this message. 71 | Role ChatCompletionResponseMessageRole `json:"role"` 72 | } 73 | 74 | func (o *ChatCompletionResponseMessage) GetContent() *string { 75 | if o == nil { 76 | return nil 77 | } 78 | return o.Content 79 | } 80 | 81 | func (o *ChatCompletionResponseMessage) GetFunctionCall() *ChatCompletionResponseMessageFunctionCall { 82 | if o == nil { 83 | return nil 84 | } 85 | return o.FunctionCall 86 | } 87 | 88 | func (o *ChatCompletionResponseMessage) GetRole() ChatCompletionResponseMessageRole { 89 | if o == nil { 90 | return ChatCompletionResponseMessageRole("") 91 | } 92 | return o.Role 93 | } 94 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createchatcompletionresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | ) 9 | 10 | type FinishReason string 11 | 12 | const ( 13 | FinishReasonStop FinishReason = "stop" 14 | FinishReasonLength FinishReason = "length" 15 | FinishReasonFunctionCall FinishReason = "function_call" 16 | ) 17 | 18 | func (e FinishReason) ToPointer() *FinishReason { 19 | return &e 20 | } 21 | func (e *FinishReason) UnmarshalJSON(data []byte) error { 22 | var v string 23 | if err := json.Unmarshal(data, &v); err != nil { 24 | return err 25 | } 26 | switch v { 27 | case "stop": 28 | fallthrough 29 | case "length": 30 | fallthrough 31 | case "function_call": 32 | *e = FinishReason(v) 33 | return nil 34 | default: 35 | return fmt.Errorf("invalid value for FinishReason: %v", v) 36 | } 37 | } 38 | 39 | type Choices struct { 40 | FinishReason FinishReason `json:"finish_reason"` 41 | Index int64 `json:"index"` 42 | Message ChatCompletionResponseMessage `json:"message"` 43 | } 44 | 45 | func (o *Choices) GetFinishReason() FinishReason { 46 | if o == nil { 47 | return FinishReason("") 48 | } 49 | return o.FinishReason 50 | } 51 | 52 | func (o *Choices) GetIndex() int64 { 53 | if o == nil { 54 | return 0 55 | } 56 | return o.Index 57 | } 58 | 59 | func (o *Choices) GetMessage() ChatCompletionResponseMessage { 60 | if o == nil { 61 | return ChatCompletionResponseMessage{} 62 | } 63 | return o.Message 64 | } 65 | 66 | type Usage struct { 67 | CompletionTokens int64 `json:"completion_tokens"` 68 | PromptTokens int64 `json:"prompt_tokens"` 69 | TotalTokens int64 `json:"total_tokens"` 70 | } 71 | 72 | func (o *Usage) GetCompletionTokens() int64 { 73 | if o == nil { 74 | return 0 75 | } 76 | return o.CompletionTokens 77 | } 78 | 79 | func (o *Usage) GetPromptTokens() int64 { 80 | if o == nil { 81 | return 0 82 | } 83 | return o.PromptTokens 84 | } 85 | 86 | func (o *Usage) GetTotalTokens() int64 { 87 | if o == nil { 88 | return 0 89 | } 90 | return o.TotalTokens 91 | } 92 | 93 | type CreateChatCompletionResponse struct { 94 | Choices []Choices `json:"choices"` 95 | Created int64 `json:"created"` 96 | ID string `json:"id"` 97 | Model string `json:"model"` 98 | Object string `json:"object"` 99 | Usage *Usage `json:"usage,omitempty"` 100 | } 101 | 102 | func (o *CreateChatCompletionResponse) GetChoices() []Choices { 103 | if o == nil { 104 | return []Choices{} 105 | } 106 | return o.Choices 107 | } 108 | 109 | func (o *CreateChatCompletionResponse) GetCreated() int64 { 110 | if o == nil { 111 | return 0 112 | } 113 | return o.Created 114 | } 115 | 116 | func (o *CreateChatCompletionResponse) GetID() string { 117 | if o == nil { 118 | return "" 119 | } 120 | return o.ID 121 | } 122 | 123 | func (o *CreateChatCompletionResponse) GetModel() string { 124 | if o == nil { 125 | return "" 126 | } 127 | return o.Model 128 | } 129 | 130 | func (o *CreateChatCompletionResponse) GetObject() string { 131 | if o == nil { 132 | return "" 133 | } 134 | return o.Object 135 | } 136 | 137 | func (o *CreateChatCompletionResponse) GetUsage() *Usage { 138 | if o == nil { 139 | return nil 140 | } 141 | return o.Usage 142 | } 143 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createcompletionresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | ) 9 | 10 | type CreateCompletionResponseFinishReason string 11 | 12 | const ( 13 | CreateCompletionResponseFinishReasonStop CreateCompletionResponseFinishReason = "stop" 14 | CreateCompletionResponseFinishReasonLength CreateCompletionResponseFinishReason = "length" 15 | ) 16 | 17 | func (e CreateCompletionResponseFinishReason) ToPointer() *CreateCompletionResponseFinishReason { 18 | return &e 19 | } 20 | func (e *CreateCompletionResponseFinishReason) UnmarshalJSON(data []byte) error { 21 | var v string 22 | if err := json.Unmarshal(data, &v); err != nil { 23 | return err 24 | } 25 | switch v { 26 | case "stop": 27 | fallthrough 28 | case "length": 29 | *e = CreateCompletionResponseFinishReason(v) 30 | return nil 31 | default: 32 | return fmt.Errorf("invalid value for CreateCompletionResponseFinishReason: %v", v) 33 | } 34 | } 35 | 36 | type Logprobs struct { 37 | TextOffset []int64 `json:"text_offset,omitempty"` 38 | TokenLogprobs []float64 `json:"token_logprobs,omitempty"` 39 | Tokens []string `json:"tokens,omitempty"` 40 | TopLogprobs any `json:"top_logprobs,omitempty"` 41 | } 42 | 43 | func (o *Logprobs) GetTextOffset() []int64 { 44 | if o == nil { 45 | return nil 46 | } 47 | return o.TextOffset 48 | } 49 | 50 | func (o *Logprobs) GetTokenLogprobs() []float64 { 51 | if o == nil { 52 | return nil 53 | } 54 | return o.TokenLogprobs 55 | } 56 | 57 | func (o *Logprobs) GetTokens() []string { 58 | if o == nil { 59 | return nil 60 | } 61 | return o.Tokens 62 | } 63 | 64 | func (o *Logprobs) GetTopLogprobs() any { 65 | if o == nil { 66 | return nil 67 | } 68 | return o.TopLogprobs 69 | } 70 | 71 | type CreateCompletionResponseChoices struct { 72 | FinishReason CreateCompletionResponseFinishReason `json:"finish_reason"` 73 | Index int64 `json:"index"` 74 | Logprobs *Logprobs `json:"logprobs"` 75 | Text string `json:"text"` 76 | } 77 | 78 | func (o *CreateCompletionResponseChoices) GetFinishReason() CreateCompletionResponseFinishReason { 79 | if o == nil { 80 | return CreateCompletionResponseFinishReason("") 81 | } 82 | return o.FinishReason 83 | } 84 | 85 | func (o *CreateCompletionResponseChoices) GetIndex() int64 { 86 | if o == nil { 87 | return 0 88 | } 89 | return o.Index 90 | } 91 | 92 | func (o *CreateCompletionResponseChoices) GetLogprobs() *Logprobs { 93 | if o == nil { 94 | return nil 95 | } 96 | return o.Logprobs 97 | } 98 | 99 | func (o *CreateCompletionResponseChoices) GetText() string { 100 | if o == nil { 101 | return "" 102 | } 103 | return o.Text 104 | } 105 | 106 | type CreateCompletionResponseUsage struct { 107 | CompletionTokens int64 `json:"completion_tokens"` 108 | PromptTokens int64 `json:"prompt_tokens"` 109 | TotalTokens int64 `json:"total_tokens"` 110 | } 111 | 112 | func (o *CreateCompletionResponseUsage) GetCompletionTokens() int64 { 113 | if o == nil { 114 | return 0 115 | } 116 | return o.CompletionTokens 117 | } 118 | 119 | func (o *CreateCompletionResponseUsage) GetPromptTokens() int64 { 120 | if o == nil { 121 | return 0 122 | } 123 | return o.PromptTokens 124 | } 125 | 126 | func (o *CreateCompletionResponseUsage) GetTotalTokens() int64 { 127 | if o == nil { 128 | return 0 129 | } 130 | return o.TotalTokens 131 | } 132 | 133 | type CreateCompletionResponse struct { 134 | Choices []CreateCompletionResponseChoices `json:"choices"` 135 | Created int64 `json:"created"` 136 | ID string `json:"id"` 137 | Model string `json:"model"` 138 | Object string `json:"object"` 139 | Usage *CreateCompletionResponseUsage `json:"usage,omitempty"` 140 | } 141 | 142 | func (o *CreateCompletionResponse) GetChoices() []CreateCompletionResponseChoices { 143 | if o == nil { 144 | return []CreateCompletionResponseChoices{} 145 | } 146 | return o.Choices 147 | } 148 | 149 | func (o *CreateCompletionResponse) GetCreated() int64 { 150 | if o == nil { 151 | return 0 152 | } 153 | return o.Created 154 | } 155 | 156 | func (o *CreateCompletionResponse) GetID() string { 157 | if o == nil { 158 | return "" 159 | } 160 | return o.ID 161 | } 162 | 163 | func (o *CreateCompletionResponse) GetModel() string { 164 | if o == nil { 165 | return "" 166 | } 167 | return o.Model 168 | } 169 | 170 | func (o *CreateCompletionResponse) GetObject() string { 171 | if o == nil { 172 | return "" 173 | } 174 | return o.Object 175 | } 176 | 177 | func (o *CreateCompletionResponse) GetUsage() *CreateCompletionResponseUsage { 178 | if o == nil { 179 | return nil 180 | } 181 | return o.Usage 182 | } 183 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createeditrequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/internal/utils" 9 | ) 10 | 11 | // CreateEditRequestModel - ID of the model to use. You can use the `text-davinci-edit-001` or `code-davinci-edit-001` model with this endpoint. 12 | type CreateEditRequestModel string 13 | 14 | const ( 15 | CreateEditRequestModelTextDavinciEdit001 CreateEditRequestModel = "text-davinci-edit-001" 16 | CreateEditRequestModelCodeDavinciEdit001 CreateEditRequestModel = "code-davinci-edit-001" 17 | ) 18 | 19 | func (e CreateEditRequestModel) ToPointer() *CreateEditRequestModel { 20 | return &e 21 | } 22 | func (e *CreateEditRequestModel) UnmarshalJSON(data []byte) error { 23 | var v string 24 | if err := json.Unmarshal(data, &v); err != nil { 25 | return err 26 | } 27 | switch v { 28 | case "text-davinci-edit-001": 29 | fallthrough 30 | case "code-davinci-edit-001": 31 | *e = CreateEditRequestModel(v) 32 | return nil 33 | default: 34 | return fmt.Errorf("invalid value for CreateEditRequestModel: %v", v) 35 | } 36 | } 37 | 38 | type CreateEditRequest struct { 39 | // The input text to use as a starting point for the edit. 40 | Input *string `default:"" json:"input"` 41 | // The instruction that tells the model how to edit the prompt. 42 | Instruction string `json:"instruction"` 43 | // ID of the model to use. You can use the `text-davinci-edit-001` or `code-davinci-edit-001` model with this endpoint. 44 | Model CreateEditRequestModel `json:"model"` 45 | // How many edits to generate for the input and instruction. 46 | N *int64 `default:"1" json:"n"` 47 | // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. 48 | // 49 | // We generally recommend altering this or `top_p` but not both. 50 | // 51 | Temperature *float64 `default:"1" json:"temperature"` 52 | // An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. 53 | // 54 | // We generally recommend altering this or `temperature` but not both. 55 | // 56 | TopP *float64 `default:"1" json:"top_p"` 57 | } 58 | 59 | func (c CreateEditRequest) MarshalJSON() ([]byte, error) { 60 | return utils.MarshalJSON(c, "", false) 61 | } 62 | 63 | func (c *CreateEditRequest) UnmarshalJSON(data []byte) error { 64 | if err := utils.UnmarshalJSON(data, &c, "", false, false); err != nil { 65 | return err 66 | } 67 | return nil 68 | } 69 | 70 | func (o *CreateEditRequest) GetInput() *string { 71 | if o == nil { 72 | return nil 73 | } 74 | return o.Input 75 | } 76 | 77 | func (o *CreateEditRequest) GetInstruction() string { 78 | if o == nil { 79 | return "" 80 | } 81 | return o.Instruction 82 | } 83 | 84 | func (o *CreateEditRequest) GetModel() CreateEditRequestModel { 85 | if o == nil { 86 | return CreateEditRequestModel("") 87 | } 88 | return o.Model 89 | } 90 | 91 | func (o *CreateEditRequest) GetN() *int64 { 92 | if o == nil { 93 | return nil 94 | } 95 | return o.N 96 | } 97 | 98 | func (o *CreateEditRequest) GetTemperature() *float64 { 99 | if o == nil { 100 | return nil 101 | } 102 | return o.Temperature 103 | } 104 | 105 | func (o *CreateEditRequest) GetTopP() *float64 { 106 | if o == nil { 107 | return nil 108 | } 109 | return o.TopP 110 | } 111 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createeditresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | ) 9 | 10 | type CreateEditResponseFinishReason string 11 | 12 | const ( 13 | CreateEditResponseFinishReasonStop CreateEditResponseFinishReason = "stop" 14 | CreateEditResponseFinishReasonLength CreateEditResponseFinishReason = "length" 15 | ) 16 | 17 | func (e CreateEditResponseFinishReason) ToPointer() *CreateEditResponseFinishReason { 18 | return &e 19 | } 20 | func (e *CreateEditResponseFinishReason) UnmarshalJSON(data []byte) error { 21 | var v string 22 | if err := json.Unmarshal(data, &v); err != nil { 23 | return err 24 | } 25 | switch v { 26 | case "stop": 27 | fallthrough 28 | case "length": 29 | *e = CreateEditResponseFinishReason(v) 30 | return nil 31 | default: 32 | return fmt.Errorf("invalid value for CreateEditResponseFinishReason: %v", v) 33 | } 34 | } 35 | 36 | type CreateEditResponseChoices struct { 37 | FinishReason CreateEditResponseFinishReason `json:"finish_reason"` 38 | Index int64 `json:"index"` 39 | Text string `json:"text"` 40 | } 41 | 42 | func (o *CreateEditResponseChoices) GetFinishReason() CreateEditResponseFinishReason { 43 | if o == nil { 44 | return CreateEditResponseFinishReason("") 45 | } 46 | return o.FinishReason 47 | } 48 | 49 | func (o *CreateEditResponseChoices) GetIndex() int64 { 50 | if o == nil { 51 | return 0 52 | } 53 | return o.Index 54 | } 55 | 56 | func (o *CreateEditResponseChoices) GetText() string { 57 | if o == nil { 58 | return "" 59 | } 60 | return o.Text 61 | } 62 | 63 | type CreateEditResponseUsage struct { 64 | CompletionTokens int64 `json:"completion_tokens"` 65 | PromptTokens int64 `json:"prompt_tokens"` 66 | TotalTokens int64 `json:"total_tokens"` 67 | } 68 | 69 | func (o *CreateEditResponseUsage) GetCompletionTokens() int64 { 70 | if o == nil { 71 | return 0 72 | } 73 | return o.CompletionTokens 74 | } 75 | 76 | func (o *CreateEditResponseUsage) GetPromptTokens() int64 { 77 | if o == nil { 78 | return 0 79 | } 80 | return o.PromptTokens 81 | } 82 | 83 | func (o *CreateEditResponseUsage) GetTotalTokens() int64 { 84 | if o == nil { 85 | return 0 86 | } 87 | return o.TotalTokens 88 | } 89 | 90 | type CreateEditResponse struct { 91 | Choices []CreateEditResponseChoices `json:"choices"` 92 | Created int64 `json:"created"` 93 | Object string `json:"object"` 94 | Usage CreateEditResponseUsage `json:"usage"` 95 | } 96 | 97 | func (o *CreateEditResponse) GetChoices() []CreateEditResponseChoices { 98 | if o == nil { 99 | return []CreateEditResponseChoices{} 100 | } 101 | return o.Choices 102 | } 103 | 104 | func (o *CreateEditResponse) GetCreated() int64 { 105 | if o == nil { 106 | return 0 107 | } 108 | return o.Created 109 | } 110 | 111 | func (o *CreateEditResponse) GetObject() string { 112 | if o == nil { 113 | return "" 114 | } 115 | return o.Object 116 | } 117 | 118 | func (o *CreateEditResponse) GetUsage() CreateEditResponseUsage { 119 | if o == nil { 120 | return CreateEditResponseUsage{} 121 | } 122 | return o.Usage 123 | } 124 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createembeddingresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type Data struct { 6 | Embedding []float64 `json:"embedding"` 7 | Index int64 `json:"index"` 8 | Object string `json:"object"` 9 | } 10 | 11 | func (o *Data) GetEmbedding() []float64 { 12 | if o == nil { 13 | return []float64{} 14 | } 15 | return o.Embedding 16 | } 17 | 18 | func (o *Data) GetIndex() int64 { 19 | if o == nil { 20 | return 0 21 | } 22 | return o.Index 23 | } 24 | 25 | func (o *Data) GetObject() string { 26 | if o == nil { 27 | return "" 28 | } 29 | return o.Object 30 | } 31 | 32 | type CreateEmbeddingResponseUsage struct { 33 | PromptTokens int64 `json:"prompt_tokens"` 34 | TotalTokens int64 `json:"total_tokens"` 35 | } 36 | 37 | func (o *CreateEmbeddingResponseUsage) GetPromptTokens() int64 { 38 | if o == nil { 39 | return 0 40 | } 41 | return o.PromptTokens 42 | } 43 | 44 | func (o *CreateEmbeddingResponseUsage) GetTotalTokens() int64 { 45 | if o == nil { 46 | return 0 47 | } 48 | return o.TotalTokens 49 | } 50 | 51 | type CreateEmbeddingResponse struct { 52 | Data []Data `json:"data"` 53 | Object string `json:"object"` 54 | Usage CreateEmbeddingResponseUsage `json:"usage"` 55 | } 56 | 57 | func (o *CreateEmbeddingResponse) GetData() []Data { 58 | if o == nil { 59 | return []Data{} 60 | } 61 | return o.Data 62 | } 63 | 64 | func (o *CreateEmbeddingResponse) GetObject() string { 65 | if o == nil { 66 | return "" 67 | } 68 | return o.Object 69 | } 70 | 71 | func (o *CreateEmbeddingResponse) GetUsage() CreateEmbeddingResponseUsage { 72 | if o == nil { 73 | return CreateEmbeddingResponseUsage{} 74 | } 75 | return o.Usage 76 | } 77 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createfilerequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type File struct { 6 | Content []byte `multipartForm:"content"` 7 | FileName string `multipartForm:"name=file"` 8 | } 9 | 10 | func (o *File) GetContent() []byte { 11 | if o == nil { 12 | return []byte{} 13 | } 14 | return o.Content 15 | } 16 | 17 | func (o *File) GetFileName() string { 18 | if o == nil { 19 | return "" 20 | } 21 | return o.FileName 22 | } 23 | 24 | type CreateFileRequest struct { 25 | // Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded. 26 | // 27 | // If the `purpose` is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data). 28 | // 29 | File File `multipartForm:"file"` 30 | // The intended purpose of the uploaded documents. 31 | // 32 | // Use "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file. 33 | // 34 | Purpose string `multipartForm:"name=purpose"` 35 | } 36 | 37 | func (o *CreateFileRequest) GetFile() File { 38 | if o == nil { 39 | return File{} 40 | } 41 | return o.File 42 | } 43 | 44 | func (o *CreateFileRequest) GetPurpose() string { 45 | if o == nil { 46 | return "" 47 | } 48 | return o.Purpose 49 | } 50 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createimagerequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/internal/utils" 9 | ) 10 | 11 | // CreateImageRequestResponseFormat - The format in which the generated images are returned. Must be one of `url` or `b64_json`. 12 | type CreateImageRequestResponseFormat string 13 | 14 | const ( 15 | CreateImageRequestResponseFormatURL CreateImageRequestResponseFormat = "url" 16 | CreateImageRequestResponseFormatB64JSON CreateImageRequestResponseFormat = "b64_json" 17 | ) 18 | 19 | func (e CreateImageRequestResponseFormat) ToPointer() *CreateImageRequestResponseFormat { 20 | return &e 21 | } 22 | func (e *CreateImageRequestResponseFormat) UnmarshalJSON(data []byte) error { 23 | var v string 24 | if err := json.Unmarshal(data, &v); err != nil { 25 | return err 26 | } 27 | switch v { 28 | case "url": 29 | fallthrough 30 | case "b64_json": 31 | *e = CreateImageRequestResponseFormat(v) 32 | return nil 33 | default: 34 | return fmt.Errorf("invalid value for CreateImageRequestResponseFormat: %v", v) 35 | } 36 | } 37 | 38 | // CreateImageRequestSize - The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 39 | type CreateImageRequestSize string 40 | 41 | const ( 42 | CreateImageRequestSizeTwoHundredAndFiftySixx256 CreateImageRequestSize = "256x256" 43 | CreateImageRequestSizeFiveHundredAndTwelvex512 CreateImageRequestSize = "512x512" 44 | CreateImageRequestSizeOneThousandAndTwentyFourx1024 CreateImageRequestSize = "1024x1024" 45 | ) 46 | 47 | func (e CreateImageRequestSize) ToPointer() *CreateImageRequestSize { 48 | return &e 49 | } 50 | func (e *CreateImageRequestSize) UnmarshalJSON(data []byte) error { 51 | var v string 52 | if err := json.Unmarshal(data, &v); err != nil { 53 | return err 54 | } 55 | switch v { 56 | case "256x256": 57 | fallthrough 58 | case "512x512": 59 | fallthrough 60 | case "1024x1024": 61 | *e = CreateImageRequestSize(v) 62 | return nil 63 | default: 64 | return fmt.Errorf("invalid value for CreateImageRequestSize: %v", v) 65 | } 66 | } 67 | 68 | type CreateImageRequest struct { 69 | // The number of images to generate. Must be between 1 and 10. 70 | N *int64 `default:"1" json:"n"` 71 | // A text description of the desired image(s). The maximum length is 1000 characters. 72 | Prompt string `json:"prompt"` 73 | // The format in which the generated images are returned. Must be one of `url` or `b64_json`. 74 | ResponseFormat *CreateImageRequestResponseFormat `default:"url" json:"response_format"` 75 | // The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. 76 | Size *CreateImageRequestSize `default:"1024x1024" json:"size"` 77 | // A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 78 | // 79 | User *string `json:"user,omitempty"` 80 | } 81 | 82 | func (c CreateImageRequest) MarshalJSON() ([]byte, error) { 83 | return utils.MarshalJSON(c, "", false) 84 | } 85 | 86 | func (c *CreateImageRequest) UnmarshalJSON(data []byte) error { 87 | if err := utils.UnmarshalJSON(data, &c, "", false, false); err != nil { 88 | return err 89 | } 90 | return nil 91 | } 92 | 93 | func (o *CreateImageRequest) GetN() *int64 { 94 | if o == nil { 95 | return nil 96 | } 97 | return o.N 98 | } 99 | 100 | func (o *CreateImageRequest) GetPrompt() string { 101 | if o == nil { 102 | return "" 103 | } 104 | return o.Prompt 105 | } 106 | 107 | func (o *CreateImageRequest) GetResponseFormat() *CreateImageRequestResponseFormat { 108 | if o == nil { 109 | return nil 110 | } 111 | return o.ResponseFormat 112 | } 113 | 114 | func (o *CreateImageRequest) GetSize() *CreateImageRequestSize { 115 | if o == nil { 116 | return nil 117 | } 118 | return o.Size 119 | } 120 | 121 | func (o *CreateImageRequest) GetUser() *string { 122 | if o == nil { 123 | return nil 124 | } 125 | return o.User 126 | } 127 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createmoderationresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type Categories struct { 6 | Hate bool `json:"hate"` 7 | HateThreatening bool `json:"hate/threatening"` 8 | SelfHarm bool `json:"self-harm"` 9 | Sexual bool `json:"sexual"` 10 | SexualMinors bool `json:"sexual/minors"` 11 | Violence bool `json:"violence"` 12 | ViolenceGraphic bool `json:"violence/graphic"` 13 | } 14 | 15 | func (o *Categories) GetHate() bool { 16 | if o == nil { 17 | return false 18 | } 19 | return o.Hate 20 | } 21 | 22 | func (o *Categories) GetHateThreatening() bool { 23 | if o == nil { 24 | return false 25 | } 26 | return o.HateThreatening 27 | } 28 | 29 | func (o *Categories) GetSelfHarm() bool { 30 | if o == nil { 31 | return false 32 | } 33 | return o.SelfHarm 34 | } 35 | 36 | func (o *Categories) GetSexual() bool { 37 | if o == nil { 38 | return false 39 | } 40 | return o.Sexual 41 | } 42 | 43 | func (o *Categories) GetSexualMinors() bool { 44 | if o == nil { 45 | return false 46 | } 47 | return o.SexualMinors 48 | } 49 | 50 | func (o *Categories) GetViolence() bool { 51 | if o == nil { 52 | return false 53 | } 54 | return o.Violence 55 | } 56 | 57 | func (o *Categories) GetViolenceGraphic() bool { 58 | if o == nil { 59 | return false 60 | } 61 | return o.ViolenceGraphic 62 | } 63 | 64 | type CategoryScores struct { 65 | Hate float64 `json:"hate"` 66 | HateThreatening float64 `json:"hate/threatening"` 67 | SelfHarm float64 `json:"self-harm"` 68 | Sexual float64 `json:"sexual"` 69 | SexualMinors float64 `json:"sexual/minors"` 70 | Violence float64 `json:"violence"` 71 | ViolenceGraphic float64 `json:"violence/graphic"` 72 | } 73 | 74 | func (o *CategoryScores) GetHate() float64 { 75 | if o == nil { 76 | return 0.0 77 | } 78 | return o.Hate 79 | } 80 | 81 | func (o *CategoryScores) GetHateThreatening() float64 { 82 | if o == nil { 83 | return 0.0 84 | } 85 | return o.HateThreatening 86 | } 87 | 88 | func (o *CategoryScores) GetSelfHarm() float64 { 89 | if o == nil { 90 | return 0.0 91 | } 92 | return o.SelfHarm 93 | } 94 | 95 | func (o *CategoryScores) GetSexual() float64 { 96 | if o == nil { 97 | return 0.0 98 | } 99 | return o.Sexual 100 | } 101 | 102 | func (o *CategoryScores) GetSexualMinors() float64 { 103 | if o == nil { 104 | return 0.0 105 | } 106 | return o.SexualMinors 107 | } 108 | 109 | func (o *CategoryScores) GetViolence() float64 { 110 | if o == nil { 111 | return 0.0 112 | } 113 | return o.Violence 114 | } 115 | 116 | func (o *CategoryScores) GetViolenceGraphic() float64 { 117 | if o == nil { 118 | return 0.0 119 | } 120 | return o.ViolenceGraphic 121 | } 122 | 123 | type Results struct { 124 | Categories Categories `json:"categories"` 125 | CategoryScores CategoryScores `json:"category_scores"` 126 | Flagged bool `json:"flagged"` 127 | } 128 | 129 | func (o *Results) GetCategories() Categories { 130 | if o == nil { 131 | return Categories{} 132 | } 133 | return o.Categories 134 | } 135 | 136 | func (o *Results) GetCategoryScores() CategoryScores { 137 | if o == nil { 138 | return CategoryScores{} 139 | } 140 | return o.CategoryScores 141 | } 142 | 143 | func (o *Results) GetFlagged() bool { 144 | if o == nil { 145 | return false 146 | } 147 | return o.Flagged 148 | } 149 | 150 | type CreateModerationResponse struct { 151 | ID string `json:"id"` 152 | Model string `json:"model"` 153 | Results []Results `json:"results"` 154 | } 155 | 156 | func (o *CreateModerationResponse) GetID() string { 157 | if o == nil { 158 | return "" 159 | } 160 | return o.ID 161 | } 162 | 163 | func (o *CreateModerationResponse) GetModel() string { 164 | if o == nil { 165 | return "" 166 | } 167 | return o.Model 168 | } 169 | 170 | func (o *CreateModerationResponse) GetResults() []Results { 171 | if o == nil { 172 | return []Results{} 173 | } 174 | return o.Results 175 | } 176 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createtranscriptionresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type CreateTranscriptionResponse struct { 6 | Text string `json:"text"` 7 | } 8 | 9 | func (o *CreateTranscriptionResponse) GetText() string { 10 | if o == nil { 11 | return "" 12 | } 13 | return o.Text 14 | } 15 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createtranslationrequest.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/internal/utils" 9 | ) 10 | 11 | type CreateTranslationRequestFile struct { 12 | Content []byte `multipartForm:"content"` 13 | FileName string `multipartForm:"name=file"` 14 | } 15 | 16 | func (o *CreateTranslationRequestFile) GetContent() []byte { 17 | if o == nil { 18 | return []byte{} 19 | } 20 | return o.Content 21 | } 22 | 23 | func (o *CreateTranslationRequestFile) GetFileName() string { 24 | if o == nil { 25 | return "" 26 | } 27 | return o.FileName 28 | } 29 | 30 | // CreateTranslationRequestModel - ID of the model to use. Only `whisper-1` is currently available. 31 | type CreateTranslationRequestModel string 32 | 33 | const ( 34 | CreateTranslationRequestModelWhisper1 CreateTranslationRequestModel = "whisper-1" 35 | ) 36 | 37 | func (e CreateTranslationRequestModel) ToPointer() *CreateTranslationRequestModel { 38 | return &e 39 | } 40 | func (e *CreateTranslationRequestModel) UnmarshalJSON(data []byte) error { 41 | var v string 42 | if err := json.Unmarshal(data, &v); err != nil { 43 | return err 44 | } 45 | switch v { 46 | case "whisper-1": 47 | *e = CreateTranslationRequestModel(v) 48 | return nil 49 | default: 50 | return fmt.Errorf("invalid value for CreateTranslationRequestModel: %v", v) 51 | } 52 | } 53 | 54 | type CreateTranslationRequest struct { 55 | // The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. 56 | // 57 | File CreateTranslationRequestFile `multipartForm:"file"` 58 | // ID of the model to use. Only `whisper-1` is currently available. 59 | // 60 | Model CreateTranslationRequestModel `multipartForm:"name=model"` 61 | // An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. 62 | // 63 | Prompt *string `multipartForm:"name=prompt"` 64 | // The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt. 65 | // 66 | ResponseFormat *string `default:"json" multipartForm:"name=response_format"` 67 | // The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. 68 | // 69 | Temperature *float64 `default:"0" multipartForm:"name=temperature"` 70 | } 71 | 72 | func (c CreateTranslationRequest) MarshalJSON() ([]byte, error) { 73 | return utils.MarshalJSON(c, "", false) 74 | } 75 | 76 | func (c *CreateTranslationRequest) UnmarshalJSON(data []byte) error { 77 | if err := utils.UnmarshalJSON(data, &c, "", false, false); err != nil { 78 | return err 79 | } 80 | return nil 81 | } 82 | 83 | func (o *CreateTranslationRequest) GetFile() CreateTranslationRequestFile { 84 | if o == nil { 85 | return CreateTranslationRequestFile{} 86 | } 87 | return o.File 88 | } 89 | 90 | func (o *CreateTranslationRequest) GetModel() CreateTranslationRequestModel { 91 | if o == nil { 92 | return CreateTranslationRequestModel("") 93 | } 94 | return o.Model 95 | } 96 | 97 | func (o *CreateTranslationRequest) GetPrompt() *string { 98 | if o == nil { 99 | return nil 100 | } 101 | return o.Prompt 102 | } 103 | 104 | func (o *CreateTranslationRequest) GetResponseFormat() *string { 105 | if o == nil { 106 | return nil 107 | } 108 | return o.ResponseFormat 109 | } 110 | 111 | func (o *CreateTranslationRequest) GetTemperature() *float64 { 112 | if o == nil { 113 | return nil 114 | } 115 | return o.Temperature 116 | } 117 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/createtranslationresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type CreateTranslationResponse struct { 6 | Text string `json:"text"` 7 | } 8 | 9 | func (o *CreateTranslationResponse) GetText() string { 10 | if o == nil { 11 | return "" 12 | } 13 | return o.Text 14 | } 15 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/deletefileresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type DeleteFileResponse struct { 6 | Deleted bool `json:"deleted"` 7 | ID string `json:"id"` 8 | Object string `json:"object"` 9 | } 10 | 11 | func (o *DeleteFileResponse) GetDeleted() bool { 12 | if o == nil { 13 | return false 14 | } 15 | return o.Deleted 16 | } 17 | 18 | func (o *DeleteFileResponse) GetID() string { 19 | if o == nil { 20 | return "" 21 | } 22 | return o.ID 23 | } 24 | 25 | func (o *DeleteFileResponse) GetObject() string { 26 | if o == nil { 27 | return "" 28 | } 29 | return o.Object 30 | } 31 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/deletemodelresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type DeleteModelResponse struct { 6 | Deleted bool `json:"deleted"` 7 | ID string `json:"id"` 8 | Object string `json:"object"` 9 | } 10 | 11 | func (o *DeleteModelResponse) GetDeleted() bool { 12 | if o == nil { 13 | return false 14 | } 15 | return o.Deleted 16 | } 17 | 18 | func (o *DeleteModelResponse) GetID() string { 19 | if o == nil { 20 | return "" 21 | } 22 | return o.ID 23 | } 24 | 25 | func (o *DeleteModelResponse) GetObject() string { 26 | if o == nil { 27 | return "" 28 | } 29 | return o.Object 30 | } 31 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/finetune.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type Hyperparams struct { 6 | BatchSize int64 `json:"batch_size"` 7 | ClassificationNClasses *int64 `json:"classification_n_classes,omitempty"` 8 | ClassificationPositiveClass *string `json:"classification_positive_class,omitempty"` 9 | ComputeClassificationMetrics *bool `json:"compute_classification_metrics,omitempty"` 10 | LearningRateMultiplier float64 `json:"learning_rate_multiplier"` 11 | NEpochs int64 `json:"n_epochs"` 12 | PromptLossWeight float64 `json:"prompt_loss_weight"` 13 | } 14 | 15 | func (o *Hyperparams) GetBatchSize() int64 { 16 | if o == nil { 17 | return 0 18 | } 19 | return o.BatchSize 20 | } 21 | 22 | func (o *Hyperparams) GetClassificationNClasses() *int64 { 23 | if o == nil { 24 | return nil 25 | } 26 | return o.ClassificationNClasses 27 | } 28 | 29 | func (o *Hyperparams) GetClassificationPositiveClass() *string { 30 | if o == nil { 31 | return nil 32 | } 33 | return o.ClassificationPositiveClass 34 | } 35 | 36 | func (o *Hyperparams) GetComputeClassificationMetrics() *bool { 37 | if o == nil { 38 | return nil 39 | } 40 | return o.ComputeClassificationMetrics 41 | } 42 | 43 | func (o *Hyperparams) GetLearningRateMultiplier() float64 { 44 | if o == nil { 45 | return 0.0 46 | } 47 | return o.LearningRateMultiplier 48 | } 49 | 50 | func (o *Hyperparams) GetNEpochs() int64 { 51 | if o == nil { 52 | return 0 53 | } 54 | return o.NEpochs 55 | } 56 | 57 | func (o *Hyperparams) GetPromptLossWeight() float64 { 58 | if o == nil { 59 | return 0.0 60 | } 61 | return o.PromptLossWeight 62 | } 63 | 64 | type FineTune struct { 65 | CreatedAt int64 `json:"created_at"` 66 | Events []FineTuneEvent `json:"events,omitempty"` 67 | FineTunedModel *string `json:"fine_tuned_model"` 68 | Hyperparams Hyperparams `json:"hyperparams"` 69 | ID string `json:"id"` 70 | Model string `json:"model"` 71 | Object string `json:"object"` 72 | OrganizationID string `json:"organization_id"` 73 | ResultFiles []OpenAIFile `json:"result_files"` 74 | Status string `json:"status"` 75 | TrainingFiles []OpenAIFile `json:"training_files"` 76 | UpdatedAt int64 `json:"updated_at"` 77 | ValidationFiles []OpenAIFile `json:"validation_files"` 78 | } 79 | 80 | func (o *FineTune) GetCreatedAt() int64 { 81 | if o == nil { 82 | return 0 83 | } 84 | return o.CreatedAt 85 | } 86 | 87 | func (o *FineTune) GetEvents() []FineTuneEvent { 88 | if o == nil { 89 | return nil 90 | } 91 | return o.Events 92 | } 93 | 94 | func (o *FineTune) GetFineTunedModel() *string { 95 | if o == nil { 96 | return nil 97 | } 98 | return o.FineTunedModel 99 | } 100 | 101 | func (o *FineTune) GetHyperparams() Hyperparams { 102 | if o == nil { 103 | return Hyperparams{} 104 | } 105 | return o.Hyperparams 106 | } 107 | 108 | func (o *FineTune) GetID() string { 109 | if o == nil { 110 | return "" 111 | } 112 | return o.ID 113 | } 114 | 115 | func (o *FineTune) GetModel() string { 116 | if o == nil { 117 | return "" 118 | } 119 | return o.Model 120 | } 121 | 122 | func (o *FineTune) GetObject() string { 123 | if o == nil { 124 | return "" 125 | } 126 | return o.Object 127 | } 128 | 129 | func (o *FineTune) GetOrganizationID() string { 130 | if o == nil { 131 | return "" 132 | } 133 | return o.OrganizationID 134 | } 135 | 136 | func (o *FineTune) GetResultFiles() []OpenAIFile { 137 | if o == nil { 138 | return []OpenAIFile{} 139 | } 140 | return o.ResultFiles 141 | } 142 | 143 | func (o *FineTune) GetStatus() string { 144 | if o == nil { 145 | return "" 146 | } 147 | return o.Status 148 | } 149 | 150 | func (o *FineTune) GetTrainingFiles() []OpenAIFile { 151 | if o == nil { 152 | return []OpenAIFile{} 153 | } 154 | return o.TrainingFiles 155 | } 156 | 157 | func (o *FineTune) GetUpdatedAt() int64 { 158 | if o == nil { 159 | return 0 160 | } 161 | return o.UpdatedAt 162 | } 163 | 164 | func (o *FineTune) GetValidationFiles() []OpenAIFile { 165 | if o == nil { 166 | return []OpenAIFile{} 167 | } 168 | return o.ValidationFiles 169 | } 170 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/finetuneevent.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type FineTuneEvent struct { 6 | CreatedAt int64 `json:"created_at"` 7 | Level string `json:"level"` 8 | Message string `json:"message"` 9 | Object string `json:"object"` 10 | } 11 | 12 | func (o *FineTuneEvent) GetCreatedAt() int64 { 13 | if o == nil { 14 | return 0 15 | } 16 | return o.CreatedAt 17 | } 18 | 19 | func (o *FineTuneEvent) GetLevel() string { 20 | if o == nil { 21 | return "" 22 | } 23 | return o.Level 24 | } 25 | 26 | func (o *FineTuneEvent) GetMessage() string { 27 | if o == nil { 28 | return "" 29 | } 30 | return o.Message 31 | } 32 | 33 | func (o *FineTuneEvent) GetObject() string { 34 | if o == nil { 35 | return "" 36 | } 37 | return o.Object 38 | } 39 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/imagesresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type ImagesResponseData struct { 6 | B64JSON *string `json:"b64_json,omitempty"` 7 | URL *string `json:"url,omitempty"` 8 | } 9 | 10 | func (o *ImagesResponseData) GetB64JSON() *string { 11 | if o == nil { 12 | return nil 13 | } 14 | return o.B64JSON 15 | } 16 | 17 | func (o *ImagesResponseData) GetURL() *string { 18 | if o == nil { 19 | return nil 20 | } 21 | return o.URL 22 | } 23 | 24 | type ImagesResponse struct { 25 | Created int64 `json:"created"` 26 | Data []ImagesResponseData `json:"data"` 27 | } 28 | 29 | func (o *ImagesResponse) GetCreated() int64 { 30 | if o == nil { 31 | return 0 32 | } 33 | return o.Created 34 | } 35 | 36 | func (o *ImagesResponse) GetData() []ImagesResponseData { 37 | if o == nil { 38 | return []ImagesResponseData{} 39 | } 40 | return o.Data 41 | } 42 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/listfilesresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type ListFilesResponse struct { 6 | Data []OpenAIFile `json:"data"` 7 | Object string `json:"object"` 8 | } 9 | 10 | func (o *ListFilesResponse) GetData() []OpenAIFile { 11 | if o == nil { 12 | return []OpenAIFile{} 13 | } 14 | return o.Data 15 | } 16 | 17 | func (o *ListFilesResponse) GetObject() string { 18 | if o == nil { 19 | return "" 20 | } 21 | return o.Object 22 | } 23 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/listfinetuneeventsresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type ListFineTuneEventsResponse struct { 6 | Data []FineTuneEvent `json:"data"` 7 | Object string `json:"object"` 8 | } 9 | 10 | func (o *ListFineTuneEventsResponse) GetData() []FineTuneEvent { 11 | if o == nil { 12 | return []FineTuneEvent{} 13 | } 14 | return o.Data 15 | } 16 | 17 | func (o *ListFineTuneEventsResponse) GetObject() string { 18 | if o == nil { 19 | return "" 20 | } 21 | return o.Object 22 | } 23 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/listfinetunesresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type ListFineTunesResponse struct { 6 | Data []FineTune `json:"data"` 7 | Object string `json:"object"` 8 | } 9 | 10 | func (o *ListFineTunesResponse) GetData() []FineTune { 11 | if o == nil { 12 | return []FineTune{} 13 | } 14 | return o.Data 15 | } 16 | 17 | func (o *ListFineTunesResponse) GetObject() string { 18 | if o == nil { 19 | return "" 20 | } 21 | return o.Object 22 | } 23 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/listmodelsresponse.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type ListModelsResponse struct { 6 | Data []Model `json:"data"` 7 | Object string `json:"object"` 8 | } 9 | 10 | func (o *ListModelsResponse) GetData() []Model { 11 | if o == nil { 12 | return []Model{} 13 | } 14 | return o.Data 15 | } 16 | 17 | func (o *ListModelsResponse) GetObject() string { 18 | if o == nil { 19 | return "" 20 | } 21 | return o.Object 22 | } 23 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/model.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type Model struct { 6 | Created int64 `json:"created"` 7 | ID string `json:"id"` 8 | Object string `json:"object"` 9 | OwnedBy string `json:"owned_by"` 10 | } 11 | 12 | func (o *Model) GetCreated() int64 { 13 | if o == nil { 14 | return 0 15 | } 16 | return o.Created 17 | } 18 | 19 | func (o *Model) GetID() string { 20 | if o == nil { 21 | return "" 22 | } 23 | return o.ID 24 | } 25 | 26 | func (o *Model) GetObject() string { 27 | if o == nil { 28 | return "" 29 | } 30 | return o.Object 31 | } 32 | 33 | func (o *Model) GetOwnedBy() string { 34 | if o == nil { 35 | return "" 36 | } 37 | return o.OwnedBy 38 | } 39 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/openaifile.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type OpenAIFile struct { 6 | Bytes int64 `json:"bytes"` 7 | CreatedAt int64 `json:"created_at"` 8 | Filename string `json:"filename"` 9 | ID string `json:"id"` 10 | Object string `json:"object"` 11 | Purpose string `json:"purpose"` 12 | Status *string `json:"status,omitempty"` 13 | StatusDetails *string `json:"status_details,omitempty"` 14 | } 15 | 16 | func (o *OpenAIFile) GetBytes() int64 { 17 | if o == nil { 18 | return 0 19 | } 20 | return o.Bytes 21 | } 22 | 23 | func (o *OpenAIFile) GetCreatedAt() int64 { 24 | if o == nil { 25 | return 0 26 | } 27 | return o.CreatedAt 28 | } 29 | 30 | func (o *OpenAIFile) GetFilename() string { 31 | if o == nil { 32 | return "" 33 | } 34 | return o.Filename 35 | } 36 | 37 | func (o *OpenAIFile) GetID() string { 38 | if o == nil { 39 | return "" 40 | } 41 | return o.ID 42 | } 43 | 44 | func (o *OpenAIFile) GetObject() string { 45 | if o == nil { 46 | return "" 47 | } 48 | return o.Object 49 | } 50 | 51 | func (o *OpenAIFile) GetPurpose() string { 52 | if o == nil { 53 | return "" 54 | } 55 | return o.Purpose 56 | } 57 | 58 | func (o *OpenAIFile) GetStatus() *string { 59 | if o == nil { 60 | return nil 61 | } 62 | return o.Status 63 | } 64 | 65 | func (o *OpenAIFile) GetStatusDetails() *string { 66 | if o == nil { 67 | return nil 68 | } 69 | return o.StatusDetails 70 | } 71 | -------------------------------------------------------------------------------- /internal/sdk/models/shared/security.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package shared 4 | 5 | type Security struct { 6 | APIKey *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` 7 | } 8 | 9 | func (o *Security) GetAPIKey() *string { 10 | if o == nil { 11 | return nil 12 | } 13 | return o.APIKey 14 | } 15 | -------------------------------------------------------------------------------- /internal/sdk/retry/config.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package retry 4 | 5 | type BackoffStrategy struct { 6 | InitialInterval int 7 | MaxInterval int 8 | Exponent float64 9 | MaxElapsedTime int 10 | } 11 | 12 | type Config struct { 13 | Strategy string 14 | Backoff *BackoffStrategy 15 | RetryConnectionErrors bool 16 | } 17 | -------------------------------------------------------------------------------- /internal/sdk/types/bigint.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import ( 6 | "fmt" 7 | "math/big" 8 | ) 9 | 10 | // MustNewBigIntFromString returns an instance of big.Int from a string 11 | // The string is assumed to be base 10 and if it is not a valid big.Int 12 | // then the function panics. 13 | // Avoid using this function in production code. 14 | func MustNewBigIntFromString(s string) *big.Int { 15 | i, ok := new(big.Int).SetString(s, 10) 16 | if !ok { 17 | panic(fmt.Errorf("failed to parse string as big.Int")) 18 | } 19 | 20 | return i 21 | } 22 | -------------------------------------------------------------------------------- /internal/sdk/types/date.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | // Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02". 13 | type Date struct { 14 | time.Time 15 | } 16 | 17 | var ( 18 | _ json.Marshaler = &Date{} 19 | _ json.Unmarshaler = &Date{} 20 | _ fmt.Stringer = &Date{} 21 | ) 22 | 23 | // NewDate returns an instance of Date from a time.Time. 24 | func NewDate(t time.Time) *Date { 25 | d := DateFromTime(t) 26 | return &d 27 | } 28 | 29 | // DateFromTime returns a Date from a time.Time. 30 | func DateFromTime(t time.Time) Date { 31 | return Date{t} 32 | } 33 | 34 | // NewDateFromString returns an instance of Date from a string formatted as "2006-01-02". 35 | func NewDateFromString(str string) (*Date, error) { 36 | d, err := DateFromString(str) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | return &d, nil 42 | } 43 | 44 | // DateFromString returns a Date from a string formatted as "2006-01-02". 45 | func DateFromString(str string) (Date, error) { 46 | var d Date 47 | var err error 48 | 49 | d.Time, err = time.Parse("2006-01-02", str) 50 | return d, err 51 | } 52 | 53 | // MustNewDateFromString returns an instance of Date from a string formatted as "2006-01-02" or panics. 54 | // Avoid using this function in production code. 55 | func MustNewDateFromString(str string) *Date { 56 | d := MustDateFromString(str) 57 | return &d 58 | } 59 | 60 | // MustDateFromString returns a Date from a string formatted as "2006-01-02" or panics. 61 | // Avoid using this function in production code. 62 | func MustDateFromString(str string) Date { 63 | d, err := DateFromString(str) 64 | if err != nil { 65 | panic(err) 66 | } 67 | return d 68 | } 69 | 70 | func (d Date) GetTime() time.Time { 71 | return d.Time 72 | } 73 | 74 | func (d Date) MarshalJSON() ([]byte, error) { 75 | return []byte(fmt.Sprintf(`"%s"`, d.Time.Format("2006-01-02"))), nil 76 | } 77 | 78 | func (d *Date) UnmarshalJSON(data []byte) error { 79 | var err error 80 | 81 | str := string(data) 82 | str = strings.Trim(str, `"`) 83 | 84 | d.Time, err = time.Parse("2006-01-02", str) 85 | return err 86 | } 87 | 88 | func (d Date) String() string { 89 | return d.Time.Format("2006-01-02") 90 | } 91 | -------------------------------------------------------------------------------- /internal/sdk/types/datetime.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import "time" 6 | 7 | // MustTimeFromString returns a time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. 8 | // Avoid using this function in production code. 9 | func MustTimeFromString(str string) time.Time { 10 | t, err := time.Parse(time.RFC3339, str) 11 | if err != nil { 12 | panic(err) 13 | } 14 | 15 | return t 16 | } 17 | 18 | // MustNewTimeFromString returns an instance of time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. 19 | // Avoid using this function in production code. 20 | func MustNewTimeFromString(str string) *time.Time { 21 | t := MustTimeFromString(str) 22 | return &t 23 | } 24 | -------------------------------------------------------------------------------- /internal/sdk/types/decimal.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | import ( 6 | "fmt" 7 | 8 | "github.com/ericlagergren/decimal" 9 | ) 10 | 11 | // MustNewDecimalFromString returns an instance of Decimal from a string 12 | // Avoid using this function in production code. 13 | func MustNewDecimalFromString(s string) *decimal.Big { 14 | d, ok := new(decimal.Big).SetString(s) 15 | if !ok { 16 | panic(fmt.Errorf("failed to parse string as decimal.Big")) 17 | } 18 | 19 | return d 20 | } 21 | -------------------------------------------------------------------------------- /internal/sdk/types/pointers.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package types 4 | 5 | func String(s string) *string { return &s } 6 | func Bool(b bool) *bool { return &b } 7 | func Int(i int) *int { return &i } 8 | func Int64(i int64) *int64 { return &i } 9 | func Float32(f float32) *float32 { return &f } 10 | func Float64(f float64) *float64 { return &f } 11 | -------------------------------------------------------------------------------- /internal/validators/DateValidator.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package validators 4 | 5 | import ( 6 | "context" 7 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/sdk/types" 8 | "github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag" 9 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 10 | ) 11 | 12 | var _ validator.String = DateValidator{} 13 | 14 | type DateValidator struct { 15 | } 16 | 17 | func (validator DateValidator) Description(ctx context.Context) string { 18 | return "value must be a string in YYYY-MM-DD format" 19 | } 20 | 21 | func (validator DateValidator) MarkdownDescription(ctx context.Context) string { 22 | return validator.Description(ctx) 23 | } 24 | 25 | func (validator DateValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { 26 | // Only validate the attribute configuration value if it is known. 27 | if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() { 28 | return 29 | } 30 | 31 | if _, err := types.NewDateFromString(req.ConfigValue.ValueString()); err != nil { 32 | resp.Diagnostics.Append(validatordiag.InvalidAttributeTypeDiagnostic( 33 | req.Path, 34 | validator.MarkdownDescription(ctx), 35 | req.ConfigValue.ValueString(), 36 | )) 37 | return 38 | } 39 | } 40 | 41 | // IsDate returns an AttributeValidator which ensures that any configured 42 | // attribute value: 43 | // 44 | // - Is a String. 45 | // - Is in YYYY-MM-DD Format. 46 | // 47 | // Null (unconfigured) and unknown (known after apply) values are skipped. 48 | func IsValidDate() validator.String { 49 | return DateValidator{} 50 | } 51 | -------------------------------------------------------------------------------- /internal/validators/ExactlyOneChild.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package validators 4 | 5 | import ( 6 | "context" 7 | "github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag" 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Object = exactlyOneChild{} 12 | 13 | // exactlyOneChild validates if the provided value is of type string and can be parsed as JSON. 14 | type exactlyOneChild struct { 15 | } 16 | 17 | func (validator exactlyOneChild) ValidateObject(ctx context.Context, req validator.ObjectRequest, resp *validator.ObjectResponse) { 18 | // Only validate the attribute configuration value if it is known. 19 | if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() { 20 | return 21 | } 22 | defined := make(map[string]bool) 23 | count := 0 24 | for key, attr := range req.ConfigValue.Attributes() { 25 | if attr.IsUnknown() || attr.IsNull() { 26 | continue 27 | } 28 | defined[key] = true 29 | count++ 30 | } 31 | if count != 1 { 32 | resp.Diagnostics.Append(validatordiag.InvalidAttributeTypeDiagnostic( 33 | req.Path, 34 | validator.MarkdownDescription(ctx), 35 | req.ConfigValue.String(), 36 | )) 37 | } 38 | } 39 | 40 | func (validator exactlyOneChild) Description(ctx context.Context) string { 41 | return "value must have exactly one child attribute defined" 42 | } 43 | 44 | func (validator exactlyOneChild) MarkdownDescription(ctx context.Context) string { 45 | return validator.Description(ctx) 46 | } 47 | 48 | // ExactlyOneChild returns an AttributeValidator which ensures that any configured 49 | // attribute object has only one child attribute. 50 | // Null (unconfigured) and unknown values are skipped. 51 | func ExactlyOneChild() validator.Object { 52 | return exactlyOneChild{} 53 | } 54 | -------------------------------------------------------------------------------- /internal/validators/JSONParseValidator.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package validators 4 | 5 | import ( 6 | "context" 7 | "encoding/json" 8 | "github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag" 9 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 10 | ) 11 | 12 | var _ validator.String = JSONParseValidator{} 13 | 14 | // JSONParseValidator validates if the provided value is of type string and can be parsed as JSON. 15 | type JSONParseValidator struct { 16 | } 17 | 18 | func (validator JSONParseValidator) Description(ctx context.Context) string { 19 | return "value must be parsable as JSON" 20 | } 21 | 22 | func (validator JSONParseValidator) MarkdownDescription(ctx context.Context) string { 23 | return validator.Description(ctx) 24 | } 25 | 26 | func (validator JSONParseValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { 27 | // Only validate the attribute configuration value if it is known. 28 | if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() { 29 | return 30 | } 31 | 32 | if !json.Valid([]byte(req.ConfigValue.ValueString())) { 33 | resp.Diagnostics.Append(validatordiag.InvalidAttributeTypeDiagnostic( 34 | req.Path, 35 | validator.MarkdownDescription(ctx), 36 | req.ConfigValue.ValueString(), 37 | )) 38 | return 39 | } 40 | } 41 | 42 | // IsValidJSON returns an AttributeValidator which ensures that any configured 43 | // attribute value: 44 | // 45 | // - Is a String. 46 | // - Is considered valid JSON. 47 | // 48 | // Null (unconfigured) and unknown (known after apply) values are skipped. 49 | func IsValidJSON() validator.String { 50 | return JSONParseValidator{} 51 | } 52 | -------------------------------------------------------------------------------- /internal/validators/RFC3339Validator.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package validators 4 | 5 | import ( 6 | "context" 7 | "time" 8 | 9 | "github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag" 10 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 11 | ) 12 | 13 | var _ validator.String = RFC3339TimeValidator{} 14 | 15 | type RFC3339TimeValidator struct{} 16 | 17 | func (validator RFC3339TimeValidator) Description(ctx context.Context) string { 18 | return "value must be a string in RFC3339 format" 19 | } 20 | 21 | func (validator RFC3339TimeValidator) MarkdownDescription(ctx context.Context) string { 22 | return validator.Description(ctx) 23 | } 24 | 25 | func (validator RFC3339TimeValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { 26 | // Only validate the attribute configuration value if it is known. 27 | if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() { 28 | return 29 | } 30 | 31 | if _, err := time.Parse(time.RFC3339Nano, req.ConfigValue.ValueString()); err != nil { 32 | resp.Diagnostics.Append(validatordiag.InvalidAttributeTypeDiagnostic( 33 | req.Path, 34 | validator.MarkdownDescription(ctx), 35 | req.ConfigValue.ValueString(), 36 | )) 37 | return 38 | } 39 | } 40 | 41 | // IsRFC3339 returns an AttributeValidator which ensures that any configured 42 | // attribute value: 43 | // 44 | // - Is a String. 45 | // - Is in RFC3339Nano Format. 46 | // 47 | // Null (unconfigured) and unknown (known after apply) values are skipped. 48 | func IsRFC3339() validator.String { 49 | return RFC3339TimeValidator{} 50 | } 51 | -------------------------------------------------------------------------------- /internal/validators/boolvalidators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package boolvalidators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Bool = BoolNotNullValidator{} 12 | 13 | // BoolNotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type BoolNotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v BoolNotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v BoolNotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v BoolNotNullValidator) ValidateBool(ctx context.Context, req validator.BoolRequest, resp *validator.BoolResponse) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.Bool { 48 | return BoolNotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/float64validators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package float64validators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Float64 = Float64NotNullValidator{} 12 | 13 | // Float64NotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type Float64NotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v Float64NotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v Float64NotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v Float64NotNullValidator) ValidateFloat64(ctx context.Context, req validator.Float64Request, resp *validator.Float64Response) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.Float64 { 48 | return Float64NotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/int64validators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package int64validators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Int64 = Int64NotNullValidator{} 12 | 13 | // Int64NotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type Int64NotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v Int64NotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v Int64NotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v Int64NotNullValidator) ValidateInt64(ctx context.Context, req validator.Int64Request, resp *validator.Int64Response) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.Int64 { 48 | return Int64NotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/listvalidators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package listvalidators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.List = ListNotNullValidator{} 12 | 13 | // ListNotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type ListNotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v ListNotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v ListNotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v ListNotNullValidator) ValidateList(ctx context.Context, req validator.ListRequest, resp *validator.ListResponse) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.List { 48 | return ListNotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/mapvalidators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package mapvalidators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Map = MapNotNullValidator{} 12 | 13 | // MapNotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type MapNotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v MapNotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v MapNotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v MapNotNullValidator) ValidateMap(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.Map { 48 | return MapNotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/numbervalidators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package numbervalidators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Number = NumberNotNullValidator{} 12 | 13 | // NumberNotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type NumberNotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v NumberNotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v NumberNotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v NumberNotNullValidator) ValidateNumber(ctx context.Context, req validator.NumberRequest, resp *validator.NumberResponse) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.Number { 48 | return NumberNotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/objectvalidators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package objectvalidators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Object = ObjectNotNullValidator{} 12 | 13 | // ObjectNotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type ObjectNotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v ObjectNotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v ObjectNotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v ObjectNotNullValidator) ValidateObject(ctx context.Context, req validator.ObjectRequest, resp *validator.ObjectResponse) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.Object { 48 | return ObjectNotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/setvalidators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package setvalidators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.Set = SetNotNullValidator{} 12 | 13 | // SetNotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type SetNotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v SetNotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v SetNotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v SetNotNullValidator) ValidateSet(ctx context.Context, req validator.SetRequest, resp *validator.SetResponse) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.Set { 48 | return SetNotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /internal/validators/stringvalidators/not_null.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package stringvalidators 4 | 5 | import ( 6 | "context" 7 | 8 | "github.com/hashicorp/terraform-plugin-framework/schema/validator" 9 | ) 10 | 11 | var _ validator.String = StringNotNullValidator{} 12 | 13 | // StringNotNullValidator validates that an attribute is not null. Most 14 | // attributes should set Required: true instead, however in certain scenarios, 15 | // such as a computed nested attribute, all underlying attributes must also be 16 | // computed for planning to not show unexpected differences. 17 | type StringNotNullValidator struct{} 18 | 19 | // Description describes the validation in plain text formatting. 20 | func (v StringNotNullValidator) Description(_ context.Context) string { 21 | return "value must be configured" 22 | } 23 | 24 | // MarkdownDescription describes the validation in Markdown formatting. 25 | func (v StringNotNullValidator) MarkdownDescription(ctx context.Context) string { 26 | return v.Description(ctx) 27 | } 28 | 29 | // Validate performs the validation. 30 | func (v StringNotNullValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { 31 | if !req.ConfigValue.IsNull() { 32 | return 33 | } 34 | 35 | resp.Diagnostics.AddAttributeError( 36 | req.Path, 37 | "Missing Attribute Value", 38 | req.Path.String()+": "+v.Description(ctx), 39 | ) 40 | } 41 | 42 | // NotNull returns an validator which ensures that the attribute is 43 | // configured. Most attributes should set Required: true instead, however in 44 | // certain scenarios, such as a computed nested attribute, all underlying 45 | // attributes must also be computed for planning to not show unexpected 46 | // differences. 47 | func NotNull() validator.String { 48 | return StringNotNullValidator{} 49 | } 50 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | package main 4 | 5 | import ( 6 | "context" 7 | "flag" 8 | "log" 9 | 10 | "github.com/antonbabenko/terraform-provider-openai/v2/internal/provider" 11 | "github.com/hashicorp/terraform-plugin-framework/providerserver" 12 | ) 13 | 14 | // Run "go generate" to generate the docs for the registry/website on each regeneration of the provider. 15 | 16 | // Run the docs generation tool, check its repository for more information on how it works and how docs 17 | // can be customized. 18 | //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-name terraform-provider-openai --rendered-provider-name terraform-provider-openai 19 | 20 | var ( 21 | // these will be set by the goreleaser configuration 22 | // to appropriate values for the compiled binary 23 | version string = "dev" 24 | ) 25 | 26 | func main() { 27 | var debug bool 28 | 29 | flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") 30 | flag.Parse() 31 | 32 | opts := providerserver.ServeOpts{ 33 | Address: "registry.terraform.io/antonbabenko/openai", 34 | Debug: debug, 35 | } 36 | 37 | err := providerserver.Serve(context.Background(), provider.New(version), opts) 38 | 39 | if err != nil { 40 | log.Fatal(err.Error()) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /terraform-registry-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "metadata": { 4 | "protocol_versions": ["6.0"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tools/tools.go: -------------------------------------------------------------------------------- 1 | // Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. 2 | 3 | //go:build tools 4 | 5 | package tools 6 | 7 | import ( 8 | // Documentation generation 9 | _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" 10 | ) 11 | --------------------------------------------------------------------------------