mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
61d0427898
Signed-off-by: dusan <borovcanindusan1@gmail.com>
73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/absmach/magistrala"
|
|
"github.com/absmach/magistrala/pkg/sdk"
|
|
)
|
|
|
|
var _ magistrala.Response = (*provisionRes)(nil)
|
|
|
|
type provisionRes struct {
|
|
Clients []sdk.Client `json:"clients"`
|
|
Channels []sdk.Channel `json:"channels"`
|
|
ClientCert map[string]string `json:"client_cert,omitempty"`
|
|
ClientKey map[string]string `json:"client_key,omitempty"`
|
|
CACert string `json:"ca_cert,omitempty"`
|
|
Whitelisted map[string]bool `json:"whitelisted,omitempty"`
|
|
}
|
|
|
|
func (res provisionRes) Code() int {
|
|
return http.StatusCreated
|
|
}
|
|
|
|
func (res provisionRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res provisionRes) Empty() bool {
|
|
return false
|
|
}
|
|
|
|
type mappingRes struct {
|
|
Data any
|
|
}
|
|
|
|
func (res mappingRes) Code() int {
|
|
return http.StatusOK
|
|
}
|
|
|
|
func (res mappingRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res mappingRes) Empty() bool {
|
|
return false
|
|
}
|
|
|
|
type certRes struct {
|
|
Certificate string `json:"certificate"`
|
|
Key string `json:"key"`
|
|
}
|
|
|
|
func (res certRes) Code() int {
|
|
return http.StatusCreated
|
|
}
|
|
|
|
func (res certRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res certRes) Empty() bool {
|
|
return false
|
|
}
|
|
|
|
func (res mappingRes) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(res.Data)
|
|
}
|