diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 2d6f94d..a739035 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,7 +1,7 @@ lockVersion: 2.0.0 id: a592d325-751d-447c-af2a-581b9e706313 management: - docChecksum: 7c83c37d0d3c4bd49001fc001a8219c3 + docChecksum: f9a1075ba371591c3887ffe1e9319c03 docVersion: 1.0.0 speakeasyVersion: internal generationVersion: 2.272.7 diff --git a/docs/index.md b/docs/index.md index ed3414b..db87ca0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -40,7 +40,7 @@ terraform { required_providers { airbyte = { source = "aballiet/airbyte-oss" - version = "1.2.1" + version = "1.2.2" } } } diff --git a/docs/resources/airbyte_destination_definition.md b/docs/resources/airbyte_destination_definition.md index 9a4030e..e7fe1fa 100644 --- a/docs/resources/airbyte_destination_definition.md +++ b/docs/resources/airbyte_destination_definition.md @@ -14,19 +14,14 @@ DestinationDefinition Resource ```terraform resource "airbyte_destination_definition" "my_destinationdefinition" { - cpu_limit = "...my_cpu_limit..." - cpu_request = "...my_cpu_request..." docker_image_tag = "...my_docker_image_tag..." docker_repository = "...my_docker_repository..." documentation_url = "https://healthy-bandolier.com" icon = "...my_icon..." - job_type = "get_spec" - memory_limit = "...my_memory_limit..." - memory_request = "...my_memory_request..." - name = "Thelma Dooley" - scope_id = "7515722b-625e-4fa1-bbfa-8d645f719d13" + name = "Julie Frami" + scope_id = "87515722-b625-4efa-9bbf-a8d645f719d1" scope_type = "workspace" - workspace_id = "279f15ad-8bb3-4fe3-bfac-9256cf878498" + workspace_id = "3279f15a-d8bb-43fe-b3fa-c9256cf87849" } ``` @@ -38,16 +33,12 @@ resource "airbyte_destination_definition" "my_destinationdefinition" { - `docker_image_tag` (String) - `docker_repository` (String) Requires replacement if changed. - `documentation_url` (String) Requires replacement if changed. -- `job_type` (String) enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"] - `name` (String) Requires replacement if changed. ### Optional -- `cpu_limit` (String) -- `cpu_request` (String) - `icon` (String) Requires replacement if changed. -- `memory_limit` (String) -- `memory_request` (String) +- `resource_requirements` (Attributes) actor definition specific resource requirements. if default is set, these are the requirements that should be set for ALL jobs run for this actor definition. it is overriden by the job type specific configurations. if not set, the platform will use defaults. these values will be overriden by configuration at the connection level. (see [below for nested schema](#nestedatt--resource_requirements)) - `scope_id` (String) Requires replacement if changed. - `scope_type` (String) Requires replacement if changed. ; must be one of ["workspace", "organization"] - `workspace_id` (String) Requires replacement if changed. @@ -60,25 +51,13 @@ resource "airbyte_destination_definition" "my_destinationdefinition" { - `protocol_version` (String) The Airbyte Protocol version supported by the connector - `release_date` (String) The date when this connector was first released, in yyyy-mm-dd format. - `release_stage` (String) must be one of ["alpha", "beta", "generally_available", "custom"] -- `resource_requirements` (Attributes) actor definition specific resource requirements. if default is set, these are the requirements that should be set for ALL jobs run for this actor definition. it is overriden by the job type specific configurations. if not set, the platform will use defaults. these values will be overriden by configuration at the connection level. (see [below for nested schema](#nestedatt--resource_requirements)) - `support_level` (String) must be one of ["community", "certified", "none"] - `supports_dbt` (Boolean) an optional flag indicating whether DBT is used in the normalization. If the flag value is NULL - DBT is not used. - -### Nested Schema for `normalization_config` - -Read-Only: - -- `normalization_integration_type` (String) a field indicating the type of integration dialect to use for normalization. -- `normalization_repository` (String) a field indicating the name of the repository to be used for normalization. If the value of the flag is NULL - normalization is not used. -- `normalization_tag` (String) a field indicating the tag of the docker repository to be used for normalization. -- `supported` (Boolean) whether the destination definition supports normalization. - - ### Nested Schema for `resource_requirements` -Read-Only: +Optional: - `default` (Attributes) optional resource requirements to run workers (blank for unbounded allocations) (see [below for nested schema](#nestedatt--resource_requirements--default)) - `job_specific` (Attributes List) (see [below for nested schema](#nestedatt--resource_requirements--job_specific)) @@ -86,7 +65,7 @@ Read-Only: ### Nested Schema for `resource_requirements.default` -Read-Only: +Optional: - `cpu_limit` (String) - `cpu_request` (String) @@ -97,15 +76,15 @@ Read-Only: ### Nested Schema for `resource_requirements.job_specific` -Read-Only: +Optional: -- `job_type` (String) enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"] -- `resource_requirements` (Attributes) optional resource requirements to run workers (blank for unbounded allocations) (see [below for nested schema](#nestedatt--resource_requirements--job_specific--resource_requirements)) +- `job_type` (String) enum that describes the different types of jobs that the platform runs. Not Null; must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"] +- `resource_requirements` (Attributes) optional resource requirements to run workers (blank for unbounded allocations). Not Null (see [below for nested schema](#nestedatt--resource_requirements--job_specific--resource_requirements)) ### Nested Schema for `resource_requirements.job_specific.resource_requirements` -Read-Only: +Optional: - `cpu_limit` (String) - `cpu_request` (String) @@ -113,3 +92,16 @@ Read-Only: - `memory_request` (String) + + + +### Nested Schema for `normalization_config` + +Read-Only: + +- `normalization_integration_type` (String) a field indicating the type of integration dialect to use for normalization. +- `normalization_repository` (String) a field indicating the name of the repository to be used for normalization. If the value of the flag is NULL - normalization is not used. +- `normalization_tag` (String) a field indicating the tag of the docker repository to be used for normalization. +- `supported` (Boolean) whether the destination definition supports normalization. + + diff --git a/docs/resources/airbyte_operation.md b/docs/resources/airbyte_operation.md index f90874e..a9895da 100644 --- a/docs/resources/airbyte_operation.md +++ b/docs/resources/airbyte_operation.md @@ -14,7 +14,7 @@ Operation Resource ```terraform resource "airbyte_operation" "my_operation" { - name = "Jeff Barton" + name = "Dr. Arturo Fisher" operator_configuration = { dbt = { dbt_arguments = "...my_dbt_arguments..." diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 57a8b9c..31f57bb 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { airbyte = { source = "aballiet/airbyte-oss" - version = "1.2.1" + version = "1.2.2" } } } diff --git a/examples/resources/airbyte_destination_definition/resource.tf b/examples/resources/airbyte_destination_definition/resource.tf index 500895e..62f4aef 100644 --- a/examples/resources/airbyte_destination_definition/resource.tf +++ b/examples/resources/airbyte_destination_definition/resource.tf @@ -1,15 +1,10 @@ resource "airbyte_destination_definition" "my_destinationdefinition" { - cpu_limit = "...my_cpu_limit..." - cpu_request = "...my_cpu_request..." docker_image_tag = "...my_docker_image_tag..." docker_repository = "...my_docker_repository..." documentation_url = "https://healthy-bandolier.com" icon = "...my_icon..." - job_type = "get_spec" - memory_limit = "...my_memory_limit..." - memory_request = "...my_memory_request..." - name = "Thelma Dooley" - scope_id = "7515722b-625e-4fa1-bbfa-8d645f719d13" + name = "Julie Frami" + scope_id = "87515722-b625-4efa-9bbf-a8d645f719d1" scope_type = "workspace" - workspace_id = "279f15ad-8bb3-4fe3-bfac-9256cf878498" + workspace_id = "3279f15a-d8bb-43fe-b3fa-c9256cf87849" } \ No newline at end of file diff --git a/examples/resources/airbyte_operation/resource.tf b/examples/resources/airbyte_operation/resource.tf index 1f6c2ac..9235a62 100644 --- a/examples/resources/airbyte_operation/resource.tf +++ b/examples/resources/airbyte_operation/resource.tf @@ -1,5 +1,5 @@ resource "airbyte_operation" "my_operation" { - name = "Jeff Barton" + name = "Dr. Arturo Fisher" operator_configuration = { dbt = { dbt_arguments = "...my_dbt_arguments..." diff --git a/internal/provider/destinationdefinition_resource.go b/internal/provider/destinationdefinition_resource.go index 16117e8..c109745 100644 --- a/internal/provider/destinationdefinition_resource.go +++ b/internal/provider/destinationdefinition_resource.go @@ -9,6 +9,8 @@ import ( "github.com/aballiet/terraform-provider-airbyte/internal/sdk" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/aballiet/terraform-provider-airbyte/internal/validators" + speakeasy_objectvalidators "github.com/aballiet/terraform-provider-airbyte/internal/validators/objectvalidators" + speakeasy_stringvalidators "github.com/aballiet/terraform-provider-airbyte/internal/validators/stringvalidators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -35,17 +37,12 @@ type DestinationDefinitionResource struct { // DestinationDefinitionResourceModel describes the resource data model. type DestinationDefinitionResourceModel struct { - CPULimit types.String `tfsdk:"cpu_limit"` - CPURequest types.String `tfsdk:"cpu_request"` Custom types.Bool `tfsdk:"custom"` DestinationDefinitionID types.String `tfsdk:"destination_definition_id"` DockerImageTag types.String `tfsdk:"docker_image_tag"` DockerRepository types.String `tfsdk:"docker_repository"` DocumentationURL types.String `tfsdk:"documentation_url"` Icon types.String `tfsdk:"icon"` - JobType types.String `tfsdk:"job_type"` - MemoryLimit types.String `tfsdk:"memory_limit"` - MemoryRequest types.String `tfsdk:"memory_request"` Name types.String `tfsdk:"name"` NormalizationConfig NormalizationDestinationDefinitionConfig `tfsdk:"normalization_config"` ProtocolVersion types.String `tfsdk:"protocol_version"` @@ -68,12 +65,6 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource MarkdownDescription: "DestinationDefinition Resource", Attributes: map[string]schema.Attribute{ - "cpu_limit": schema.StringAttribute{ - Optional: true, - }, - "cpu_request": schema.StringAttribute{ - Optional: true, - }, "custom": schema.BoolAttribute{ Computed: true, Description: `Whether the connector is custom or not`, @@ -109,27 +100,6 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource Optional: true, Description: `Requires replacement if changed. `, }, - "job_type": schema.StringAttribute{ - Required: true, - Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "get_spec", - "check_connection", - "discover_schema", - "sync", - "reset_connection", - "connection_updater", - "replicate", - ), - }, - }, - "memory_limit": schema.StringAttribute{ - Optional: true, - }, - "memory_request": schema.StringAttribute{ - Optional: true, - }, "name": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplaceIfConfigured(), @@ -185,33 +155,42 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource }, "resource_requirements": schema.SingleNestedAttribute{ Computed: true, + Optional: true, Attributes: map[string]schema.Attribute{ "default": schema.SingleNestedAttribute{ Computed: true, + Optional: true, Attributes: map[string]schema.Attribute{ "cpu_limit": schema.StringAttribute{ Computed: true, + Optional: true, }, "cpu_request": schema.StringAttribute{ Computed: true, + Optional: true, }, "memory_limit": schema.StringAttribute{ Computed: true, + Optional: true, }, "memory_request": schema.StringAttribute{ Computed: true, + Optional: true, }, }, Description: `optional resource requirements to run workers (blank for unbounded allocations)`, }, "job_specific": schema.ListNestedAttribute{ Computed: true, + Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "job_type": schema.StringAttribute{ Computed: true, - Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, + Optional: true, + Description: `enum that describes the different types of jobs that the platform runs. Not Null; must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), stringvalidator.OneOf( "get_spec", "check_connection", @@ -225,21 +204,29 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource }, "resource_requirements": schema.SingleNestedAttribute{ Computed: true, + Optional: true, Attributes: map[string]schema.Attribute{ "cpu_limit": schema.StringAttribute{ Computed: true, + Optional: true, }, "cpu_request": schema.StringAttribute{ Computed: true, + Optional: true, }, "memory_limit": schema.StringAttribute{ Computed: true, + Optional: true, }, "memory_request": schema.StringAttribute{ Computed: true, + Optional: true, }, }, - Description: `optional resource requirements to run workers (blank for unbounded allocations)`, + Description: `optional resource requirements to run workers (blank for unbounded allocations). Not Null`, + Validators: []validator.Object{ + speakeasy_objectvalidators.NotNull(), + }, }, }, }, @@ -338,80 +325,7 @@ func (r *DestinationDefinitionResource) Create(ctx context.Context, req resource } else { workspaceID = nil } - name := data.Name.ValueString() - dockerRepository := data.DockerRepository.ValueString() - dockerImageTag := data.DockerImageTag.ValueString() - documentationURL := data.DocumentationURL.ValueString() - icon := new(string) - if !data.Icon.IsUnknown() && !data.Icon.IsNull() { - *icon = data.Icon.ValueString() - } else { - icon = nil - } - var resourceRequirements *shared.ActorDefinitionResourceRequirements - if data != nil { - var defaultVar *shared.ResourceRequirements - if data != nil { - cpuRequest := new(string) - if !data.CPURequest.IsUnknown() && !data.CPURequest.IsNull() { - *cpuRequest = data.CPURequest.ValueString() - } else { - cpuRequest = nil - } - cpuLimit := new(string) - if !data.CPULimit.IsUnknown() && !data.CPULimit.IsNull() { - *cpuLimit = data.CPULimit.ValueString() - } else { - cpuLimit = nil - } - memoryRequest := new(string) - if !data.MemoryRequest.IsUnknown() && !data.MemoryRequest.IsNull() { - *memoryRequest = data.MemoryRequest.ValueString() - } else { - memoryRequest = nil - } - memoryLimit := new(string) - if !data.MemoryLimit.IsUnknown() && !data.MemoryLimit.IsNull() { - *memoryLimit = data.MemoryLimit.ValueString() - } else { - memoryLimit = nil - } - defaultVar = &shared.ResourceRequirements{ - CPURequest: cpuRequest, - CPULimit: cpuLimit, - MemoryRequest: memoryRequest, - MemoryLimit: memoryLimit, - } - } - var jobType *shared.JobType - var cpuRequest1 *string - var cpuLimit1 *string - var memoryRequest1 *string - var memoryLimit1 *string - resourceRequirements1 := shared.ResourceRequirements{ - CPURequest: cpuRequest1, - CPULimit: cpuLimit1, - MemoryRequest: memoryRequest1, - MemoryLimit: memoryLimit1, - } - jobSpecificSingleton := shared.JobTypeResourceLimit{ - JobType: *jobType, - ResourceRequirements: resourceRequirements1, - } - jobSpecific := []shared.JobTypeResourceLimit{jobSpecificSingleton} - resourceRequirements = &shared.ActorDefinitionResourceRequirements{ - Default: defaultVar, - JobSpecific: jobSpecific, - } - } - destinationDefinition := shared.DestinationDefinitionCreate{ - Name: name, - DockerRepository: dockerRepository, - DockerImageTag: dockerImageTag, - DocumentationURL: documentationURL, - Icon: icon, - ResourceRequirements: resourceRequirements, - } + destinationDefinition := *data.ToSharedDestinationDefinitionCreate() scopeID := new(string) if !data.ScopeID.IsUnknown() && !data.ScopeID.IsNull() { *scopeID = data.ScopeID.ValueString() @@ -545,74 +459,7 @@ func (r *DestinationDefinitionResource) Update(ctx context.Context, req resource return } - destinationDefinitionID := data.DestinationDefinitionID.ValueString() - dockerImageTag := new(string) - if !data.DockerImageTag.IsUnknown() && !data.DockerImageTag.IsNull() { - *dockerImageTag = data.DockerImageTag.ValueString() - } else { - dockerImageTag = nil - } - var resourceRequirements *shared.ActorDefinitionResourceRequirements - if data != nil { - var defaultVar *shared.ResourceRequirements - if data != nil { - cpuRequest := new(string) - if !data.CPURequest.IsUnknown() && !data.CPURequest.IsNull() { - *cpuRequest = data.CPURequest.ValueString() - } else { - cpuRequest = nil - } - cpuLimit := new(string) - if !data.CPULimit.IsUnknown() && !data.CPULimit.IsNull() { - *cpuLimit = data.CPULimit.ValueString() - } else { - cpuLimit = nil - } - memoryRequest := new(string) - if !data.MemoryRequest.IsUnknown() && !data.MemoryRequest.IsNull() { - *memoryRequest = data.MemoryRequest.ValueString() - } else { - memoryRequest = nil - } - memoryLimit := new(string) - if !data.MemoryLimit.IsUnknown() && !data.MemoryLimit.IsNull() { - *memoryLimit = data.MemoryLimit.ValueString() - } else { - memoryLimit = nil - } - defaultVar = &shared.ResourceRequirements{ - CPURequest: cpuRequest, - CPULimit: cpuLimit, - MemoryRequest: memoryRequest, - MemoryLimit: memoryLimit, - } - } - var jobType *shared.JobType - var cpuRequest1 *string - var cpuLimit1 *string - var memoryRequest1 *string - var memoryLimit1 *string - resourceRequirements1 := shared.ResourceRequirements{ - CPURequest: cpuRequest1, - CPULimit: cpuLimit1, - MemoryRequest: memoryRequest1, - MemoryLimit: memoryLimit1, - } - jobSpecificSingleton := shared.JobTypeResourceLimit{ - JobType: *jobType, - ResourceRequirements: resourceRequirements1, - } - jobSpecific := []shared.JobTypeResourceLimit{jobSpecificSingleton} - resourceRequirements = &shared.ActorDefinitionResourceRequirements{ - Default: defaultVar, - JobSpecific: jobSpecific, - } - } - request := shared.DestinationDefinitionUpdate{ - DestinationDefinitionID: destinationDefinitionID, - DockerImageTag: dockerImageTag, - ResourceRequirements: resourceRequirements, - } + request := *data.ToSharedDestinationDefinitionUpdate() res, err := r.client.DestinationDefinition.UpdateDestinationDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -635,32 +482,6 @@ func (r *DestinationDefinitionResource) Update(ctx context.Context, req resource } data.RefreshFromSharedDestinationDefinitionRead(res.DestinationDefinitionRead) refreshPlan(ctx, plan, &data, resp.Diagnostics) - destinationDefinitionId1 := data.DestinationDefinitionID.ValueString() - request1 := shared.DestinationDefinitionIDRequestBody{ - DestinationDefinitionID: destinationDefinitionId1, - } - res1, err := r.client.DestinationDefinition.GetDestinationDefinition(ctx, request1) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res1 != nil && res1.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) - } - return - } - if res1 == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) - return - } - if res1.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) - return - } - if res1.DestinationDefinitionRead == nil { - resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) - return - } - data.RefreshFromSharedDestinationDefinitionRead(res1.DestinationDefinitionRead) - refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/destinationdefinition_resource_sdk.go b/internal/provider/destinationdefinition_resource_sdk.go index 52b74f8..787e49d 100644 --- a/internal/provider/destinationdefinition_resource_sdk.go +++ b/internal/provider/destinationdefinition_resource_sdk.go @@ -7,6 +7,106 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) +func (r *DestinationDefinitionResourceModel) ToSharedDestinationDefinitionCreate() *shared.DestinationDefinitionCreate { + name := r.Name.ValueString() + dockerRepository := r.DockerRepository.ValueString() + dockerImageTag := r.DockerImageTag.ValueString() + documentationURL := r.DocumentationURL.ValueString() + icon := new(string) + if !r.Icon.IsUnknown() && !r.Icon.IsNull() { + *icon = r.Icon.ValueString() + } else { + icon = nil + } + var resourceRequirements *shared.ActorDefinitionResourceRequirements + if r.ResourceRequirements != nil { + var defaultVar *shared.ResourceRequirements + if r.ResourceRequirements.Default != nil { + cpuRequest := new(string) + if !r.ResourceRequirements.Default.CPURequest.IsUnknown() && !r.ResourceRequirements.Default.CPURequest.IsNull() { + *cpuRequest = r.ResourceRequirements.Default.CPURequest.ValueString() + } else { + cpuRequest = nil + } + cpuLimit := new(string) + if !r.ResourceRequirements.Default.CPULimit.IsUnknown() && !r.ResourceRequirements.Default.CPULimit.IsNull() { + *cpuLimit = r.ResourceRequirements.Default.CPULimit.ValueString() + } else { + cpuLimit = nil + } + memoryRequest := new(string) + if !r.ResourceRequirements.Default.MemoryRequest.IsUnknown() && !r.ResourceRequirements.Default.MemoryRequest.IsNull() { + *memoryRequest = r.ResourceRequirements.Default.MemoryRequest.ValueString() + } else { + memoryRequest = nil + } + memoryLimit := new(string) + if !r.ResourceRequirements.Default.MemoryLimit.IsUnknown() && !r.ResourceRequirements.Default.MemoryLimit.IsNull() { + *memoryLimit = r.ResourceRequirements.Default.MemoryLimit.ValueString() + } else { + memoryLimit = nil + } + defaultVar = &shared.ResourceRequirements{ + CPURequest: cpuRequest, + CPULimit: cpuLimit, + MemoryRequest: memoryRequest, + MemoryLimit: memoryLimit, + } + } + var jobSpecific []shared.JobTypeResourceLimit = nil + for _, jobSpecificItem := range r.ResourceRequirements.JobSpecific { + jobType := shared.JobType(jobSpecificItem.JobType.ValueString()) + cpuRequest1 := new(string) + if !jobSpecificItem.ResourceRequirements.CPURequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPURequest.IsNull() { + *cpuRequest1 = jobSpecificItem.ResourceRequirements.CPURequest.ValueString() + } else { + cpuRequest1 = nil + } + cpuLimit1 := new(string) + if !jobSpecificItem.ResourceRequirements.CPULimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPULimit.IsNull() { + *cpuLimit1 = jobSpecificItem.ResourceRequirements.CPULimit.ValueString() + } else { + cpuLimit1 = nil + } + memoryRequest1 := new(string) + if !jobSpecificItem.ResourceRequirements.MemoryRequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryRequest.IsNull() { + *memoryRequest1 = jobSpecificItem.ResourceRequirements.MemoryRequest.ValueString() + } else { + memoryRequest1 = nil + } + memoryLimit1 := new(string) + if !jobSpecificItem.ResourceRequirements.MemoryLimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryLimit.IsNull() { + *memoryLimit1 = jobSpecificItem.ResourceRequirements.MemoryLimit.ValueString() + } else { + memoryLimit1 = nil + } + resourceRequirements1 := shared.ResourceRequirements{ + CPURequest: cpuRequest1, + CPULimit: cpuLimit1, + MemoryRequest: memoryRequest1, + MemoryLimit: memoryLimit1, + } + jobSpecific = append(jobSpecific, shared.JobTypeResourceLimit{ + JobType: jobType, + ResourceRequirements: resourceRequirements1, + }) + } + resourceRequirements = &shared.ActorDefinitionResourceRequirements{ + Default: defaultVar, + JobSpecific: jobSpecific, + } + } + out := shared.DestinationDefinitionCreate{ + Name: name, + DockerRepository: dockerRepository, + DockerImageTag: dockerImageTag, + DocumentationURL: documentationURL, + Icon: icon, + ResourceRequirements: resourceRequirements, + } + return &out +} + func (r *DestinationDefinitionResourceModel) RefreshFromSharedDestinationDefinitionRead(resp *shared.DestinationDefinitionRead) { r.Custom = types.BoolPointerValue(resp.Custom) r.DestinationDefinitionID = types.StringValue(resp.DestinationDefinitionID) @@ -68,3 +168,97 @@ func (r *DestinationDefinitionResourceModel) RefreshFromSharedDestinationDefinit } r.SupportsDbt = types.BoolValue(resp.SupportsDbt) } + +func (r *DestinationDefinitionResourceModel) ToSharedDestinationDefinitionUpdate() *shared.DestinationDefinitionUpdate { + destinationDefinitionID := r.DestinationDefinitionID.ValueString() + dockerImageTag := new(string) + if !r.DockerImageTag.IsUnknown() && !r.DockerImageTag.IsNull() { + *dockerImageTag = r.DockerImageTag.ValueString() + } else { + dockerImageTag = nil + } + var resourceRequirements *shared.ActorDefinitionResourceRequirements + if r.ResourceRequirements != nil { + var defaultVar *shared.ResourceRequirements + if r.ResourceRequirements.Default != nil { + cpuRequest := new(string) + if !r.ResourceRequirements.Default.CPURequest.IsUnknown() && !r.ResourceRequirements.Default.CPURequest.IsNull() { + *cpuRequest = r.ResourceRequirements.Default.CPURequest.ValueString() + } else { + cpuRequest = nil + } + cpuLimit := new(string) + if !r.ResourceRequirements.Default.CPULimit.IsUnknown() && !r.ResourceRequirements.Default.CPULimit.IsNull() { + *cpuLimit = r.ResourceRequirements.Default.CPULimit.ValueString() + } else { + cpuLimit = nil + } + memoryRequest := new(string) + if !r.ResourceRequirements.Default.MemoryRequest.IsUnknown() && !r.ResourceRequirements.Default.MemoryRequest.IsNull() { + *memoryRequest = r.ResourceRequirements.Default.MemoryRequest.ValueString() + } else { + memoryRequest = nil + } + memoryLimit := new(string) + if !r.ResourceRequirements.Default.MemoryLimit.IsUnknown() && !r.ResourceRequirements.Default.MemoryLimit.IsNull() { + *memoryLimit = r.ResourceRequirements.Default.MemoryLimit.ValueString() + } else { + memoryLimit = nil + } + defaultVar = &shared.ResourceRequirements{ + CPURequest: cpuRequest, + CPULimit: cpuLimit, + MemoryRequest: memoryRequest, + MemoryLimit: memoryLimit, + } + } + var jobSpecific []shared.JobTypeResourceLimit = nil + for _, jobSpecificItem := range r.ResourceRequirements.JobSpecific { + jobType := shared.JobType(jobSpecificItem.JobType.ValueString()) + cpuRequest1 := new(string) + if !jobSpecificItem.ResourceRequirements.CPURequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPURequest.IsNull() { + *cpuRequest1 = jobSpecificItem.ResourceRequirements.CPURequest.ValueString() + } else { + cpuRequest1 = nil + } + cpuLimit1 := new(string) + if !jobSpecificItem.ResourceRequirements.CPULimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPULimit.IsNull() { + *cpuLimit1 = jobSpecificItem.ResourceRequirements.CPULimit.ValueString() + } else { + cpuLimit1 = nil + } + memoryRequest1 := new(string) + if !jobSpecificItem.ResourceRequirements.MemoryRequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryRequest.IsNull() { + *memoryRequest1 = jobSpecificItem.ResourceRequirements.MemoryRequest.ValueString() + } else { + memoryRequest1 = nil + } + memoryLimit1 := new(string) + if !jobSpecificItem.ResourceRequirements.MemoryLimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryLimit.IsNull() { + *memoryLimit1 = jobSpecificItem.ResourceRequirements.MemoryLimit.ValueString() + } else { + memoryLimit1 = nil + } + resourceRequirements1 := shared.ResourceRequirements{ + CPURequest: cpuRequest1, + CPULimit: cpuLimit1, + MemoryRequest: memoryRequest1, + MemoryLimit: memoryLimit1, + } + jobSpecific = append(jobSpecific, shared.JobTypeResourceLimit{ + JobType: jobType, + ResourceRequirements: resourceRequirements1, + }) + } + resourceRequirements = &shared.ActorDefinitionResourceRequirements{ + Default: defaultVar, + JobSpecific: jobSpecific, + } + } + out := shared.DestinationDefinitionUpdate{ + DestinationDefinitionID: destinationDefinitionID, + DockerImageTag: dockerImageTag, + ResourceRequirements: resourceRequirements, + } + return &out +}