Skip to content

Commit

Permalink
Implement auth_expiration_seconds attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchnielsen committed Feb 18, 2025
1 parent acbbb28 commit 54fd6d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/resources/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ resource "prefect_account" "example" {

### Optional

- `auth_expiration_seconds` (Number) The number of seconds a user should be considered to be authenticated against this Account.
- `billing_email` (String) Billing email to apply to the account's Stripe customer
- `link` (String) An optional for an external url associated with the account, e.g. https://prefect.io/
- `location` (String) An optional physical location for the account, e.g. Washington, D.C.
Expand Down
29 changes: 18 additions & 11 deletions internal/provider/resources/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ type AccountResource struct {
type AccountResourceModel struct {
BaseModel

Name types.String `tfsdk:"name"`
Handle types.String `tfsdk:"handle"`
Location types.String `tfsdk:"location"`
Link types.String `tfsdk:"link"`
Settings types.Object `tfsdk:"settings"`
BillingEmail types.String `tfsdk:"billing_email"`
Name types.String `tfsdk:"name"`
Handle types.String `tfsdk:"handle"`
Location types.String `tfsdk:"location"`
Link types.String `tfsdk:"link"`
Settings types.Object `tfsdk:"settings"`
BillingEmail types.String `tfsdk:"billing_email"`
AuthExpirationSeconds types.Int64 `tfsdk:"auth_expiration_seconds"`
}

// NewAccountResource returns a new AccountResource.
Expand Down Expand Up @@ -120,6 +121,10 @@ func (r *AccountResource) Schema(_ context.Context, _ resource.SchemaRequest, re
Description: "An optional for an external url associated with the account, e.g. https://prefect.io/",
Optional: true,
},
"auth_expiration_seconds": schema.Int64Attribute{
Description: "The number of seconds a user should be considered to be authenticated against this Account.",
Optional: true,
},
"settings": schema.SingleNestedAttribute{
Description: "Group of settings related to accounts",
Optional: true,
Expand Down Expand Up @@ -162,6 +167,7 @@ func copyAccountToModel(_ context.Context, account *api.Account, tfModel *Accoun
tfModel.Link = types.StringPointerValue(account.Link)
tfModel.Location = types.StringPointerValue(account.Location)
tfModel.Name = types.StringValue(account.Name)
tfModel.AuthExpirationSeconds = types.Int64PointerValue(account.AuthExpirationSeconds)

settingsObject, diags := types.ObjectValue(
map[string]attr.Type{
Expand Down Expand Up @@ -247,11 +253,12 @@ func (r *AccountResource) Update(ctx context.Context, req resource.UpdateRequest
}

err = client.Update(ctx, api.AccountUpdate{
Name: plan.Name.ValueString(),
Handle: plan.Handle.ValueString(),
Location: plan.Location.ValueStringPointer(),
Link: plan.Link.ValueStringPointer(),
BillingEmail: plan.BillingEmail.ValueStringPointer(),
Name: plan.Name.ValueString(),
Handle: plan.Handle.ValueString(),
Location: plan.Location.ValueStringPointer(),
Link: plan.Link.ValueStringPointer(),
BillingEmail: plan.BillingEmail.ValueStringPointer(),
AuthExpirationSeconds: plan.AuthExpirationSeconds.ValueInt64Pointer(),
})
if err != nil {
resp.Diagnostics.Append(helpers.ResourceClientErrorDiagnostic("Account", "update", err))
Expand Down

0 comments on commit 54fd6d0

Please sign in to comment.