Documentation
¶
Overview ¶
Copyright 2025 BeyondTrust. All rights reserved. Package utils implements common utility functions
Copyright 2024 BeyondTrust. All rights reserved. utils responsible for utility functions.
Copyright 2024 BeyondTrust. All rights reserved. Package utils implements inputs validations
Index ¶
- func DeleteResourceByID(resourceID string, resourceType string, methodConstant string, ...) error
- func FormatErrorMessage(err validator.FieldError) string
- func GetIntField(data map[string]interface{}, key string, defaultValue int) int
- func GetOwnerDetailsGroupIdList(data map[string]interface{}, groupId int, ...) []entities.OwnerDetailsGroupId
- func GetOwnerDetailsOwnerIdList(data map[string]interface{}, signAppinResponse entities.SignAppinResponse) []entities.OwnerDetailsOwnerId
- func GetPFXContent(clientCertificatePath string, clientCertificateName string, ...) (string, string, error)
- func GetStringField(data map[string]interface{}, key string, defaultValue string) string
- func GetUrlsDetailsList(d map[string]interface{}) []entities.UrlDetails
- func ValidateCertificateInfo(params ValidationParams) error
- func ValidateCreateManagedAccountInput(accountDetails entities.AccountDetails) (entities.AccountDetails, error)
- func ValidateData(objDetails interface{}) error
- func ValidateInputs(params ValidationParams) error
- func ValidatePaths(secretPaths []string, isManagedAccount bool, separator string, ...) []string
- func ValidateSinglePath(maxPath int, maxName int, invalidPathName string, invalidName string, ...) (string, error)
- func ValidateURL(apiUrl string) error
- type HttpClientObj
- func (client *HttpClientObj) CallSecretSafeAPI(callSecretSafeAPIObj entities.CallSecretSafeAPIObj) (io.ReadCloser, int, error, error)
- func (client *HttpClientObj) CreateMultiPartRequest(url, fileName string, metadata []byte, fileContent string, apiVersion string) (io.ReadCloser, error)
- func (client *HttpClientObj) GetAuthorizationHeader(accessToken string, apiKey string) string
- func (client *HttpClientObj) GetGeneralList(url string, apiVersion string, method string, ...) ([]byte, error)
- func (client *HttpClientObj) HttpRequest(url string, method string, body bytes.Buffer, accessToken string, ...) (closer io.ReadCloser, scode int, technicalError error, businessError error)
- func (client *HttpClientObj) MakeRequest(callSecretSafeAPIObj *entities.CallSecretSafeAPIObj, ...) ([]byte, error)
- func (client *HttpClientObj) SetApiVersion(url string, apiVersion string) string
- type UserInputValidaton
- type ValidationParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteResourceByID ¶ added in v0.23.0
func DeleteResourceByID( resourceID string, resourceType string, methodConstant string, urlBuilder func(id string) string, validateAsUUID bool, httpClient *HttpClientObj, exponentialBackOff *backoff.ExponentialBackOff, logger logging.Logger, ) error
DeleteResourceByID is a reusable function for deleting resources by ID. It supports both UUID and integer IDs and flexible URL construction.
func FormatErrorMessage ¶ added in v0.16.0
func FormatErrorMessage(err validator.FieldError) string
FormatErrorMessage responsible for formating errors text.
func GetIntField ¶ added in v0.24.0
GetIntField retrieves a numeric field from a map, returning a default value if the key does not exist.
func GetOwnerDetailsGroupIdList ¶ added in v0.24.0
func GetOwnerDetailsGroupIdList(data map[string]interface{}, groupId int, signAppinResponse entities.SignAppinResponse) []entities.OwnerDetailsGroupId
GetOwnerDetailsGroupIdList constructs a list of owner details with group IDs from the provided data map.
func GetOwnerDetailsOwnerIdList ¶ added in v0.24.0
func GetOwnerDetailsOwnerIdList(data map[string]interface{}, signAppinResponse entities.SignAppinResponse) []entities.OwnerDetailsOwnerId
GetOwnerDetailsOwnerIdList get Owners details list.
func GetPFXContent ¶ added in v0.7.0
func GetPFXContent(clientCertificatePath string, clientCertificateName string, clientCertificatePassword string, logger logging.Logger) (string, string, error)
GetPFXContent decrypt pfx certificate.
func GetStringField ¶ added in v0.24.0
GetStringField retrieves a string field from a map, returning a default value if the key does not exist.
func GetUrlsDetailsList ¶ added in v0.24.0
func GetUrlsDetailsList(d map[string]interface{}) []entities.UrlDetails
GetUrlsDetailsList extracts and parses URL details from the provided data map.
func ValidateCertificateInfo ¶ added in v0.18.0
func ValidateCertificateInfo(params ValidationParams) error
ValidateCertificateInfo validate certificate data.
func ValidateCreateManagedAccountInput ¶ added in v0.8.4
func ValidateCreateManagedAccountInput(accountDetails entities.AccountDetails) (entities.AccountDetails, error)
ValidateCreateManagedAccountInput responsible for validating Managed Account input
func ValidateData ¶ added in v0.15.0
func ValidateData(objDetails interface{}) error
ValidateInputs responsible for validating objects Details (WorkGroupDetails, FolderDetails, SecretTextDetails...)
func ValidateInputs ¶
func ValidateInputs(params ValidationParams) error
ValidateInputs is responsible for validating end-user inputs.
func ValidatePaths ¶
func ValidatePaths(secretPaths []string, isManagedAccount bool, separator string, logger logging.Logger) []string
This method is responsbile for validating that the paths and names are valid.
func ValidateSinglePath ¶ added in v0.18.0
func ValidateSinglePath(maxPath int, maxName int, invalidPathName string, invalidName string, maxPathDepth int, retrievalData []string, separator string) (string, error)
ValidateSinglePath responsbile for validating that one path and one name are valid.
func ValidateURL ¶
ValidateURL responsible for validating the Password Safe API URL.
Types ¶
type HttpClientObj ¶
HttpClientObj responsible for http request instance.
func GetHttpClient ¶
func GetHttpClient(clientTimeOut int, verifyCa bool, certificate string, certificate_key string, logger logging.Logger) (*HttpClientObj, error)
GetHttpClient is responsible for configuring an HTTP client and transport for API calls.
func (*HttpClientObj) CallSecretSafeAPI ¶
func (client *HttpClientObj) CallSecretSafeAPI(callSecretSafeAPIObj entities.CallSecretSafeAPIObj) (io.ReadCloser, int, error, error)
func (*HttpClientObj) CreateMultiPartRequest ¶ added in v0.10.0
func (client *HttpClientObj) CreateMultiPartRequest(url, fileName string, metadata []byte, fileContent string, apiVersion string) (io.ReadCloser, error)
CreateMultipartRequest creates and sends multipart request.
func (*HttpClientObj) GetAuthorizationHeader ¶ added in v0.18.0
func (client *HttpClientObj) GetAuthorizationHeader(accessToken string, apiKey string) string
GetAuthorizationHeader Get authorization header string
func (*HttpClientObj) GetGeneralList ¶ added in v0.21.0
func (client *HttpClientObj) GetGeneralList(url string, apiVersion string, method string, exponentialBackOff *backoff.ExponentialBackOff) ([]byte, error)
GetGeneralList get list for any module.
func (*HttpClientObj) HttpRequest ¶
func (client *HttpClientObj) HttpRequest(url string, method string, body bytes.Buffer, accessToken string, apiKey string, contentType string, apiVersion string) (closer io.ReadCloser, scode int, technicalError error, businessError error)
HttpRequest makes http request to the server.
func (*HttpClientObj) MakeRequest ¶ added in v0.21.0
func (client *HttpClientObj) MakeRequest(callSecretSafeAPIObj *entities.CallSecretSafeAPIObj, exponentialBackOff *backoff.ExponentialBackOff) ([]byte, error)
MakeRequest Make http request to API.
func (*HttpClientObj) SetApiVersion ¶ added in v0.18.0
func (client *HttpClientObj) SetApiVersion(url string, apiVersion string) string
SetApiVersion Set API Version to URL.
type UserInputValidaton ¶
type UserInputValidaton struct {
ApiKey string `validate:"omitempty,min=128,max=263"`
ClientId string `validate:"omitempty,min=36,max=36,required_without=ApiKey"`
ClientSecret string `validate:"omitempty,min=36,max=64,required_without=ApiKey"`
ApiVersion string `validate:"omitempty,min=3,max=3"`
ApiUrl string `validate:"required,http_url"`
ClientTimeOutinSeconds int `validate:"gte=1,lte=300"`
Separator string `validate:"omitempty,required,min=1,max=1"`
MaxFileSecretSizeBytes int `validate:"omitempty,gte=1,lte=5000000"`
}
UserInputValidaton responsible for input paramerter validation.