Skip to content

Commit

Permalink
fix(marketplace): error detail serialization and model mapping (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoaguimaraes authored Nov 10, 2021
1 parent 066c6da commit 0908189
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions pkg/component/marketplace/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,33 @@ import (

// UsageEventReq a type to represent the usage metering event request
type UsageEventReq struct {
ResourceId string `json:"resourceId"` // unique identifier of the resource against which usage is emitted.
Quantity float32 `json:"quantity"` // how many units were consumed for the date and hour specified in effectiveStartTime, must be greater than 0, can be integer or float value
Dimension string `json:"dimension"` // custom dimension identifier
StartTime time.Time `json:"startTime"` // time in UTC when the usage event occurred, from now and until 24 hours back
Plan string `json:"plan"` // id of the plan purchased for the offer
ResourceId string `json:"resourceUri"` // unique identifier of the resource against which usage is emitted.
Quantity float32 `json:"quantity"` // how many units were consumed for the date and hour specified in effectiveStartTime, must be greater than 0, can be integer or float value
Dimension string `json:"dimension"` // custom dimension identifier
StartTime time.Time `json:"effectiveStartTime"` // time in UTC when the usage event occurred, from now and until 24 hours back
Plan string `json:"planId"` // id of the plan purchased for the offer
}

// UsageEventRes a type to represent the usage metering event response
type UsageEventRes struct {
autorest.Response `json:"-"`
UsageEventId string `json:"usageEventId"` // unique identifier associated with the usage event in Microsoft records
Status string `json:"status"` // this is the only value in case of single usage event
MessageTime time.Time `json:"messageTime"` // time in UTC this event was accepted
ResourceId string `json:"resourceId"` // unique identifier of the resource against which usage is emitted. For SaaS it's the subscriptionId.
Quantity float32 `json:"quantity"` // amount of emitted units as recorded by Microsoft
Dimension string `json:"dimension"` // custom dimension identifier
EffectiveStartTime time.Time `json:"effectiveStartTime"` // time in UTC when the usage event occurred, as sent by the ISV
PlanId string `json:"planId"` // id of the plan purchased for the offer
UsageEventId string `json:"usageEventId"` // unique identifier associated with the usage event in Microsoft records
Status string `json:"status"` // this is the only value in case of single usage event
MessageTime time.Time `json:"messageTime"` // time in UTC this event was accepted
ResourceId string `json:"resourceId"` // unique identifier of the resource against which usage is emitted. For SaaS it's the subscriptionId.
Quantity float32 `json:"quantity"` // amount of emitted units as recorded by Microsoft
Dimension string `json:"dimension"` // custom dimension identifier
EffectiveStartTime time.Time `json:"effectiveStartTime"` // time in UTC when the usage event occurred, as sent by the ISV
PlanId string `json:"planId"` // id of the plan purchased for the offer
Error UsageEventErrorDetail `json:"error"`
}

// UsageEventErrorDetail represents a detail error mensage.
type UsageEventErrorDetail struct {
Message string `json:"message"`
Target string `json:"target"`
Code string `json:"code"`
Details []UsageEventErrorDetail `json:"details,omitempty"`
}

// UsageEventBatchReq a type to represent the usage metering batch events request
Expand Down

0 comments on commit 0908189

Please sign in to comment.