@@ -50,10 +50,10 @@ func (r *OrganizationInviteResource) Schema(ctx context.Context, req resource.Sc
5050 },
5151 },
5252 "role" : schema.StringAttribute {
53- MarkdownDescription : "Role to assign to the invited user. Must be one of `user` or `developer `." ,
53+ MarkdownDescription : "Role to assign to the invited user. Must be one of `user`, `developer`, `billing`, `admin`, or `claude_code_user `." ,
5454 Required : true ,
5555 Validators : []validator.String {
56- stringvalidator .OneOf ("user" , "developer" ),
56+ stringvalidator .OneOf ("user" , "developer" , "billing" , "admin" , "claude_code_user" ),
5757 },
5858 PlanModifiers : []planmodifier.String {
5959 stringplanmodifier .RequiresReplace (),
@@ -127,14 +127,17 @@ func (r *OrganizationInviteResource) Read(ctx context.Context, req resource.Read
127127 return
128128 }
129129
130- // Note: The API doesn't provide a GET endpoint for individual invites
131- // We need to list all invites and find the matching one
132- httpResp , err := r .client .ListInvitesWithResponse (ctx , & apiclient.ListInvitesParams {})
130+ httpResp , err := r .client .GetInviteWithResponse (ctx , data .Id .ValueString ())
133131 if err != nil {
134132 resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read invite, got error: %s" , err ))
135133 return
136134 }
137135
136+ if httpResp .StatusCode () == http .StatusNotFound {
137+ resp .State .RemoveResource (ctx )
138+ return
139+ }
140+
138141 if httpResp .StatusCode () != http .StatusOK {
139142 resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read invite, got status code %d: %s" , httpResp .StatusCode (), string (httpResp .Body )))
140143 return
@@ -145,22 +148,7 @@ func (r *OrganizationInviteResource) Read(ctx context.Context, req resource.Read
145148 return
146149 }
147150
148- // Find the invite by ID
149- inviteId := data .Id .ValueString ()
150- var foundInvite * apiclient.Invite
151- for _ , invite := range httpResp .JSON200 .Data {
152- if invite .Id == inviteId {
153- foundInvite = & invite
154- break
155- }
156- }
157-
158- if foundInvite == nil {
159- resp .State .RemoveResource (ctx )
160- return
161- }
162-
163- if err := data .Fill (* foundInvite ); err != nil {
151+ if err := data .Fill (* httpResp .JSON200 ); err != nil {
164152 resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to fill data: %s" , err ))
165153 return
166154 }
0 commit comments