Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : created interfaces #10

Merged
merged 15 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Oras/Exceptions/AlreadyExistsException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
/// <summary>
/// AlreadyExistsException is thrown when a resource already exists.
/// </summary>
public class AlreadyExistsException : Exception
{
public AlreadyExistsException()
{
}

public AlreadyExistsException(string message)
: base(message)
{
}

public AlreadyExistsException(string message, Exception inner)
: base(message, inner)
{
}
}
}
26 changes: 26 additions & 0 deletions Oras/Exceptions/InvalidDigestException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
/// <summary>
/// InvalidDigestException is thrown when a digest is invalid.
/// </summary>
public class InvalidDigestException : Exception
{
public InvalidDigestException()
{
}

public InvalidDigestException(string message)
: base(message)
{
}

public InvalidDigestException(string message, Exception inner)
: base(message, inner)
{
}
}
}
26 changes: 26 additions & 0 deletions Oras/Exceptions/InvalidReferenceException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
/// <summary>
/// InvalidReferenceException is thrown when the reference is invlid
/// </summary>
public class InvalidReferenceException : Exception
{
public InvalidReferenceException()
{
}

public InvalidReferenceException(string message)
: base(message)
{
}

public InvalidReferenceException(string message, Exception inner)
: base(message, inner)
{
}
}
}
26 changes: 26 additions & 0 deletions Oras/Exceptions/MissingReferenceException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
/// <summary>
/// MissingReferenceException is thrown when a reference is missing.
/// </summary>
public class MissingReferenceException : Exception
{
public MissingReferenceException()
{
}

public MissingReferenceException(string message)
: base(message)
{
}

public MissingReferenceException(string message, Exception inner)
: base(message, inner)
{
}
}
}
26 changes: 26 additions & 0 deletions Oras/Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
/// <summary>
/// NotFoundException is thrown when a resource is not found.
/// </summary>
public class NotFoundException : Exception
{
public NotFoundException()
{
}

public NotFoundException(string message)
: base(message)
{
}

public NotFoundException(string message, Exception inner)
: base(message, inner)
{
}
}
}
26 changes: 26 additions & 0 deletions Oras/Exceptions/SizeExceedsLimitException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
/// <summary>
/// SizeExceedsLimitException is thrown when a size exceeds the limit.
/// </summary>
public class SizeExceedsLimitException : Exception
{
public SizeExceedsLimitException()
{
}

public SizeExceedsLimitException(string message)
: base(message)
{
}

public SizeExceedsLimitException(string message, Exception inner)
: base(message, inner)
{
}
}
}
26 changes: 26 additions & 0 deletions Oras/Exceptions/UnsupportedException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
/// <summary>
/// UnsupportedException is thrown when a feature is not supported.
/// </summary>
public class UnsupportedException : Exception
{
public UnsupportedException()
{
}

public UnsupportedException(string message)
: base(message)
{
}

public UnsupportedException(string message, Exception inner)
: base(message, inner)
{
}
}
}
26 changes: 26 additions & 0 deletions Oras/Exceptions/UnsupportedVersionException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Exceptions
{
public class UnsupportedVersionException : Exception
{
/// <summary>
/// UnsupportedVersionException is thrown when a version is not supported
/// </summary>
public UnsupportedVersionException()
{
}

public UnsupportedVersionException(string message)
: base(message)
{
}

public UnsupportedVersionException(string message, Exception inner)
: base(message, inner)
{
}
}
}
29 changes: 29 additions & 0 deletions Oras/Interfaces/IReadOnlyStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Oras.Models;
using System.Threading;
using System.IO;
using System.Threading.Tasks;

namespace Oras.Interfaces
{
/// <summary>
/// IReadOnlyStorage represents a read-only Storage.
/// </summary>
public interface IReadOnlyStorage
{
/// <summary>
/// ExistsAsync returns true if the described content exists.
/// </summary>
/// <param name="target"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<bool> ExistsAsync(Descriptor target, CancellationToken cancellationToken = default);

/// <summary>
/// FetchAsync fetches the content identified by the descriptor.
/// </summary>
/// <param name="target"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Stream> FetchAsync(Descriptor target, CancellationToken cancellationToken = default);
}
}
13 changes: 13 additions & 0 deletions Oras/Interfaces/IReadOnlyTarget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Interfaces
{
/// <summary>
/// IReadOnlyTarget represents a read-only Target.
/// </summary>
public interface IReadOnlyTarget : IReadOnlyStorage, IResolver
{
}
}
23 changes: 23 additions & 0 deletions Oras/Interfaces/IResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Oras.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Oras.Interfaces
{
/// <summary>
/// IResolver resolves reference tags.
/// </summary>
public interface IResolver
{
/// <summary>
/// ResolveAsync resolves the reference to a descriptor.
/// </summary>
/// <param name="reference"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<Descriptor> ResolveAsync(string reference, CancellationToken cancellationToken = default);
}
}
28 changes: 28 additions & 0 deletions Oras/Interfaces/IStorage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Oras.Models;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Oras.Interfaces
{
/// <summary>
/// IStorage represents a content-addressable storage (CAS) where contents are accessed via Descriptors.
/// The storage is designed to handle blobs of large sizes.
/// </summary>
public interface IStorage : IReadOnlyStorage
{
/// <summary>
/// PushAsync pushes the content, matching the expected descriptor.
/// </summary>
/// <param name="expected"></param>
/// <param name="content"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task PushAsync(Descriptor expected, Stream content, CancellationToken cancellationToken = default);
}

}
25 changes: 25 additions & 0 deletions Oras/Interfaces/ITagResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Oras.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using Oras.Models;

namespace Oras.Interfaces
{
/// <summary>
/// ITagResolver provides reference tag indexing services.
/// </summary>
public interface ITagResolver : IResolver
{
/// <summary>
/// TagAsync tags the descriptor with the reference.
/// </summary>
/// <param name="descriptor"></param>
/// <param name="reference"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task TagAsync(Descriptor descriptor, string reference, CancellationToken cancellationToken = default);
}
}
13 changes: 13 additions & 0 deletions Oras/Interfaces/ITarget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Oras.Interfaces
{
/// <summary>
/// Target is a CAS with generic tags
/// </summary>
public interface ITarget : IStorage, ITagResolver
{
}
}
Loading