[#26] All: Remove V2 from naming
Rename project, namespaces and class names Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
c406df1a78
commit
766f61a5f7
219 changed files with 219 additions and 974 deletions
12
src/FrostFS.SDK.Client/Mappers/Object/Object.cs
Normal file
12
src/FrostFS.SDK.Client/Mappers/Object/Object.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
namespace FrostFS.SDK.Client.Mappers.GRPC;
|
||||
|
||||
internal static class ObjectMapper
|
||||
{
|
||||
internal static FrostFsObject ToModel(this Object.Object obj)
|
||||
{
|
||||
return new FrostFsObject(obj.Header.ToModel())
|
||||
{
|
||||
ObjectId = FrostFsObjectId.FromHash(obj.ObjectId.Value.ToByteArray())
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
|
||||
using FrostFS.Object;
|
||||
|
||||
namespace FrostFS.SDK.Client.Mappers.GRPC;
|
||||
|
||||
public static class ObjectAttributeMapper
|
||||
{
|
||||
public static Header.Types.Attribute ToMessage(this FrostFsAttributePair attribute)
|
||||
{
|
||||
if (attribute is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
return new Header.Types.Attribute
|
||||
{
|
||||
Key = attribute.Key,
|
||||
Value = attribute.Value
|
||||
};
|
||||
}
|
||||
|
||||
public static FrostFsAttributePair ToModel(this Header.Types.Attribute attribute)
|
||||
{
|
||||
if (attribute is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attribute));
|
||||
}
|
||||
|
||||
return new FrostFsAttributePair(attribute.Key, attribute.Value);
|
||||
}
|
||||
}
|
34
src/FrostFS.SDK.Client/Mappers/Object/ObjectFilterMapper.cs
Normal file
34
src/FrostFS.SDK.Client/Mappers/Object/ObjectFilterMapper.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
|
||||
using FrostFS.Object;
|
||||
|
||||
namespace FrostFS.SDK.Client.Mappers.GRPC;
|
||||
|
||||
public static class ObjectFilterMapper
|
||||
{
|
||||
public static SearchRequest.Types.Body.Types.Filter ToMessage(this IObjectFilter filter)
|
||||
{
|
||||
if (filter is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filter));
|
||||
}
|
||||
|
||||
var objMatchTypeName = filter.MatchType switch
|
||||
{
|
||||
FrostFsMatchType.Unspecified => MatchType.Unspecified,
|
||||
FrostFsMatchType.Equals => MatchType.StringEqual,
|
||||
FrostFsMatchType.NotEquals => MatchType.StringNotEqual,
|
||||
FrostFsMatchType.KeyAbsent => MatchType.NotPresent,
|
||||
FrostFsMatchType.StartsWith => MatchType.CommonPrefix,
|
||||
|
||||
_ => throw new ArgumentException($"Unknown MatchType. Value: '{filter.MatchType}'.")
|
||||
};
|
||||
|
||||
return new SearchRequest.Types.Body.Types.Filter
|
||||
{
|
||||
MatchType = objMatchTypeName,
|
||||
Key = filter.Key,
|
||||
Value = filter.GetSerializedValue()
|
||||
};
|
||||
}
|
||||
}
|
55
src/FrostFS.SDK.Client/Mappers/Object/ObjectHeaderMapper.cs
Normal file
55
src/FrostFS.SDK.Client/Mappers/Object/ObjectHeaderMapper.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
using FrostFS.Object;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
|
||||
namespace FrostFS.SDK.Client.Mappers.GRPC;
|
||||
|
||||
public static class ObjectHeaderMapper
|
||||
{
|
||||
public static FrostFsObjectHeader ToModel(this Header header)
|
||||
{
|
||||
if (header is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(header));
|
||||
}
|
||||
|
||||
var objTypeName = header.ObjectType switch
|
||||
{
|
||||
ObjectType.Regular => FrostFsObjectType.Regular,
|
||||
ObjectType.Lock => FrostFsObjectType.Lock,
|
||||
ObjectType.Tombstone => FrostFsObjectType.Tombstone,
|
||||
_ => throw new ArgumentException($"Unknown ObjectType. Value: '{header.ObjectType}'.")
|
||||
};
|
||||
|
||||
FrostFsSplit? split = null;
|
||||
|
||||
if (header.Split != null)
|
||||
{
|
||||
var children = header.Split.Children.Count != 0 ? new ReadOnlyCollection<FrostFsObjectId>(
|
||||
header.Split.Children.Select(x => x.ToModel()).ToList()) : null;
|
||||
|
||||
split = new FrostFsSplit(new SplitId(header.Split.SplitId.ToUuid()),
|
||||
header.Split.Previous?.ToModel(),
|
||||
header.Split.Parent?.ToModel(),
|
||||
header.Split.ParentHeader?.ToModel(),
|
||||
null,
|
||||
children);
|
||||
}
|
||||
|
||||
var model = new FrostFsObjectHeader(
|
||||
new FrostFsContainerId(Base58.Encode(header.ContainerId.Value.ToByteArray())),
|
||||
objTypeName,
|
||||
header.Attributes.Select(attribute => attribute.ToModel()).ToArray(),
|
||||
split,
|
||||
header.OwnerId.ToModel(),
|
||||
header.Version.ToModel())
|
||||
{
|
||||
PayloadLength = header.PayloadLength,
|
||||
};
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
33
src/FrostFS.SDK.Client/Mappers/Object/ObjectId.cs
Normal file
33
src/FrostFS.SDK.Client/Mappers/Object/ObjectId.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
|
||||
using FrostFS.Refs;
|
||||
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.Client.Mappers.GRPC;
|
||||
|
||||
public static class ObjectIdMapper
|
||||
{
|
||||
public static ObjectID ToMessage(this FrostFsObjectId objectId)
|
||||
{
|
||||
if (objectId is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(objectId));
|
||||
}
|
||||
|
||||
return new ObjectID
|
||||
{
|
||||
Value = ByteString.CopyFrom(objectId.ToHash())
|
||||
};
|
||||
}
|
||||
|
||||
public static FrostFsObjectId ToModel(this ObjectID objectId)
|
||||
{
|
||||
if (objectId is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(objectId));
|
||||
}
|
||||
|
||||
return FrostFsObjectId.FromHash(objectId.Value.ToByteArray());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue