diff --git a/iota-config-group.go b/iota-config-group.go index 385e876..d22d4fc 100644 --- a/iota-config-group.go +++ b/iota-config-group.go @@ -78,7 +78,7 @@ func (i IoTA) ReadConfigGroup(fs FiwareService, r Resource, a Apikey) (*RespRead return nil, fmt.Errorf("Error while eding response body %w", err) } var apiError ApiError - json.Unmarshal(resData, &apiError) + err = json.Unmarshal(resData, &apiError) if err != nil { return nil, fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host) } @@ -123,7 +123,7 @@ func (i IoTA) ListConfigGroups(fs FiwareService) (*RespReadConfigGroup, error) { return nil, fmt.Errorf("Error while eding response body %w", err) } var apiError ApiError - json.Unmarshal(resData, &apiError) + err = json.Unmarshal(resData, &apiError) if err != nil { return nil, fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host) } @@ -193,7 +193,7 @@ func (i IoTA) CreateConfigGroups(fs FiwareService, sgs []ConfigGroup) error { return fmt.Errorf("Error while eding response body %w", err) } var apiError ApiError - json.Unmarshal(resData, &apiError) + err = json.Unmarshal(resData, &apiError) if err != nil { return fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host) } @@ -241,7 +241,7 @@ func (i IoTA) UpdateConfigGroup(fs FiwareService, r Resource, a Apikey, sg Confi return fmt.Errorf("Error while eding response body %w", err) } var apiError ApiError - json.Unmarshal(resData, &apiError) + err = json.Unmarshal(resData, &apiError) if err != nil { return fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host) } @@ -279,7 +279,7 @@ func (i IoTA) DeleteConfigGroup(fs FiwareService, r Resource, a Apikey) error { return fmt.Errorf("Error while eding response body %w", err) } var apiError ApiError - json.Unmarshal(resData, &apiError) + err = json.Unmarshal(resData, &apiError) if err != nil { return fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host) } diff --git a/iota-device.go b/iota-device.go index 4d7aa44..6cc3dd4 100644 --- a/iota-device.go +++ b/iota-device.go @@ -84,7 +84,7 @@ func (i IoTA) ReadDevice(fs FiwareService, id DeciveId) (*Device, error) { } var device Device - json.Unmarshal(responseData, &device) + err = json.Unmarshal(responseData, &device) if err != nil { log.Panic().Err(err).Msg("Could not Marshal struct") } @@ -126,7 +126,7 @@ func (i IoTA) ListDevices(fs FiwareService) (*respListDevices, error) { return nil, fmt.Errorf("Error while eding response body %w", err) } var apiError ApiError - json.Unmarshal(resData, &apiError) + err = json.Unmarshal(resData, &apiError) if err != nil { log.Panic().Err(err).Msg("Could not Marshal struct") } diff --git a/iota-types.go b/iota-types.go index 5aeaf2b..3f62d70 100644 --- a/iota-types.go +++ b/iota-types.go @@ -37,48 +37,48 @@ type ApiError struct { // Attribute represents an attribute in the data model. type Attribute struct { - ObjectID string `json:"object_id,omitempty" formam:"object_id"` - Name string `json:"name" formam:"name"` - Type string `json:"type" formam:"type"` - Expression string `json:"expression,omitempty" formam:"expression"` - SkipValue string `json:"skipValue,omitempty" formam:"skipValue"` - EntityName string `json:"entity_name,omitempty" formam:"entity_name"` - EntityType string `json:"entity_type,omitempty" formam:"entity_type"` - Metadata map[string]Metadata `json:"metadata,omitempty" formam:"metadata"` + ObjectID string `json:"object_id,omitempty" form:"object_id"` + Name string `json:"name" form:"name"` + Type string `json:"type" form:"type"` + Expression string `json:"expression,omitempty" form:"expression"` + SkipValue string `json:"skipValue,omitempty" form:"skipValue"` + EntityName string `json:"entity_name,omitempty" form:"entity_name"` + EntityType string `json:"entity_type,omitempty" form:"entity_type"` + Metadata map[string]Metadata `json:"metadata,omitempty" form:"metadata"` } // LazyAttribute represents a lazy attribute in the data model. type LazyAttribute struct { - ObjectID string `json:"object_id,omitempty" formam:"object_id"` - Name string `json:"name" formam:"name"` - Type string `json:"type" formam:"type"` - Metadata map[string]Metadata `json:"metadata,omitempty" formam:"metadata"` + ObjectID string `json:"object_id,omitempty" form:"object_id"` + Name string `json:"name" form:"name"` + Type string `json:"type" form:"type"` + Metadata map[string]Metadata `json:"metadata,omitempty" form:"metadata"` } // StaticAttribute represents a static attribute in the data model. type StaticAttribute struct { - ObjectID string `json:"object_id,omitempty" formam:"object_id"` - Name string `json:"name" formam:"name"` - Type string `json:"type" formam:"type"` - Value any `json:"value" formam:"value"` - Metadata map[string]Metadata `json:"metadata,omitempty" formam:"metadata"` + ObjectID string `json:"object_id,omitempty" form:"object_id"` + Name string `json:"name" form:"name"` + Type string `json:"type" form:"type"` + Value any `json:"value" form:"value"` + Metadata map[string]Metadata `json:"metadata,omitempty" form:"metadata"` } // Command represents a command in the data model. type Command struct { - ObjectID string `json:"object_id,omitempty" formam:"object_id"` - Name string `json:"name" formam:"name"` - Type string `json:"type" formam:"type"` - Expression string `json:"expression,omitempty" formam:"expression"` - PayloadType string `json:"payloadType,omitempty" formam:"payloadType"` - ContentType string `json:"contentType,omitempty" formam:"contentType"` - Metadata map[string]Metadata `json:"metadata,omitempty" formam:"metadata"` + ObjectID string `json:"object_id,omitempty" form:"object_id"` + Name string `json:"name" form:"name"` + Type string `json:"type" form:"type"` + Expression string `json:"expression,omitempty" form:"expression"` + PayloadType string `json:"payloadType,omitempty" form:"payloadType"` + ContentType string `json:"contentType,omitempty" form:"contentType"` + Metadata map[string]Metadata `json:"metadata,omitempty" form:"metadata"` } // Metadata represents metadata for attributes and commands. type Metadata struct { - Type string `json:"type" formam:"type"` - Value string `json:"value" formam:"value"` + Type string `json:"type" form:"type"` + Value string `json:"value" form:"value"` } // Apikey represents an API key. @@ -90,27 +90,27 @@ type Resource string // ConfigGroup represents a configuration group. // See datamodel [Config Group]: https://iotagent-node-lib.readthedocs.io/en/latest/api.html#service-group-datamodel type ConfigGroup struct { - Service string `json:"service,omitempty" formam:"service"` - ServicePath string `json:"subservice,omitempty" formam:"subservice"` - Resource Resource `json:"resource" formam:"resource"` - Apikey Apikey `json:"apikey" formam:"apikey"` - Timestamp *bool `json:"timestamp,omitempty" formam:"timestamp"` - EntityType string `json:"entity_type,omitempty" formam:"entity_type"` - Trust string `json:"trust,omitempty" formam:"trust"` - CbHost string `json:"cbHost,omitempty" formam:"cbHost"` - Lazy []LazyAttribute `json:"lazy,omitempty" formam:"lazy"` - Commands []Command `json:"commands,omitempty" formam:"commands"` - Attributes []Attribute `json:"attributes,omitempty" formam:"attributes"` - StaticAttributes []StaticAttribute `json:"static_attributes,omitempty" formam:"static_attributes"` - InternalAttributes []interface{} `json:"internal_attributes,omitempty" formam:"internal_attributes"` - ExplicitAttrs string `json:"explicitAttrs,omitempty" formam:"explicitAttrs"` - EntityNameExp string `json:"entityNameExp,omitempty" formam:"entityNameExp"` - NgsiVersion string `json:"ngsiVersion,omitempty" formam:"ngsiVersion"` - DefaultEntityNameConjunction string `json:"defaultEntityNameConjunction,omitempty" formam:"defaultEntityNameConjunction"` - Autoprovision bool `json:"autoprovision,omitempty" formam:"autoprovision"` - PayloadType string `json:"payloadType,omitempty" formam:"payloadType"` - Transport string `json:"transport,omitempty" formam:"transport"` - Endpoint string `json:"endpoint,omitempty" formam:"endpoint"` + Service string `json:"service,omitempty" form:"service"` + ServicePath string `json:"subservice,omitempty" form:"subservice"` + Resource Resource `json:"resource" form:"resource"` + Apikey Apikey `json:"apikey" form:"apikey"` + Timestamp *bool `json:"timestamp,omitempty" form:"timestamp"` + EntityType string `json:"entity_type,omitempty" form:"entity_type"` + Trust string `json:"trust,omitempty" form:"trust"` + CbHost string `json:"cbHost,omitempty" form:"cbHost"` + Lazy []LazyAttribute `json:"lazy,omitempty" form:"lazy"` + Commands []Command `json:"commands,omitempty" form:"commands"` + Attributes []Attribute `json:"attributes,omitempty" form:"attributes"` + StaticAttributes []StaticAttribute `json:"static_attributes,omitempty" form:"static_attributes"` + InternalAttributes []interface{} `json:"internal_attributes,omitempty" form:"internal_attributes"` + ExplicitAttrs string `json:"explicitAttrs,omitempty" form:"explicitAttrs"` + EntityNameExp string `json:"entityNameExp,omitempty" form:"entityNameExp"` + NgsiVersion string `json:"ngsiVersion,omitempty" form:"ngsiVersion"` + DefaultEntityNameConjunction string `json:"defaultEntityNameConjunction,omitempty" form:"defaultEntityNameConjunction"` + Autoprovision bool `json:"autoprovision,omitempty" form:"autoprovision"` + PayloadType string `json:"payloadType,omitempty" form:"payloadType"` + Transport string `json:"transport,omitempty" form:"transport"` + Endpoint string `json:"endpoint,omitempty" form:"endpoint"` } // DeciveId represents a device ID. @@ -119,25 +119,25 @@ type DeciveId string // Device represents a device. // See datamodel [Device]: https://iotagent-node-lib.readthedocs.io/en/3.3.0/api.html#device-datamodel type Device struct { - Id DeciveId `json:"device_id,omitempty" formam:"device_id"` - Service string `json:"service,omitempty" formam:"service"` - ServicePath string `json:"service_path,omitempty" formam:"service_path"` - EntityName string `json:"entity_name,omitempty" formam:"entity_name"` - EntityType string `json:"entity_type,omitempty" formam:"entity_type"` - Timezone string `json:"timezon,omitempty" formam:"timezone"` - Timestamp *bool `json:"timestamp,omitempty" formam:"timestamp"` - Apikey Apikey `json:"apikey,omitempty" formam:"apikey"` - Endpoint string `json:"endpoint,omitempty" formam:"endpoint"` - Protocol string `json:"protocol,omitempty" formam:"protocol"` - Transport string `json:"transport,omitempty" formam:"transport"` - Attributes []Attribute `json:"attributes,omitempty" formam:"attributes"` - Commands []Command `json:"commands,omitempty" formam:"commands"` - Lazy []LazyAttribute `json:"lazy,omitempty" formam:"lazy"` - StaticAttributes []StaticAttribute `json:"static_attributes,omitempty" formam:"static_attributes"` - InternalAttributes []interface{} `json:"internal_attributes,omitempty" formam:"internal_attributes"` - ExplicitAttrs string `json:"explicitAttrs,omitempty" formam:"explicitAttrs"` - NgsiVersion string `json:"ngsiVersion,omitempty" formam:"ngsiVersion"` - PayloadType string `json:"payloadType,omitempty" formam:"payloadType"` + Id DeciveId `json:"device_id,omitempty" form:"device_id"` + Service string `json:"service,omitempty" form:"service"` + ServicePath string `json:"service_path,omitempty" form:"service_path"` + EntityName string `json:"entity_name,omitempty" form:"entity_name"` + EntityType string `json:"entity_type,omitempty" form:"entity_type"` + Timezone string `json:"timezon,omitempty" form:"timezone"` + Timestamp *bool `json:"timestamp,omitempty" form:"timestamp"` + Apikey Apikey `json:"apikey,omitempty" form:"apikey"` + Endpoint string `json:"endpoint,omitempty" form:"endpoint"` + Protocol string `json:"protocol,omitempty" form:"protocol"` + Transport string `json:"transport,omitempty" form:"transport"` + Attributes []Attribute `json:"attributes,omitempty" form:"attributes"` + Commands []Command `json:"commands,omitempty" form:"commands"` + Lazy []LazyAttribute `json:"lazy,omitempty" form:"lazy"` + StaticAttributes []StaticAttribute `json:"static_attributes,omitempty" form:"static_attributes"` + InternalAttributes []interface{} `json:"internal_attributes,omitempty" form:"internal_attributes"` + ExplicitAttrs any `json:"explicitAttrs,omitempty" form:"explicitAttrs"` + NgsiVersion string `json:"ngsiVersion,omitempty" form:"ngsiVersion"` + PayloadType string `json:"payloadType,omitempty" form:"payloadType"` } type MissingFields struct {