Skip to content

Commit 00691a1

Browse files
authored
ref: OpenAPI-based project client (#536)
* ref: project api client * ref: update basic test
1 parent fa9d8b2 commit 00691a1

File tree

7 files changed

+1461
-327
lines changed

7 files changed

+1461
-327
lines changed

internal/acctest/acctest.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/jianyuan/go-sentry/v2/sentry"
99
"github.com/jianyuan/go-utils/must"
10+
"github.com/jianyuan/terraform-provider-sentry/internal/apiclient"
1011
"github.com/jianyuan/terraform-provider-sentry/internal/sentryclient"
1112
)
1213

@@ -48,6 +49,9 @@ var (
4849
// TestVSTSRepositoryIdentifier is the VSTS repository identifier used for acceptance tests.
4950
TestVSTSRepositoryIdentifier = os.Getenv("SENTRY_TEST_VSTS_REPOSITORY_IDENTIFIER")
5051

52+
// SharedApiClient is a shared Sentry API client for acceptance tests.
53+
SharedApiClient *apiclient.ClientWithResponses
54+
5155
// SharedClient is a shared Sentry client for acceptance tests.
5256
SharedClient *sentry.Client
5357
)
@@ -73,6 +77,11 @@ func init() {
7377
}
7478
httpClient := config.HttpClient(context.Background())
7579

