diff --git a/RELEASES.md b/RELEASES.md index 3754f46..13e5f90 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -64,4 +64,10 @@ Based on: ### Changes Based on: - OpenAPI Doc v1 +- Speakeasy CLI 1.65.1 (2.73.1) https://github.com/speakeasy-api/speakeasy + +## 2023-07-27 04:31:21 +### Changes +Based on: +- OpenAPI Doc v1 - Speakeasy CLI 1.65.1 (2.73.1) https://github.com/speakeasy-api/speakeasy \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 1c4bd66..d80afa5 100755 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { abbey = { source = "abbeylabs/abbey" - version = "2.1.2" + version = "2.1.3" } } } diff --git a/examples/resources/abbey_identity/resource.tf b/examples/resources/abbey_identity/resource.tf index 5127548..ac0e26f 100755 --- a/examples/resources/abbey_identity/resource.tf +++ b/examples/resources/abbey_identity/resource.tf @@ -1,4 +1,5 @@ resource "abbey_identity" "my_identity" { - linked = "...my_linked..." - name = "Johnnie Stamm" + abbey_account = "...my_abbey_account..." + metadata = "...my_metadata..." + source = "...my_source..." } \ No newline at end of file diff --git a/files.gen b/files.gen index 6d087ee..e261550 100755 --- a/files.gen +++ b/files.gen @@ -86,6 +86,7 @@ internal/sdk/pkg/models/operations/revokegrant.go internal/sdk/pkg/models/operations/createidentity.go internal/sdk/pkg/models/operations/deleteidentity.go internal/sdk/pkg/models/operations/getidentity.go +internal/sdk/pkg/models/operations/updateidentity.go internal/sdk/pkg/models/operations/cancelrequestbyid.go internal/sdk/pkg/models/operations/createrequest.go internal/sdk/pkg/models/operations/getrequestbyid.go diff --git a/gen.yaml b/gen.yaml index 5a5636b..d8d75ec 100755 --- a/gen.yaml +++ b/gen.yaml @@ -1,6 +1,6 @@ configVersion: 1.0.0 management: - docChecksum: 809631c3933d3b3704193d18f529f859 + docChecksum: 1782e6a415dc8b830f4be9836e6c6fe6 docVersion: v1 speakeasyVersion: 1.65.1 generationVersion: 2.73.1 @@ -8,6 +8,6 @@ generation: sdkClassName: SDK singleTagPerOp: false terraform: - version: 2.1.2 + version: 2.1.3 author: abbeylabs packageName: abbey diff --git a/internal/provider/identity_resource.go b/internal/provider/identity_resource.go index 6aa499b..65ca10f 100755 --- a/internal/provider/identity_resource.go +++ b/internal/provider/identity_resource.go @@ -12,8 +12,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" @@ -34,10 +32,12 @@ type IdentityResource struct { // IdentityResourceModel describes the resource data model. type IdentityResourceModel struct { - CreatedAt types.String `tfsdk:"created_at"` - ID types.String `tfsdk:"id"` - Linked types.String `tfsdk:"linked"` - Name types.String `tfsdk:"name"` + AbbeyAccount types.String `tfsdk:"abbey_account"` + CreatedAt types.String `tfsdk:"created_at"` + ID types.String `tfsdk:"id"` + Metadata types.String `tfsdk:"metadata"` + Source types.String `tfsdk:"source"` + UpdatedAt types.String `tfsdk:"updated_at"` } func (r *IdentityResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -49,6 +49,9 @@ func (r *IdentityResource) Schema(ctx context.Context, req resource.SchemaReques MarkdownDescription: "Identity Resource", Attributes: map[string]schema.Attribute{ + "abbey_account": schema.StringAttribute{ + Required: true, + }, "created_at": schema.StringAttribute{ Computed: true, Validators: []validator.String{ @@ -58,19 +61,19 @@ func (r *IdentityResource) Schema(ctx context.Context, req resource.SchemaReques "id": schema.StringAttribute{ Computed: true, }, - "linked": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, + "metadata": schema.StringAttribute{ Required: true, - Description: `Json encoded string. See documentation for details`, + Description: `Json encoded string. See documentation for details.`, }, - "name": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, + "source": schema.StringAttribute{ Required: true, }, + "updated_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, }, } } @@ -189,7 +192,30 @@ func (r *IdentityResource) Update(ctx context.Context, req resource.UpdateReques return } - // Not Implemented; all attributes marked as RequiresReplace + identityParams := *data.ToUpdateSDKType() + identityID := data.ID.ValueString() + request := operations.UpdateIdentityRequest{ + IdentityParams: identityParams, + IdentityID: identityID, + } + res, err := r.client.Identities.UpdateIdentity(ctx, request) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + return + } + if res == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) + return + } + if res.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) + return + } + if res.Identity == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) + return + } + data.RefreshFromUpdateResponse(res.Identity) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/identity_resource_sdk.go b/internal/provider/identity_resource_sdk.go index ea73321..46b40fe 100755 --- a/internal/provider/identity_resource_sdk.go +++ b/internal/provider/identity_resource_sdk.go @@ -9,11 +9,13 @@ import ( ) func (r *IdentityResourceModel) ToCreateSDKType() *shared.IdentityParams { - linked := r.Linked.ValueString() - name := r.Name.ValueString() + abbeyAccount := r.AbbeyAccount.ValueString() + metadata := r.Metadata.ValueString() + source := r.Source.ValueString() out := shared.IdentityParams{ - Linked: linked, - Name: name, + AbbeyAccount: abbeyAccount, + Metadata: metadata, + Source: source, } return &out } @@ -23,18 +25,29 @@ func (r *IdentityResourceModel) ToGetSDKType() *shared.IdentityParams { return out } +func (r *IdentityResourceModel) ToUpdateSDKType() *shared.IdentityParams { + out := r.ToCreateSDKType() + return out +} + func (r *IdentityResourceModel) ToDeleteSDKType() *shared.IdentityParams { out := r.ToCreateSDKType() return out } func (r *IdentityResourceModel) RefreshFromGetResponse(resp *shared.Identity) { + r.AbbeyAccount = types.StringValue(resp.AbbeyAccount) r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339)) r.ID = types.StringValue(resp.ID) - r.Linked = types.StringValue(resp.Linked) - r.Name = types.StringValue(resp.Name) + r.Metadata = types.StringValue(resp.Metadata) + r.Source = types.StringValue(resp.Source) + r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339)) } func (r *IdentityResourceModel) RefreshFromCreateResponse(resp *shared.Identity) { r.RefreshFromGetResponse(resp) } + +func (r *IdentityResourceModel) RefreshFromUpdateResponse(resp *shared.Identity) { + r.RefreshFromGetResponse(resp) +} diff --git a/internal/sdk/identities.go b/internal/sdk/identities.go index ec04fc2..383dc27 100755 --- a/internal/sdk/identities.go +++ b/internal/sdk/identities.go @@ -245,3 +245,85 @@ func (s *identities) GetIdentity(ctx context.Context, request operations.GetIden return res, nil } + +// UpdateIdentity - Update an Identity +// Updates an identity. +func (s *identities) UpdateIdentity(ctx context.Context, request operations.UpdateIdentityRequest) (*operations.UpdateIdentityResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url, err := utils.GenerateURL(ctx, baseURL, "/identities/{identity_id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "IdentityParams", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + req, err := http.NewRequestWithContext(ctx, "PUT", url, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json;q=1, application/json;q=0") + req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.UpdateIdentityResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Identity + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return nil, err + } + + res.Identity = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return nil, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/sdk/pkg/models/operations/updateidentity.go b/internal/sdk/pkg/models/operations/updateidentity.go new file mode 100755 index 0000000..ffb6532 --- /dev/null +++ b/internal/sdk/pkg/models/operations/updateidentity.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type UpdateIdentityRequest struct { + IdentityParams shared.IdentityParams `request:"mediaType=application/json"` + // The ID of the identity to retrieve + IdentityID string `pathParam:"style=simple,explode=false,name=identity_id"` +} + +type UpdateIdentityResponse struct { + ContentType string + // Authentication Failed + Error *shared.Error + // Success + Identity *shared.Identity + StatusCode int + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/shared/identity.go b/internal/sdk/pkg/models/shared/identity.go index 8af65da..7ae3090 100755 --- a/internal/sdk/pkg/models/shared/identity.go +++ b/internal/sdk/pkg/models/shared/identity.go @@ -8,9 +8,11 @@ import ( // Identity - Created type Identity struct { - CreatedAt time.Time `json:"created_at"` - ID string `json:"id"` - // Json encoded string. See documentation for details - Linked string `json:"linked"` - Name string `json:"name"` + AbbeyAccount string `json:"abbey_account"` + CreatedAt time.Time `json:"created_at"` + ID string `json:"id"` + // Json encoded string. See documentation for details. + Metadata string `json:"metadata"` + Source string `json:"source"` + UpdatedAt time.Time `json:"updated_at"` } diff --git a/internal/sdk/pkg/models/shared/identityparams.go b/internal/sdk/pkg/models/shared/identityparams.go index 78fd333..8229508 100755 --- a/internal/sdk/pkg/models/shared/identityparams.go +++ b/internal/sdk/pkg/models/shared/identityparams.go @@ -3,7 +3,8 @@ package shared type IdentityParams struct { - // Json encoded string. See documentation for details - Linked string `json:"linked"` - Name string `json:"name"` + AbbeyAccount string `json:"abbey_account"` + // Json encoded string. See documentation for details. + Metadata string `json:"metadata"` + Source string `json:"source"` } diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index c8cb224..e9fca67 100755 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -177,7 +177,7 @@ func New(opts ...SDKOption) *SDK { sdkConfiguration: sdkConfiguration{ Language: "terraform", OpenAPIDocVersion: "v1", - SDKVersion: "2.1.2", + SDKVersion: "2.1.3", GenVersion: "2.73.1", }, }