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

chore: Migrates privatelink_endpoint_service to new auto-generated SDK #2222

Merged
merged 7 commits into from
May 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead,
ReadContext: dataSourceRead,
Schema: map[string]*schema.Schema{
"project_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -100,34 +100,34 @@ func DataSource() *schema.Resource {
}
}

func dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
// Get client connection.
conn := meta.(*config.MongoDBClient).Atlas
connV2 := meta.(*config.MongoDBClient).AtlasV2

projectID := d.Get("project_id").(string)
privateLinkID := conversion.GetEncodedID(d.Get("private_link_id").(string), "private_link_id")
endpointServiceID := conversion.GetEncodedID(d.Get("endpoint_service_id").(string), "endpoint_service_id")
providerName := d.Get("provider_name").(string)

serviceEndpoint, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(ctx, projectID, providerName, privateLinkID, endpointServiceID)
serviceEndpoint, _, err := connV2.PrivateEndpointServicesApi.GetPrivateEndpoint(ctx, projectID, providerName, endpointServiceID, privateLinkID).Execute()
if err != nil {
return diag.FromErr(fmt.Errorf(ErrorServiceEndpointRead, endpointServiceID, err))
}

if err := d.Set("delete_requested", cast.ToBool(serviceEndpoint.DeleteRequested)); err != nil {
if err := d.Set("delete_requested", cast.ToBool(serviceEndpoint.GetDeleteRequested())); err != nil {
return diag.FromErr(fmt.Errorf(ErrorEndpointSetting, "delete_requested", endpointServiceID, err))
}

if err := d.Set("error_message", serviceEndpoint.ErrorMessage); err != nil {
if err := d.Set("error_message", serviceEndpoint.GetErrorMessage()); err != nil {
return diag.FromErr(fmt.Errorf(ErrorEndpointSetting, "error_message", endpointServiceID, err))
}

if err := d.Set("aws_connection_status", serviceEndpoint.AWSConnectionStatus); err != nil {
if err := d.Set("aws_connection_status", serviceEndpoint.GetConnectionStatus()); err != nil {
return diag.FromErr(fmt.Errorf(ErrorEndpointSetting, "aws_connection_status", endpointServiceID, err))
}

if strings.EqualFold(providerName, "azure") {
if err := d.Set("azure_status", serviceEndpoint.Status); err != nil {
if err := d.Set("azure_status", serviceEndpoint.GetStatus()); err != nil {
return diag.FromErr(fmt.Errorf(ErrorEndpointSetting, "azure_status", endpointServiceID, err))
}
}
Expand All @@ -137,7 +137,7 @@ func dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead(ctx context.Context, d
}

if strings.EqualFold(providerName, "gcp") {
if err := d.Set("gcp_status", serviceEndpoint.Status); err != nil {
if err := d.Set("gcp_status", serviceEndpoint.GetStatus()); err != nil {
return diag.FromErr(fmt.Errorf(ErrorEndpointSetting, "gcp_status", endpointServiceID, err))
}
}
Expand Down

This file was deleted.

Loading