mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
Start of blob api
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class BlobsClient : ApiClient
|
||||
{
|
||||
public BlobsClient(IApiConnection apiConnection)
|
||||
: base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single Blob by SHA.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/blobs/#get-a-blob
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The SHA of the blob</param>
|
||||
/// <returns>The <see cref="Blob"/> for the specified SHA.</returns>
|
||||
public Task<Blob> Get(string owner, string name, string reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return ApiConnection.Get<Blob>(ApiUrls.Blob(owner, name, reference));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Blob
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/blobs/#create-a-blob
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="newBlob">The new Blob</param>
|
||||
/// <returns>The <see cref="Blob"/> that was just created.</returns>
|
||||
public Task<Blob> Create(string owner, string name, NewBlob newBlob)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(newBlob, "newBlob");
|
||||
|
||||
return ApiConnection.Post<Blob>(ApiUrls.Blob(owner, name), newBlob);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -472,5 +472,30 @@ namespace Octokit
|
||||
{
|
||||
return "users/{0}/events/orgs/{1}".FormatUri(user, organization);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for a specifc blob.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the blob</param>
|
||||
/// <param name="name">The name of the organization</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Blob(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/git/blobs/{2}".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for a specifc blob.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the blob</param>
|
||||
/// <param name="name">The name of the organization</param>
|
||||
/// <param name="reference">The SHA of the blob</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Blob(string owner, string name, string reference)
|
||||
{
|
||||
var uri = Blob(owner, name).ToString();
|
||||
uri += string.Format("/{0}", reference);
|
||||
return uri.FormatUri();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Octokit
|
||||
{
|
||||
public class NewBlob
|
||||
{
|
||||
/// <summary>
|
||||
/// The content of the blob.
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The encoding of the blob.
|
||||
/// </summary>
|
||||
public string Encoding { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace Octokit
|
||||
{
|
||||
public class Blob
|
||||
{
|
||||
/// <summary>
|
||||
/// The content of the blob.
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The encoding of the blob.
|
||||
/// </summary>
|
||||
public string Encoding { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The SHA of the blob.
|
||||
/// </summary>
|
||||
public string Sha { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The size of the blob.
|
||||
/// </summary>
|
||||
public int Size { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,9 @@
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Clients\ActivitiesClient.cs" />
|
||||
<Compile Include="Models\Request\NewBlob.cs" />
|
||||
<Compile Include="Models\Response\Blob.cs" />
|
||||
<Compile Include="Clients\BlobsClient.cs" />
|
||||
<Compile Include="Clients\EventsClient.cs" />
|
||||
<Compile Include="Clients\IActivitiesClient.cs" />
|
||||
<Compile Include="Models\Response\Activity.cs" />
|
||||
|
||||
Reference in New Issue
Block a user