@ -55,13 +55,13 @@ const (
func ( payload * endpointCreatePayload ) Validate ( r * http . Request ) error {
func ( payload * endpointCreatePayload ) Validate ( r * http . Request ) error {
name , err := request . RetrieveMultiPartFormValue ( r , "Name" , false )
name , err := request . RetrieveMultiPartFormValue ( r , "Name" , false )
if err != nil {
if err != nil {
return errors . New ( " I nvalid environment name")
return errors . New ( " i nvalid environment name")
}
}
payload . Name = name
payload . Name = name
endpointCreationType , err := request . RetrieveNumericMultiPartFormValue ( r , "EndpointCreationType" , false )
endpointCreationType , err := request . RetrieveNumericMultiPartFormValue ( r , "EndpointCreationType" , false )
if err != nil || endpointCreationType == 0 {
if err != nil || endpointCreationType == 0 {
return errors . New ( " I nvalid environment type value. Value must be one of: 1 (Docker environment), 2 (Agent environment), 3 (Azure environment), 4 (Edge Agent environment) or 5 (Local Kubernetes environment)")
return errors . New ( " i nvalid environment type value. Value must be one of: 1 (Docker environment), 2 (Agent environment), 3 (Azure environment), 4 (Edge Agent environment) or 5 (Local Kubernetes environment)")
}
}
payload . EndpointCreationType = endpointCreationEnum ( endpointCreationType )
payload . EndpointCreationType = endpointCreationEnum ( endpointCreationType )
@ -74,7 +74,7 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
var tagIDs [ ] portainer . TagID
var tagIDs [ ] portainer . TagID
err = request . RetrieveMultiPartFormJSONValue ( r , "TagIds" , & tagIDs , true )
err = request . RetrieveMultiPartFormJSONValue ( r , "TagIds" , & tagIDs , true )
if err != nil {
if err != nil {
return errors . New ( " I nvalid TagIds parameter")
return errors . New ( " i nvalid TagIds parameter")
}
}
payload . TagIDs = tagIDs
payload . TagIDs = tagIDs
if payload . TagIDs == nil {
if payload . TagIDs == nil {
@ -93,7 +93,7 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
if ! payload . TLSSkipVerify {
if ! payload . TLSSkipVerify {
caCert , _ , err := request . RetrieveMultiPartFormFile ( r , "TLSCACertFile" )
caCert , _ , err := request . RetrieveMultiPartFormFile ( r , "TLSCACertFile" )
if err != nil {
if err != nil {
return errors . New ( " I nvalid CA certificate file. Ensure that the file is uploaded correctly")
return errors . New ( " i nvalid CA certificate file. Ensure that the file is uploaded correctly")
}
}
payload . TLSCACertFile = caCert
payload . TLSCACertFile = caCert
}
}
@ -101,13 +101,13 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
if ! payload . TLSSkipClientVerify {
if ! payload . TLSSkipClientVerify {
cert , _ , err := request . RetrieveMultiPartFormFile ( r , "TLSCertFile" )
cert , _ , err := request . RetrieveMultiPartFormFile ( r , "TLSCertFile" )
if err != nil {
if err != nil {
return errors . New ( " I nvalid certificate file. Ensure that the file is uploaded correctly")
return errors . New ( " i nvalid certificate file. Ensure that the file is uploaded correctly")
}
}
payload . TLSCertFile = cert
payload . TLSCertFile = cert
key , _ , err := request . RetrieveMultiPartFormFile ( r , "TLSKeyFile" )
key , _ , err := request . RetrieveMultiPartFormFile ( r , "TLSKeyFile" )
if err != nil {
if err != nil {
return errors . New ( " I nvalid key file. Ensure that the file is uploaded correctly")
return errors . New ( " i nvalid key file. Ensure that the file is uploaded correctly")
}
}
payload . TLSKeyFile = key
payload . TLSKeyFile = key
}
}
@ -117,19 +117,19 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
case azureEnvironment :
case azureEnvironment :
azureApplicationID , err := request . RetrieveMultiPartFormValue ( r , "AzureApplicationID" , false )
azureApplicationID , err := request . RetrieveMultiPartFormValue ( r , "AzureApplicationID" , false )
if err != nil {
if err != nil {
return errors . New ( " I nvalid Azure application ID")
return errors . New ( " i nvalid Azure application ID")
}
}
payload . AzureApplicationID = azureApplicationID
payload . AzureApplicationID = azureApplicationID
azureTenantID , err := request . RetrieveMultiPartFormValue ( r , "AzureTenantID" , false )
azureTenantID , err := request . RetrieveMultiPartFormValue ( r , "AzureTenantID" , false )
if err != nil {
if err != nil {
return errors . New ( " I nvalid Azure tenant ID")
return errors . New ( " i nvalid Azure tenant ID")
}
}
payload . AzureTenantID = azureTenantID
payload . AzureTenantID = azureTenantID
azureAuthenticationKey , err := request . RetrieveMultiPartFormValue ( r , "AzureAuthenticationKey" , false )
azureAuthenticationKey , err := request . RetrieveMultiPartFormValue ( r , "AzureAuthenticationKey" , false )
if err != nil {
if err != nil {
return errors . New ( " I nvalid Azure authentication key")
return errors . New ( " i nvalid Azure authentication key")
}
}
payload . AzureAuthenticationKey = azureAuthenticationKey
payload . AzureAuthenticationKey = azureAuthenticationKey
@ -146,7 +146,7 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
default :
default :
endpointURL , err := request . RetrieveMultiPartFormValue ( r , "URL" , true )
endpointURL , err := request . RetrieveMultiPartFormValue ( r , "URL" , true )
if err != nil {
if err != nil {
return errors . New ( " I nvalid environment URL")
return errors . New ( " i nvalid environment URL")
}
}
payload . URL = endpointURL
payload . URL = endpointURL
@ -157,7 +157,7 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
gpus := make ( [ ] portainer . Pair , 0 )
gpus := make ( [ ] portainer . Pair , 0 )
err = request . RetrieveMultiPartFormJSONValue ( r , "Gpus" , & gpus , true )
err = request . RetrieveMultiPartFormJSONValue ( r , "Gpus" , & gpus , true )
if err != nil {
if err != nil {
return errors . New ( " I nvalid Gpus parameter")
return errors . New ( " i nvalid Gpus parameter")
}
}
payload . Gpus = gpus
payload . Gpus = gpus
@ -195,6 +195,9 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
// @param AzureAuthenticationKey formData string false "Azure authentication key. Required if environment(endpoint) type is set to 3"
// @param AzureAuthenticationKey formData string false "Azure authentication key. Required if environment(endpoint) type is set to 3"
// @param TagIDs formData []int false "List of tag identifiers to which this environment(endpoint) is associated"
// @param TagIDs formData []int false "List of tag identifiers to which this environment(endpoint) is associated"
// @param EdgeCheckinInterval formData int false "The check in interval for edge agent (in seconds)"
// @param EdgeCheckinInterval formData int false "The check in interval for edge agent (in seconds)"
// @param EdgeTunnelServerAddress formData string true "URL or IP address that will be used to establish a reverse tunnel"
// @param IsEdgeDevice formData bool false "Is Edge Device"
// @param Gpus formData array false "List of GPUs"
// @success 200 {object} portainer.Endpoint "Success"
// @success 200 {object} portainer.Endpoint "Success"
// @failure 400 "Invalid request"
// @failure 400 "Invalid request"
// @failure 500 "Server error"
// @failure 500 "Server error"