Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert ports #25

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/resources/data_destination.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ resource "ambar_data_destination" "example_destination" {
]
description = "My Terraform DataDestination"
destination_endpoint = "https://1.2.3.4.com/data"
destination_port = "8443"
username = "username"
password = "password"
}
Expand All @@ -37,7 +36,6 @@ resource "ambar_data_destination" "example_destination" {
### Optional

- `description` (String) A user friendly description of this DataDestination. Use the description filed to help augment information about this DataDestination which may may not be apparent from describing the resource, such as details about the filtered record sequences being sent.
- `destination_port` (String) The port on which your endpoint service is listening for connections.
- `filter_ids` (List of String) A List of Ambar resource ids belonging to Ambar Filter resources which should be used with this DataDestination. These control what DataSources and applied filters will be delivered to your destination. Note that a DataSource can only be used once per DataDestination.

### Read-Only
Expand Down
1 change: 0 additions & 1 deletion examples/resources/ambar_data_destination/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ resource "ambar_data_destination" "example_destination" {
]
description = "My Terraform DataDestination"
destination_endpoint = "https://1.2.3.4.com/data"
destination_port = "8443"
username = "username"
password = "password"
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.3

require (
github.com/ambarltd/ambar_go_client v0.0.0-20240612194214-44b202099e5c
github.com/ambarltd/ambar_go_client v0.0.0-20240426011029-07769d17e756
github.com/hashicorp/terraform-plugin-docs v0.19.1
github.com/hashicorp/terraform-plugin-framework v1.8.0
github.com/hashicorp/terraform-plugin-go v0.22.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ github.com/ambarltd/ambar_go_client v0.0.0-20240426004432-d77bae50e0e1 h1:gUL6Lv
github.com/ambarltd/ambar_go_client v0.0.0-20240426004432-d77bae50e0e1/go.mod h1:nQxYJrrTczECNnwozf9Nn0RUgWX1KPBXoT2/Jhy/q98=
github.com/ambarltd/ambar_go_client v0.0.0-20240426011029-07769d17e756 h1:wcKpwSiVTN8YwUdvf6EjqTb09bqc0I4IJZn1NOgDS4g=
github.com/ambarltd/ambar_go_client v0.0.0-20240426011029-07769d17e756/go.mod h1:nQxYJrrTczECNnwozf9Nn0RUgWX1KPBXoT2/Jhy/q98=
github.com/ambarltd/ambar_go_client v0.0.0-20240612194214-44b202099e5c h1:IkaP0FfbQZ/yA64tMW1Ua9fHBlwtO+xZiEia1Rj+5aA=
github.com/ambarltd/ambar_go_client v0.0.0-20240612194214-44b202099e5c/go.mod h1:nQxYJrrTczECNnwozf9Nn0RUgWX1KPBXoT2/Jhy/q98=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
Expand Down
16 changes: 3 additions & 13 deletions internal/provider/data_destination_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type dataDestinationResourceModel struct {
FilterIds types.List `tfsdk:"filter_ids"`
Description types.String `tfsdk:"description"`
DestinationEndpoint types.String `tfsdk:"destination_endpoint"`
DestinationPort types.String `tfsdk:"destination_port"`
Username types.String `tfsdk:"username"`
Password types.String `tfsdk:"password"`
State types.String `tfsdk:"state"`
Expand Down Expand Up @@ -79,12 +78,6 @@ func (r *DataDestinationResource) Schema(ctx context.Context, req resource.Schem
Description: "The HTTP endpoint where Ambar will send your filtered record sequences to.",
Required: true,
},
"destination_port": schema.StringAttribute{
MarkdownDescription: "The port on which your endpoint service is listening for connections.",
Description: "The port on which your endpoint service is listening for connections.",
Optional: true,
Computed: true,
},
"username": schema.StringAttribute{
MarkdownDescription: "A username credential which Ambar can use to communicate with your destination.",
Description: "A username credential which Ambar can use to communicate with your destination.",
Expand Down Expand Up @@ -152,7 +145,6 @@ func (r *DataDestinationResource) Create(ctx context.Context, req resource.Creat
createDataDestination.FilterIds = elements

createDataDestination.Description = plan.Description.ValueStringPointer()
createDataDestination.DestinationPort = plan.DestinationPort.ValueStringPointer()
createDataDestination.Username = plan.Username.ValueString()
createDataDestination.Password = plan.Password.ValueString()
createDataDestination.DestinationEndpoint = plan.DestinationEndpoint.ValueString()
Expand Down Expand Up @@ -231,7 +223,7 @@ func (r *DataDestinationResource) Read(ctx context.Context, req resource.ReadReq

tflog.Error(ctx, "Unexpected error, dumping logs and returning.")
tflog.Error(ctx, "Got http response, code: "+strconv.Itoa(httpResponse.StatusCode)+", status: "+httpResponse.Status)
resp.Diagnostics.AddError("Unable to read DataDestination resource.", err.Error())
resp.Diagnostics.AddError("Unable to read DataSource resource.", err.Error())
return
}

Expand All @@ -245,7 +237,6 @@ func (r *DataDestinationResource) Read(ctx context.Context, req resource.ReadReq

data.State = types.StringValue(describeResourceResponse.State)
data.DestinationEndpoint = types.StringValue(describeResourceResponse.DestinationEndpoint)
data.DestinationPort = types.StringValue(describeResourceResponse.DestinationPort)
data.Description = types.StringPointerValue(describeResourceResponse.Description)

data.FilterIds, _ = types.ListValueFrom(ctx, types.StringType, describeResourceResponse.FilterIds)
Expand All @@ -270,7 +261,7 @@ func (r *DataDestinationResource) Update(ctx context.Context, req resource.Updat
}

var updatedCredentials = plan.Username.ValueString() != current.Username.ValueString() || plan.Password.ValueString() != current.Password.ValueString()
var updatedNonCredentials = plan.DestinationEndpoint.ValueString() != current.DestinationEndpoint.ValueString() || plan.DestinationPort.String() != current.DestinationPort.String()
var updatedNonCredentials = plan.DestinationEndpoint.ValueString() != current.DestinationEndpoint.ValueString()

var updateResourceResponse Ambar.ResourceStateChangeResponse

Expand All @@ -297,8 +288,7 @@ func (r *DataDestinationResource) Update(ctx context.Context, req resource.Updat
// Make the call to update the endpoint.
var updateDestinationRequest Ambar.UpdateDataDestinationRequest
updateDestinationRequest.ResourceId = plan.ResourceId.ValueString()
updateDestinationRequest.DestinationEndpoint = plan.DestinationEndpoint.ValueStringPointer()
updateDestinationRequest.DestinationPort = plan.DestinationPort.ValueStringPointer()
updateDestinationRequest.DestinationEndpoint = plan.DestinationEndpoint.ValueString()

updateResourceResponse, httpResponse, err := r.client.AmbarAPI.UpdateDataDestination(ctx).UpdateDataDestinationRequest(updateDestinationRequest).Execute()
if err != nil || updateResourceResponse == nil || httpResponse == nil {
Expand Down
Loading