[#11] Add Network Snapshot
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
b69d22966f
commit
c988ff3c76
84 changed files with 2238 additions and 933 deletions
56
src/FrostFS.SDK.ClientV2/Tools/Object.cs
Normal file
56
src/FrostFS.SDK.ClientV2/Tools/Object.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2.Extensions;
|
||||
|
||||
public static class ObjectExtensions
|
||||
{
|
||||
public static ModelsV2.Object SetPayloadLength(this ModelsV2.Object obj, ulong length)
|
||||
{
|
||||
obj.Header.PayloadLength = length;
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static ModelsV2.Object AddAttribute(this ModelsV2.Object obj, string key, string value)
|
||||
{
|
||||
obj.AddAttribute(new ObjectAttribute(key, value));
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static ModelsV2.Object AddAttribute(this ModelsV2.Object obj, ObjectAttribute attribute)
|
||||
{
|
||||
obj.Header.Attributes.Add(attribute);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static ModelsV2.Object AddAttributes(this ModelsV2.Object obj, IEnumerable<ObjectAttribute> attributes)
|
||||
{
|
||||
obj.Header.Attributes.AddRange(attributes);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static ModelsV2.Object SetSplit(this ModelsV2.Object obj, Split split)
|
||||
{
|
||||
obj.Header.Split = split;
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static LinkObject AddChildren(this LinkObject linkObject, IEnumerable<ObjectId> objectIds)
|
||||
{
|
||||
linkObject.Header.Split!.Children.AddRange(objectIds);
|
||||
return linkObject;
|
||||
}
|
||||
|
||||
public static ModelsV2.Object CalculateObjectId(this ModelsV2.Object obj)
|
||||
{
|
||||
if (obj.Payload == null)
|
||||
throw new MissingFieldException("Payload cannot be null");
|
||||
|
||||
if (obj.Header == null)
|
||||
throw new MissingFieldException("Header cannot be null");
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue