Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dp): Use mutable installation params for mutable cbsd API #12891

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 4 additions & 26 deletions dp/cloud/go/services/dp/builders/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func NewCbsdProtoPayloadBuilder() *CbsdProtoPayloadBuilder {
DesiredState: registered,
CbsdCategory: catB,
SingleStepEnabled: false,
InstallationParam: &protos.InstallationParam{},
},
}
}
Expand Down Expand Up @@ -441,7 +442,7 @@ type CbsdModelPayloadBuilder struct {

func NewCbsdModelPayloadBuilder() *CbsdModelPayloadBuilder {
return &CbsdModelPayloadBuilder{Payload: &models.Cbsd{
Capabilities: &models.Capabilities{
Capabilities: models.Capabilities{
MaxPower: to_pointer.Float(20),
MinPower: to_pointer.Float(10),
NumberOfAntennas: 2,
Expand Down Expand Up @@ -496,7 +497,7 @@ type MutableCbsdModelBuilder struct {

func NewMutableCbsdModelPayloadBuilder() *MutableCbsdModelBuilder {
return &MutableCbsdModelBuilder{Payload: &models.MutableCbsd{
Capabilities: &models.Capabilities{
Capabilities: models.Capabilities{
MaxPower: to_pointer.Float(20),
MinPower: to_pointer.Float(10),
NumberOfAntennas: 2,
Expand Down Expand Up @@ -530,22 +531,11 @@ func (b *MutableCbsdModelBuilder) WithFccId(id string) *MutableCbsdModelBuilder
}

func (b *MutableCbsdModelBuilder) WithEmptyInstallationParam() *MutableCbsdModelBuilder {
b.Payload.InstallationParam = &models.InstallationParam{}
return b
}

func (b *MutableCbsdModelBuilder) WithHeightType(heightType string) *MutableCbsdModelBuilder {
if b.Payload.InstallationParam == nil {
b.Payload.InstallationParam = &models.InstallationParam{}
}
b.Payload.InstallationParam.HeightType = to_pointer.String(heightType)
b.Payload.InstallationParam = models.MutableInstallationParam{}
return b
}

func (b *MutableCbsdModelBuilder) WithAntennaGain(gain float64) *MutableCbsdModelBuilder {
if b.Payload.InstallationParam == nil {
b.Payload.InstallationParam = &models.InstallationParam{}
}
b.Payload.InstallationParam.AntennaGain = to_pointer.Float(gain)
return b
}
Expand Down Expand Up @@ -579,18 +569,6 @@ func (b *MutableCbsdModelBuilder) WithSingleStepEnabled(enabled *bool) *MutableC
return b
}

func (b *MutableCbsdModelBuilder) WithIndoorDeployment(indoor *bool) *MutableCbsdModelBuilder {
if b.Payload.InstallationParam == nil {
b.Payload.InstallationParam = &models.InstallationParam{}
}
if indoor == nil {
b.Payload.InstallationParam.IndoorDeployment = nil
} else {
b.Payload.InstallationParam.IndoorDeployment = to_pointer.Bool(*indoor)
}
return b
}

func (b *MutableCbsdModelBuilder) WithMinPower(power *float64) *MutableCbsdModelBuilder {
if power == nil {
b.Payload.Capabilities.MinPower = nil
Expand Down
68 changes: 26 additions & 42 deletions dp/cloud/go/services/dp/obsidian/models/cbsd_swaggergen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 8 additions & 23 deletions dp/cloud/go/services/dp/obsidian/models/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ func CbsdToBackend(m *MutableCbsd) *protos.CbsdData {
BandwidthMhz: m.FrequencyPreferences.BandwidthMhz,
FrequenciesMhz: m.FrequencyPreferences.FrequenciesMhz,
},
DesiredState: m.DesiredState,
InstallationParam: getProtoInstallationParam(m.InstallationParam),
DesiredState: m.DesiredState,
InstallationParam: &protos.InstallationParam{
AntennaGain: to_pointer.FloatToDoubleValue(m.InstallationParam.AntennaGain),
},
}
}

func CbsdFromBackend(details *protos.CbsdDetails) *Cbsd {
return &Cbsd{
Capabilities: &Capabilities{
Capabilities: Capabilities{
MaxPower: &details.Data.Capabilities.MaxPower,
MinPower: &details.Data.Capabilities.MinPower,
NumberOfAntennas: details.Data.Capabilities.NumberOfAntennas,
Expand All @@ -63,7 +65,7 @@ func CbsdFromBackend(details *protos.CbsdDetails) *Cbsd {
UserID: details.Data.UserId,
SingleStepEnabled: details.Data.SingleStepEnabled,
CbsdCategory: details.Data.CbsdCategory,
InstallationParam: getModelInstallationParam(details.Data.GetInstallationParam()),
InstallationParam: getModelInstallationParam(details.Data.InstallationParam),
}
}

Expand All @@ -88,11 +90,8 @@ func getGrant(grant *protos.GrantDetails) *Grant {
}
}

func getModelInstallationParam(params *protos.InstallationParam) *InstallationParam {
if params == nil {
return nil
}
return &InstallationParam{
func getModelInstallationParam(params *protos.InstallationParam) InstallationParam {
return InstallationParam{
AntennaGain: to_pointer.DoubleValueToFloat(params.AntennaGain),
Heightm: to_pointer.DoubleValueToFloat(params.HeightM),
HeightType: to_pointer.StringValueToString(params.HeightType),
Expand All @@ -102,20 +101,6 @@ func getModelInstallationParam(params *protos.InstallationParam) *InstallationPa
}
}

func getProtoInstallationParam(params *InstallationParam) *protos.InstallationParam {
if params == nil {
return nil
}
return &protos.InstallationParam{
AntennaGain: to_pointer.FloatToDoubleValue(params.AntennaGain),
HeightM: to_pointer.FloatToDoubleValue(params.Heightm),
HeightType: to_pointer.StringToStringValue(params.HeightType),
IndoorDeployment: to_pointer.BoolToBoolValue(params.IndoorDeployment),
LatitudeDeg: to_pointer.FloatToDoubleValue(params.LatitudeDeg),
LongitudeDeg: to_pointer.FloatToDoubleValue(params.LongitudeDeg),
}
}

type LogInterface struct {
Body string `json:"log_message"`
FccID string `json:"fcc_id"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestCbsdFromBackendWithoutInstallationParam(t *testing.T) {
details := b.NewDetailedProtoCbsdBuilder(
b.NewCbsdProtoPayloadBuilder()).Details
data := models.CbsdFromBackend(details)
assert.Nil(t, data.InstallationParam)
assert.Empty(t, data.InstallationParam)
}

func TestCbsdFromBackendWithInstallationParam(t *testing.T) {
Expand Down
64 changes: 26 additions & 38 deletions dp/cloud/go/services/dp/obsidian/models/mutable_cbsd_swaggergen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.