dae47101fa
I noticed that the JSON api endpoints for peerings json encodes protobufs directly, rather than converting them into their `api` package equivalents before marshal/unmarshaling them. I updated this and used `mog` to do the annoying part in the middle. Other changes: - the status enum was converted into the friendlier string form of the enum for readability with tools like `curl` - some of the `api` library functions were slightly modified to match other similar endpoints in UX (cc: @ndhanushkodi ) - peeringRead returns `nil` if not found - partitions are NOT inferred from the agent's partition (matching 1.11-style logic)
101 lines
2.3 KiB
Go
101 lines
2.3 KiB
Go
// Code generated by mog. DO NOT EDIT.
|
|
|
|
package pbpeering
|
|
|
|
import "github.com/hashicorp/consul/api"
|
|
|
|
func GenerateTokenRequestToAPI(s *GenerateTokenRequest, t *api.PeeringGenerateTokenRequest) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.PeerName = s.PeerName
|
|
t.Partition = s.Partition
|
|
t.Datacenter = s.Datacenter
|
|
t.Token = s.Token
|
|
t.Meta = s.Meta
|
|
}
|
|
func GenerateTokenRequestFromAPI(t *api.PeeringGenerateTokenRequest, s *GenerateTokenRequest) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.PeerName = t.PeerName
|
|
s.Partition = t.Partition
|
|
s.Datacenter = t.Datacenter
|
|
s.Token = t.Token
|
|
s.Meta = t.Meta
|
|
}
|
|
func GenerateTokenResponseToAPI(s *GenerateTokenResponse, t *api.PeeringGenerateTokenResponse) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.PeeringToken = s.PeeringToken
|
|
}
|
|
func GenerateTokenResponseFromAPI(t *api.PeeringGenerateTokenResponse, s *GenerateTokenResponse) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.PeeringToken = t.PeeringToken
|
|
}
|
|
func InitiateRequestToAPI(s *InitiateRequest, t *api.PeeringInitiateRequest) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.PeerName = s.PeerName
|
|
t.PeeringToken = s.PeeringToken
|
|
t.Datacenter = s.Datacenter
|
|
t.Token = s.Token
|
|
t.Meta = s.Meta
|
|
}
|
|
func InitiateRequestFromAPI(t *api.PeeringInitiateRequest, s *InitiateRequest) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.PeerName = t.PeerName
|
|
s.PeeringToken = t.PeeringToken
|
|
s.Datacenter = t.Datacenter
|
|
s.Token = t.Token
|
|
s.Meta = t.Meta
|
|
}
|
|
func InitiateResponseToAPI(s *InitiateResponse, t *api.PeeringInitiateResponse) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
}
|
|
func InitiateResponseFromAPI(t *api.PeeringInitiateResponse, s *InitiateResponse) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
}
|
|
func PeeringToAPI(s *Peering, t *api.Peering) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
t.ID = s.ID
|
|
t.Name = s.Name
|
|
t.Partition = s.Partition
|
|
t.Meta = s.Meta
|
|
t.State = PeeringStateToAPI(s.State)
|
|
t.PeerID = s.PeerID
|
|
t.PeerCAPems = s.PeerCAPems
|
|
t.PeerServerName = s.PeerServerName
|
|
t.PeerServerAddresses = s.PeerServerAddresses
|
|
t.CreateIndex = s.CreateIndex
|
|
t.ModifyIndex = s.ModifyIndex
|
|
}
|
|
func PeeringFromAPI(t *api.Peering, s *Peering) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.ID = t.ID
|
|
s.Name = t.Name
|
|
s.Partition = t.Partition
|
|
s.Meta = t.Meta
|
|
s.State = PeeringStateFromAPI(t.State)
|
|
s.PeerID = t.PeerID
|
|
s.PeerCAPems = t.PeerCAPems
|
|
s.PeerServerName = t.PeerServerName
|
|
s.PeerServerAddresses = t.PeerServerAddresses
|
|
s.CreateIndex = t.CreateIndex
|
|
s.ModifyIndex = t.ModifyIndex
|
|
}
|