Skip to content

Commit f05b890

Browse files
committed
feat: project data source and resource
1 parent dc34fc0 commit f05b890

File tree

24 files changed

+1508
-22
lines changed

24 files changed

+1508
-22
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ jobs:
6464
fail-fast: false
6565
matrix:
6666
terraform:
67-
- "1.0.*"
68-
- "1.1.*"
69-
- "1.2.*"
70-
- "1.3.*"
7167
- "1.4.*"
7268
- "1.5.*"
7369
- "1.6.*"

docs/data-sources/project.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "openai_project Data Source - terraform-provider-openai"
4+
subcategory: ""
5+
description: |-
6+
Retrieve a project by ID.
7+
---
8+
9+
# openai_project (Data Source)
10+
11+
Retrieve a project by ID.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "openai_project" "example" {
17+
id = "proj_000000000000000000000000"
18+
organization_id = "org-000000000000000000000000"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `id` (String) Project ID.
28+
- `organization_id` (String) Organization ID.
29+
30+
### Read-Only
31+
32+
- `title` (String) Human-friendly label for the project, shown in user interfaces.

docs/data-sources/projects.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "openai_projects Data Source - terraform-provider-openai"
4+
subcategory: ""
5+
description: |-
6+
List all projects in an organization.
7+
---
8+
9+
# openai_projects (Data Source)
10+
11+
List all projects in an organization.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "openai_projects" "example" {
17+
organization_id = "org-000000000000000000000000"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `organization_id` (String) The unique identifier for the organization.
27+
28+
### Read-Only
29+
30+
- `projects` (Attributes Set) List of projects. (see [below for nested schema](#nestedatt--projects))
31+
32+
<a id="nestedatt--projects"></a>
33+
### Nested Schema for `projects`
34+
35+
Read-Only:
36+
37+
- `id` (String) Project ID.
38+
- `title` (String) Human-friendly label for the project, shown in user interfaces.

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ provider "openai" {
2525

2626
- `api_key` (String, Sensitive) API key for the OpenAI API.
2727
- `base_url` (String) Base URL for the OpenAI API. Defaults to `https://api.openai.com`.
28+
- `session_key` (String, Sensitive) Session key for the OpenAI API.

docs/resources/project.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "openai_project Resource - terraform-provider-openai"
4+
subcategory: ""
5+
description: |-
6+
Project resource.
7+
---
8+
9+
# openai_project (Resource)
10+
11+
Project resource.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "openai_project" "example" {
17+
organization_id = "org-000000000000000000000000"
18+
title = "Example Project"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `organization_id` (String) The ID of the organization to which the project belongs.
28+
- `title` (String) Human-friendly label for the project, shown in user interfaces.
29+
30+
### Read-Only
31+
32+
- `id` (String) The ID of the project.
33+
34+
## Import
35+
36+
Import is supported using the following syntax:
37+
38+
```shell
39+
# Import an existing project
40+
terraform import openai_project.example organisation-id/project-id
41+
42+
# Example
43+
terraform import openai_project.example org-000000000000000000000000/proj_000000000000000000000000
44+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
data "openai_project" "example" {
2+
id = "proj_000000000000000000000000"
3+
organization_id = "org-000000000000000000000000"
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "openai_projects" "example" {
2+
organization_id = "org-000000000000000000000000"
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Import an existing project
2+
terraform import openai_project.example organisation-id/project-id
3+
4+
# Example
5+
terraform import openai_project.example org-000000000000000000000000/proj_000000000000000000000000
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource "openai_project" "example" {
2+
organization_id = "org-000000000000000000000000"
3+
title = "Example Project"
4+
}

examples/resources/scaffolding_example/resource.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ go 1.21
44

55
require (
66
github.com/deepmap/oapi-codegen/v2 v2.1.0
7-
github.com/hashicorp/go-version v1.6.0
87
github.com/hashicorp/terraform-plugin-docs v0.19.2
98
github.com/hashicorp/terraform-plugin-framework v1.8.0
109
github.com/hashicorp/terraform-plugin-go v0.23.0
11-
github.com/hashicorp/terraform-plugin-log v0.9.0
1210
github.com/hashicorp/terraform-plugin-testing v1.8.0
13-
golang.org/x/oauth2 v0.20.0
11+
github.com/oapi-codegen/runtime v1.1.1
1412
)
1513

1614
require (
@@ -43,11 +41,13 @@ require (
4341
github.com/hashicorp/go-multierror v1.1.1 // indirect
4442
github.com/hashicorp/go-plugin v1.6.1 // indirect
4543
github.com/hashicorp/go-uuid v1.0.3 // indirect
44+
github.com/hashicorp/go-version v1.6.0 // indirect
4645
github.com/hashicorp/hc-install v0.6.4 // indirect
4746
github.com/hashicorp/hcl/v2 v2.20.1 // indirect
4847
github.com/hashicorp/logutils v1.0.0 // indirect
4948
github.com/hashicorp/terraform-exec v0.21.0 // indirect
5049
github.com/hashicorp/terraform-json v0.22.1 // indirect
50+
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
5151
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 // indirect
5252
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
5353
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
@@ -66,7 +66,6 @@ require (
6666
github.com/mitchellh/mapstructure v1.5.0 // indirect
6767
github.com/mitchellh/reflectwalk v1.0.2 // indirect
6868
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
69-
github.com/oapi-codegen/runtime v1.1.1 // indirect
7069
github.com/oklog/run v1.1.0 // indirect
7170
github.com/perimeterx/marshmallow v1.1.5 // indirect
7271
github.com/posener/complete v1.2.3 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
22
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
3-
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
4-
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
53
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
64
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
75
github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0=
@@ -261,8 +259,6 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
261259
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
262260
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
263261
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
264-
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
265-
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
266262
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
267263
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
268264
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

internal/acctest/random.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package acctest
2+
3+
import (
4+
sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
5+
)
6+
7+
func RandomWithPrefix(name string) string {
8+
return sdkacctest.RandomWithPrefix(name)
9+
}

internal/apiclient/api.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,117 @@ paths:
7777
$ref: "#/components/schemas/ObjectList"
7878
401:
7979
$ref: "#/components/responses/Unauthorized"
80+
/dashboard/organizations/{organizationId}/projects:
81+
get:
82+
operationId: getOrganizationProjects
83+
parameters:
84+
- name: organizationId
85+
in: path
86+
required: true
87+
schema:
88+
type: string
89+
responses:
90+
200:
91+
content:
92+
application/json:
93+
schema:
94+
type: object
95+
required:
96+
- data
97+
- object
98+
properties:
99+
data:
100+
type: array
101+
items:
102+
$ref: "#/components/schemas/Project"
103+
object:
104+
$ref: "#/components/schemas/ObjectList"
105+
401:
106+
$ref: "#/components/responses/Unauthorized"
107+
post:
108+
operationId: createOrganizationProject
109+
parameters:
110+
- name: organizationId
111+
in: path
112+
required: true
113+
schema:
114+
type: string
115+
requestBody:
116+
required: true
117+
content:
118+
application/json:
119+
schema:
120+
type: object
121+
required:
122+
- title
123+
- geography
124+
properties:
125+
title:
126+
type: string
127+
geography:
128+
type: string
129+
responses:
130+
200:
131+
content:
132+
application/json:
133+
schema:
134+
$ref: "#/components/schemas/Project"
135+
401:
136+
$ref: "#/components/responses/Unauthorized"
137+
/dashboard/organizations/{organizationId}/projects/{projectId}:
138+
get:
139+
operationId: getOrganizationProject
140+
parameters:
141+
- name: organizationId
142+
in: path
143+
required: true
144+
schema:
145+
type: string
146+
- name: projectId
147+
in: path
148+
required: true
149+
schema:
150+
type: string
151+
responses:
152+
200:
153+
content:
154+
application/json:
155+
schema:
156+
$ref: "#/components/schemas/Project"
157+
401:
158+
$ref: "#/components/responses/Unauthorized"
159+
post:
160+
operationId: updateOrganizationProject
161+
parameters:
162+
- name: organizationId
163+
in: path
164+
required: true
165+
schema:
166+
type: string
167+
- name: projectId
168+
in: path
169+
required: true
170+
schema:
171+
type: string
172+
requestBody:
173+
required: true
174+
content:
175+
application/json:
176+
schema:
177+
type: object
178+
properties:
179+
title:
180+
type: string
181+
archive:
182+
type: boolean
183+
responses:
184+
200:
185+
content:
186+
application/json:
187+
schema:
188+
$ref: "#/components/schemas/Project"
189+
401:
190+
$ref: "#/components/responses/Unauthorized"
80191
components:
81192
securitySchemes:
82193
bearerAuth:
@@ -204,6 +315,8 @@ components:
204315
- project
205316
organization_id:
206317
type: string
318+
role:
319+
type: string
207320
title:
208321
type: string
209322
User:

0 commit comments

Comments
 (0)