func (c *FusionAuthClient) CreateAPIKey(keyId string, request APIKeyRequest) (*APIKeyResponse, *Errors, error) {
	var resp APIKeyResponse
	var errors Errors
	restClient := c.Start(&resp, &errors)
	err := restClient.WithUri("/api/api-key").
		WithUriSegment(keyId).
		WithJSONBody(request).
		WithMethod(http.MethodPost).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}
CreateAPIKey
Creates an API key. You can optionally specify a unique Id for the key, if not provided one will be generated.
an API key can only be created with equal or lesser authority. An API key cannot create another API key unless it is granted
to that API key.

If an API key is locked to a tenant, it can only create API Keys for that same tenant.
string keyId (Optional) The unique Id of the API key. If not provided a secure random Id will be generated.
APIKeyRequest request The request object that contains all of the information needed to create the APIKey.
package fusionauth
import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"net/http/httputil"
	"net/url"
	"path"
	"strconv"
	"strings"
	"time"
)
func NewClient(httpClient *http.Client, baseURL *url.URL, apiKey string) *FusionAuthClient {
	if httpClient == nil {
		httpClient = &http.Client{
			Timeout: 5 * time.Minute,
		}
	}
	c := &FusionAuthClient{
		HTTPClient: httpClient,
		BaseURL:    baseURL,
		APIKey:     apiKey,
	}
	return c
}
func (c *FusionAuthClient) SetTenantId(tenantId string) {
	c.TenantId = tenantId
}
type FusionAuthClient struct {
	HTTPClient *http.Client
	BaseURL    *url.URL
	APIKey     string
	Debug      bool
	TenantId   string
}
type restClient struct {
	Body        io.Reader
	Debug       bool
	ErrorRef    interface{}
	Headers     map[string]string
	HTTPClient  *http.Client
	Method      string
	ResponseRef interface{}
	Uri         *url.URL
}
func (c *FusionAuthClient) Start(responseRef interface{}, errorRef interface{}) *restClient {
	return c.StartAnonymous(responseRef, errorRef).WithAuthorization(c.APIKey)
}
func (c *FusionAuthClient) StartAnonymous(responseRef interface{}, errorRef interface{}) *restClient {
	rc := &restClient{
		Debug:       c.Debug,
		ErrorRef:    errorRef,
		Headers:     make(map[string]string),
		HTTPClient:  c.HTTPClient,
		ResponseRef: responseRef,
	}
	rc.Uri, _ = url.Parse(c.BaseURL.String())
	if c.TenantId != "" {
		rc.WithHeader("X-FusionAuth-TenantId", c.TenantId)
	}
	rc.WithHeader("Content-Type", "text/plain")
	rc.WithHeader("Accept", "application/json")
	return rc
}
func (rc *restClient) Do() error {
	req, err := http.NewRequest(rc.Method, rc.Uri.String(), rc.Body)
	if err != nil {
		return err
	}
	for key, val := range rc.Headers {
		req.Header.Set(key, val)
	}
	resp, err := rc.HTTPClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	if rc.Debug {
		responseDump, _ := httputil.DumpResponse(resp, true)
		fmt.Println(string(responseDump))
	}
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		if err = json.NewDecoder(resp.Body).Decode(rc.ErrorRef); err == io.EOF {
			err = nil
		}
	} else {
		rc.ErrorRef = nil
		if _, ok := rc.ResponseRef.(*BaseHTTPResponse); !ok {
			err = json.NewDecoder(resp.Body).Decode(rc.ResponseRef)
		}
	}
	rc.ResponseRef.(StatusAble).SetStatus(resp.StatusCode)
	return err
}
func (rc *restClient) WithAuthorization(key string) *restClient {
	if key != "" {
		rc.WithHeader("Authorization", key)
	}
	return rc
}
func (rc *restClient) WithFormData(formBody url.Values) *restClient {
	rc.WithHeader("Content-Type", "application/x-www-form-urlencoded")
	rc.Body = strings.NewReader(formBody.Encode())
	return rc
}
func (rc *restClient) WithHeader(key string, value string) *restClient {
	rc.Headers[key] = value
	return rc
}
func (rc *restClient) WithJSONBody(body interface{}) *restClient {
	rc.WithHeader("Content-Type", "application/json")
	buf := new(bytes.Buffer)
	json.NewEncoder(buf).Encode(body)
	rc.Body = buf
	return rc
}
func (rc *restClient) WithMethod(method string) *restClient {
	rc.Method = method
	return rc
}
func (rc *restClient) WithParameter(key string, value interface{}) *restClient {
	q := rc.Uri.Query()
	if x, ok := value.([]string); ok {
		for _, i := range x {
			q.Add(key, i)
		}
	} else {
		q.Add(key, fmt.Sprintf("%v", value))
	}
	rc.Uri.RawQuery = q.Encode()
	return rc
}
func (rc *restClient) WithUri(uri string) *restClient {
	rc.Uri.Path = path.Join(rc.Uri.Path, uri)
	return rc
}
func (rc *restClient) WithUriSegment(segment string) *restClient {
	if segment != "" {
		rc.Uri.Path = path.Join(rc.Uri.Path, "/"+segment)
	}
	return rc
}
func (c *FusionAuthClient) ActionUser(request ActionRequest) (*ActionResponse, *Errors, error) {
	var resp ActionResponse
	var errors Errors
	restClient := c.Start(&resp, &errors)
	err := restClient.WithUri("/api/user/action").
		WithJSONBody(request).
		WithMethod(http.MethodPost).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}