80+
SharedApiClient = must.Get(apiclient.NewClientWithResponses(
81+
baseUrl,
82+
apiclient.WithHTTPClient(httpClient),
83+
))
84+
7685
if baseUrl == "" {
7786
SharedClient = sentry.NewClient(httpClient)
7887
} else {

internal/apiclient/api.yaml

Lines changed: 170 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ servers:
77

88
paths:
99
/0/organizations/{organization_id_or_slug}/:
10+
parameters:
11+
- $ref: "#/components/parameters/organization_id_or_slug"
1012
get:
1113
summary: Retrieve an Organization
1214
operationId: getOrganization
13-
parameters:
14-
- $ref: "#/components/parameters/organization_id_or_slug"
1515
responses:
1616
"200":
1717
description: OK
@@ -25,13 +25,143 @@ paths:
2525
description: Forbidden
2626
"404":
2727
description: Not Found
28+
/0/teams/{organization_id_or_slug}/{team_id_or_slug}/projects/:
29+
parameters:
30+
- $ref: "#/components/parameters/organization_id_or_slug"
31+
- $ref: "#/components/parameters/team_id_or_slug"
32+
post:
33+
summary: Create a Project
34+
operationId: createOrganizationTeamProject
35+
requestBody:
36+
required: true
37+
content:
38+
application/json:
39+
schema:
40+
type: object
41+
required:
42+
- name
43+
properties:
44+
name:
45+
type: string
46+
slug:
47+
type: string
48+
platform:
49+
type: string
50+
default_rules:
51+
type: boolean
52+
responses:
53+
"201":
54+
description: Created
55+
content:
56+
application/json:
57+
schema:
58+
$ref: "#/components/schemas/Project"
59+
"401":
60+
description: Unauthorized
61+
"403":
62+
description: Forbidden
63+
"404":
64+
description: Not Found
2865
/0/projects/{organization_id_or_slug}/{project_id_or_slug}/:
66+
parameters:
67+
- $ref: "#/components/parameters/organization_id_or_slug"
68+
- $ref: "#/components/parameters/project_id_or_slug"
2969
get:
3070
summary: Retrieve a Project
3171
operationId: getOrganizationProject
32-
parameters:
33-
- $ref: "#/components/parameters/organization_id_or_slug"
34-
- $ref: "#/components/parameters/project_id_or_slug"
72+
responses:
73+
"200":
74+
description: OK
75+
content:
76+
application/json:
77+
schema:
78+
$ref: "#/components/schemas/Project"
79+
"401":
80+
description: Unauthorized
81+
"403":
82+
description: Forbidden
83+
"404":
84+
description: Not Found
85+
put:
86+
summary: Update a Project
87+
operationId: updateOrganizationProject
88+
requestBody:
89+
required: true
90+
content:
91+
application/json:
92+
schema:
93+
type: object
94+
properties:
95+
name:
96+
type: string
97+
slug:
98+
type: string
99+
platform:
100+
type: string
101+
digestsMinDelay:
102+
type: integer
103+
format: int64
104+
digestsMaxDelay:
105+
type: integer
106+
format: int64
107+
resolveAge:
108+
type: integer
109+
format: int64
110+
fingerprintingRules:
111+
type: string
112+
groupingEnhancements:
113+
type: string
114+
options:
115+
type: object
116+
responses:
117+
"200":
118+
description: OK
119+
content:
120+
application/json:
121+
schema:
122+
$ref: "#/components/schemas/Project"
123+
"401":
124+
description: Unauthorized
125+
"403":
126+
description: Forbidden
127+
"404":
128+
description: Not Found
129+
delete:
130+
summary: Delete a Project
131+
operationId: deleteOrganizationProject
132+
responses:
133+
"204":
134+
description: No Content
135+
"401":
136+
description: Unauthorized
137+
"403":
138+
description: Forbidden
139+
"404":
140+
description: Not Found
141+
/0/projects/{organization_id_or_slug}/{project_id_or_slug}/teams/{team_id_or_slug}/:
142+
parameters:
143+
- $ref: "#/components/parameters/organization_id_or_slug"
144+
- $ref: "#/components/parameters/project_id_or_slug"
145+
- $ref: "#/components/parameters/team_id_or_slug"
146+
post:
147+
summary: Add a Team to a Project
148+
operationId: addTeamToProject
149+
responses:
150+
"201":
151+
description: Created
152+
content:
153+
application/json:
154+
schema:
155+
$ref: "#/components/schemas/Project"
156+
"401":
157+
description: Unauthorized
158+
"403":
159+
description: Forbidden
160+
"404":
161+
description: Not Found
162+
delete:
163+
summary: Remove a Team from a Project
164+
operationId: removeTeamFromProject
35165
responses:
36166
"200":
37167
description: OK
@@ -46,12 +176,13 @@ paths:
46176
"404":
47177
description: Not Found
48178
/0/projects/{organization_id_or_slug}/{project_id_or_slug}/keys/:
179+
parameters:
180+
- $ref: "#/components/parameters/organization_id_or_slug"
181+
- $ref: "#/components/parameters/project_id_or_slug"
49182
get:
50183
summary: List Client Keys
51184
operationId: listProjectClientKeys
52185
parameters:
53-
- $ref: "#/components/parameters/organization_id_or_slug"
54-
- $ref: "#/components/parameters/project_id_or_slug"
55186
- $ref: "#/components/parameters/cursor"
56187
- name: status
57188
in: query
@@ -79,9 +210,6 @@ paths:
79210
post:
80211
summary: Create a Client Key
81212
operationId: createProjectClientKey
82-
parameters:
83-
- $ref: "#/components/parameters/organization_id_or_slug"
84-
- $ref: "#/components/parameters/project_id_or_slug"
85213
requestBody:
86214
required: true
87215
content:
@@ -130,17 +258,17 @@ paths:
130258
"404":
131259
description: Not Found
132260
/0/projects/{organization_id_or_slug}/{project_id_or_slug}/keys/{key_id}/:
261+
parameters:
262+
- $ref: "#/components/parameters/organization_id_or_slug"
263+
- $ref: "#/components/parameters/project_id_or_slug"
264+
- name: key_id
265+
in: path
266+
required: true
267+
schema:
268+
type: string
133269
get:
134270
summary: Retrieve a Client Key
135271
operationId: getProjectClientKey
136-
parameters:
137-
- $ref: "#/components/parameters/organization_id_or_slug"
138-
- $ref: "#/components/parameters/project_id_or_slug"
139-
- name: key_id
140-
in: path
141-
required: true
142-
schema:
143-
type: string
144272
responses:
145273
"200":
146274
description: OK
@@ -157,14 +285,6 @@ paths:
157285
put:
158286
summary: Update a Client Key
159287
operationId: updateProjectClientKey
160-
parameters:
161-
- $ref: "#/components/parameters/organization_id_or_slug"
162-
- $ref: "#/components/parameters/project_id_or_slug"
163-
- name: key_id
164-
in: path
165-
required: true
166-
schema:
167-
type: string
168288
requestBody:
169289
required: true
170290
content:
@@ -210,6 +330,18 @@ paths:
210330
description: Forbidden
211331
"404":
212332
description: Not Found
333+
delete:
334+
summary: Delete a Client Key
335+
operationId: deleteProjectClientKey
336+
responses:
337+
"204":
338+
description: No Content
339+
"401":
340+
description: Unauthorized
341+
"403":
342+
description: Forbidden
343+
"404":
344+
description: Not Found
213345
security:
214346
- bearerAuth: []
215347
components:
@@ -230,6 +362,12 @@ components:
230362
required: true
231363
schema:
232364
type: string
365+
team_id_or_slug:
366+
name: team_id_or_slug
367+
in: path
368+
required: true
369+
schema:
370+
type: string
233371
cursor:
234372
name: cursor
235373
in: query
@@ -267,6 +405,8 @@ components:
267405
- digestsMinDelay
268406
- digestsMaxDelay
269407
- resolveAge
408+
- fingerprintingRules
409+
- groupingEnhancements
270410
properties:
271411
organization:
272412
$ref: "#/components/schemas/Organization"
@@ -305,6 +445,10 @@ components:
305445
resolveAge:
306446
type: integer
307447
format: int64
448+
fingerprintingRules:
449+
type: string
450+
groupingEnhancements:
451+
type: string
308452
ProjectKey:
309453
type: object
310454
required:

0 commit comments

Comments
 (0)