diff --git a/graphql/generated.go b/graphql/generated.go index 9128e60..0aa3a49 100644 --- a/graphql/generated.go +++ b/graphql/generated.go @@ -261,11 +261,16 @@ func (v *CreateAppMutationCreateAppCreateAppPayloadApp) GetOrganization() Create // CreateAppMutationCreateAppCreateAppPayloadAppOrganization includes the requested fields of the GraphQL type Organization. type CreateAppMutationCreateAppCreateAppPayloadAppOrganization struct { Id string `json:"id"` + // Unique organization slug + Slug string `json:"slug"` } // GetId returns CreateAppMutationCreateAppCreateAppPayloadAppOrganization.Id, and is useful for accessing the field via an interface. func (v *CreateAppMutationCreateAppCreateAppPayloadAppOrganization) GetId() string { return v.Id } +// GetSlug returns CreateAppMutationCreateAppCreateAppPayloadAppOrganization.Slug, and is useful for accessing the field via an interface. +func (v *CreateAppMutationCreateAppCreateAppPayloadAppOrganization) GetSlug() string { return v.Slug } + // CreateAppMutationResponse is returned by CreateAppMutation on success. type CreateAppMutationResponse struct { CreateApp CreateAppMutationCreateAppCreateAppPayload `json:"createApp"` @@ -817,11 +822,16 @@ func (v *GetFullAppAppIpAddressesIPAddressConnectionNodesIPAddress) GetId() stri // GetFullAppAppOrganization includes the requested fields of the GraphQL type Organization. type GetFullAppAppOrganization struct { Id string `json:"id"` + // Unique organization slug + Slug string `json:"slug"` } // GetId returns GetFullAppAppOrganization.Id, and is useful for accessing the field via an interface. func (v *GetFullAppAppOrganization) GetId() string { return v.Id } +// GetSlug returns GetFullAppAppOrganization.Slug, and is useful for accessing the field via an interface. +func (v *GetFullAppAppOrganization) GetSlug() string { return v.Slug } + // GetFullAppAppRole includes the requested fields of the GraphQL interface AppRole. // // GetFullAppAppRole is implemented by the following types: @@ -1623,6 +1633,7 @@ mutation CreateAppMutation ($name: String, $organizationId: ID!) { status organization { id + slug } } } @@ -1867,6 +1878,7 @@ query GetFullApp ($name: String) { network organization { id + slug } autoscaling { preferredRegion diff --git a/graphql/genqlient.graphql b/graphql/genqlient.graphql index 8a54ec7..c2633db 100644 --- a/graphql/genqlient.graphql +++ b/graphql/genqlient.graphql @@ -4,6 +4,7 @@ query GetFullApp($name: String) { network organization { id + slug } autoscaling { preferredRegion @@ -47,6 +48,7 @@ mutation CreateAppMutation($name: String, $organizationId: ID!) { status organization { id + slug } } } diff --git a/internal/provider/app_resource.go b/internal/provider/app_resource.go index 9fbeb70..db44dd5 100644 --- a/internal/provider/app_resource.go +++ b/internal/provider/app_resource.go @@ -22,8 +22,9 @@ var _ tfsdk.ResourceWithImportState = flyAppResource{} type flyAppResourceType struct{} type flyAppResourceData struct { - Name types.String `tfsdk:"name"` - Org types.String `tfsdk:"org"` + Name types.String `tfsdk:"name"` + Org types.String `tfsdk:"org"` + OrgId types.String `tfsdk:"orgid"` } func (ar flyAppResourceType) GetSchema(context.Context) (tfsdk.Schema, diag.Diagnostics) { @@ -40,7 +41,12 @@ func (ar flyAppResourceType) GetSchema(context.Context) (tfsdk.Schema, diag.Diag "org": { Computed: true, Optional: true, - MarkdownDescription: "Optional org ID to operate upon", + MarkdownDescription: "Optional org slug to operate upon", + Type: types.StringType, + }, + "orgid": { + Computed: true, + MarkdownDescription: "readonly orgid", Type: types.StringType, }, }, @@ -82,7 +88,7 @@ func (r flyAppResource) Create(ctx context.Context, req tfsdk.CreateResourceRequ resp.Diagnostics.AddError("Could not resolve organization", err.Error()) return } - data.Org.Value = org.Organization.Id + data.OrgId.Value = org.Organization.Id } mresp, err := graphql.CreateAppMutation(context.Background(), *r.provider.client, data.Name.Value, data.Org.Value) @@ -92,8 +98,9 @@ func (r flyAppResource) Create(ctx context.Context, req tfsdk.CreateResourceRequ } data = flyAppResourceData{ - Org: types.String{Value: mresp.CreateApp.App.Organization.Id}, - Name: types.String{Value: mresp.CreateApp.App.Name}, + Org: types.String{Value: mresp.CreateApp.App.Organization.Slug}, + OrgId: types.String{Value: mresp.CreateApp.App.Organization.Id}, + Name: types.String{Value: mresp.CreateApp.App.Name}, } diags = resp.State.Set(ctx, &data) @@ -127,8 +134,9 @@ func (r flyAppResource) Read(ctx context.Context, req tfsdk.ReadResourceRequest, } data = flyAppResourceData{ - Name: types.String{Value: query.App.Name}, - Org: types.String{Value: query.App.Organization.Id}, + Name: types.String{Value: query.App.Name}, + Org: types.String{Value: query.App.Organization.Slug}, + OrgId: types.String{Value: query.App.Organization.Id}, } diags = resp.State.Set(ctx, &data)