Skip to content

Commit

Permalink
Merge pull request #24 from yuuu/add_binary_parser_to_air_config
Browse files Browse the repository at this point in the history
add binary parser config to AirConfig.
  • Loading branch information
bearmini authored Nov 8, 2022
2 parents d17c574 + ece8a9d commit 229c35a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
20 changes: 18 additions & 2 deletions api_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,9 @@ func TestUpdateAirConfig(t *testing.T) {
ReadOnly: true,
AllowOrigin: "http://some.example.com",
},
UserData: "foobar",
UserData: "foobar",
BinaryParserEnabled: true,
BinaryParserFormat: "flag:0:bool:7 temp:1:int:13:/10 humid:3:uint:8:/100 lat::float:32 long:float:32",
}

g1, err := apiClient.UpdateAirConfig(group.GroupID, airConfig1)
Expand All @@ -1304,6 +1306,12 @@ func TestUpdateAirConfig(t *testing.T) {
if air1["userdata"].(string) != "foobar" {
t.Fatalf("Unexpected value found")
}
if air1["binaryParserEnabled"].(bool) != true {
t.Fatalf("Unexpected value found")
}
if air1["binaryParserFormat"].(string) != "flag:0:bool:7 temp:1:int:13:/10 humid:3:uint:8:/100 lat::float:32 long:float:32" {
t.Fatalf("Unexpected value found")
}

airConfig2 := &AirConfig{
UseCustomDNS: false,
Expand All @@ -1315,7 +1323,9 @@ func TestUpdateAirConfig(t *testing.T) {
ReadOnly: false,
AllowOrigin: "http://any.example.com",
},
UserData: "helloworld",
UserData: "helloworld",
BinaryParserEnabled: false,
BinaryParserFormat: "",
}

g2, err := apiClient.UpdateAirConfig(group.GroupID, airConfig2)
Expand All @@ -1342,6 +1352,12 @@ func TestUpdateAirConfig(t *testing.T) {
if air2["userdata"].(string) != "helloworld" {
t.Fatalf("Unexpected value found")
}
if air2["binaryParserEnabled"].(bool) != false {
t.Fatalf("Unexpected value found")
}
if air2["binaryParserFormat"].(string) != "" {
t.Fatalf("Unexpected value found")
}
}

func TestUpdateBeamTCPConfig(t *testing.T) {
Expand Down
12 changes: 8 additions & 4 deletions sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,12 @@ type MetaData struct {

// AirConfig holds configuration parameters for SORACOM Air
type AirConfig struct {
UseCustomDNS bool `json:"useCustomDns"`
DNSServers []string `json:"dnsServers"`
MetaData MetaData `json:"metadata"`
UserData string `json:"userdata"`
UseCustomDNS bool `json:"useCustomDns"`
DNSServers []string `json:"dnsServers"`
MetaData MetaData `json:"metadata"`
UserData string `json:"userdata"`
BinaryParserEnabled bool `json:"binaryParserEnabled"`
BinaryParserFormat string `json:"binaryParserFormat"`
}

// JSON converts AirConfig into JSON string
Expand All @@ -768,6 +770,8 @@ func (ac *AirConfig) JSON() string {
{Key: "dnsServers", Value: ac.DNSServers},
{Key: "metadata", Value: ac.MetaData},
{Key: "userdata", Value: ac.UserData},
{Key: "binaryParserEnabled", Value: ac.BinaryParserEnabled},
{Key: "binaryParserFormat", Value: ac.BinaryParserFormat},
})
}

Expand Down

0 comments on commit 229c35a

Please sign in to comment.