func (c *FusionAuthClient) ActivateReactor(request ReactorRequest) (*BaseHTTPResponse, *Errors, error) {
	var resp BaseHTTPResponse
	var errors Errors
	restClient := c.Start(&resp, &errors)
	err := restClient.WithUri("/api/reactor").
		WithJSONBody(request).
		WithMethod(http.MethodPost).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}
func (c *FusionAuthClient) AddUserToFamily(familyId string, request FamilyRequest) (*FamilyResponse, *Errors, error) {
	var resp FamilyResponse
	var errors Errors
	restClient := c.Start(&resp, &errors)
	err := restClient.WithUri("/api/user/family").
		WithUriSegment(familyId).
		WithJSONBody(request).
		WithMethod(http.MethodPut).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}
func (c *FusionAuthClient) CancelAction(actionId string, request ActionRequest) (*ActionResponse, *Errors, error) {
	var resp ActionResponse
	var errors Errors
	restClient := c.Start(&resp, &errors)
	err := restClient.WithUri("/api/user/action").
		WithUriSegment(actionId).
		WithJSONBody(request).
		WithMethod(http.MethodDelete).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}
func (c *FusionAuthClient) ChangePassword(changePasswordId string, request ChangePasswordRequest) (*ChangePasswordResponse, *Errors, error) {
	var resp ChangePasswordResponse
	var errors Errors
	restClient := c.StartAnonymous(&resp, &errors)
	err := restClient.WithUri("/api/user/change-password").
		WithUriSegment(changePasswordId).
		WithJSONBody(request).
		WithMethod(http.MethodPost).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}
func (c *FusionAuthClient) ChangePasswordByIdentity(request ChangePasswordRequest) (*BaseHTTPResponse, *Errors, error) {
	var resp BaseHTTPResponse
	var errors Errors
	restClient := c.Start(&resp, &errors)
	err := restClient.WithUri("/api/user/change-password").
		WithJSONBody(request).
		WithMethod(http.MethodPost).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}
func (c *FusionAuthClient) CommentOnUser(request UserCommentRequest) (*BaseHTTPResponse, *Errors, error) {
	var resp BaseHTTPResponse
	var errors Errors
	restClient := c.Start(&resp, &errors)
	err := restClient.WithUri("/api/user/comment").
		WithJSONBody(request).
		WithMethod(http.MethodPost).
		Do()
	if restClient.ErrorRef == nil {
		return &resp, nil, err
	}
	return &resp, &errors, err
}