mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 06:10:19 +00:00
eb14615cf5
* feat: update provison service Signed-off-by: Felix Gateru <felix.gateru@gmail.com> * refactor: remove duplicate env variables Signed-off-by: Felix Gateru <felix.gateru@gmail.com> * ci: make fetch_supermq Signed-off-by: Felix Gateru <felix.gateru@gmail.com> * docs(README.md): update README Signed-off-by: Felix Gateru <felix.gateru@gmail.com> --------- Signed-off-by: Felix Gateru <felix.gateru@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/supermq"
|
|
sdk "github.com/absmach/supermq/pkg/sdk"
|
|
)
|
|
|
|
var _ supermq.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)
|
|
}
|