Skip to content

Commit

Permalink
feat: use mapping v2 instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateus Nardo committed Mar 18, 2024
1 parent bb3d0c8 commit c9dd665
Show file tree
Hide file tree
Showing 22 changed files with 811 additions and 468 deletions.
15 changes: 9 additions & 6 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
lockVersion: 2.0.0
id: a76d605f-5242-4bd3-8bd6-56a119e8eec5
management:
docChecksum: 9831faf457882e4b7bc0b7c48f868243
docChecksum: ae29b3fcceec01e66c2cc82511b7ead8
docVersion: 1.0.0
speakeasyVersion: internal
generationVersion: 2.277.0
releaseVersion: 0.4.0
configChecksum: fb45ccd414fc5968746be04cae188174
speakeasyVersion: 1.209.3
generationVersion: 2.281.2
releaseVersion: 0.6.3
configChecksum: b1a2776f8c531a591daf0dcbb133693c
repoURL: https://github.com/epilot-dev/terraform-provider-epilot-entitymapping.git
repoSubDirectory: .
published: true
features:
terraform:
additionalProperties: 0.1.2
constsAndDefaults: 0.1.4
core: 3.10.2
core: 3.10.3
deprecations: 2.81.1
globalSecurity: 2.81.5
globalServerURLs: 2.82.1
Expand Down Expand Up @@ -89,6 +89,8 @@ generatedFiles:
- internal/sdk/pkg/models/operations/getallversions.go
- internal/sdk/pkg/models/operations/getconfig.go
- internal/sdk/pkg/models/operations/getconfigversion.go
- internal/sdk/pkg/models/operations/getmappingconfig.go
- internal/sdk/pkg/models/operations/putmappingconfig.go
- internal/sdk/pkg/models/operations/querymappinghistory.go
- internal/sdk/pkg/models/operations/searchconfigs.go
- internal/sdk/pkg/models/operations/storeconfig.go
Expand Down Expand Up @@ -118,6 +120,7 @@ generatedFiles:
- internal/sdk/pkg/models/shared/executerelationsreq.go
- internal/sdk/pkg/models/shared/relationitem.go
- internal/sdk/pkg/models/shared/mappingconfigsresp.go
- internal/sdk/pkg/models/shared/mappingconfigv2.go
- internal/sdk/pkg/models/shared/mappinghistoryresp.go
- internal/sdk/pkg/models/shared/mappinghistoryentry.go
- internal/sdk/pkg/models/shared/searchmappingreq.go
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ terraform {
required_providers {
epilot-entitymapping = {
source = "epilot-dev/epilot-entitymapping"
version = "0.4.0"
version = "0.6.3"
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions docs/data-sources/entity_mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ EntityMapping DataSource

```terraform
data "epilot-entitymapping_entity_mapping" "my_entitymapping" {
id = "uuidv4"
id = "70542580-2b38-4bfc-af8d-bb90102f9f47"
}
```

Expand All @@ -27,10 +27,8 @@ data "epilot-entitymapping_entity_mapping" "my_entitymapping" {

### Read-Only

- `org_id` (String)
- `source` (Attributes) (see [below for nested schema](#nestedatt--source))
- `targets` (Attributes List) (see [below for nested schema](#nestedatt--targets))
- `version` (Number)

<a id="nestedatt--source"></a>
### Nested Schema for `source`
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
required_providers {
epilot-entitymapping = {
source = "epilot-dev/epilot-entitymapping"
version = "0.4.0"
version = "0.6.3"
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions docs/resources/entity_mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ EntityMapping Resource

```terraform
resource "epilot-entitymapping_entity_mapping" "my_entitymapping" {
id = "20fec022-fdfb-42b1-b545-9c73d2673f99"
org_id = "...my_org_id..."
id = "20fec022-fdfb-42b1-b545-9c73d2673f99"
source = {
config = {
entity_ref = {
Expand Down Expand Up @@ -80,7 +79,6 @@ resource "epilot-entitymapping_entity_mapping" "my_entitymapping" {
]
},
]
version = 34.53
}
```

Expand All @@ -90,10 +88,8 @@ resource "epilot-entitymapping_entity_mapping" "my_entitymapping" {
### Required

- `id` (String) Mapping Config Id. Requires replacement if changed.
- `org_id` (String) Requires replacement if changed.
- `source` (Attributes) Requires replacement if changed. (see [below for nested schema](#nestedatt--source))
- `targets` (Attributes List) Requires replacement if changed. (see [below for nested schema](#nestedatt--targets))
- `version` (Number) Requires replacement if changed.

<a id="nestedatt--source"></a>
### Nested Schema for `source`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
data "epilot-entitymapping_entity_mapping" "my_entitymapping" {
id = "uuidv4"
id = "70542580-2b38-4bfc-af8d-bb90102f9f47"
}
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
epilot-entitymapping = {
source = "epilot-dev/epilot-entitymapping"
version = "0.4.0"
version = "0.6.3"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generation:
sdkFlattening: true
telemetryEnabled: false
terraform:
version: 0.4.0
version: 0.6.3
author: epilot-dev
imports:
option: openapi
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05
github.com/hashicorp/terraform-plugin-framework v1.3.5
github.com/hashicorp/terraform-plugin-go v0.18.0
github.com/spyzhov/ajson v0.9.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
github.com/spyzhov/ajson v0.9.0 h1:tF46gJGOenYVj+k9K1U1XpCxVWhmiyY5PsVCAs1+OJ0=
github.com/spyzhov/ajson v0.9.0/go.mod h1:a6oSw0MMb7Z5aD2tPoPO+jq11ETKgXUr2XktHdT8Wt8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
Expand Down
16 changes: 4 additions & 12 deletions internal/provider/entitymapping_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ type EntityMappingDataSource struct {
// EntityMappingDataSourceModel describes the data model.
type EntityMappingDataSourceModel struct {
ID types.String `tfsdk:"id"`
OrgID types.String `tfsdk:"org_id"`
Source SourceConfig `tfsdk:"source"`
Targets []TargetConfig `tfsdk:"targets"`
Version types.Number `tfsdk:"version"`
}

// Metadata returns the data source type name.
Expand All @@ -50,9 +48,6 @@ func (r *EntityMappingDataSource) Schema(ctx context.Context, req datasource.Sch
Required: true,
Description: `Mapping Config Id`,
},
"org_id": schema.StringAttribute{
Computed: true,
},
"source": schema.SingleNestedAttribute{
Computed: true,
Attributes: map[string]schema.Attribute{
Expand Down Expand Up @@ -373,9 +368,6 @@ func (r *EntityMappingDataSource) Schema(ctx context.Context, req datasource.Sch
},
},
},
"version": schema.NumberAttribute{
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -419,10 +411,10 @@ func (r *EntityMappingDataSource) Read(ctx context.Context, req datasource.ReadR
}

id := data.ID.ValueString()
request := operations.GetConfigRequest{
request := operations.GetMappingConfigRequest{
ID: id,
}
res, err := r.client.Mappings.GetConfig(ctx, request)
res, err := r.client.Mappings.GetMappingConfig(ctx, request)
if err != nil {
resp.Diagnostics.AddError("failure to invoke API", err.Error())
if res != nil && res.RawResponse != nil {
Expand All @@ -438,11 +430,11 @@ func (r *EntityMappingDataSource) Read(ctx context.Context, req datasource.ReadR
resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse))
return
}
if res.MappingConfig == nil {
if res.MappingConfigV2 == nil {
resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse))
return
}
data.RefreshFromSharedMappingConfig(res.MappingConfig)
data.RefreshFromSharedMappingConfigV2(res.MappingConfigV2)

// Save updated data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
Expand Down
Loading

0 comments on commit c9dd665

Please sign in to comment.