Skip to content

Commit

Permalink
GANDI_V5: allow customization of endpoint URL - e.g. to use the Sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
llange committed Dec 18, 2023
1 parent bad2832 commit 3867899
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions documentation/providers/gandi_v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ migrated to the new LiveDNS API, which should be all domains.

* API Documentation: https://api.gandi.net/docs
* API Endpoint: https://api.gandi.net/
* Sandbox API Documentation: https://api.sandbox.gandi.net/docs/
* Sandbox API Endpoint: https://api.sandbox.gandi.net/

## Configuration

Expand All @@ -13,6 +15,8 @@ along with other settings:
* (mandatory, string) your Gandi.net access credentials (see below) - one of:
* `token`: Personal Access Token (PAT)
* `apikey` API Key (deprecated)
* `apiurl`: (optional, string) the endpoint of the API. When empty or absent the production
endpoint is used (default) ; you can use it to select the Sandbox API Endpoint instead.
* `sharing_id`: (optional, string) let you scope to a specific organization. When empty or absent
calls are not scoped to a specific organization.

Expand Down Expand Up @@ -122,3 +126,6 @@ organization or no organization. The solution is to set `sharing_id` in

### Debugging
Set `GANDI_V5_DEBUG` environment variable to a [boolean-compatible](https://pkg.go.dev/strconv#ParseBool) value to dump all API calls made by this provider.

### Testing
Set `apiurl` key to the endpoint url for the sandbox (https://api.sandbox.gandi.net/), along with corresponding `token` (or (deprecated) `apikey`) created in this sandbox environment (Cf https://api.sandbox.gandi.net/docs/sandbox/) to make all API calls against Gandi sandbox environment.
3 changes: 3 additions & 0 deletions providers/gandiv5/gandi_v5Provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type gandiv5Provider struct {
token string
sharingid string
debug bool
apiurl string
}

// newDsp generates a DNS Service Provider client handle.
Expand All @@ -92,6 +93,7 @@ func newHelper(m map[string]string, metadata json.RawMessage) (*gandiv5Provider,
return nil, fmt.Errorf("missing Gandi personal access token (or apikey - deprecated)")
}
api.sharingid = m["sharing_id"]
api.apiurl = m["apiurl"]
debug, err := strconv.ParseBool(os.Getenv("GANDI_V5_DEBUG"))
if err == nil {
api.debug = debug
Expand All @@ -110,6 +112,7 @@ func NewLiveDNSClient(client *gandiv5Provider) *livedns.LiveDNS {
PersonalAccessToken: client.token,
SharingID: client.sharingid,
Debug: client.debug,
APIURL: client.apiurl,
})
return g
}
Expand Down

0 comments on commit 3867899

Please sign in to comment.