[#26] All: Remove V2 from naming
All checks were successful
DCO / DCO (pull_request) Successful in 47s
lint-build / dotnet8.0 (pull_request) Successful in 47s
lint-build / dotnet8.0 (push) Successful in 1m0s

Rename project, namespaces and class names

Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
Pavel Gross 2024-11-18 11:11:17 +03:00
parent c406df1a78
commit 766f61a5f7
219 changed files with 219 additions and 974 deletions

View file

@ -0,0 +1,45 @@
using System;
using System.Collections.ObjectModel;
using System.Security.Cryptography;
using System.Threading;
using FrostFS.SDK.Cryptography;
using Google.Protobuf;
using Grpc.Core.Interceptors;
namespace FrostFS.SDK.Client;
public class CallContext()
{
private ByteString? publicKeyCache;
internal Action<Exception>? PoolErrorHandler { get; set; }
public ECDsa? Key { get; set; }
public FrostFsOwner? OwnerId { get; set; }
public FrostFsVersion? Version { get; set; }
public CancellationToken CancellationToken { get; set; }
public TimeSpan Timeout { get; set; }
public DateTime? Deadline => Timeout.Ticks > 0 ? DateTime.UtcNow.Add(Timeout) : null;
public Action<CallStatistics>? Callback { get; set; }
public Collection<Interceptor> Interceptors { get; } = [];
public ByteString? GetPublicKeyCache()
{
if (publicKeyCache == null && Key != null)
{
publicKeyCache = ByteString.CopyFrom(Key.PublicKey());
}
return publicKeyCache;
}
}

View file

@ -0,0 +1,10 @@
using System.Security.Cryptography;
namespace FrostFS.SDK.Client;
public class Credentials(ECDsa key, FrostFsOwner ownerId)
{
public ECDsa Key { get; } = key;
public FrostFsOwner OwnerId { get; } = ownerId;
}

View file

@ -0,0 +1,11 @@
namespace FrostFS.SDK.Client;
public interface IContext
{
/// <summary>
/// The method call can be extended with additional behavior like canceling by timeout or user's request,
/// callbacks, interceptors.
/// </summary>
/// <value>Additional parameters for calling the method</value>
CallContext? Context { get; }
}

View file

@ -0,0 +1,12 @@
namespace FrostFS.SDK.Client;
public interface ISessionToken
{
/// <summary>
/// Object represents token of the FrostFS Object session. A session is opened between any two sides of the
/// system, and implements a mechanism for transferring the power of attorney of actions to another network
/// member. The session has a limited validity period, and applies to a strictly defined set of operations.
/// </summary>
/// <value>Instance of the session obtained from the server</value>
FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,6 @@
namespace FrostFS.SDK.Client;
public sealed class PrmApeChainList(FrostFsChainTarget target, CallContext? ctx = null) : PrmBase(ctx)
{
public FrostFsChainTarget Target { get; } = target;
}

View file

@ -0,0 +1,8 @@
namespace FrostFS.SDK.Client;
public sealed class PrmApeChainRemove(FrostFsChainTarget target, FrostFsChain chain, CallContext? ctx = null) : PrmBase(ctx)
{
public FrostFsChainTarget Target { get; } = target;
public FrostFsChain Chain { get; } = chain;
}

View file

@ -0,0 +1,8 @@
namespace FrostFS.SDK.Client;
public sealed class PrmApeChainAdd(FrostFsChainTarget target, FrostFsChain chain, CallContext? ctx = null) : PrmBase(ctx)
{
public FrostFsChainTarget Target { get; } = target;
public FrostFsChain Chain { get; } = chain;
}

View file

@ -0,0 +1,5 @@
namespace FrostFS.SDK.Client;
public sealed class PrmBalance(CallContext? ctx = null) : PrmBase(ctx)
{
}

View file

@ -0,0 +1,14 @@
using System.Collections.Specialized;
namespace FrostFS.SDK.Client;
public class PrmBase(CallContext? ctx, NameValueCollection? xheaders = null) : IContext
{
/// <summary>
/// FrostFS request X-Headers
/// </summary>
public NameValueCollection XHeaders { get; } = xheaders ?? [];
/// <inheritdoc />
public CallContext Context { get; } = ctx ?? new CallContext();
}

View file

@ -0,0 +1,17 @@
namespace FrostFS.SDK.Client;
public sealed class PrmContainerCreate(FrostFsContainerInfo container, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsContainerInfo Container { get; set; } = container;
/// <summary>
/// Since the container becomes available with some delay, it needs to poll the container status
/// </summary>
/// <value>Rules for polling the result</value>
public PrmWait? WaitParams { get; set; }
/// <summary>
/// Blank session token
/// </summary>
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,14 @@
namespace FrostFS.SDK.Client;
public sealed class PrmContainerDelete(FrostFsContainerId containerId, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsContainerId ContainerId { get; set; } = containerId;
/// <summary>
/// Since the container is removed with some delay, it needs to poll the container status
/// </summary>
/// <value>Rules for polling the result</value>
public PrmWait? WaitParams { get; set; }
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,6 @@
namespace FrostFS.SDK.Client;
public sealed class PrmContainerGet(FrostFsContainerId container, CallContext? ctx = null) : PrmBase(ctx)
{
public FrostFsContainerId Container { get; set; } = container;
}

View file

@ -0,0 +1,5 @@
namespace FrostFS.SDK.Client;
public sealed class PrmContainerGetAll(CallContext? ctx = null) : PrmBase(ctx)
{
}

View file

@ -0,0 +1,5 @@
namespace FrostFS.SDK.Client;
public sealed class PrmNetmapSnapshot(CallContext? ctx = null) : PrmBase(ctx)
{
}

View file

@ -0,0 +1,5 @@
namespace FrostFS.SDK.Client;
public sealed class PrmNetworkSettings(CallContext? ctx = null) : PrmBase(ctx)
{
}

View file

@ -0,0 +1,5 @@
namespace FrostFS.SDK.Client;
public sealed class PrmNodeInfo(CallContext? ctx = null) : PrmBase(ctx)
{
}

View file

@ -0,0 +1,11 @@
namespace FrostFS.SDK.Client;
public sealed class PrmObjectDelete(FrostFsContainerId containerId, FrostFsObjectId objectId, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsContainerId ContainerId { get; set; } = containerId;
public FrostFsObjectId ObjectId { get; set; } = objectId;
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,11 @@
namespace FrostFS.SDK.Client;
public sealed class PrmObjectGet(FrostFsContainerId containerId, FrostFsObjectId objectId, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsContainerId ContainerId { get; set; } = containerId;
public FrostFsObjectId ObjectId { get; set; } = objectId;
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,11 @@
namespace FrostFS.SDK.Client;
public sealed class PrmObjectHeadGet(FrostFsContainerId containerId, FrostFsObjectId objectId, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsContainerId ContainerId { get; set; } = containerId;
public FrostFsObjectId ObjectId { get; set; } = objectId;
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,24 @@
using System.IO;
namespace FrostFS.SDK.Client;
public sealed class PrmObjectPatch(FrostFsAddress address, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsAddress Address { get; } = address;
public FrostFsRange Range { get; set; }
/// <summary>
/// A stream with source data
/// </summary>
public Stream? Payload { get; set; }
public FrostFsAttributePair[]? NewAttributes { get; set; }
public bool ReplaceAttributes { get; set; }
public int MaxPayloadPatchChunkLength { get; set; }
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,46 @@
using System.IO;
namespace FrostFS.SDK.Client;
public sealed class PrmObjectPut(CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
/// <summary>
/// Need to provide values like <c>ContainerId</c> and <c>ObjectType</c> to create and object.
/// Optional parameters ike <c>Attributes</c> can be provided as well.
/// </summary>
/// <value>Header with required parameters to create an object</value>
public FrostFsObjectHeader? Header { get; set; }
/// <summary>
/// A stream with source data
/// </summary>
public Stream? Payload { get; set; }
/// <summary>
/// Object size is limited. In the data exceeds the limit, the object will be splitted.
/// If the parameter is <c>true</c>, the client side cut is applied. Otherwise, the data is transferred
/// as a stream and will be cut on server side.
/// </summary>
/// <value>Is client cut is applied</value>
public bool ClientCut { get; set; }
/// <summary>
/// Overrides default size of the buffer for stream transferring.
/// </summary>
/// <value>Size of the buffer</value>
public int BufferMaxSize { get; set; }
/// <summary>
/// Allows to define a buffer for chunks to manage by the memory allocation and releasing.
/// </summary>
public byte[]? CustomBuffer { get; set; }
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
internal int MaxObjectSizeCache { get; set; }
internal ulong CurrentStreamPosition { get; set; }
internal ulong FullLength { get; set; }
}

View file

@ -0,0 +1,21 @@
using System.Collections.Generic;
namespace FrostFS.SDK.Client;
public sealed class PrmObjectSearch(FrostFsContainerId containerId, CallContext? ctx = null, params IObjectFilter[] filters) : PrmBase(ctx), ISessionToken
{
/// <summary>
/// Defines container for the search
/// </summary>
/// <value></value>
public FrostFsContainerId ContainerId { get; set; } = containerId;
/// <summary>
/// Defines the search criteria
/// </summary>
/// <value>Collection of filters</value>
public IEnumerable<IObjectFilter> Filters { get; set; } = filters;
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,20 @@
namespace FrostFS.SDK.Client;
public sealed class PrmRangeGet(
FrostFsContainerId containerId,
FrostFsObjectId objectId,
FrostFsRange range,
bool raw = false,
CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsContainerId ContainerId { get; } = containerId;
public FrostFsObjectId ObjectId { get; } = objectId;
public FrostFsRange Range { get; } = range;
public bool Raw { get; } = raw;
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,20 @@
namespace FrostFS.SDK.Client;
public sealed class PrmRangeHashGet(
FrostFsContainerId containerId,
FrostFsObjectId objectId,
FrostFsRange[] ranges,
byte[] salt,
CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsContainerId ContainerId { get; } = containerId;
public FrostFsObjectId ObjectId { get; } = objectId;
public FrostFsRange[] Ranges { get; } = ranges;
public byte[] Salt { get; } = salt;
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,6 @@
namespace FrostFS.SDK.Client;
public sealed class PrmSessionCreate(ulong expiration, CallContext? ctx = null) : PrmBase(ctx)
{
public ulong Expiration { get; set; } = expiration;
}

View file

@ -0,0 +1,9 @@
namespace FrostFS.SDK.Client;
public sealed class PrmSingleObjectPut(FrostFsObject frostFsObject, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
{
public FrostFsObject FrostFsObject { get; set; } = frostFsObject;
/// <inheritdoc />
public FrostFsSessionToken? SessionToken { get; set; }
}

View file

@ -0,0 +1,24 @@
using System;
namespace FrostFS.SDK.Client;
public class PrmWait(TimeSpan timeout, TimeSpan pollInterval)
{
private static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(120);
private static TimeSpan DefaultPollInterval = TimeSpan.FromSeconds(5);
public PrmWait(int timeout, int interval) : this(TimeSpan.FromSeconds(timeout), TimeSpan.FromSeconds(interval))
{
}
public static PrmWait DefaultParams { get; } = new PrmWait(DefaultTimeout, DefaultPollInterval);
public TimeSpan Timeout { get; set; } = timeout.Ticks == 0 ? DefaultTimeout : timeout;
public TimeSpan PollInterval { get; set; } = pollInterval.Ticks == 0 ? DefaultPollInterval : pollInterval;
public DateTime GetDeadline()
{
return DateTime.UtcNow.AddTicks(Timeout.Ticks);
}
}