Skip to content

Commit

Permalink
fix(HMS-2830): Add resource group to Azure response
Browse files Browse the repository at this point in the history
We have misseadding Resource Group to the response in b369cf8.
  • Loading branch information
ezr-ondrej authored and akhil-jha committed Oct 19, 2023
1 parent 84cb331 commit 8a733b2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 29 deletions.
5 changes: 5 additions & 0 deletions api/openapi.gen.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"poweroff": false,
"pubkey_id": 42,
"reservation_id": 1310,
"resource_group": "myCustom Azure RG",
"source_id": "654321"
}
},
Expand All @@ -109,6 +110,7 @@
"poweroff": false,
"pubkey_id": 42,
"reservation_id": 1310,
"resource_group": "myCustom Azure RG",
"source_id": "654321"
}
},
Expand Down Expand Up @@ -757,6 +759,9 @@
"format": "int64",
"type": "integer"
},
"resource_group": {
"type": "string"
},
"source_id": {
"type": "string"
}
Expand Down
4 changes: 4 additions & 0 deletions api/openapi.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ components:
reservation_id:
type: integer
format: int64
resource_group:
type: string
source_id:
type: string
v1.GCPReservationRequest:
Expand Down Expand Up @@ -685,6 +687,7 @@ components:
poweroff: false
pubkey_id: 42
reservation_id: 1310
resource_group: myCustom Azure RG
source_id: "654321"
v1.AzureReservationResponsePayloadPendingExample:
value:
Expand All @@ -697,6 +700,7 @@ components:
poweroff: false
pubkey_id: 42
reservation_id: 1310
resource_group: myCustom Azure RG
source_id: "654321"
v1.GCPReservationRequestPayloadExample:
value:
Expand Down
40 changes: 21 additions & 19 deletions cmd/spec/example_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,28 +132,30 @@ var AzureReservationRequestPayloadExample = payloads.AzureReservationRequest{
}

var AzureReservationResponsePayloadPendingExample = payloads.AzureReservationResponse{
ID: 1310,
PubkeyID: 42,
SourceID: "654321",
Location: "useast",
InstanceSize: "Basic_A0",
Amount: 1,
ImageID: "composer-api-081fc867-838f-44a5-af03-8b8def808431",
Name: "my-instance",
PowerOff: false,
Instances: nil,
ID: 1310,
PubkeyID: 42,
SourceID: "654321",
ResourceGroup: "myCustom Azure RG",
Location: "useast",
InstanceSize: "Basic_A0",
Amount: 1,
ImageID: "composer-api-081fc867-838f-44a5-af03-8b8def808431",
Name: "my-instance",
PowerOff: false,
Instances: nil,
}

var AzureReservationResponsePayloadDoneExample = payloads.AzureReservationResponse{
ID: 1310,
PubkeyID: 42,
SourceID: "654321",
Location: "useast",
InstanceSize: "Basic_A0",
Amount: 1,
ImageID: "composer-api-081fc867-838f-44a5-af03-8b8def808431",
Name: "my-instance",
PowerOff: false,
ID: 1310,
PubkeyID: 42,
SourceID: "654321",
ResourceGroup: "myCustom Azure RG",
Location: "useast",
InstanceSize: "Basic_A0",
Amount: 1,
ImageID: "composer-api-081fc867-838f-44a5-af03-8b8def808431",
Name: "my-instance",
PowerOff: false,
Instances: []payloads.InstanceResponse{{
InstanceID: "/subscriptions/4b9d213f-712f-4d17-a483-8a10bbe9df3a/resourceGroups/redhat-deployed/providers/Microsoft.Compute/images/composer-api-92ea98f8-7697-472e-80b1-7454fa0e7fa7",
Detail: models.ReservationInstanceDetail{
Expand Down
23 changes: 13 additions & 10 deletions internal/payloads/reservation_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ type AzureReservationResponse struct {

SourceID string `json:"source_id" yaml:"source_id"`

ResourceGroup string `json:"resource_group" yaml:"resource_group"`

// Azure Location.
Location string `json:"location" yaml:"location"`

Expand Down Expand Up @@ -320,16 +322,17 @@ func NewAzureReservationResponse(reservation *models.AzureReservation, instances
}

response := AzureReservationResponse{
PubkeyID: reservation.PubkeyID,
ImageID: reservation.ImageID,
SourceID: reservation.SourceID,
Location: reservation.Detail.Location,
Amount: reservation.Detail.Amount,
InstanceSize: reservation.Detail.InstanceSize,
ID: reservation.ID,
Name: reservation.Detail.Name,
PowerOff: reservation.Detail.PowerOff,
Instances: instanceIds,
PubkeyID: reservation.PubkeyID,
ImageID: reservation.ImageID,
SourceID: reservation.SourceID,
ResourceGroup: reservation.Detail.ResourceGroup,
Location: reservation.Detail.Location,
Amount: reservation.Detail.Amount,
InstanceSize: reservation.Detail.InstanceSize,
ID: reservation.ID,
Name: reservation.Detail.Name,
PowerOff: reservation.Detail.PowerOff,
Instances: instanceIds,
}
return &response
}
Expand Down

0 comments on commit 8a733b2

Please sign in to comment.