William Petit
8e574c299b
All checks were successful
arcad/edge/pipeline/pr-master This commit looks good
38 lines
833 B
Go
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
|
|
}
|