Files
platform-services/gen/platform-services_zap.go

189 lines
5.7 KiB
Go

// Code generated by zapgen; DO NOT EDIT.
// source: platform-services.zap
package ps
import (
zap "github.com/zap-proto/go"
)
const (
pSRequestOpOff = 0
pSRequestOrgOff = 4
pSRequestProjectOff = 12
pSRequestParamsOff = 20
pSRequestSize = 28
)
// PSRequest is a zero-copy view into a ZAP-encoded PSRequest message.
type PSRequest struct{ o zap.Object }
// WrapPSRequest parses b and returns a typed view. Returns an error if the
// wire-level checks (magic, version, size) fail.
func WrapPSRequest(b []byte) (PSRequest, error) {
m, err := zap.Parse(b)
if err != nil {
return PSRequest{}, err
}
return PSRequest{o: m.Root()}, nil
}
func (t PSRequest) Op() uint32 { return t.o.Uint32(pSRequestOpOff) }
func (t PSRequest) Org() string { return t.o.Text(pSRequestOrgOff) }
func (t PSRequest) Project() string { return t.o.Text(pSRequestProjectOff) }
func (t PSRequest) Params() []byte { return t.o.Bytes(pSRequestParamsOff) }
// PSRequestInput collects the field values for NewPSRequest.
type PSRequestInput struct {
Op uint32
Org string
Project string
Params []byte
}
// NewPSRequest builds a ZAP-encoded PSRequest message from in and returns the bytes.
func NewPSRequest(in PSRequestInput) []byte {
b := zap.NewBuilder(256)
ob := b.StartObject(pSRequestSize)
ob.SetUint32(pSRequestOpOff, in.Op)
ob.SetText(pSRequestOrgOff, in.Org)
ob.SetText(pSRequestProjectOff, in.Project)
ob.SetBytes(pSRequestParamsOff, in.Params)
ob.FinishAsRoot()
return b.Finish()
}
const (
pSResponseStatusOff = 0
pSResponseBodyOff = 4
pSResponseSize = 12
)
// PSResponse is a zero-copy view into a ZAP-encoded PSResponse message.
type PSResponse struct{ o zap.Object }
// WrapPSResponse parses b and returns a typed view. Returns an error if the
// wire-level checks (magic, version, size) fail.
func WrapPSResponse(b []byte) (PSResponse, error) {
m, err := zap.Parse(b)
if err != nil {
return PSResponse{}, err
}
return PSResponse{o: m.Root()}, nil
}
func (t PSResponse) Status() uint32 { return t.o.Uint32(pSResponseStatusOff) }
func (t PSResponse) Body() []byte { return t.o.Bytes(pSResponseBodyOff) }
// PSResponseInput collects the field values for NewPSResponse.
type PSResponseInput struct {
Status uint32
Body []byte
}
// NewPSResponse builds a ZAP-encoded PSResponse message from in and returns the bytes.
func NewPSResponse(in PSResponseInput) []byte {
b := zap.NewBuilder(256)
ob := b.StartObject(pSResponseSize)
ob.SetUint32(pSResponseStatusOff, in.Status)
ob.SetBytes(pSResponseBodyOff, in.Body)
ob.FinishAsRoot()
return b.Finish()
}
const (
spendAlertIdOff = 0
spendAlertOrgOff = 8
spendAlertTitleOff = 16
spendAlertThresholdOff = 24
spendAlertTriggeredAtOff = 32
spendAlertCreatedOff = 40
spendAlertUpdatedOff = 48
spendAlertSize = 56
)
// SpendAlert is a zero-copy view into a ZAP-encoded SpendAlert message.
type SpendAlert struct{ o zap.Object }
// WrapSpendAlert parses b and returns a typed view. Returns an error if the
// wire-level checks (magic, version, size) fail.
func WrapSpendAlert(b []byte) (SpendAlert, error) {
m, err := zap.Parse(b)
if err != nil {
return SpendAlert{}, err
}
return SpendAlert{o: m.Root()}, nil
}
func (t SpendAlert) Id() string { return t.o.Text(spendAlertIdOff) }
func (t SpendAlert) Org() string { return t.o.Text(spendAlertOrgOff) }
func (t SpendAlert) Title() string { return t.o.Text(spendAlertTitleOff) }
func (t SpendAlert) Threshold() float64 { return t.o.Float64(spendAlertThresholdOff) }
func (t SpendAlert) TriggeredAt() int64 { return t.o.Int64(spendAlertTriggeredAtOff) }
func (t SpendAlert) Created() int64 { return t.o.Int64(spendAlertCreatedOff) }
func (t SpendAlert) Updated() int64 { return t.o.Int64(spendAlertUpdatedOff) }
// SpendAlertInput collects the field values for NewSpendAlert.
type SpendAlertInput struct {
Id string
Org string
Title string
Threshold float64
TriggeredAt int64
Created int64
Updated int64
}
// NewSpendAlert builds a ZAP-encoded SpendAlert message from in and returns the bytes.
func NewSpendAlert(in SpendAlertInput) []byte {
b := zap.NewBuilder(256)
ob := b.StartObject(spendAlertSize)
ob.SetText(spendAlertIdOff, in.Id)
ob.SetText(spendAlertOrgOff, in.Org)
ob.SetText(spendAlertTitleOff, in.Title)
ob.SetFloat64(spendAlertThresholdOff, in.Threshold)
ob.SetUint64(spendAlertTriggeredAtOff, uint64(in.TriggeredAt))
ob.SetUint64(spendAlertCreatedOff, uint64(in.Created))
ob.SetUint64(spendAlertUpdatedOff, uint64(in.Updated))
ob.FinishAsRoot()
return b.Finish()
}
const (
spendAlertListAlertsOff = 0
spendAlertListSize = 8
)
// SpendAlertList is a zero-copy view into a ZAP-encoded SpendAlertList message.
type SpendAlertList struct{ o zap.Object }
// WrapSpendAlertList parses b and returns a typed view. Returns an error if the
// wire-level checks (magic, version, size) fail.
func WrapSpendAlertList(b []byte) (SpendAlertList, error) {
m, err := zap.Parse(b)
if err != nil {
return SpendAlertList{}, err
}
return SpendAlertList{o: m.Root()}, nil
}
func (t SpendAlertList) Alerts() zap.List { return t.o.List(spendAlertListAlertsOff) }
// SpendAlertListInput collects the field values for NewSpendAlertList.
type SpendAlertListInput struct {
Alerts [][]byte
}
// NewSpendAlertList builds a ZAP-encoded SpendAlertList message from in and returns the bytes.
func NewSpendAlertList(in SpendAlertListInput) []byte {
b := zap.NewBuilder(256)
ob := b.StartObject(spendAlertListSize)
alertsLB := b.StartList(0)
for _, elem := range in.Alerts {
alertsLB.AddObjectBytes(elem)
}
ob.SetList(spendAlertListAlertsOff, alertsLB.FinishOffset(), len(in.Alerts))
ob.FinishAsRoot()
return b.Finish()
}