diff --git a/src/FrostFS.SDK.ClientV2/Cache.cs b/src/FrostFS.SDK.ClientV2/Cache.cs index a41c8b9..19ec83b 100644 --- a/src/FrostFS.SDK.ClientV2/Cache.cs +++ b/src/FrostFS.SDK.ClientV2/Cache.cs @@ -1,6 +1,4 @@ - - -using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Caching.Memory; namespace FrostFS.SDK.ClientV2 { diff --git a/src/FrostFS.SDK.ClientV2/Client.cs b/src/FrostFS.SDK.ClientV2/Client.cs index b8d03b2..436a85b 100644 --- a/src/FrostFS.SDK.ClientV2/Client.cs +++ b/src/FrostFS.SDK.ClientV2/Client.cs @@ -1,21 +1,21 @@ -using FrostFS.Container; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; + +using FrostFS.Container; using FrostFS.Netmap; using FrostFS.Object; using FrostFS.SDK.ClientV2.Interfaces; using FrostFS.SDK.ClientV2.Parameters; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; -using FrostFS.SDK.ModelsV2.Netmap; using FrostFS.Session; + using Grpc.Core; using Grpc.Core.Interceptors; using Grpc.Net.Client; + using Microsoft.Extensions.Options; -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Version = FrostFS.SDK.ModelsV2.Version; namespace FrostFS.SDK.ClientV2; @@ -77,7 +77,7 @@ public class Client : IFrostFSClient key: ecdsaKey, owner: OwnerId.FromKey(ecdsaKey), channel: InitGrpcChannel(settings.Value.Host, channelOptions), - version: new Version(2, 13)); + version: new FrostFsVersion(2, 13)); ContainerServiceClient = containerService; NetmapServiceClient = netmapService; @@ -98,7 +98,7 @@ public class Client : IFrostFSClient key: null, owner: null, channel: channel, - version: new Version(2, 13)); + version: new FrostFsVersion(2, 13)); // TODO: define timeout logic // CheckFrostFsVersionSupport(new Context { Timeout = TimeSpan.FromSeconds(20) }); @@ -119,7 +119,7 @@ public class Client : IFrostFSClient key: ecdsaKey, owner: OwnerId.FromKey(ecdsaKey), channel: channel, - version: new Version(2, 13)); + version: new FrostFsVersion(2, 13)); // TODO: define timeout logic CheckFrostFsVersionSupport(new Context { Timeout = TimeSpan.FromSeconds(20)}); @@ -141,7 +141,7 @@ public class Client : IFrostFSClient } #region ContainerImplementation - public Task GetContainerAsync(PrmContainerGet args) + public Task GetContainerAsync(PrmContainerGet args) { var service = GetContainerService(args); return service.GetContainerAsync(args); @@ -175,7 +175,7 @@ public class Client : IFrostFSClient return service.GetNetmapSnapshotAsync(args); } - public Task GetNodeInfoAsync(PrmNodeInfo? args) + public Task GetNodeInfoAsync(PrmNodeInfo? args) { args ??= new PrmNodeInfo(); var service = GetNetmapService(args); @@ -229,12 +229,12 @@ public class Client : IFrostFSClient #endregion #region SessionImplementation - public async Task CreateSessionAsync(PrmSessionCreate args) + public async Task CreateSessionAsync(PrmSessionCreate args) { var session = await CreateSessionInternalAsync(args); var token = session.Serialize(); - return new ModelsV2.SessionToken(token); + return new FrostFsSessionToken(token); } internal Task CreateSessionInternalAsync(PrmSessionCreate args) diff --git a/src/FrostFS.SDK.ClientV2/CllientKey.cs b/src/FrostFS.SDK.ClientV2/CllientKey.cs index e415a98..5b10485 100644 --- a/src/FrostFS.SDK.ClientV2/CllientKey.cs +++ b/src/FrostFS.SDK.ClientV2/CllientKey.cs @@ -1,6 +1,8 @@ -using FrostFS.SDK.Cryptography; +using System.Security.Cryptography; + +using FrostFS.SDK.Cryptography; + using Google.Protobuf; -using System.Security.Cryptography; namespace FrostFS.SDK.ClientV2 { diff --git a/src/FrostFS.SDK.ClientV2/Exceptions/ResponseException.cs b/src/FrostFS.SDK.ClientV2/Exceptions/ResponseException.cs index d72f173..ad3c63e 100644 --- a/src/FrostFS.SDK.ClientV2/Exceptions/ResponseException.cs +++ b/src/FrostFS.SDK.ClientV2/Exceptions/ResponseException.cs @@ -1,9 +1,8 @@ -using FrostFS.SDK.ModelsV2; using System; namespace FrostFS.SDK.ClientV2; -public class ResponseException(ResponseStatus status) : Exception() +public class ResponseException(FrostFsResponseStatus status) : Exception() { - public ResponseStatus Status { get; set; } = status; + public FrostFsResponseStatus Status { get; set; } = status; } \ No newline at end of file diff --git a/src/FrostFS.SDK.ClientV2/Interceptors/MetricsInterceptor.cs b/src/FrostFS.SDK.ClientV2/Interceptors/MetricsInterceptor.cs index c395629..dc439f9 100644 --- a/src/FrostFS.SDK.ClientV2/Interceptors/MetricsInterceptor.cs +++ b/src/FrostFS.SDK.ClientV2/Interceptors/MetricsInterceptor.cs @@ -1,7 +1,7 @@ using System; using System.Diagnostics; using System.Threading.Tasks; -using FrostFS.SDK.ModelsV2; + using Grpc.Core; using Grpc.Core.Interceptors; diff --git a/src/FrostFS.SDK.ClientV2/Interfaces/IFrostFSClient.cs b/src/FrostFS.SDK.ClientV2/Interfaces/IFrostFSClient.cs index 6b6aa5e..e78fa4e 100644 --- a/src/FrostFS.SDK.ClientV2/Interfaces/IFrostFSClient.cs +++ b/src/FrostFS.SDK.ClientV2/Interfaces/IFrostFSClient.cs @@ -1,9 +1,8 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; + using FrostFS.SDK.ClientV2.Parameters; -using FrostFS.SDK.ModelsV2; -using FrostFS.SDK.ModelsV2.Netmap; namespace FrostFS.SDK.ClientV2.Interfaces; public interface IFrostFSClient : IDisposable @@ -11,17 +10,17 @@ public interface IFrostFSClient : IDisposable #region Network Task GetNetmapSnapshotAsync(PrmNetmapSnapshot? args = null); - Task GetNodeInfoAsync(PrmNodeInfo? args = null); + Task GetNodeInfoAsync(PrmNodeInfo? args = null); Task GetNetworkSettingsAsync(PrmNetworkSettings? args = null); #endregion #region Session - Task CreateSessionAsync(PrmSessionCreate args); + Task CreateSessionAsync(PrmSessionCreate args); #endregion #region Container - Task GetContainerAsync(PrmContainerGet args); + Task GetContainerAsync(PrmContainerGet args); IAsyncEnumerable ListContainersAsync(PrmContainerGetAll? args = null); diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Container.cs b/src/FrostFS.SDK.ClientV2/Mappers/Container.cs index 83bfb32..cb47c39 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Container.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Container.cs @@ -1,16 +1,15 @@ using System; -using Google.Protobuf; - using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2.Enums; + +using Google.Protobuf; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; public static class ContainerMapper { - public static Container.Container ToMessage(this ModelsV2.Container container) + public static Container.Container ToMessage(this FrostFsContainer container) { return new Container.Container { @@ -20,14 +19,14 @@ public static class ContainerMapper }; } - public static ModelsV2.Container ToModel(this Container.Container container) + public static FrostFsContainer ToModel(this Container.Container container) { if (!Enum.IsDefined(typeof(BasicAcl),(int)container.BasicAcl)) throw new ArgumentException($"Unknown BasicACL rule. Value: '{container.BasicAcl}'."); BasicAcl acl = (BasicAcl)container.BasicAcl; - return new ModelsV2.Container(acl, container.PlacementPolicy.ToModel()) + return new FrostFsContainer(acl, container.PlacementPolicy.ToModel()) { Nonce = container.Nonce.ToUuid(), Version = container.Version.ToModel() diff --git a/src/FrostFS.SDK.ClientV2/Mappers/ContainerId.cs b/src/FrostFS.SDK.ClientV2/Mappers/ContainerId.cs index 65199ca..6c5755e 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/ContainerId.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/ContainerId.cs @@ -1,9 +1,11 @@ +using System; + using FrostFS.Refs; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; + using Google.Protobuf; + using Microsoft.Extensions.Caching.Memory; -using System; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/MetaHeader.cs b/src/FrostFS.SDK.ClientV2/Mappers/MetaHeader.cs index 360ddd4..6b4901c 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/MetaHeader.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/MetaHeader.cs @@ -1,4 +1,3 @@ -using FrostFS.SDK.ModelsV2; using FrostFS.Session; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Netmap.cs b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Netmap.cs index 7d44809..3afca8c 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Netmap.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Netmap.cs @@ -1,6 +1,6 @@ using System.Linq; + using FrostFS.Netmap; -using FrostFS.SDK.ModelsV2.Netmap; namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/NodeInfo.cs b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/NodeInfo.cs index da87dfd..988df0d 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/NodeInfo.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/NodeInfo.cs @@ -1,30 +1,29 @@ using System; using System.Linq; + using FrostFS.Netmap; -using FrostFS.SDK.ModelsV2.Enums; -using NodeInfo = FrostFS.SDK.ModelsV2.Netmap.NodeInfo; namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; public static class NodeInfoMapper { - public static NodeInfo ToModel(this LocalNodeInfoResponse.Types.Body node) + public static FrostFsNodeInfo ToModel(this LocalNodeInfoResponse.Types.Body node) { return node.NodeInfo.ToModel(node.Version); } - public static NodeInfo ToModel(this FrostFS.Netmap.NodeInfo nodeInfo, Refs.Version version) + public static FrostFsNodeInfo ToModel(this NodeInfo nodeInfo, Refs.Version version) { NodeState state = nodeInfo.State switch { - FrostFS.Netmap.NodeInfo.Types.State.Unspecified => NodeState.Unspecified, - FrostFS.Netmap.NodeInfo.Types.State.Online => NodeState.Online, - FrostFS.Netmap.NodeInfo.Types.State.Offline => NodeState.Offline, - FrostFS.Netmap.NodeInfo.Types.State.Maintenance => NodeState.Maintenance, + NodeInfo.Types.State.Unspecified => NodeState.Unspecified, + NodeInfo.Types.State.Online => NodeState.Online, + NodeInfo.Types.State.Offline => NodeState.Offline, + NodeInfo.Types.State.Maintenance => NodeState.Maintenance, _ => throw new ArgumentException($"Unknown NodeState. Value: '{nodeInfo.State}'.") }; - return new NodeInfo( + return new FrostFsNodeInfo( version: version.ToModel(), state: state, addresses: [.. nodeInfo.Addresses], diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/PlacementPolicy.cs b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/PlacementPolicy.cs index 47b51fa..2fef0c4 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/PlacementPolicy.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/PlacementPolicy.cs @@ -1,11 +1,12 @@ using System.Linq; + using FrostFS.Netmap; namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; public static class PlacementPolicyMapper { - public static PlacementPolicy ToMessage(this ModelsV2.Netmap.PlacementPolicy placementPolicy) + public static PlacementPolicy ToMessage(this FrostFsPlacementPolicy placementPolicy) { var pp = new PlacementPolicy { @@ -23,9 +24,9 @@ public static class PlacementPolicyMapper return pp; } - public static ModelsV2.Netmap.PlacementPolicy ToModel(this PlacementPolicy placementPolicy) + public static FrostFsPlacementPolicy ToModel(this PlacementPolicy placementPolicy) { - return new ModelsV2.Netmap.PlacementPolicy( + return new FrostFsPlacementPolicy( placementPolicy.Unique, placementPolicy.Replicas.Select(replica => replica.ToModel()).ToArray() ); diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Replica.cs b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Replica.cs index 215a127..60883e0 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Replica.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Netmap/Replica.cs @@ -4,7 +4,7 @@ namespace FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; public static class ReplicaMapper { - public static Replica ToMessage(this ModelsV2.Netmap.Replica replica) + public static Replica ToMessage(this FrostFsReplica replica) { return new Replica { @@ -13,8 +13,8 @@ public static class ReplicaMapper }; } - public static ModelsV2.Netmap.Replica ToModel(this Replica replica) + public static FrostFsReplica ToModel(this Replica replica) { - return new ModelsV2.Netmap.Replica((int)replica.Count, replica.Selector); + return new FrostFsReplica((int)replica.Count, replica.Selector); } } \ No newline at end of file diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Object/Object.cs b/src/FrostFS.SDK.ClientV2/Mappers/Object/Object.cs index bda31fe..f9498d6 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Object/Object.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Object/Object.cs @@ -1,5 +1,3 @@ -using FrostFS.SDK.ModelsV2; - namespace FrostFS.SDK.ClientV2.Mappers.GRPC; internal static class ObjectMapper diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectAttributeMapper.cs b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectAttributeMapper.cs index 7528152..dec5ed5 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectAttributeMapper.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectAttributeMapper.cs @@ -1,5 +1,4 @@ using FrostFS.Object; -using FrostFS.SDK.ModelsV2; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectFilterMapper.cs b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectFilterMapper.cs index 8353f5f..e59f51b 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectFilterMapper.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectFilterMapper.cs @@ -1,7 +1,6 @@ using System; + using FrostFS.Object; -using FrostFS.SDK.ModelsV2; -using MatchType = FrostFS.Object.MatchType; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; @@ -11,11 +10,11 @@ public static class ObjectFilterMapper { var objMatchTypeName = filter.MatchType switch { - ModelsV2.Enums.ObjectMatchType.Unspecified => MatchType.Unspecified, - ModelsV2.Enums.ObjectMatchType.Equals => MatchType.StringEqual, - ModelsV2.Enums.ObjectMatchType.NotEquals => MatchType.StringNotEqual, - ModelsV2.Enums.ObjectMatchType.KeyAbsent => MatchType.NotPresent, - ModelsV2.Enums.ObjectMatchType.StartsWith => MatchType.CommonPrefix, + FrostFsObjectMatchType.Unspecified => MatchType.Unspecified, + FrostFsObjectMatchType.Equals => MatchType.StringEqual, + FrostFsObjectMatchType.NotEquals => MatchType.StringNotEqual, + FrostFsObjectMatchType.KeyAbsent => MatchType.NotPresent, + FrostFsObjectMatchType.StartsWith => MatchType.CommonPrefix, _ => throw new ArgumentException($"Unknown MatchType. Value: '{filter.MatchType}'.") }; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectHeaderMapper.cs b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectHeaderMapper.cs index e9c07f7..fd3a210 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectHeaderMapper.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectHeaderMapper.cs @@ -1,10 +1,8 @@ using System; using System.Linq; + using FrostFS.Object; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; -using Google.Protobuf; -using ObjectType = FrostFS.Object.ObjectType; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; @@ -14,9 +12,9 @@ public static class ObjectHeaderMapper { var objTypeName = header.ObjectType switch { - ModelsV2.Enums.ObjectType.Regular => ObjectType.Regular, - ModelsV2.Enums.ObjectType.Lock => ObjectType.Lock, - ModelsV2.Enums.ObjectType.Tombstone => ObjectType.Tombstone, + FrostFsObjectType.Regular => ObjectType.Regular, + FrostFsObjectType.Lock => ObjectType.Lock, + FrostFsObjectType.Tombstone => ObjectType.Tombstone, _ => throw new ArgumentException($"Unknown ObjectType. Value: '{header.ObjectType}'.") }; @@ -50,9 +48,9 @@ public static class ObjectHeaderMapper { var objTypeName = header.ObjectType switch { - ObjectType.Regular => ModelsV2.Enums.ObjectType.Regular, - ObjectType.Lock => ModelsV2.Enums.ObjectType.Lock, - ObjectType.Tombstone => ModelsV2.Enums.ObjectType.Tombstone, + ObjectType.Regular => FrostFsObjectType.Regular, + ObjectType.Lock => FrostFsObjectType.Lock, + ObjectType.Tombstone => FrostFsObjectType.Tombstone, _ => throw new ArgumentException($"Unknown ObjectType. Value: '{header.ObjectType}'.") }; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectId.cs b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectId.cs index c9afe0c..6dbf43b 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectId.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Object/ObjectId.cs @@ -1,5 +1,5 @@ using FrostFS.Refs; -using FrostFS.SDK.ModelsV2; + using Google.Protobuf; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/OwnerId.cs b/src/FrostFS.SDK.ClientV2/Mappers/OwnerId.cs index de8db49..8a68ddb 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/OwnerId.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/OwnerId.cs @@ -1,9 +1,11 @@ +using System; + using FrostFS.Refs; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; + using Google.Protobuf; + using Microsoft.Extensions.Caching.Memory; -using System; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; diff --git a/src/FrostFS.SDK.ClientV2/Mappers/SignatureMapper.cs b/src/FrostFS.SDK.ClientV2/Mappers/SignatureMapper.cs index 4343d4d..0b280cf 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/SignatureMapper.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/SignatureMapper.cs @@ -1,12 +1,12 @@ using System; -using FrostFS.SDK.ModelsV2; + using Google.Protobuf; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; public static class SignatureMapper { - public static Refs.Signature ToMessage(this Signature signature) + public static Refs.Signature ToMessage(this FrostFsSignature signature) { var scheme = signature.Scheme switch { diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Status.cs b/src/FrostFS.SDK.ClientV2/Mappers/Status.cs index d489239..d3555ac 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Status.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Status.cs @@ -1,19 +1,18 @@ using System; -using FrostFS.SDK.ModelsV2.Enums; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; public static class StatusMapper { - public static ModelsV2.ResponseStatus ToModel(this Status.Status status) + public static FrostFsResponseStatus ToModel(this Status.Status status) { if (status is null) - return new ModelsV2.ResponseStatus(StatusCode.Success); + return new FrostFsResponseStatus(FrostFsStatusCode.Success); + + var codeName = Enum.GetName(typeof(FrostFsStatusCode), status.Code); - var codeName = Enum.GetName(typeof(StatusCode), status.Code); - return codeName is null ? throw new ArgumentException($"Unknown StatusCode. Value: '{status.Code}'.") - : new ModelsV2.ResponseStatus((StatusCode)Enum.Parse(typeof(StatusCode), codeName), status.Message); + : new FrostFsResponseStatus((FrostFsStatusCode)status.Code, status.Message); } } \ No newline at end of file diff --git a/src/FrostFS.SDK.ClientV2/Mappers/Version.cs b/src/FrostFS.SDK.ClientV2/Mappers/Version.cs index df2066c..f17509a 100644 --- a/src/FrostFS.SDK.ClientV2/Mappers/Version.cs +++ b/src/FrostFS.SDK.ClientV2/Mappers/Version.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Threading; -using Version = FrostFS.Refs.Version; + +using FrostFS.Refs; namespace FrostFS.SDK.ClientV2.Mappers.GRPC; @@ -10,7 +11,7 @@ public static class VersionMapper private static readonly Hashtable _cacheModels = []; private static SpinLock _spinlock = new(); - public static Version ToMessage(this ModelsV2.Version model) + public static Version ToMessage(this FrostFsVersion model) { var key = model.Major << 16 + model.Minor; @@ -31,7 +32,7 @@ public static class VersionMapper } catch (System.ArgumentException) { - // ignore attempt to add duplicate error. + // ignore attempt to add duplicate } finally { @@ -43,7 +44,7 @@ public static class VersionMapper return (Version)_cacheMessages[key]; } - public static ModelsV2.Version ToModel(this Version message) + public static FrostFsVersion ToModel(this Version message) { var key = (int)message.Major << 16 + (int)message.Minor; @@ -53,14 +54,14 @@ public static class VersionMapper try { _spinlock.Enter(ref lockTaken); - var model = new ModelsV2.Version((int)message.Major, (int)message.Minor); + var model = new FrostFsVersion((int)message.Major, (int)message.Minor); _cacheModels.Add(key, model); return model; } catch (System.ArgumentException) { - // ignore attempt to add duplicate error. + // ignore attempt to add duplicate } finally { @@ -69,6 +70,6 @@ public static class VersionMapper } } - return (ModelsV2.Version)_cacheModels[key]; + return (FrostFsVersion)_cacheModels[key]; } } \ No newline at end of file diff --git a/src/FrostFS.SDK.ClientV2/Parameters/Context.cs b/src/FrostFS.SDK.ClientV2/Parameters/Context.cs index ca3728a..0bac810 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/Context.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/Context.cs @@ -2,9 +2,11 @@ using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Threading; -using FrostFS.SDK.ModelsV2; + using FrostFS.SDK.Cryptography; + using Google.Protobuf; + using Grpc.Core.Interceptors; namespace FrostFS.SDK.ClientV2; @@ -13,13 +15,13 @@ public class Context() { private List? interceptors; - private ByteString publicKeyCache; + private ByteString? publicKeyCache; public ECDsa Key { get; set; } public OwnerId OwnerId { get; set; } - public ModelsV2.Version Version { get; set; } + public FrostFsVersion Version { get; set; } public CancellationToken CancellationToken { get; set; } = default; @@ -35,16 +37,13 @@ public class Context() set { this.interceptors = value; } } - public ByteString PublicKeyCache + public ByteString? GetPublicKeyCache() { - get + if (publicKeyCache == null && Key != null) { - if (publicKeyCache == null) - { - publicKeyCache = ByteString.CopyFrom(Key.PublicKey()); - } - - return publicKeyCache; + publicKeyCache = ByteString.CopyFrom(Key.PublicKey()); } + + return publicKeyCache; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/Credentials.cs b/src/FrostFS.SDK.ClientV2/Parameters/Credentials.cs index a4915c3..1c23547 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/Credentials.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/Credentials.cs @@ -1,5 +1,4 @@ -using FrostFS.SDK.ModelsV2; -using System.Security.Cryptography; +using System.Security.Cryptography; namespace FrostFS.SDK.ClientV2.Parameters; diff --git a/src/FrostFS.SDK.ClientV2/Parameters/ISessionToken.cs b/src/FrostFS.SDK.ClientV2/Parameters/ISessionToken.cs index c5ac1da..7127b87 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/ISessionToken.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/ISessionToken.cs @@ -1,5 +1,3 @@ -using FrostFS.SDK.ModelsV2; - namespace FrostFS.SDK.ClientV2.Parameters; public interface ISessionToken @@ -10,5 +8,5 @@ public interface ISessionToken /// member. The session has a limited validity period, and applies to a strictly defined set of operations. /// /// Instance of the session obtained from the server - SessionToken? SessionToken { get; set; } + FrostFsSessionToken? SessionToken { get; set; } } \ No newline at end of file diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerCreate.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerCreate.cs index a2a3315..c364071 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerCreate.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerCreate.cs @@ -1,11 +1,8 @@ -using FrostFS.SDK.ModelsV2; -using System.Security.Cryptography; +namespace FrostFS.SDK.ClientV2.Parameters; -namespace FrostFS.SDK.ClientV2.Parameters; - -public sealed class PrmContainerCreate(ModelsV2.Container container) : PrmBase, ISessionToken +public sealed class PrmContainerCreate(FrostFsContainer container) : PrmBase, ISessionToken { - public ModelsV2.Container Container { get; set; } = container; + public FrostFsContainer Container { get; set; } = container; /// /// Since the container becomes available with some delay, it needs to poll the container status @@ -16,5 +13,5 @@ public sealed class PrmContainerCreate(ModelsV2.Container container) : PrmBase, /// /// Blank session token /// - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerDelete.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerDelete.cs index 63308aa..0daed30 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerDelete.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerDelete.cs @@ -1,6 +1,4 @@ -using FrostFS.SDK.ModelsV2; - -namespace FrostFS.SDK.ClientV2.Parameters; +namespace FrostFS.SDK.ClientV2.Parameters; public sealed class PrmContainerDelete(ContainerId containerId) : PrmBase, ISessionToken { @@ -12,5 +10,5 @@ public sealed class PrmContainerDelete(ContainerId containerId) : PrmBase, ISess /// Rules for polling the result public PrmWait? WaitParams { get; set; } - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerGet.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerGet.cs index cebdaca..0b6fea0 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerGet.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmContainerGet.cs @@ -1,6 +1,4 @@ -using FrostFS.SDK.ModelsV2; - -namespace FrostFS.SDK.ClientV2.Parameters; +namespace FrostFS.SDK.ClientV2.Parameters; public sealed class PrmContainerGet(ContainerId containerId) : PrmBase { diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectDelete.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectDelete.cs index 3195bb8..76ca621 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectDelete.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectDelete.cs @@ -1,6 +1,4 @@ -using FrostFS.SDK.ModelsV2; - -namespace FrostFS.SDK.ClientV2.Parameters; +namespace FrostFS.SDK.ClientV2.Parameters; public sealed class PrmObjectDelete(ContainerId containerId, ObjectId objectId) : PrmBase, ISessionToken { @@ -9,5 +7,5 @@ public sealed class PrmObjectDelete(ContainerId containerId, ObjectId objectId) public ObjectId ObjectId { get; set; } = objectId; /// - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectGet.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectGet.cs index 07e717f..5c57133 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectGet.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectGet.cs @@ -1,6 +1,4 @@ -using FrostFS.SDK.ModelsV2; - -namespace FrostFS.SDK.ClientV2.Parameters; +namespace FrostFS.SDK.ClientV2.Parameters; public sealed class PrmObjectGet(ContainerId containerId, ObjectId objectId) : PrmBase, ISessionToken { @@ -9,5 +7,5 @@ public sealed class PrmObjectGet(ContainerId containerId, ObjectId objectId) : P public ObjectId ObjectId { get; set; } = objectId; /// - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectHeadGet.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectHeadGet.cs index f5a9b77..111df97 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectHeadGet.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectHeadGet.cs @@ -1,6 +1,4 @@ -using FrostFS.SDK.ModelsV2; - -namespace FrostFS.SDK.ClientV2.Parameters; +namespace FrostFS.SDK.ClientV2.Parameters; public sealed class PrmObjectHeadGet(ContainerId containerId, ObjectId objectId) : PrmBase, ISessionToken { @@ -9,5 +7,5 @@ public sealed class PrmObjectHeadGet(ContainerId containerId, ObjectId objectId) public ObjectId ObjectId { get; set; } = objectId; /// - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs index e2c7a51..253e014 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectPut.cs @@ -1,5 +1,4 @@ using System.IO; -using FrostFS.SDK.ModelsV2; namespace FrostFS.SDK.ClientV2.Parameters; @@ -37,7 +36,7 @@ public sealed class PrmObjectPut : PrmBase, ISessionToken public byte[]? CustomBuffer { get; set; } /// - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } internal int MaxObjectSizeCache { get; set; } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectSearch.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectSearch.cs index 778b4a0..e20e685 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectSearch.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmObjectSearch.cs @@ -1,5 +1,5 @@ -using FrostFS.SDK.ModelsV2; -using System.Collections.Generic; +using System.Collections.Generic; + namespace FrostFS.SDK.ClientV2.Parameters; public sealed class PrmObjectSearch(ContainerId containerId, params IObjectFilter[] filters) : PrmBase, ISessionToken @@ -17,5 +17,5 @@ public sealed class PrmObjectSearch(ContainerId containerId, params IObjectFilte public IEnumerable Filters { get; set; } = filters; /// - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmSingleObjectPut.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmSingleObjectPut.cs index fc22bf7..ac49964 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmSingleObjectPut.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmSingleObjectPut.cs @@ -1,11 +1,9 @@ -using FrostFS.SDK.ModelsV2; - -namespace FrostFS.SDK.ClientV2.Parameters; +namespace FrostFS.SDK.ClientV2.Parameters; public sealed class PrmSingleObjectPut(FrostFsObject frostFsObject) : PrmBase, ISessionToken { public FrostFsObject FrostFsObject { get; set; } = frostFsObject; /// - public SessionToken? SessionToken { get; set; } + public FrostFsSessionToken? SessionToken { get; set; } } diff --git a/src/FrostFS.SDK.ClientV2/Parameters/PrmWait.cs b/src/FrostFS.SDK.ClientV2/Parameters/PrmWait.cs index 86e32d7..d11c5cc 100644 --- a/src/FrostFS.SDK.ClientV2/Parameters/PrmWait.cs +++ b/src/FrostFS.SDK.ClientV2/Parameters/PrmWait.cs @@ -1,4 +1,5 @@ using System; + namespace FrostFS.SDK.ClientV2.Parameters; public class PrmWait(TimeSpan timeout, TimeSpan pollInterval) diff --git a/src/FrostFS.SDK.ClientV2/Services/ContainerServiceProvider.cs b/src/FrostFS.SDK.ClientV2/Services/ContainerServiceProvider.cs index cac64dd..997d5d8 100644 --- a/src/FrostFS.SDK.ClientV2/Services/ContainerServiceProvider.cs +++ b/src/FrostFS.SDK.ClientV2/Services/ContainerServiceProvider.cs @@ -7,7 +7,6 @@ using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; using FrostFS.Container; using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; using FrostFS.SDK.ClientV2.Parameters; using FrostFS.Refs; using FrostFS.Session; @@ -23,7 +22,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient return await sessions.GetOrCreateSession(args, ctx); } - internal async Task GetContainerAsync(PrmContainerGet args) + internal async Task GetContainerAsync(PrmContainerGet args) { GetRequest request = GetContainerRequest(args.ContainerId.ToMessage(), args.XHeaders, args.Context!); @@ -40,9 +39,9 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient var request = new ListRequest { - Body = new ListRequest.Types.Body + Body = new () { - OwnerId = ctx.OwnerId.ToMessage() + OwnerId = ctx.OwnerId.ToMessage() } }; @@ -81,7 +80,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient null, ContainerSessionContext.Types.Verb.Put, ctx.Key, - ctx.PublicKeyCache); + ctx.GetPublicKeyCache()); request.AddMetaHeader(args.XHeaders, sessionToken); @@ -114,7 +113,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient request.Body.ContainerId, ContainerSessionContext.Types.Verb.Delete, ctx.Key, - ctx.PublicKeyCache); + ctx.GetPublicKeyCache()); request.AddMetaHeader(args.XHeaders, sessionToken); @@ -191,7 +190,7 @@ internal class ContainerServiceProvider(ContainerService.ContainerServiceClient if (DateTime.UtcNow >= deadLine) throw new TimeoutException(); - if (ex.Status.Code != ModelsV2.Enums.StatusCode.ContainerNotFound) + if (ex.Status.Code != FrostFsStatusCode.ContainerNotFound) throw; if (expect == WaitExpects.Removed) diff --git a/src/FrostFS.SDK.ClientV2/Services/NetmapServiceProvider.cs b/src/FrostFS.SDK.ClientV2/Services/NetmapServiceProvider.cs index 60c7e1f..43e2976 100644 --- a/src/FrostFS.SDK.ClientV2/Services/NetmapServiceProvider.cs +++ b/src/FrostFS.SDK.ClientV2/Services/NetmapServiceProvider.cs @@ -1,14 +1,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; + using FrostFS.Netmap; using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; -using NodeInfo = FrostFS.SDK.ModelsV2.Netmap.NodeInfo; - -using FrostFS.SDK.ModelsV2.Netmap; -using static FrostFS.Netmap.NetworkConfig.Types; using FrostFS.SDK.ClientV2.Parameters; +using static FrostFS.Netmap.NetworkConfig.Types; + namespace FrostFS.SDK.ClientV2; internal class NetmapServiceProvider : ContextAccessor @@ -40,7 +39,7 @@ internal class NetmapServiceProvider : ContextAccessor return settings; } - internal async Task GetLocalNodeInfoAsync(PrmNodeInfo args) + internal async Task GetLocalNodeInfoAsync(PrmNodeInfo args) { var ctx = args.Context!; var request = new LocalNodeInfoRequest diff --git a/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs b/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs index 95106b7..bece8b1 100644 --- a/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs +++ b/src/FrostFS.SDK.ClientV2/Services/ObjectServiceProvider.cs @@ -1,19 +1,18 @@ using System; +using System.Buffers; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Google.Protobuf; - using FrostFS.Object; using FrostFS.Refs; +using FrostFS.SDK.ClientV2.Extensions; using FrostFS.SDK.ClientV2.Mappers.GRPC; +using FrostFS.SDK.ClientV2.Parameters; using FrostFS.SDK.Cryptography; using FrostFS.Session; -using FrostFS.SDK.ModelsV2; -using FrostFS.SDK.ClientV2.Extensions; -using FrostFS.SDK.ClientV2.Parameters; -using System.Buffers; + +using Google.Protobuf; namespace FrostFS.SDK.ClientV2; @@ -210,7 +209,7 @@ internal class ObjectServiceProvider(ObjectService.ObjectServiceClient client, C var ctx = args.Context!; var tokenRaw = await GetOrCreateSession(args, ctx); - var token = new ModelsV2.SessionToken(tokenRaw.Serialize()); + var token = new FrostFsSessionToken(tokenRaw.Serialize()); args.SessionToken = token; diff --git a/src/FrostFS.SDK.ClientV2/Services/SessionServiceProvider.cs b/src/FrostFS.SDK.ClientV2/Services/SessionServiceProvider.cs index 104fa4c..eba29a3 100644 --- a/src/FrostFS.SDK.ClientV2/Services/SessionServiceProvider.cs +++ b/src/FrostFS.SDK.ClientV2/Services/SessionServiceProvider.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; + using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.SDK.ClientV2.Parameters; using FrostFS.Session; diff --git a/src/FrostFS.SDK.ClientV2/Services/Shared/ContextAccessor.cs b/src/FrostFS.SDK.ClientV2/Services/Shared/ContextAccessor.cs index 75edcc6..05797de 100644 --- a/src/FrostFS.SDK.ClientV2/Services/Shared/ContextAccessor.cs +++ b/src/FrostFS.SDK.ClientV2/Services/Shared/ContextAccessor.cs @@ -4,5 +4,3 @@ internal class ContextAccessor(ClientEnvironment context) { protected ClientEnvironment Context { get; set; } = context; } - - diff --git a/src/FrostFS.SDK.ClientV2/Services/Shared/SessionProvider.cs b/src/FrostFS.SDK.ClientV2/Services/Shared/SessionProvider.cs index ccfec71..abbaa66 100644 --- a/src/FrostFS.SDK.ClientV2/Services/Shared/SessionProvider.cs +++ b/src/FrostFS.SDK.ClientV2/Services/Shared/SessionProvider.cs @@ -1,5 +1,5 @@ - using System.Threading.Tasks; + using FrostFS.SDK.ClientV2.Parameters; namespace FrostFS.SDK.ClientV2; diff --git a/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs b/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs index 08d0827..2e4989f 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/ClientEnvironment.cs @@ -1,12 +1,12 @@ -using FrostFS.SDK.ModelsV2; -using Grpc.Net.Client; using System; -using System.Security.Cryptography; using System.Buffers; +using System.Security.Cryptography; + +using Grpc.Net.Client; namespace FrostFS.SDK.ClientV2; -public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcChannel channel, ModelsV2.Version version) : IDisposable +public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcChannel channel, FrostFsVersion version) : IDisposable { private ArrayPool _arrayPool; @@ -14,7 +14,7 @@ public class ClientEnvironment(Client client, ECDsa? key, OwnerId? owner, GrpcCh internal GrpcChannel Channel { get; private set; } = channel; - internal ModelsV2.Version Version { get; } = version; + internal FrostFsVersion Version { get; } = version; internal NetworkSettings? NetworkSettings { get; set; } diff --git a/src/FrostFS.SDK.ClientV2/Tools/Object.cs b/src/FrostFS.SDK.ClientV2/Tools/Object.cs index 0dd931e..109b22d 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/Object.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/Object.cs @@ -1,7 +1,5 @@ - using System; using System.Collections.Generic; -using FrostFS.SDK.ModelsV2; namespace FrostFS.SDK.ClientV2.Extensions; diff --git a/src/FrostFS.SDK.ClientV2/Tools/ObjectReader.cs b/src/FrostFS.SDK.ClientV2/Tools/ObjectReader.cs index 663edc2..07c4793 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/ObjectReader.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/ObjectReader.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using Grpc.Core; using FrostFS.Object; -using FrostFS.SDK.ModelsV2; using System.Threading; namespace FrostFS.SDK.ClientV2; diff --git a/src/FrostFS.SDK.ClientV2/Tools/ObjectTools.cs b/src/FrostFS.SDK.ClientV2/Tools/ObjectTools.cs index 7ea09cc..73f59c3 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/ObjectTools.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/ObjectTools.cs @@ -6,7 +6,6 @@ using FrostFS.Object; using FrostFS.Refs; using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; namespace FrostFS.SDK.ClientV2; @@ -47,14 +46,14 @@ internal class ObjectTools obj.Signature = new Refs.Signature { - Key = ctx.PublicKeyCache, + Key = ctx.GetPublicKeyCache(), Sign = ByteString.CopyFrom(ctx.Key.SignData(obj.ObjectId.ToByteArray())), }; return obj; } - internal static void SetSplitValues(Header grpcHeader, ModelsV2.Split split, Context ctx) + internal static void SetSplitValues(Header grpcHeader, Split split, Context ctx) { if (split == null) return; @@ -75,7 +74,7 @@ internal class ObjectTools grpcHeader.Split.ParentHeader = grpcParentHeader; grpcHeader.Split.ParentSignature = new Refs.Signature { - Key = ctx.PublicKeyCache, + Key = ctx.GetPublicKeyCache(), Sign = ByteString.CopyFrom(ctx.Key.SignData(grpcHeader.Split.Parent.ToByteArray())), }; diff --git a/src/FrostFS.SDK.ClientV2/Tools/Range.cs b/src/FrostFS.SDK.ClientV2/Tools/Range.cs index 9c989c1..eae7b50 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/Range.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/Range.cs @@ -24,10 +24,8 @@ namespace System public Index(int value, bool fromEnd = false) { if (value < 0) - { throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative"); - } - + if (fromEnd) _value = ~value; else @@ -52,10 +50,8 @@ namespace System public static Index FromStart(int value) { if (value < 0) - { throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative"); - } - + return new Index(value); } @@ -65,10 +61,8 @@ namespace System public static Index FromEnd(int value) { if (value < 0) - { throw new ArgumentOutOfRangeException(nameof(value), "value must be non-negative"); - } - + return new Index(~value); } @@ -77,14 +71,7 @@ namespace System { get { - if (_value < 0) - { - return ~_value; - } - else - { - return _value; - } + return _value < 0 ? ~_value : _value; } } @@ -202,6 +189,7 @@ namespace System { int start; var startIndex = Start; + if (startIndex.IsFromEnd) start = length - startIndex.Value; else @@ -209,16 +197,15 @@ namespace System int end; var endIndex = End; + if (endIndex.IsFromEnd) end = length - endIndex.Value; else end = endIndex.Value; if ((uint)end > (uint)length || (uint)start > (uint)end) - { throw new ArgumentOutOfRangeException(nameof(length)); - } - + return (start, end - start); } } @@ -234,10 +221,8 @@ namespace System.Runtime.CompilerServices public static T[] GetSubArray(T[] array, Range range) { if (array == null) - { throw new ArgumentNullException(nameof(array)); - } - + (int offset, int length) = range.GetOffsetAndLength(array.Length); if (default(T) != null || typeof(T[]) == array.GetType()) @@ -245,10 +230,8 @@ namespace System.Runtime.CompilerServices // We know the type of the array to be exactly T[]. if (length == 0) - { return []; - } - + var dest = new T[length]; Array.Copy(array, offset, dest, 0, length); return dest; diff --git a/src/FrostFS.SDK.ClientV2/Tools/RequestConstructor.cs b/src/FrostFS.SDK.ClientV2/Tools/RequestConstructor.cs index 2bbba92..c12d280 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/RequestConstructor.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/RequestConstructor.cs @@ -5,7 +5,6 @@ using System.Security.Cryptography; using FrostFS.Refs; using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; using FrostFS.SDK.ProtosV2.Interfaces; using FrostFS.Session; diff --git a/src/FrostFS.SDK.ClientV2/Tools/RequestSigner.cs b/src/FrostFS.SDK.ClientV2/Tools/RequestSigner.cs index f5057eb..c2d80f7 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/RequestSigner.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/RequestSigner.cs @@ -1,6 +1,11 @@ using System; using System.Security.Cryptography; +using FrostFS.Refs; +using FrostFS.SDK.Cryptography; +using FrostFS.SDK.ProtosV2.Interfaces; +using FrostFS.Session; + using Google.Protobuf; using Org.BouncyCastle.Asn1.Sec; @@ -9,11 +14,6 @@ using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Crypto.Signers; using Org.BouncyCastle.Math; -using FrostFS.Refs; -using FrostFS.SDK.Cryptography; -using FrostFS.Session; -using FrostFS.SDK.ProtosV2.Interfaces; - namespace FrostFS.SDK.ClientV2; public static class RequestSigner diff --git a/src/FrostFS.SDK.ClientV2/Tools/SearchReader.cs b/src/FrostFS.SDK.ClientV2/Tools/SearchReader.cs index 7b327bf..1bcf398 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/SearchReader.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/SearchReader.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; -using Grpc.Core; - using FrostFS.Object; using FrostFS.Refs; -using System.Threading; + +using Grpc.Core; namespace FrostFS.SDK.ClientV2; diff --git a/src/FrostFS.SDK.ClientV2/Tools/Verifier.cs b/src/FrostFS.SDK.ClientV2/Tools/Verifier.cs index bd8ddec..2640e45 100644 --- a/src/FrostFS.SDK.ClientV2/Tools/Verifier.cs +++ b/src/FrostFS.SDK.ClientV2/Tools/Verifier.cs @@ -1,6 +1,12 @@ using System; using System.Security.Cryptography; +using FrostFS.Refs; +using FrostFS.SDK.ClientV2.Mappers.GRPC; +using FrostFS.SDK.Cryptography; +using FrostFS.SDK.ProtosV2.Interfaces; +using FrostFS.Session; + using Google.Protobuf; using Org.BouncyCastle.Asn1.Sec; @@ -9,12 +15,6 @@ using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Crypto.Signers; using Org.BouncyCastle.Math; -using FrostFS.Refs; -using FrostFS.SDK.ClientV2.Mappers.GRPC; -using FrostFS.SDK.Cryptography; -using FrostFS.Session; -using FrostFS.SDK.ProtosV2.Interfaces; - namespace FrostFS.SDK.ClientV2; public static class Verifier diff --git a/src/FrostFS.SDK.ModelsV2/Client/ClientSettings.cs b/src/FrostFS.SDK.ModelsV2/Client/ClientSettings.cs index c2abf26..80ba47a 100644 --- a/src/FrostFS.SDK.ModelsV2/Client/ClientSettings.cs +++ b/src/FrostFS.SDK.ModelsV2/Client/ClientSettings.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Text; -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class ClientSettings { @@ -13,7 +13,7 @@ public class ClientSettings public virtual void Validate() { var errors = CheckFields(); - if (errors != null) + if (errors != null) ThrowException(errors); } @@ -28,7 +28,7 @@ public class ClientSettings } protected static void ThrowException(List errors) - { + { StringBuilder messages = new(); foreach (var error in errors) @@ -48,7 +48,7 @@ public class SingleOwnerClientSettings : ClientSettings { var errors = CheckFields(); if (errors != null) - ThrowException(errors); + ThrowException(errors); } protected List? CheckFields() @@ -59,5 +59,5 @@ public class SingleOwnerClientSettings : ClientSettings (errors ??= []).Add(string.Format(errorTemplate, nameof(Key))); return errors; - } + } } \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Containers/Container.cs b/src/FrostFS.SDK.ModelsV2/Containers/Container.cs deleted file mode 100644 index 02543b3..0000000 --- a/src/FrostFS.SDK.ModelsV2/Containers/Container.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using FrostFS.SDK.ModelsV2.Enums; -using FrostFS.SDK.ModelsV2.Netmap; - -namespace FrostFS.SDK.ModelsV2; - -public class Container(BasicAcl basicAcl, PlacementPolicy placementPolicy) -{ - public Guid Nonce { get; set; } = Guid.NewGuid(); - public BasicAcl BasicAcl { get; set; } = basicAcl; - public PlacementPolicy PlacementPolicy { get; set; } = placementPolicy; - public Version? Version { get; set; } -} \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Containers/ContainerId.cs b/src/FrostFS.SDK.ModelsV2/Containers/ContainerId.cs index 349eb1c..4543dcd 100644 --- a/src/FrostFS.SDK.ModelsV2/Containers/ContainerId.cs +++ b/src/FrostFS.SDK.ModelsV2/Containers/ContainerId.cs @@ -1,4 +1,4 @@ -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class ContainerId(string id) { diff --git a/src/FrostFS.SDK.ModelsV2/Containers/FrostFsContainer.cs b/src/FrostFS.SDK.ModelsV2/Containers/FrostFsContainer.cs new file mode 100644 index 0000000..45d3b58 --- /dev/null +++ b/src/FrostFS.SDK.ModelsV2/Containers/FrostFsContainer.cs @@ -0,0 +1,11 @@ +using System; + +namespace FrostFS.SDK; + +public class FrostFsContainer(BasicAcl basicAcl, FrostFsPlacementPolicy placementPolicy) +{ + public Guid Nonce { get; set; } = Guid.NewGuid(); + public BasicAcl BasicAcl { get; set; } = basicAcl; + public FrostFsPlacementPolicy PlacementPolicy { get; set; } = placementPolicy; + public FrostFsVersion? Version { get; set; } +} \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Enums/BasicAcl.cs b/src/FrostFS.SDK.ModelsV2/Enums/BasicAcl.cs index 9418039..dd3252b 100644 --- a/src/FrostFS.SDK.ModelsV2/Enums/BasicAcl.cs +++ b/src/FrostFS.SDK.ModelsV2/Enums/BasicAcl.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace FrostFS.SDK.ModelsV2.Enums; +namespace FrostFS.SDK; public enum BasicAcl { diff --git a/src/FrostFS.SDK.ModelsV2/Enums/ObjectMatchType.cs b/src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectMatchType.cs similarity index 59% rename from src/FrostFS.SDK.ModelsV2/Enums/ObjectMatchType.cs rename to src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectMatchType.cs index 4d6026c..1fdeb60 100644 --- a/src/FrostFS.SDK.ModelsV2/Enums/ObjectMatchType.cs +++ b/src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectMatchType.cs @@ -1,6 +1,6 @@ -namespace FrostFS.SDK.ModelsV2.Enums; +namespace FrostFS.SDK; -public enum ObjectMatchType +public enum FrostFsObjectMatchType { Unspecified = 0, Equals = 1, diff --git a/src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectType.cs b/src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectType.cs new file mode 100644 index 0000000..793fe2e --- /dev/null +++ b/src/FrostFS.SDK.ModelsV2/Enums/FrostFsObjectType.cs @@ -0,0 +1,8 @@ +namespace FrostFS.SDK; + +public enum FrostFsObjectType +{ + Regular = 0, + Tombstone = 1, + Lock = 3 +} \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Enums/StatusCode.cs b/src/FrostFS.SDK.ModelsV2/Enums/FrostFsStatusCode.cs similarity index 88% rename from src/FrostFS.SDK.ModelsV2/Enums/StatusCode.cs rename to src/FrostFS.SDK.ModelsV2/Enums/FrostFsStatusCode.cs index df0fa57..7eb185c 100644 --- a/src/FrostFS.SDK.ModelsV2/Enums/StatusCode.cs +++ b/src/FrostFS.SDK.ModelsV2/Enums/FrostFsStatusCode.cs @@ -1,6 +1,6 @@ -namespace FrostFS.SDK.ModelsV2.Enums; +namespace FrostFS.SDK; -public enum StatusCode +public enum FrostFsStatusCode { Success = 0, Internal = 1024, diff --git a/src/FrostFS.SDK.ModelsV2/Enums/NodeState.cs b/src/FrostFS.SDK.ModelsV2/Enums/NodeState.cs index 2293c0f..2821e55 100644 --- a/src/FrostFS.SDK.ModelsV2/Enums/NodeState.cs +++ b/src/FrostFS.SDK.ModelsV2/Enums/NodeState.cs @@ -1,4 +1,4 @@ -namespace FrostFS.SDK.ModelsV2.Enums; +namespace FrostFS.SDK; public enum NodeState { diff --git a/src/FrostFS.SDK.ModelsV2/Enums/ObjectType.cs b/src/FrostFS.SDK.ModelsV2/Enums/ObjectType.cs deleted file mode 100644 index 6f8a905..0000000 --- a/src/FrostFS.SDK.ModelsV2/Enums/ObjectType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FrostFS.SDK.ModelsV2.Enums; - -public enum ObjectType -{ - Regular = 0, - Tombstone = 1, - Lock = 3 -} \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Enums/SignatureScheme.cs b/src/FrostFS.SDK.ModelsV2/Enums/SignatureScheme.cs index bd6c41d..4b5634c 100644 --- a/src/FrostFS.SDK.ModelsV2/Enums/SignatureScheme.cs +++ b/src/FrostFS.SDK.ModelsV2/Enums/SignatureScheme.cs @@ -1,7 +1,8 @@ -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; -public enum SignatureScheme { +public enum SignatureScheme +{ EcdsaSha512, EcdsaRfc6979Sha256, EcdsaRfc6979Sha256WalletConnect - } +} diff --git a/src/FrostFS.SDK.ModelsV2/Misc/CallStatistics.cs b/src/FrostFS.SDK.ModelsV2/Misc/CallStatistics.cs index a6cbcbf..706b3f2 100644 --- a/src/FrostFS.SDK.ModelsV2/Misc/CallStatistics.cs +++ b/src/FrostFS.SDK.ModelsV2/Misc/CallStatistics.cs @@ -1,7 +1,7 @@ -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class CallStatistics -{ +{ public string? MethodName { get; set; } public long ElapsedMicroSeconds { get; set; } } \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Misc/CheckSum.cs b/src/FrostFS.SDK.ModelsV2/Misc/CheckSum.cs index 872038b..82017f9 100644 --- a/src/FrostFS.SDK.ModelsV2/Misc/CheckSum.cs +++ b/src/FrostFS.SDK.ModelsV2/Misc/CheckSum.cs @@ -1,7 +1,7 @@ using FrostFS.SDK.Cryptography; using System; -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class CheckSum { diff --git a/src/FrostFS.SDK.ModelsV2/Misc/Constants.cs b/src/FrostFS.SDK.ModelsV2/Misc/Constants.cs index 4b72aa1..332a3e3 100644 --- a/src/FrostFS.SDK.ModelsV2/Misc/Constants.cs +++ b/src/FrostFS.SDK.ModelsV2/Misc/Constants.cs @@ -1,4 +1,4 @@ -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class Constants { diff --git a/src/FrostFS.SDK.ModelsV2/Netmap/NodeInfo.cs b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsNodeInfo.cs similarity index 74% rename from src/FrostFS.SDK.ModelsV2/Netmap/NodeInfo.cs rename to src/FrostFS.SDK.ModelsV2/Netmap/FrostFsNodeInfo.cs index 8fa4704..9581b21 100644 --- a/src/FrostFS.SDK.ModelsV2/Netmap/NodeInfo.cs +++ b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsNodeInfo.cs @@ -1,18 +1,17 @@ using System; using System.Collections.Generic; -using FrostFS.SDK.ModelsV2.Enums; -namespace FrostFS.SDK.ModelsV2.Netmap; +namespace FrostFS.SDK; -public class NodeInfo( - Version version, +public class FrostFsNodeInfo( + FrostFsVersion version, NodeState state, IReadOnlyCollection addresses, IReadOnlyDictionary attributes, ReadOnlyMemory publicKey) { public NodeState State { get; private set; } = state; - public Version Version { get; private set; } = version; + public FrostFsVersion Version { get; private set; } = version; public IReadOnlyCollection Addresses { get; private set; } = addresses; public IReadOnlyDictionary Attributes { get; private set; } = attributes; public ReadOnlyMemory PublicKey { get; private set; } = publicKey; diff --git a/src/FrostFS.SDK.ModelsV2/Netmap/PlacementPolicy.cs b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsPlacementPolicy.cs similarity index 59% rename from src/FrostFS.SDK.ModelsV2/Netmap/PlacementPolicy.cs rename to src/FrostFS.SDK.ModelsV2/Netmap/FrostFsPlacementPolicy.cs index bb7b1a3..410598c 100644 --- a/src/FrostFS.SDK.ModelsV2/Netmap/PlacementPolicy.cs +++ b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsPlacementPolicy.cs @@ -1,16 +1,16 @@ using System; using System.Linq; -namespace FrostFS.SDK.ModelsV2.Netmap; +namespace FrostFS.SDK; -public class PlacementPolicy(bool unique, params Replica[] replicas) : IComparable +public class FrostFsPlacementPolicy(bool unique, params FrostFsReplica[] replicas) : IComparable { - public Replica[] Replicas { get; private set; } = replicas; + public FrostFsReplica[] Replicas { get; private set; } = replicas; public bool Unique { get; private set; } = unique; - public int CompareTo(PlacementPolicy other) + public int CompareTo(FrostFsPlacementPolicy other) { - var notEqual = other == null + var notEqual = other == null || Unique != other.Unique || Replicas.Length != other.Replicas.Length; diff --git a/src/FrostFS.SDK.ModelsV2/Netmap/Replica.cs b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsReplica.cs similarity index 60% rename from src/FrostFS.SDK.ModelsV2/Netmap/Replica.cs rename to src/FrostFS.SDK.ModelsV2/Netmap/FrostFsReplica.cs index a6aeac9..8fd1bd9 100644 --- a/src/FrostFS.SDK.ModelsV2/Netmap/Replica.cs +++ b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsReplica.cs @@ -1,14 +1,14 @@ -namespace FrostFS.SDK.ModelsV2.Netmap; +namespace FrostFS.SDK; -public class Replica +public class FrostFsReplica { public int Count { get; set; } public string Selector { get; set; } - public Replica(int count, string? selector = null) + public FrostFsReplica(int count, string? selector = null) { selector ??= string.Empty; - + Count = count; Selector = selector; } diff --git a/src/FrostFS.SDK.ModelsV2/Netmap/Version.cs b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsVersion.cs similarity index 64% rename from src/FrostFS.SDK.ModelsV2/Netmap/Version.cs rename to src/FrostFS.SDK.ModelsV2/Netmap/FrostFsVersion.cs index 88bdee2..06c3ca2 100644 --- a/src/FrostFS.SDK.ModelsV2/Netmap/Version.cs +++ b/src/FrostFS.SDK.ModelsV2/Netmap/FrostFsVersion.cs @@ -1,11 +1,11 @@ -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; -public class Version(int major, int minor) +public class FrostFsVersion(int major, int minor) { public int Major { get; set; } = major; public int Minor { get; set; } = minor; - public bool IsSupported(Version version) + public bool IsSupported(FrostFsVersion version) { return Major == version.Major; } diff --git a/src/FrostFS.SDK.ModelsV2/Netmap/NetmapInfo.cs b/src/FrostFS.SDK.ModelsV2/Netmap/NetmapInfo.cs index fb8dba1..a371564 100644 --- a/src/FrostFS.SDK.ModelsV2/Netmap/NetmapInfo.cs +++ b/src/FrostFS.SDK.ModelsV2/Netmap/NetmapInfo.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; -namespace FrostFS.SDK.ModelsV2.Netmap; +namespace FrostFS.SDK; -public class NetmapSnapshot(ulong epoch, IReadOnlyList nodeInfoCollection) +public class NetmapSnapshot(ulong epoch, IReadOnlyList nodeInfoCollection) { public ulong Epoch { get; private set; } = epoch; - public IReadOnlyList NodeInfoCollection { get; private set; } = nodeInfoCollection; + public IReadOnlyList NodeInfoCollection { get; private set; } = nodeInfoCollection; } \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Object/FrostFsObject.cs b/src/FrostFS.SDK.ModelsV2/Object/FrostFsObject.cs index 1443abf..e382ec5 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/FrostFsObject.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/FrostFsObject.cs @@ -1,7 +1,6 @@ using System; -using FrostFS.SDK.ModelsV2.Enums; -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class FrostFsObject { @@ -11,7 +10,7 @@ public class FrostFsObject /// public FrostFsObject(ObjectHeader header) { - Header = header; + Header = header; } /// @@ -19,17 +18,17 @@ public class FrostFsObject /// /// /// - public FrostFsObject(ContainerId container, ObjectType objectType = ObjectType.Regular) + public FrostFsObject(ContainerId container, FrostFsObjectType objectType = FrostFsObjectType.Regular) { - Header = new ObjectHeader(containerId: container, type: objectType); + Header = new ObjectHeader(containerId: container, type: objectType); } - + /// /// Header contains metadata for the object /// /// public ObjectHeader Header { get; set; } - + /// /// The value is calculated internally as a hash of ObjectHeader. Do not use pre-calculated value is the object has been changed. /// @@ -50,7 +49,7 @@ public class FrostFsObject /// /// Reader for received data public IObjectReader? ObjectReader { get; set; } - + /// /// Applied only for the last Object in chain in case of manual multipart uploading /// @@ -74,11 +73,11 @@ public class LargeObject(ContainerId container) : FrostFsObject(container) public class LinkObject : FrostFsObject { - public LinkObject(ContainerId containerId, SplitId splitId, ObjectHeader largeObjectHeader) : base (containerId) + public LinkObject(ContainerId containerId, SplitId splitId, ObjectHeader largeObjectHeader) : base(containerId) { Header!.Split = new Split(splitId) { - ParentHeader = largeObjectHeader + ParentHeader = largeObjectHeader }; } } \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Object/IObjectReader.cs b/src/FrostFS.SDK.ModelsV2/Object/IObjectReader.cs index a85542f..51211fd 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/IObjectReader.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/IObjectReader.cs @@ -2,7 +2,7 @@ using System; using System.Threading; using System.Threading.Tasks; -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public interface IObjectReader : IDisposable { diff --git a/src/FrostFS.SDK.ModelsV2/Object/ObjectAttribute.cs b/src/FrostFS.SDK.ModelsV2/Object/ObjectAttribute.cs index 92d38b2..110db12 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/ObjectAttribute.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/ObjectAttribute.cs @@ -1,4 +1,4 @@ -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class ObjectAttribute(string key, string value) { diff --git a/src/FrostFS.SDK.ModelsV2/Object/ObjectFilter.cs b/src/FrostFS.SDK.ModelsV2/Object/ObjectFilter.cs index fbed30c..40f654d 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/ObjectFilter.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/ObjectFilter.cs @@ -1,18 +1,16 @@ -using FrostFS.SDK.ModelsV2.Enums; - -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public interface IObjectFilter { - public ObjectMatchType MatchType { get; set; } + public FrostFsObjectMatchType MatchType { get; set; } public string Key { get; set; } - + string? GetSerializedValue(); } -public abstract class ObjectFilter(ObjectMatchType matchType, string key, T value) : IObjectFilter +public abstract class ObjectFilter(FrostFsObjectMatchType matchType, string key, T value) : IObjectFilter { - public ObjectMatchType MatchType { get; set; } = matchType; + public FrostFsObjectMatchType MatchType { get; set; } = matchType; public string Key { get; set; } = key; public T Value { get; set; } = value; @@ -29,85 +27,85 @@ public abstract class ObjectFilter(ObjectMatchType matchType, string key, T v /// Match type /// Attribute key /// Attribute value -public class FilterByAttribute(ObjectMatchType matchType, string key, string value) : ObjectFilter(matchType, key, value) { } +public class FilterByAttribute(FrostFsObjectMatchType matchType, string key, string value) : ObjectFilter(matchType, key, value) { } /// /// Creates filter to search by ObjectId /// /// Match type /// ObjectId -public class FilterByObjectId(ObjectMatchType matchType, ObjectId objectId) : ObjectFilter(matchType, Constants.FilterHeaderObjectID, objectId) { } +public class FilterByObjectId(FrostFsObjectMatchType matchType, ObjectId objectId) : ObjectFilter(matchType, Constants.FilterHeaderObjectID, objectId) { } /// /// Creates filter to search by OwnerId /// /// Match type /// ObjectId -public class FilterByOwnerId(ObjectMatchType matchType, OwnerId ownerId) : ObjectFilter(matchType, Constants.FilterHeaderOwnerID, ownerId) {} +public class FilterByOwnerId(FrostFsObjectMatchType matchType, OwnerId ownerId) : ObjectFilter(matchType, Constants.FilterHeaderOwnerID, ownerId) { } /// /// Creates filter to search by Version /// /// Match type /// Version -public class FilterByVersion(ObjectMatchType matchType, Version version) : ObjectFilter(matchType, Constants.FilterHeaderVersion, version) {} +public class FilterByVersion(FrostFsObjectMatchType matchType, FrostFsVersion version) : ObjectFilter(matchType, Constants.FilterHeaderVersion, version) { } /// /// Creates filter to search by ContainerId /// /// Match type /// ContainerId -public class FilterByContainerId(ObjectMatchType matchType, ContainerId containerId) : ObjectFilter(matchType, Constants.FilterHeaderContainerID, containerId) {} +public class FilterByContainerId(FrostFsObjectMatchType matchType, ContainerId containerId) : ObjectFilter(matchType, Constants.FilterHeaderContainerID, containerId) { } /// /// Creates filter to search by creation Epoch /// /// Match type /// Creation Epoch -public class FilterByEpoch(ObjectMatchType matchType, ulong epoch) : ObjectFilter(matchType, Constants.FilterHeaderCreationEpoch, epoch) {} +public class FilterByEpoch(FrostFsObjectMatchType matchType, ulong epoch) : ObjectFilter(matchType, Constants.FilterHeaderCreationEpoch, epoch) { } /// /// Creates filter to search by Payload Length /// /// Match type /// Payload Length -public class FilterByPayloadLength(ObjectMatchType matchType, ulong payloadLength) : ObjectFilter(matchType, Constants.FilterHeaderPayloadLength, payloadLength) {} +public class FilterByPayloadLength(FrostFsObjectMatchType matchType, ulong payloadLength) : ObjectFilter(matchType, Constants.FilterHeaderPayloadLength, payloadLength) { } /// /// Creates filter to search by Payload Hash /// /// Match type /// Payload Hash -public class FilterByPayloadHash(ObjectMatchType matchType, CheckSum payloadHash) : ObjectFilter(matchType, Constants.FilterHeaderPayloadHash, payloadHash) {} +public class FilterByPayloadHash(FrostFsObjectMatchType matchType, CheckSum payloadHash) : ObjectFilter(matchType, Constants.FilterHeaderPayloadHash, payloadHash) { } /// /// Creates filter to search by Parent /// /// Match type /// Parent -public class FilterByParent(ObjectMatchType matchType, ObjectId parentId) : ObjectFilter(matchType, Constants.FilterHeaderParent, parentId) {} +public class FilterByParent(FrostFsObjectMatchType matchType, ObjectId parentId) : ObjectFilter(matchType, Constants.FilterHeaderParent, parentId) { } /// /// Creates filter to search by SplitId /// /// Match type /// SplitId -public class FilterBySplitId(ObjectMatchType matchType, SplitId splitId) : ObjectFilter(matchType, Constants.FilterHeaderSplitID, splitId) {} +public class FilterBySplitId(FrostFsObjectMatchType matchType, SplitId splitId) : ObjectFilter(matchType, Constants.FilterHeaderSplitID, splitId) { } /// /// Creates filter to search by Payload Hash /// /// Match type /// Payload Hash -public class FilterByECParent(ObjectMatchType matchType, ObjectId ecParentId) : ObjectFilter(matchType, Constants.FilterHeaderECParent, ecParentId) {} +public class FilterByECParent(FrostFsObjectMatchType matchType, ObjectId ecParentId) : ObjectFilter(matchType, Constants.FilterHeaderECParent, ecParentId) { } /// /// Creates filter to search Root objects /// -public class FilterByRootObject() : ObjectFilter(ObjectMatchType.Unspecified, Constants.FilterHeaderRoot, string.Empty) {} +public class FilterByRootObject() : ObjectFilter(FrostFsObjectMatchType.Unspecified, Constants.FilterHeaderRoot, string.Empty) { } /// /// Creates filter to search objects that are physically stored on the server /// (ObjectMatchType.Unspecified, Constants.FilterHeaderPhy, string.Empty) {} +public class FilterByPhysicallyStored() : ObjectFilter(FrostFsObjectMatchType.Unspecified, Constants.FilterHeaderPhy, string.Empty) { } diff --git a/src/FrostFS.SDK.ModelsV2/Object/ObjectHeader.cs b/src/FrostFS.SDK.ModelsV2/Object/ObjectHeader.cs index 715f903..3e3ecd3 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/ObjectHeader.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/ObjectHeader.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; -using FrostFS.SDK.ModelsV2.Enums; -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class ObjectHeader( ContainerId containerId, - ObjectType type = ObjectType.Regular, + FrostFsObjectType type = FrostFsObjectType.Regular, params ObjectAttribute[] attributes ) { @@ -19,9 +18,9 @@ public class ObjectHeader( public byte[]? PayloadCheckSum { get; set; } - public ObjectType ObjectType { get; set; } = type; + public FrostFsObjectType ObjectType { get; set; } = type; - public Version? Version { get; set; } + public FrostFsVersion? Version { get; set; } public Split? Split { get; set; } } diff --git a/src/FrostFS.SDK.ModelsV2/Object/ObjectId.cs b/src/FrostFS.SDK.ModelsV2/Object/ObjectId.cs index 74e6bfb..9072361 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/ObjectId.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/ObjectId.cs @@ -2,7 +2,7 @@ using FrostFS.SDK.Cryptography; -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class ObjectId(string id) { @@ -12,7 +12,7 @@ public class ObjectId(string id) { if (hash.Length != Constants.Sha256HashLength) throw new FormatException("ObjectID must be a sha256 hash."); - + return new ObjectId(Base58.Encode(hash)); } diff --git a/src/FrostFS.SDK.ModelsV2/Object/OwnerId.cs b/src/FrostFS.SDK.ModelsV2/Object/OwnerId.cs index b930bb7..5da87ef 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/OwnerId.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/OwnerId.cs @@ -2,7 +2,7 @@ using System.Security.Cryptography; using FrostFS.SDK.Cryptography; -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class OwnerId(string id) { diff --git a/src/FrostFS.SDK.ModelsV2/Object/SplitId.cs b/src/FrostFS.SDK.ModelsV2/Object/SplitId.cs index d65f35f..8af45c1 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/SplitId.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/SplitId.cs @@ -1,9 +1,10 @@ using FrostFS.SDK.Cryptography; -using Google.Protobuf; -using System; -using static FrostFS.Object.Header.Types; -namespace FrostFS.SDK.ModelsV2; +using Google.Protobuf; + +using System; + +namespace FrostFS.SDK; public class SplitId { @@ -13,22 +14,22 @@ public class SplitId public SplitId() { - this.id = Guid.NewGuid(); + id = Guid.NewGuid(); } public SplitId(Guid guid) { - this.id = guid; + id = guid; } private SplitId(byte[] binary) { - this.id = new Guid(binary); + id = new Guid(binary); } private SplitId(string str) { - this.id = new Guid(str); + id = new Guid(str); } public static SplitId CreateFromBinary(byte[] binaryData) @@ -39,19 +40,19 @@ public class SplitId public static SplitId CreateFromString(string stringData) { return new SplitId(stringData); - } + } public override string ToString() { - return this.id.ToString(); + return id.ToString(); } public byte[]? ToBinary() { - if (this.id == Guid.Empty) + if (id == Guid.Empty) return null; - return this.id.ToBytes(); + return id.ToBytes(); } public ByteString? GetMessage() diff --git a/src/FrostFS.SDK.ModelsV2/Object/Splitter.cs b/src/FrostFS.SDK.ModelsV2/Object/Splitter.cs index 3fb55df..64b3515 100644 --- a/src/FrostFS.SDK.ModelsV2/Object/Splitter.cs +++ b/src/FrostFS.SDK.ModelsV2/Object/Splitter.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; - -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; public class Split(SplitId splitId) { @@ -14,8 +13,8 @@ public class Split(SplitId splitId) public ObjectId? Parent { get; set; } public ObjectId? Previous { get; set; } - - public Signature? ParentSignature { get; set; } + + public FrostFsSignature? ParentSignature { get; set; } public ObjectHeader? ParentHeader { get; set; } diff --git a/src/FrostFS.SDK.ModelsV2/Response/FrostFsResponseStatus.cs b/src/FrostFS.SDK.ModelsV2/Response/FrostFsResponseStatus.cs new file mode 100644 index 0000000..b5e5831 --- /dev/null +++ b/src/FrostFS.SDK.ModelsV2/Response/FrostFsResponseStatus.cs @@ -0,0 +1,14 @@ +namespace FrostFS.SDK; + +public class FrostFsResponseStatus(FrostFsStatusCode code, string? message = null) +{ + public FrostFsStatusCode Code { get; set; } = code; + public string Message { get; set; } = message ?? string.Empty; + + public bool IsSuccess => Code == FrostFsStatusCode.Success; + + public override string ToString() + { + return $"Response status: {Code}. Message: {Message}."; + } +} \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Response/FrostFsSignature.cs b/src/FrostFS.SDK.ModelsV2/Response/FrostFsSignature.cs new file mode 100644 index 0000000..d7ca6b6 --- /dev/null +++ b/src/FrostFS.SDK.ModelsV2/Response/FrostFsSignature.cs @@ -0,0 +1,10 @@ +namespace FrostFS.SDK; + +public class FrostFsSignature +{ + public byte[]? Key { get; set; } + + public byte[]? Sign { get; set; } + + public SignatureScheme Scheme { get; set; } +} diff --git a/src/FrostFS.SDK.ModelsV2/Response/MetaHeader.cs b/src/FrostFS.SDK.ModelsV2/Response/MetaHeader.cs index d2b84a2..36dad09 100644 --- a/src/FrostFS.SDK.ModelsV2/Response/MetaHeader.cs +++ b/src/FrostFS.SDK.ModelsV2/Response/MetaHeader.cs @@ -1,15 +1,15 @@ -namespace FrostFS.SDK.ModelsV2; +namespace FrostFS.SDK; -public class MetaHeader(Version version, int epoch, int ttl) +public class MetaHeader(FrostFsVersion version, int epoch, int ttl) { - public Version Version { get; set; } = version; + public FrostFsVersion Version { get; set; } = version; public int Epoch { get; set; } = epoch; public int Ttl { get; set; } = ttl; public static MetaHeader Default() { return new MetaHeader( - new Version( + new FrostFsVersion( major: 2, minor: 13 ), diff --git a/src/FrostFS.SDK.ModelsV2/Response/ResponseStatus.cs b/src/FrostFS.SDK.ModelsV2/Response/ResponseStatus.cs deleted file mode 100644 index f58e1bb..0000000 --- a/src/FrostFS.SDK.ModelsV2/Response/ResponseStatus.cs +++ /dev/null @@ -1,16 +0,0 @@ -using FrostFS.SDK.ModelsV2.Enums; - -namespace FrostFS.SDK.ModelsV2; - -public class ResponseStatus(StatusCode code, string? message = null) -{ - public StatusCode Code { get; set; } = code; - public string Message { get; set; } = message ?? string.Empty; - - public bool IsSuccess => Code == StatusCode.Success; - - public override string ToString() - { - return $"Response status: {Code}. Message: {Message}."; - } -} \ No newline at end of file diff --git a/src/FrostFS.SDK.ModelsV2/Response/Signature.cs b/src/FrostFS.SDK.ModelsV2/Response/Signature.cs deleted file mode 100644 index 1d36e1c..0000000 --- a/src/FrostFS.SDK.ModelsV2/Response/Signature.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace FrostFS.SDK.ModelsV2; - -public class Signature -{ - public byte[]? Key { get; set; } - public byte[]? Sign { get; set; } - public SignatureScheme Scheme { get; set; } -} diff --git a/src/FrostFS.SDK.ModelsV2/Session/FrostFsSessionToken.cs b/src/FrostFS.SDK.ModelsV2/Session/FrostFsSessionToken.cs new file mode 100644 index 0000000..8954780 --- /dev/null +++ b/src/FrostFS.SDK.ModelsV2/Session/FrostFsSessionToken.cs @@ -0,0 +1,6 @@ +namespace FrostFS.SDK; + +public class FrostFsSessionToken(byte[] token) +{ + public byte[] Token { get; private set; } = token; +} diff --git a/src/FrostFS.SDK.ModelsV2/Session/SessionToken.cs b/src/FrostFS.SDK.ModelsV2/Session/SessionToken.cs deleted file mode 100644 index 2865ca3..0000000 --- a/src/FrostFS.SDK.ModelsV2/Session/SessionToken.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace FrostFS.SDK.ModelsV2; - -public class SessionToken(byte[] token) -{ - public byte[] Token { get; private set; } = token; -} diff --git a/src/FrostFS.SDK.Tests/ContainerTest.cs b/src/FrostFS.SDK.Tests/ContainerTest.cs index 0af0e70..96000fb 100644 --- a/src/FrostFS.SDK.Tests/ContainerTest.cs +++ b/src/FrostFS.SDK.Tests/ContainerTest.cs @@ -1,14 +1,11 @@ -using FrostFS.SDK.ModelsV2; using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; using FrostFS.SDK.ClientV2.Mappers.GRPC; +using FrostFS.SDK.ClientV2.Interfaces; +using FrostFS.SDK.ClientV2.Parameters; using FrostFS.SDK.Cryptography; using Microsoft.Extensions.Options; -using FrostFS.SDK.ModelsV2.Netmap; -using FrostFS.SDK.ModelsV2.Enums; using Google.Protobuf; -using FrostFS.SDK.ClientV2.Interfaces; -using FrostFS.SDK.ClientV2.Parameters; namespace FrostFS.SDK.Tests; @@ -29,8 +26,8 @@ public abstract class ContainerTestsBase Mocker = new ContainerMocker(this.key) { - PlacementPolicy = new PlacementPolicy(true, new Replica(1)), - Version = new ModelsV2.Version(2, 13), + PlacementPolicy = new FrostFsPlacementPolicy(true, new FrostFsReplica(1)), + Version = new FrostFsVersion(2, 13), ContainerGuid = Guid.NewGuid() }; } @@ -52,7 +49,7 @@ public class ContainerTest : ContainerTestsBase [Fact] public async void CreateContainerTest() { - var param = new PrmContainerCreate(new ModelsV2.Container(BasicAcl.PublicRW, Mocker.PlacementPolicy)); + var param = new PrmContainerCreate(new FrostFsContainer(BasicAcl.PublicRW, Mocker.PlacementPolicy)); var result = await GetClient().CreateContainerAsync(param); diff --git a/src/FrostFS.SDK.Tests/Mocks/AsyncStreamReaderMock.cs b/src/FrostFS.SDK.Tests/Mocks/AsyncStreamReaderMock.cs index 3603a92..1ea2682 100644 --- a/src/FrostFS.SDK.Tests/Mocks/AsyncStreamReaderMock.cs +++ b/src/FrostFS.SDK.Tests/Mocks/AsyncStreamReaderMock.cs @@ -3,7 +3,6 @@ using FrostFS.Session; using Google.Protobuf; using Grpc.Core; using FrostFS.SDK.ClientV2; -using FrostFS.SDK.ModelsV2; using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.SDK.Cryptography; diff --git a/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/ContainerServiceBase.cs b/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/ContainerServiceBase.cs index 7cf2690..4235f71 100644 --- a/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/ContainerServiceBase.cs +++ b/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/ContainerServiceBase.cs @@ -3,8 +3,6 @@ using FrostFS.Container; using Moq; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2.Enums; -using FrostFS.SDK.ModelsV2.Netmap; using FrostFS.Session; using Google.Protobuf; @@ -19,18 +17,18 @@ public abstract class ServiceBase(string key) { public string StringKey { get; private set; } = key; public ECDsa Key { get; private set; } = key.LoadWif(); - public ModelsV2.Version Version { get; set; } = DefaultVersion; + public FrostFsVersion Version { get; set; } = DefaultVersion; public BasicAcl Acl { get; set; } = DefaultAcl; - public PlacementPolicy PlacementPolicy { get; set; } = DefaultPlacementPolicy; + public FrostFsPlacementPolicy PlacementPolicy { get; set; } = DefaultPlacementPolicy; - public static ModelsV2.Version DefaultVersion { get; } = new(2, 13); + public static FrostFsVersion DefaultVersion { get; } = new(2, 13); public static BasicAcl DefaultAcl { get; } = BasicAcl.PublicRW; - public static PlacementPolicy DefaultPlacementPolicy { get; } = new PlacementPolicy(true, new Replica(1)); + public static FrostFsPlacementPolicy DefaultPlacementPolicy { get; } = new FrostFsPlacementPolicy(true, new FrostFsReplica(1)); public Metadata Metadata { get; protected set; } public DateTime? DateTime { get; protected set; } - public CancellationToken CancellationToken { get; protected set; } + public CancellationToken CancellationToken { get; protected set; } public CancellationTokenSource CancellationTokenSource { get; protected set; } = new CancellationTokenSource(); public static Metadata ResponseMetaData => []; diff --git a/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/GetContainerMock.cs b/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/GetContainerMock.cs index 34f6173..a5ba804 100644 --- a/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/GetContainerMock.cs +++ b/src/FrostFS.SDK.Tests/Mocks/ContainerServiceMocks/GetContainerMock.cs @@ -5,7 +5,6 @@ using Moq; using FrostFS.SDK.Cryptography; using FrostFS.SDK.ClientV2; -using FrostFS.SDK.ModelsV2.Netmap; using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.Session; diff --git a/src/FrostFS.SDK.Tests/Mocks/ObjectMock.cs b/src/FrostFS.SDK.Tests/Mocks/ObjectMock.cs index 099398d..b7ce0f2 100644 --- a/src/FrostFS.SDK.Tests/Mocks/ObjectMock.cs +++ b/src/FrostFS.SDK.Tests/Mocks/ObjectMock.cs @@ -2,7 +2,6 @@ using Google.Protobuf; using Grpc.Core; using Moq; using FrostFS.SDK.ClientV2; -using FrostFS.SDK.ModelsV2; using FrostFS.Object; using FrostFS.SDK.ClientV2.Mappers.GRPC; using System.Security.Cryptography; diff --git a/src/FrostFS.SDK.Tests/NetworkTest.cs b/src/FrostFS.SDK.Tests/NetworkTest.cs index 0fce906..57d0bcb 100644 --- a/src/FrostFS.SDK.Tests/NetworkTest.cs +++ b/src/FrostFS.SDK.Tests/NetworkTest.cs @@ -3,10 +3,11 @@ using FrostFS.SDK.ClientV2; using FrostFS.SDK.ClientV2.Interfaces; using FrostFS.SDK.ClientV2.Parameters; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; -using FrostFS.SDK.ModelsV2.Enums; + using Google.Protobuf; + using Microsoft.Extensions.Options; + using System.Security.Cryptography; namespace FrostFS.SDK.Tests; @@ -17,7 +18,7 @@ public abstract class NetworkTestsBase protected IOptions Settings { get; set; } - protected ModelsV2.Version Version { get; set; } = new ModelsV2.Version(2, 13); + protected FrostFsVersion Version { get; set; } = new FrostFsVersion(2, 13); protected ECDsa ECDsaKey { get; set; } protected OwnerId OwnerId { get; set; } diff --git a/src/FrostFS.SDK.Tests/ObjectTest.cs b/src/FrostFS.SDK.Tests/ObjectTest.cs index db20741..68b9dc3 100644 --- a/src/FrostFS.SDK.Tests/ObjectTest.cs +++ b/src/FrostFS.SDK.Tests/ObjectTest.cs @@ -4,11 +4,11 @@ using FrostFS.SDK.ClientV2.Interfaces; using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.SDK.ClientV2.Parameters; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; -using FrostFS.SDK.ModelsV2.Enums; -using FrostFS.SDK.ModelsV2.Netmap; + using Google.Protobuf; + using Microsoft.Extensions.Options; + using System.Security.Cryptography; using System.Text; @@ -38,16 +38,16 @@ public abstract class ObjectTestsBase Mocker = new ObjectMocker(key) { - PlacementPolicy = new PlacementPolicy(true, new Replica(1)), - Version = new ModelsV2.Version(2, 13), + PlacementPolicy = new FrostFsPlacementPolicy(true, new FrostFsReplica(1)), + Version = new FrostFsVersion(2, 13), ContainerGuid = Guid.NewGuid() }; ContainerId = new ContainerId(Base58.Encode(Mocker.ContainerGuid.ToBytes())); - Mocker.ObjectHeader = new(ContainerId, ModelsV2.Enums.ObjectType.Regular, [new ObjectAttribute("k", "v")]) + Mocker.ObjectHeader = new(ContainerId, FrostFsObjectType.Regular, [new ObjectAttribute("k", "v")]) { - Version = new ModelsV2.Version(2, 13), + Version = new FrostFsVersion(2, 13), OwnerId = OwnerId.FromKey(ecdsaKey) }; } @@ -76,7 +76,7 @@ public class ObjectTest : ObjectTestsBase var ctx = new Context { Key = ecdsaKey, OwnerId = OwnerId.FromKey(ecdsaKey), - Version = new ModelsV2.Version(2, 13) }; + Version = new FrostFsVersion(2, 13) }; var objectId = client.CalculateObjectId(Mocker.ObjectHeader!, ctx); @@ -256,7 +256,7 @@ public class ObjectTest : ObjectTestsBase Assert.Equal(Mocker.HeadResponse!.PayloadLength, response.PayloadLength); - Assert.Equal(ObjectType.Regular, response.ObjectType); + Assert.Equal(FrostFsObjectType.Regular, response.ObjectType); Assert.Single(response.Attributes); diff --git a/src/FrostFS.SDK.Tests/SessionTests.cs b/src/FrostFS.SDK.Tests/SessionTests.cs index 8b3dc1a..6ccf001 100644 --- a/src/FrostFS.SDK.Tests/SessionTests.cs +++ b/src/FrostFS.SDK.Tests/SessionTests.cs @@ -4,9 +4,9 @@ using FrostFS.SDK.ClientV2.Mappers.GRPC; using FrostFS.SDK.ClientV2.Mappers.GRPC.Netmap; using FrostFS.SDK.ClientV2.Parameters; using FrostFS.SDK.Cryptography; -using FrostFS.SDK.ModelsV2; -using FrostFS.SDK.ModelsV2.Netmap; + using Microsoft.Extensions.Options; + using System.Security.Cryptography; namespace FrostFS.SDK.Tests; @@ -35,8 +35,8 @@ public abstract class SessionTestsBase Mocker = new SessionMocker(this.key) { - PlacementPolicy = new PlacementPolicy(true, new Replica(1)), - Version = new ModelsV2.Version(2, 13) + PlacementPolicy = new FrostFsPlacementPolicy(true, new FrostFsReplica(1)), + Version = new FrostFsVersion(2, 13) }; } diff --git a/src/FrostFS.SDK.Tests/SmokeTests.cs b/src/FrostFS.SDK.Tests/SmokeTests.cs index 819118c..29ca2ab 100644 --- a/src/FrostFS.SDK.Tests/SmokeTests.cs +++ b/src/FrostFS.SDK.Tests/SmokeTests.cs @@ -1,9 +1,6 @@ using System.Security.Cryptography; using FrostFS.SDK.ClientV2; using FrostFS.SDK.ClientV2.Interfaces; -using FrostFS.SDK.ModelsV2; -using FrostFS.SDK.ModelsV2.Enums; -using FrostFS.SDK.ModelsV2.Netmap; using FrostFS.SDK.Cryptography; using Grpc.Core; @@ -26,7 +23,7 @@ public abstract class SmokeTestsBase protected OwnerId OwnerId { get; } - protected ModelsV2.Version Version { get; } + protected FrostFsVersion Version { get; } protected Context Ctx { get; } @@ -34,7 +31,7 @@ public abstract class SmokeTestsBase { Key = key.LoadWif(); OwnerId = OwnerId.FromKey(Key); - Version = new ModelsV2.Version(2, 13); + Version = new FrostFsVersion(2, 13); Ctx = new Context { Key = Key, OwnerId = OwnerId, Version = Version }; } @@ -134,7 +131,7 @@ public class SmokeTests : SmokeTestsBase var token = await client.CreateSessionAsync(new PrmSessionCreate(int.MaxValue)); var createContainerParam = new PrmContainerCreate( - new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1)))); + new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1)))); createContainerParam.XHeaders.Add("key1", "value1"); @@ -146,7 +143,7 @@ public class SmokeTests : SmokeTestsBase { Header = new ObjectHeader( containerId: containerId, - type: ModelsV2.Enums.ObjectType.Regular, + type: FrostFsObjectType.Regular, new ObjectAttribute("fileName", "test")), Payload = new MemoryStream(bytes), ClientCut = false, @@ -179,7 +176,7 @@ public class SmokeTests : SmokeTestsBase await Cleanup(client); var createContainerParam = new PrmContainerCreate( - new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1)))) + new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1)))) { WaitParams = lightWait }; @@ -190,7 +187,7 @@ public class SmokeTests : SmokeTestsBase var ParentHeader = new ObjectHeader( containerId: containerId, - type: ModelsV2.Enums.ObjectType.Regular) + type: FrostFsObjectType.Regular) { PayloadLength = 3 }; @@ -199,7 +196,7 @@ public class SmokeTests : SmokeTestsBase { Header = new ObjectHeader( containerId: containerId, - type: ModelsV2.Enums.ObjectType.Regular, + type: FrostFsObjectType.Regular, new ObjectAttribute("fileName", "test")) { Split = new Split(), @@ -216,25 +213,25 @@ public class SmokeTests : SmokeTestsBase var networkInfo = await client.GetNetmapSnapshotAsync(); - await CheckFilter(client, containerId, new FilterByContainerId(ObjectMatchType.Equals, containerId)); + await CheckFilter(client, containerId, new FilterByContainerId(FrostFsObjectMatchType.Equals, containerId)); - await CheckFilter(client, containerId, new FilterByOwnerId(ObjectMatchType.Equals, OwnerId.FromKey(ecdsaKey))); + await CheckFilter(client, containerId, new FilterByOwnerId(FrostFsObjectMatchType.Equals, OwnerId.FromKey(ecdsaKey))); - await CheckFilter(client, containerId, new FilterBySplitId(ObjectMatchType.Equals, param.Header.Split.SplitId)); + await CheckFilter(client, containerId, new FilterBySplitId(FrostFsObjectMatchType.Equals, param.Header.Split.SplitId)); - await CheckFilter(client, containerId, new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test")); + await CheckFilter(client, containerId, new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test")); - await CheckFilter(client, containerId, new FilterByObjectId(ObjectMatchType.Equals, objectId)); + await CheckFilter(client, containerId, new FilterByObjectId(FrostFsObjectMatchType.Equals, objectId)); - await CheckFilter(client, containerId, new FilterByVersion(ObjectMatchType.Equals, networkInfo.NodeInfoCollection[0].Version)); + await CheckFilter(client, containerId, new FilterByVersion(FrostFsObjectMatchType.Equals, networkInfo.NodeInfoCollection[0].Version)); - await CheckFilter(client, containerId, new FilterByEpoch(ObjectMatchType.Equals, networkInfo.Epoch)); + await CheckFilter(client, containerId, new FilterByEpoch(FrostFsObjectMatchType.Equals, networkInfo.Epoch)); - await CheckFilter(client, containerId, new FilterByPayloadLength(ObjectMatchType.Equals, 3)); + await CheckFilter(client, containerId, new FilterByPayloadLength(FrostFsObjectMatchType.Equals, 3)); var checkSum = CheckSum.CreateCheckSum(bytes); - await CheckFilter(client, containerId, new FilterByPayloadHash(ObjectMatchType.Equals, checkSum)); + await CheckFilter(client, containerId, new FilterByPayloadHash(FrostFsObjectMatchType.Equals, checkSum)); await CheckFilter(client, containerId, new FilterByPhysicallyStored()); } @@ -276,7 +273,7 @@ public class SmokeTests : SmokeTestsBase }; var createContainerParam = new PrmContainerCreate( - new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1)))) + new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1)))) { Context = ctx }; @@ -293,7 +290,7 @@ public class SmokeTests : SmokeTestsBase { Header = new ObjectHeader( containerId: containerId, - type: ModelsV2.Enums.ObjectType.Regular, + type: FrostFsObjectType.Regular, new ObjectAttribute("fileName", "test")), Payload = new MemoryStream(bytes), ClientCut = false, @@ -305,7 +302,7 @@ public class SmokeTests : SmokeTestsBase var objectId = await client.PutObjectAsync(param); - var filter = new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test"); + var filter = new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test"); bool hasObject = false; await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId) { Filters = [filter] })) @@ -361,7 +358,7 @@ public class SmokeTests : SmokeTestsBase }; var createContainerParam = new PrmContainerCreate( - new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1)))) + new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1)))) { Context = ctx }; @@ -377,7 +374,7 @@ public class SmokeTests : SmokeTestsBase { Header = new ObjectHeader( containerId: containerId, - type: ModelsV2.Enums.ObjectType.Regular, + type: FrostFsObjectType.Regular, new ObjectAttribute("fileName", "test")), Payload = new MemoryStream(bytes), ClientCut = false, @@ -390,7 +387,7 @@ public class SmokeTests : SmokeTestsBase var objectId = await client.PutObjectAsync(param); - var filter = new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test"); + var filter = new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test"); bool hasObject = false; await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId) { Filters = [filter], SessionToken = token })) @@ -440,7 +437,7 @@ public class SmokeTests : SmokeTestsBase await Cleanup(client); - var createContainerParam = new PrmContainerCreate(new ModelsV2.Container(BasicAcl.PublicRW, new PlacementPolicy(true, new Replica(1)))) + var createContainerParam = new PrmContainerCreate(new FrostFsContainer(BasicAcl.PublicRW, new FrostFsPlacementPolicy(true, new FrostFsReplica(1)))) { WaitParams = lightWait }; @@ -463,7 +460,7 @@ public class SmokeTests : SmokeTestsBase { Header = new ObjectHeader( containerId: containerId, - type: ModelsV2.Enums.ObjectType.Regular, + type: FrostFsObjectType.Regular, new ObjectAttribute("fileName", "test")), Payload = new MemoryStream(bytes), ClientCut = true @@ -471,7 +468,7 @@ public class SmokeTests : SmokeTestsBase var objectId = await client.PutObjectAsync(param); - var filter = new FilterByAttribute(ObjectMatchType.Equals, "fileName", "test"); + var filter = new FilterByAttribute(FrostFsObjectMatchType.Equals, "fileName", "test"); bool hasObject = false; await foreach (var objId in client.SearchObjectsAsync(new PrmObjectSearch(containerId, filter)))