Skip to content

Commit

Permalink
Merge pull request #307 from appgate/301/local-user
Browse files Browse the repository at this point in the history
read local user, handle 404
  • Loading branch information
dlnilsson authored May 3, 2023
2 parents 6badee5 + 79d5a72 commit 3b476da
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion appgate/resource_appgate_local_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"net/http"
"time"

"github.com/appgate/sdp-api-client-go/api/v18/openapi"
Expand Down Expand Up @@ -137,9 +138,12 @@ func resourceAppgateLocalUserRead(ctx context.Context, d *schema.ResourceData, m
return diag.FromErr(err)
}
api := meta.(*Client).API.LocalUsersApi
localUser, _, err := api.LocalUsersIdGet(ctx, d.Id()).Authorization(token).Execute()
localUser, response, err := api.LocalUsersIdGet(ctx, d.Id()).Authorization(token).Execute()
if err != nil {
d.SetId("")
if response != nil && response.StatusCode == http.StatusNotFound {
return nil
}
return diag.FromErr(prettyPrintAPIError(err))
}
d.SetId(localUser.GetId())
Expand Down

0 comments on commit 3b476da

Please sign in to comment.