Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd4bbaa
Changes for adding OSUpdateRun resource in inventory
SushilLakra Jun 7, 2025
324d183
Merge branch 'main' into itep-67234-changes-br
SushilLakra Jun 7, 2025
383d006
Added implementation to API handlers in APIv2 for OSUpdateRun
SushilLakra Jun 10, 2025
34ffaaf
Changes for adding OSUpdateRun resource in inventory
SushilLakra Jun 7, 2025
31dc9c5
Added implementation to API handlers in APIv2 for OSUpdateRun
SushilLakra Jun 10, 2025
dbb6394
Fix for review comments in apiv2 + chnages for resolving rebase confl…
SushilLakra Jun 12, 2025
f298daa
fixed merge conflicts
SushilLakra Jun 12, 2025
03ad15f
Merge branch 'main' into api-handler-impl-osupdaterun-br
SushilLakra Jun 12, 2025
71d2bde
fixed merge conflicts - 2
SushilLakra Jun 12, 2025
ac5c5f1
Merge branch 'main' into api-handler-impl-osupdaterun-br
SushilLakra Jun 13, 2025
74bdcbb
Ypdated version in VERSION file
SushilLakra Jun 13, 2025
dff3058
Merge branch 'api-handler-impl-osupdaterun-br' of https://github.com/…
SushilLakra Jun 13, 2025
33bc89b
fix for review comment to use correct time format for timestamp strin…
SushilLakra Jun 13, 2025
2b72d48
Merge branch 'main' into api-handler-impl-osupdaterun-br
SushilLakra Jun 13, 2025
061d3d6
fixed go-lint errors
SushilLakra Jun 13, 2025
15da55f
Merge branch 'api-handler-impl-osupdaterun-br' of https://github.com/…
SushilLakra Jun 13, 2025
dead7c5
Merge branch 'main' into api-handler-impl-osupdaterun-br
SushilLakra Jun 13, 2025
25f4d0f
changed version
SushilLakra Jun 13, 2025
8497d2b
updated build error observed
SushilLakra Jun 13, 2025
17274b7
Update apiv2/VERSION
SushilLakra Jun 13, 2025
918b05f
fixed further review comments
SushilLakra Jun 13, 2025
365f12a
Merge branch 'main' into api-handler-impl-osupdaterun-br
SushilLakra Jun 13, 2025
87c182a
fixed further review comments - 2
SushilLakra Jun 13, 2025
9591212
Merge branch 'api-handler-impl-osupdaterun-br' of https://github.com/…
SushilLakra Jun 13, 2025
0740104
fixed further review comments - 3
SushilLakra Jun 13, 2025
4b89061
Merge branch 'main' into api-handler-impl-osupdaterun-br
SushilLakra Jun 13, 2025
25640d9
fixed further review comments - 4
SushilLakra Jun 13, 2025
f9aea6d
Merge branch 'api-handler-impl-osupdaterun-br' of https://github.com/…
SushilLakra Jun 13, 2025
8655798
fixed further review comments - 5
SushilLakra Jun 13, 2025
e2869f3
Merge branch 'main' into api-handler-impl-osupdaterun-br
daniele-moro Jun 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apiv2/api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8122,12 +8122,12 @@ components:
ListOSUpdateRunResponse:
type: object
properties:
osUpdatePolicies:
osUpdateRuns:
type: array
items:
$ref: '#/components/schemas/OSUpdateRun'
title: os_update_policies
description: Sorted and filtered list of os update policies.
title: os_update_runs
description: Sorted and filtered list of os update runs.
totalElements:
type: integer
title: total_elements
Expand All @@ -8139,7 +8139,7 @@ components:
description: Inform if there are more elements
title: ListOSUpdateRunResponse
required:
- osUpdatePolicies
- osUpdateRuns
- totalElements
- hasNext
additionalProperties: false
Expand Down
4 changes: 2 additions & 2 deletions apiv2/api/proto/services/v1/services.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2583,8 +2583,8 @@ message ListOSUpdateRunRequest {

// Response message for the ListOSUpdateRun method.
message ListOSUpdateRunResponse {
// Sorted and filtered list of os update policies.
repeated resources.compute.v1.OSUpdateRun os_update_policies = 1 [(google.api.field_behavior) = REQUIRED];
// Sorted and filtered list of os update runs.
repeated resources.compute.v1.OSUpdateRun os_update_runs = 1 [(google.api.field_behavior) = REQUIRED];
// Count of items in the entire list, regardless of pagination.
int32 total_elements = 2 [(google.api.field_behavior) = REQUIRED];
// Inform if there are more elements
Expand Down
2 changes: 1 addition & 1 deletion apiv2/docs/proto.md
Original file line number Diff line number Diff line change
Expand Up @@ -3391,7 +3391,7 @@ Response message for the ListOSUpdateRun method.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| os_update_policies | [resources.compute.v1.OSUpdateRun](#resources-compute-v1-OSUpdateRun) | repeated | Sorted and filtered list of os update policies. |
| os_update_runs | [resources.compute.v1.OSUpdateRun](#resources-compute-v1-OSUpdateRun) | repeated | Sorted and filtered list of os update runs. |
| total_elements | [int32](#int32) | | Count of items in the entire list, regardless of pagination. |
| has_next | [bool](#bool) | | Inform if there are more elements |

Expand Down
2,240 changes: 1,120 additions & 1,120 deletions apiv2/internal/pbapi/services/v1/services.pb.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apiv2/internal/pbapi/services/v1/services_constants.pb.go

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

110 changes: 100 additions & 10 deletions apiv2/internal/server/os_update_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,121 @@ package server

import (
"context"
"time"

"google.golang.org/grpc/codes"
"google.golang.org/protobuf/types/known/timestamppb"

computev1 "github.com/open-edge-platform/infra-core/apiv2/v2/internal/pbapi/resources/compute/v1"
statusv1 "github.com/open-edge-platform/infra-core/apiv2/v2/internal/pbapi/resources/status/v1"
restv1 "github.com/open-edge-platform/infra-core/apiv2/v2/internal/pbapi/services/v1"
inv_computev1 "github.com/open-edge-platform/infra-core/inventory/v2/pkg/api/compute/v1"
inventory "github.com/open-edge-platform/infra-core/inventory/v2/pkg/api/inventory/v1"
"github.com/open-edge-platform/infra-core/inventory/v2/pkg/errors"
"github.com/open-edge-platform/infra-core/inventory/v2/pkg/validator"
)

func (is *InventorygRPCServer) ListOSUpdateRun(_ context.Context, _ *restv1.ListOSUpdateRunRequest) (
func fromInvOSUpdateRunResource(invOSUpdateRunResource *inv_computev1.OSUpdateRunResource) *computev1.OSUpdateRun {

parseTimestamp := func(ts string) *timestamppb.Timestamp {
Comment thread
SushilLakra marked this conversation as resolved.
Outdated
parsedTime, err := time.Parse(time.RFC3339, ts)
if err != nil {
zlog.Warn().Err(err).Msgf("Failed to parse timestamp: %s", ts)
return nil
}
return timestamppb.New(parsedTime)
}
Comment thread
daniele-moro marked this conversation as resolved.
Outdated

if invOSUpdateRunResource == nil {
return &computev1.OSUpdateRun{}
}
instance, err := fromInvInstance(invOSUpdateRunResource.GetInstance())
if err != nil {
zlog.Warn().Err(err).Msgf("Failed to get the inventory instance edge from OS Update Run resource")
return nil
}

osUpdateRunResource := &computev1.OSUpdateRun{
ResourceId: invOSUpdateRunResource.GetResourceId(),
Name: invOSUpdateRunResource.GetName(),
Description: invOSUpdateRunResource.GetDescription(),
AppliedPolicy: fromInvOSUpdatePolicy(invOSUpdateRunResource.GetAppliedPolicy()),
Instance: instance,
StatusIndicator: statusv1.StatusIndication(invOSUpdateRunResource.GetStatusIndicator()),
Status: invOSUpdateRunResource.GetStatus(),
StatusDetails: invOSUpdateRunResource.GetStatusDetails(),
StatusTimestamp: parseTimestamp(invOSUpdateRunResource.GetStatusTimestamp()),
StartTime: parseTimestamp(invOSUpdateRunResource.GetStartTime()),
EndTime: parseTimestamp(invOSUpdateRunResource.GetEndTime()),
Timestamps: GrpcToOpenAPITimestamps(invOSUpdateRunResource),
}
return osUpdateRunResource
}

func (is *InventorygRPCServer) ListOSUpdateRun(ctx context.Context, req *restv1.ListOSUpdateRunRequest) (
*restv1.ListOSUpdateRunResponse, error,
) {
// TODO implement me
return nil, errors.Errorfc(codes.Unimplemented, "ListOSUpdateRun not implemented")
zlog.Debug().Msg("ListOSUpdateRunResources")

filter := &inventory.ResourceFilter{
Resource: &inventory.Resource{Resource: &inventory.Resource_OsUpdateRun{OsUpdateRun: &inv_computev1.OSUpdateRunResource{}}},
Offset: req.GetOffset(),
Limit: req.GetPageSize(),
OrderBy: req.GetOrderBy(),
Filter: req.GetFilter(),
}
if err := validator.ValidateMessage(filter); err != nil {
zlog.InfraSec().InfraErr(err).Msg("failed to validate query params")
return nil, errors.Wrap(err)
}
invResp, err := is.InvClient.List(ctx, filter)
if err != nil {
zlog.InfraErr(err).Msg("Failed to list OS resources from inventory")
return nil, errors.Wrap(err)
}

osUpdateRunResources := []*computev1.OSUpdateRun{}
for _, invRes := range invResp.GetResources() {
osUpdateRunResource := fromInvOSUpdateRunResource(invRes.GetResource().GetOsUpdateRun())
osUpdateRunResources = append(osUpdateRunResources, osUpdateRunResource)
}

resp := &restv1.ListOSUpdateRunResponse{
OsUpdateRuns: osUpdateRunResources,
TotalElements: invResp.GetTotalElements(),
HasNext: invResp.GetHasNext(),
}
zlog.Debug().Msgf("Listed %s", resp)
return resp, nil
}

func (is *InventorygRPCServer) GetOSUpdateRun(_ context.Context, _ *restv1.GetOSUpdateRunRequest) (
func (is *InventorygRPCServer) GetOSUpdateRun(ctx context.Context, req *restv1.GetOSUpdateRunRequest) (
*computev1.OSUpdateRun, error,
) {
// TODO implement me
return nil, errors.Errorfc(codes.Unimplemented, "GetOSUpdateRun not implemented")
zlog.Debug().Msg("GetOSUpdateRunResource")

invResp, err := is.InvClient.Get(ctx, req.GetResourceId())
if err != nil {
zlog.InfraErr(err).Msg("Failed to get OS Update Run resource from inventory")
return nil, errors.Wrap(err)
}

invOSUpdateRunResource := invResp.GetResource().GetOsUpdateRun()
osUpdateRunResource := fromInvOSUpdateRunResource(invOSUpdateRunResource)

zlog.Debug().Msgf("Got %s", osUpdateRunResource)
return osUpdateRunResource, nil
}

func (is *InventorygRPCServer) DeleteOSUpdateRun(_ context.Context, _ *restv1.DeleteOSUpdateRunRequest) (
func (is *InventorygRPCServer) DeleteOSUpdateRun(ctx context.Context, req *restv1.DeleteOSUpdateRunRequest) (
*restv1.DeleteOSUpdateRunResponse, error,
) {
// TODO implement me
return nil, errors.Errorfc(codes.Unimplemented, "DeleteOSUpdateRun not implemented")
zlog.Debug().Msg("DeleteOSUpdateRunResource")

_, err := is.InvClient.Delete(ctx, req.GetResourceId())
if err != nil {
zlog.InfraErr(err).Msg("Failed to delete OS Update Run resource from inventory")
return nil, errors.Wrap(err)
}
zlog.Debug().Msgf("Deleted %s", req.GetResourceId())
return &restv1.DeleteOSUpdateRunResponse{}, nil
}
Loading
Loading