mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
243ccade0b
Signed-off-by: Felix Gateru <felix.gateru@gmail.com> Signed-off-by: Arvindh <arvindh91@gmail.com> Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com> Co-authored-by: Arvindh <30824765+arvindh123@users.noreply.github.com> Co-authored-by: Felix Gateru <felix.gateru@gmail.com>
74 lines
1.3 KiB
Go
74 lines
1.3 KiB
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
type pageRes struct {
|
|
Total uint64 `json:"total"`
|
|
Offset uint64 `json:"offset"`
|
|
Limit uint64 `json:"limit"`
|
|
}
|
|
|
|
type certsPageRes struct {
|
|
pageRes
|
|
Certs []certsRes `json:"certs"`
|
|
}
|
|
|
|
type certsRes struct {
|
|
ClientID string `json:"client_id"`
|
|
Certificate string `json:"certificate,omitempty"`
|
|
Key string `json:"key,omitempty"`
|
|
SerialNumber string `json:"serial_number"`
|
|
ExpiryTime time.Time `json:"expiry_time"`
|
|
Revoked bool `json:"revoked"`
|
|
issued bool
|
|
}
|
|
|
|
type revokeCertsRes struct {
|
|
RevocationTime time.Time `json:"revocation_time"`
|
|
}
|
|
|
|
func (res certsPageRes) Code() int {
|
|
return http.StatusOK
|
|
}
|
|
|
|
func (res certsPageRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res certsPageRes) Empty() bool {
|
|
return false
|
|
}
|
|
|
|
func (res certsRes) Code() int {
|
|
if res.issued {
|
|
return http.StatusCreated
|
|
}
|
|
return http.StatusOK
|
|
}
|
|
|
|
func (res certsRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res certsRes) Empty() bool {
|
|
return false
|
|
}
|
|
|
|
func (res revokeCertsRes) Code() int {
|
|
return http.StatusOK
|
|
}
|
|
|
|
func (res revokeCertsRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res revokeCertsRes) Empty() bool {
|
|
return false
|
|
}
|