generated from keboola/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
encryption_api.go
29 lines (24 loc) · 939 Bytes
/
encryption_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package keboola
// The file contains request definitions for the Encryption API.
// Requests can be sent by any HTTP client that implements the client.Sender interface.
import (
"fmt"
"net/http"
"github.com/spf13/cast"
"github.com/keboola/go-client/pkg/request"
)
// EncryptRequest - https://keboolaencryption.docs.apiary.io/#reference/encrypt/encryption/encrypt-data
func (a *PublicAPI) EncryptRequest(projectID int, componentID ComponentID, data map[string]string) request.APIRequest[*map[string]string] {
if componentID.String() == "" {
panic(fmt.Errorf("the componentId parameter is required"))
}
result := make(map[string]string)
req := a.newRequest(EncryptionAPI).
WithResult(&result).
WithMethod(http.MethodPost).
WithURL("encrypt").
AndQueryParam("componentId", componentID.String()).
AndQueryParam("projectId", cast.ToString(projectID)).
WithJSONBody(data)
return request.NewAPIRequest(&result, req)
}