generated from hashicorp/terraform-provider-scaffolding-framework
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add User Invite Resource #120
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "astro_user_invite Resource - astro" | ||
subcategory: "" | ||
description: |- | ||
User Invite resource | ||
--- | ||
|
||
# astro_user_invite (Resource) | ||
|
||
User Invite resource | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "astro_user_invite" "example" { | ||
email = "email@organization.com" | ||
role = "ORGANIZATION_MEMBER" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `email` (String) The email address of the user being invited | ||
- `role` (String) The Organization role to assign to the user | ||
|
||
### Read-Only | ||
|
||
- `expires_at` (String) The expiration date of the invite | ||
- `invite_id` (String) The ID of the invite | ||
- `invitee` (Attributes) The profile of the invitee (see [below for nested schema](#nestedatt--invitee)) | ||
- `inviter` (Attributes) The profile of the inviter (see [below for nested schema](#nestedatt--inviter)) | ||
- `user_id` (String) The ID of the user | ||
|
||
<a id="nestedatt--invitee"></a> | ||
### Nested Schema for `invitee` | ||
|
||
Read-Only: | ||
|
||
- `api_token_name` (String) | ||
- `avatar_url` (String) | ||
- `full_name` (String) | ||
- `id` (String) | ||
- `subject_type` (String) | ||
- `username` (String) | ||
|
||
|
||
<a id="nestedatt--inviter"></a> | ||
### Nested Schema for `inviter` | ||
|
||
Read-Only: | ||
|
||
- `api_token_name` (String) | ||
- `avatar_url` (String) | ||
- `full_name` (String) | ||
- `id` (String) | ||
- `subject_type` (String) | ||
- `username` (String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "astro_user_invite" "example" { | ||
email = "email@organization.com" | ||
role = "ORGANIZATION_MEMBER" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package models | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/astronomer/terraform-provider-astro/internal/clients/iam" | ||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
// UserInvite describes the user_invite resource | ||
type UserInvite struct { | ||
Email types.String `tfsdk:"email"` | ||
Role types.String `tfsdk:"role"` | ||
ExpiresAt types.String `tfsdk:"expires_at"` | ||
InviteId types.String `tfsdk:"invite_id"` | ||
Invitee types.Object `tfsdk:"invitee"` | ||
Inviter types.Object `tfsdk:"inviter"` | ||
UserId types.String `tfsdk:"user_id"` | ||
} | ||
|
||
func (data *UserInvite) ReadFromResponse(ctx context.Context, userInvite *iam.Invite, email string, role string) diag.Diagnostics { | ||
var diags diag.Diagnostics | ||
data.Email = types.StringValue(email) | ||
data.Role = types.StringValue(role) | ||
data.ExpiresAt = types.StringValue(userInvite.ExpiresAt) | ||
data.InviteId = types.StringValue(userInvite.InviteId) | ||
data.Invitee, diags = SubjectProfileTypesObject(ctx, userInvite.Invitee) | ||
if diags.HasError() { | ||
return diags | ||
} | ||
data.Inviter, diags = SubjectProfileTypesObject(ctx, userInvite.Inviter) | ||
if diags.HasError() { | ||
return diags | ||
} | ||
data.UserId = types.StringPointerValue(userInvite.UserId) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when we create new user invites, those users can be found in our org but by default they do not have the fields
fullName
oravatarUrl
populatedremoved so the test would not check those fields (as they'll always be empty for user invites)