-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from GK-Consulting/ikegentz/org_data_source
Data Source for Organizations
- Loading branch information
Showing
9 changed files
with
443 additions
and
64 deletions.
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,58 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "astronomer_organization Data Source - terraform-provider-astronomer" | ||
subcategory: "" | ||
description: |- | ||
Astronomer Organization Resource | ||
--- | ||
|
||
# astronomer_organization (Data Source) | ||
|
||
Astronomer Organization Resource | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "astronomer_organization" "test" { | ||
id = "abc123" # org id. | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (String) Organization's unique identifier | ||
|
||
### Optional | ||
|
||
- `payment_method` (String) Payment method (if set) | ||
|
||
### Read-Only | ||
|
||
- `billing_email` (String) Billing email on file for the organization. | ||
- `created_at` (String) Timestamped string of when this organization was created | ||
- `is_scim_enabled` (Boolean) Whether or not scim is enabled | ||
- `managed_domains` (Attributes List) List of managed domains (nested) (see [below for nested schema](#nestedatt--managed_domains)) | ||
- `name` (String) Organization's name | ||
- `product` (String) Type of astro product (e.g. hosted or hybrid) | ||
- `status` (String) Status of the organization | ||
- `support_plan` (String) Type of support plan the organization has | ||
- `trial_expires_at` (String) When the trial expires, if organization is in a trial | ||
- `updated_at` (String) Last time the organization was updated | ||
|
||
<a id="nestedatt--managed_domains"></a> | ||
### Nested Schema for `managed_domains` | ||
|
||
Required: | ||
|
||
- `created_at` (String) | ||
|
||
Read-Only: | ||
|
||
- `enforced_logins` (List of String) | ||
- `id` (Boolean) | ||
- `name` (String) | ||
- `status` (String) | ||
- `updated_at` (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,3 @@ | ||
data "astronomer_organization" "test" { | ||
id = "abc123" # org id. | ||
} |
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
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,70 @@ | ||
package api | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
type OrgListResponse struct { | ||
Organizations []OrgResponse `json:"organizations"` | ||
Limit int `json:"limit"` | ||
Offset int `json:"offset"` | ||
TotalCount int `json:"totalCount"` | ||
} | ||
|
||
type OrgResponse struct { | ||
BillingEmail string `json:"billingEmail"` | ||
CreatedAt string `json:"createdAt"` | ||
CreatedBy BasicSubjectProfileResponse `json:"createdBy"` | ||
Id string `json:"id"` | ||
IsScimEnabled bool `json:"isScimEnabled"` | ||
ManagedDomains []ManagedDomainResponse `json:"managedDomains"` | ||
Name string `json:"name"` | ||
PaymentMethod string `json:"paymentMethod"` | ||
Product string `json:"product"` | ||
Status string `json:"status"` | ||
SupportPlan string `json:"supportPlan"` | ||
TrialExpiresAt string `json:"trialExpiresAt"` | ||
UpdatedAt string `json:"updatedAt"` | ||
UpdatedBy BasicSubjectProfileResponse `json:"updatedBy"` | ||
} | ||
|
||
type BasicSubjectProfileResponse struct { | ||
APITokenName string `json:"apiTokenName"` | ||
AvatarUrl string `json:"avatarUrl"` | ||
FullName string `json:"fullName"` | ||
Id string `json:"id"` | ||
SubjectType string `json:"subjectType"` | ||
Username string `json:"username"` | ||
} | ||
|
||
type ManagedDomainResponse struct { | ||
CreatedAt string `json:"createdAt"` | ||
EnforcedLogins []string `json:"enforcedLogins"` | ||
Id string `json:"id"` | ||
Name string `json:"name"` | ||
Status string `json:"status"` | ||
UpdatedAt string `json:"updatedAt"` | ||
} | ||
|
||
func GetOrgs(apiKey string) (*OrgListResponse, error) { | ||
request, _ := http.NewRequest("GET", urlBase, nil) | ||
decoded := new(OrgListResponse) | ||
err := getObjectFromApi(apiKey, request, &decoded) | ||
if err != nil { | ||
return nil, fmt.Errorf("%s", err) | ||
} | ||
|
||
return decoded, nil | ||
} | ||
|
||
func GetOrg(apiKey string, orgId string) (*OrgResponse, error) { | ||
request, _ := http.NewRequest("GET", urlBase+orgId, nil) | ||
decoded := new(OrgResponse) | ||
err := getObjectFromApi(apiKey, request, &decoded) | ||
if err != nil { | ||
return nil, fmt.Errorf("%s", err) | ||
} | ||
|
||
return decoded, nil | ||
} |
Oops, something went wrong.