generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andy Royle
committed
Jan 14, 2022
1 parent
884027b
commit 6534f83
Showing
24 changed files
with
463 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "marklogic_user Data Source - terraform-provider-marklogic" | ||
subcategory: "" | ||
description: |- | ||
Sample data source in the Terraform provider scaffolding. | ||
--- | ||
|
||
# marklogic_user (Data Source) | ||
|
||
Sample data source in the Terraform provider scaffolding. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "marklogic_user" "test-user" { | ||
name = "test-user" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- **name** (String) The user's name. | ||
|
||
### Optional | ||
|
||
- **id** (String) The ID of this resource. | ||
|
||
### Read-Only | ||
|
||
- **description** (String) A description for the user. | ||
- **roles** (Set of String) The roles assigned to the user. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
--- | ||
page_title: "scaffolding Provider" | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "marklogic Provider" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# scaffolding Provider | ||
# marklogic Provider | ||
|
||
|
||
|
||
## Example Usage | ||
|
||
```terraform | ||
provider "scaffolding" { | ||
# example configuration here | ||
provider "marklogic" { | ||
username = "admin" // or MARKLOGIC_USERNAME | ||
password = "foobar1234" // or MARKLOGIC_PASSWORD | ||
base_url = "https://my.marklogic.host:8002" // or MARKLOGIC_BASE_URL | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- **base_url** (String) | ||
- **password** (String) | ||
- **username** (String) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "marklogic_user Resource - terraform-provider-marklogic" | ||
subcategory: "" | ||
description: |- | ||
A user in MarkLogic. | ||
--- | ||
|
||
# marklogic_user (Resource) | ||
|
||
A user in MarkLogic. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "marklogic_user" "test-user" { | ||
name = "test-user" | ||
roles = ["manage-user"] | ||
password = "foobar1234" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- **name** (String) The user's name. | ||
- **password** (String, Sensitive) The user's password. | ||
- **roles** (List of String) The roles to assign to the user. | ||
|
||
### Optional | ||
|
||
- **description** (String) A description for the user. | ||
- **id** (String) The ID of this resource. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "marklogic_user" "test-user" { | ||
name = "test-user" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
provider "scaffolding" { | ||
# example configuration here | ||
} | ||
provider "marklogic" { | ||
username = "admin" // or MARKLOGIC_USERNAME | ||
password = "foobar1234" // or MARKLOGIC_PASSWORD | ||
base_url = "https://my.marklogic.host:8002" // or MARKLOGIC_BASE_URL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "marklogic_user" "test-user" { | ||
name = "test-user" | ||
roles = ["manage-user"] | ||
password = "foobar1234" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
module github.com/hashicorp/terraform-provider-scaffolding | ||
module github.com/healx/terraform-provider-marklogic | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/hashicorp/terraform-plugin-docs v0.5.1 | ||
github.com/hashicorp/terraform-plugin-log v0.2.1 | ||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 | ||
github.com/judgegregg/go-http-digest-auth-client v0.6.1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/hashicorp/terraform-plugin-log/tflog" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
dac "github.com/judgegregg/go-http-digest-auth-client" | ||
) | ||
|
||
func (a *apiClient) GetUser(ctx context.Context, username string) (map[string]interface{}, diag.Diagnostics) { | ||
|
||
req := dac.NewRequest(a.username, a.password, "GET", fmt.Sprintf("%s/manage/v2/users/%s/properties", a.baseUrl, username), "") | ||
req.Header.Set("Accept", "application/json") | ||
req.Header.Set("User-Agent", a.userAgent) | ||
|
||
tflog.Trace(ctx, fmt.Sprintf("Calling api %s", fmt.Sprintf("%s/manage/v2/users/%s/properties", a.baseUrl, username))) | ||
tflog.Trace(ctx, fmt.Sprintf("HTTP Headers %s", req.Header)) | ||
|
||
resp, err := req.Execute() | ||
if err != nil { | ||
return nil, diag.FromErr(err) | ||
} | ||
defer resp.Body.Close() | ||
|
||
body, err := io.ReadAll(resp.Body) | ||
|
||
var result map[string]interface{} | ||
|
||
tflog.Trace(ctx, string(body)) | ||
|
||
err = json.Unmarshal([]byte(body), &result) | ||
|
||
if err != nil { | ||
return nil, diag.FromErr(err) | ||
} | ||
|
||
return result, nil | ||
} | ||
|
||
func (a *apiClient) CreateUser(ctx context.Context, user map[string]interface{}) diag.Diagnostics { | ||
payload, err := json.Marshal(user) | ||
|
||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
req := dac.NewRequest(a.username, a.password, "POST", fmt.Sprintf("%s/manage/v2/users", a.baseUrl), string(payload)) | ||
req.Header.Set("Content-Type", "application/json") | ||
req.Header.Set("User-Agent", a.userAgent) | ||
|
||
tflog.Trace(ctx, fmt.Sprintf("Calling api %s", fmt.Sprintf("%s/manage/v2/users", a.baseUrl))) | ||
tflog.Trace(ctx, fmt.Sprintf("HTTP Headers %s", req.Header)) | ||
|
||
_, err = req.Execute() | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (a *apiClient) DeleteUser(ctx context.Context, username string) diag.Diagnostics { | ||
req := dac.NewRequest(a.username, a.password, "DELETE", fmt.Sprintf("%s/manage/v2/users/%s", a.baseUrl, username), "") | ||
req.Header.Set("User-Agent", a.userAgent) | ||
|
||
tflog.Trace(ctx, fmt.Sprintf("Calling api %s", fmt.Sprintf("%s/manage/v2/users/%s", a.baseUrl, username))) | ||
tflog.Trace(ctx, fmt.Sprintf("HTTP Headers %s", req.Header)) | ||
|
||
_, err := req.Execute() | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (a *apiClient) UpdateUser(ctx context.Context, user map[string]interface{}) diag.Diagnostics { | ||
payload, err := json.Marshal(user) | ||
|
||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
req := dac.NewRequest(a.username, a.password, "PUT", fmt.Sprintf("%s/manage/v2/users/%s/properties", a.baseUrl, user["user-name"]), string(payload)) | ||
req.Header.Set("Content-Type", "application/json") | ||
req.Header.Set("User-Agent", a.userAgent) | ||
|
||
tflog.Trace(ctx, fmt.Sprintf("Calling api %s", fmt.Sprintf("%s/manage/v2/users/%s/properties", a.baseUrl, user["user-name"]))) | ||
tflog.Trace(ctx, fmt.Sprintf("HTTP Headers %s", req.Header)) | ||
|
||
_, err = req.Execute() | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.