edge/pkg/storage/driver/rpc/server/share/update_attributes.go
William Petit 8e574c299b
All checks were successful
arcad/edge/pipeline/pr-master This commit looks good
feat(storage): rpc based implementation
2023-09-28 12:36:30 -06:00

38 lines
833 B
Go

package share
import (
"context"
"forge.cadoles.com/arcad/edge/pkg/app"
"forge.cadoles.com/arcad/edge/pkg/storage/share"
"github.com/pkg/errors"
)
type UpdateAttributesArgs struct {
Origin app.ID
ResourceID share.ResourceID
Attributes []*SerializableAttribute
}
type UpdateAttributesReply struct {
Resource *SerializableResource
}
func (s *Service) UpdateAttributes(ctx context.Context, args UpdateAttributesArgs, reply *UpdateAttributesReply) error {
attributes := make([]share.Attribute, len(args.Attributes))
for idx, attr := range args.Attributes {
attributes[idx] = attr
}
resource, err := s.store.UpdateAttributes(ctx, args.Origin, args.ResourceID, attributes...)
if err != nil {
return errors.WithStack(err)
}
*reply = UpdateAttributesReply{
Resource: FromResource(resource),
}
return nil
}