Skip to content

Commit 4b066a8

Browse files
authored
remove projectId from user token resource (#528)
1 parent 6e98cbb commit 4b066a8

3 files changed

Lines changed: 3 additions & 23 deletions

File tree

client/user_token.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ type UserToken struct {
2020
ExpiresAt *int64 `json:"expiresAt"`
2121
LeakedAt *int64 `json:"leakedAt"`
2222
LeakedURL *string `json:"leakedUrl"`
23-
ProjectID *string `json:"projectId"`
2423
BearerToken *string
2524
}
2625

2726
type CreateUserTokenRequest struct {
28-
Name string `json:"name"`
29-
ExpiresAt *int64 `json:"expiresAt,omitempty"`
30-
ProjectID *string `json:"projectId,omitempty"`
31-
TeamID string `json:"-"`
27+
Name string `json:"name"`
28+
ExpiresAt *int64 `json:"expiresAt,omitempty"`
29+
TeamID string `json:"-"`
3230
}
3331

3432
func (c *Client) CreateUserToken(ctx context.Context, request CreateUserTokenRequest) (u UserToken, err error) {

docs/resources/user_token.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ resource "vercel_user_token" "example_expiring" {
4242
### Optional
4343

4444
- `expires_at` (Number) The Unix timestamp in milliseconds when the token should expire.
45-
- `project_id` (String) The ID of the project this token should be scoped to. Requires team scope.
4645
- `team_id` (String) The ID of the Vercel team scope for this token. Required when creating a team-scoped token if a default team has not been set in the provider.
4746

4847
### Read-Only

vercel/resource_user_token.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ The ` + "`bearer_token`" + ` value is only returned during creation and cannot b
8888
int64validator.AtLeast(1),
8989
},
9090
},
91-
"project_id": schema.StringAttribute{
92-
Description: "The ID of the project this token should be scoped to. Requires team scope.",
93-
Optional: true,
94-
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
95-
},
9691
"team_id": schema.StringAttribute{
9792
Description: "The ID of the Vercel team scope for this token. Required when creating a team-scoped token if a default team has not been set in the provider.",
9893
Optional: true,
@@ -153,7 +148,6 @@ type UserToken struct {
153148
ID types.String `tfsdk:"id"`
154149
Name types.String `tfsdk:"name"`
155150
ExpiresAt types.Int64 `tfsdk:"expires_at"`
156-
ProjectID types.String `tfsdk:"project_id"`
157151
TeamID types.String `tfsdk:"team_id"`
158152
BearerToken types.String `tfsdk:"bearer_token"`
159153
Type types.String `tfsdk:"type"`
@@ -175,7 +169,6 @@ func responseToUserToken(out client.UserToken, bearerToken types.String) UserTok
175169
ID: types.StringValue(out.ID),
176170
Name: types.StringValue(out.Name),
177171
ExpiresAt: types.Int64PointerValue(out.ExpiresAt),
178-
ProjectID: types.StringPointerValue(out.ProjectID),
179172
TeamID: types.StringPointerValue(out.TeamID),
180173
BearerToken: bearerToken,
181174
Type: types.StringValue(out.Type),
@@ -214,19 +207,9 @@ func (r *userTokenResource) Create(ctx context.Context, req resource.CreateReque
214207
)
215208
return
216209
}
217-
if !plan.ProjectID.IsNull() && r.client.TeamID(plan.TeamID.ValueString()) == "" {
218-
resp.Diagnostics.AddAttributeError(
219-
path.Root("project_id"),
220-
"Project-scoped token requires team scope",
221-
"`project_id` can only be used when the token is created in a team scope. Set `team_id` or configure a default team on the provider.",
222-
)
223-
return
224-
}
225-
226210
out, err := r.client.CreateUserToken(ctx, client.CreateUserTokenRequest{
227211
Name: name,
228212
ExpiresAt: plan.ExpiresAt.ValueInt64Pointer(),
229-
ProjectID: plan.ProjectID.ValueStringPointer(),
230213
TeamID: plan.TeamID.ValueString(),
231214
})
232215
if err != nil {

0 commit comments

Comments
 (0)