public async Task <byte[]> GetArchive(string org, int id) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); var endpoint = ApiUrls.EnterpriseMigrationArchive(org, id); var response = await Connection.Get <byte[]>(endpoint, null, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false); return(response.Body); }
/// <summary> /// Get an archive of a given repository's contents, using a specific format and reference /// </summary> /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param> /// <param name="reference">A valid Git reference.</param> /// <returns>The binary contents of the archive</returns> public async Task <byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference); var response = await Connection.Get <byte[]>(endpoint, TimeSpan.FromMinutes(60)); return(response.Body); }
/// <summary> /// Get an archive of a given repository's contents, in a specific format /// </summary> /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param> /// <param name="reference">A valid Git reference.</param> /// <param name="timeout"> Time span until timeout </param> public async Task <byte[]> GetArchive(int repositoryId, ArchiveFormat archiveFormat, string reference, TimeSpan timeout) { Ensure.ArgumentNotNull(reference, "reference"); Ensure.GreaterThanZero(timeout, "timeout"); var endpoint = ApiUrls.RepositoryArchiveLink(repositoryId, archiveFormat, reference); var response = await Connection.Get <byte[]>(endpoint, timeout).ConfigureAwait(false); return(response.Body); }
/// <summary> /// Get an archive of a given repository's contents, in a specific format /// </summary> /// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param> /// <param name="reference">A valid Git reference.</param> /// <param name="timeout"> Time span until timeout </param> /// <returns>The binary contents of the archive</returns> public async Task <byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.GreaterThanZero(timeout, "timeout"); var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference); var response = await Connection.Get <byte[]>(endpoint, timeout); return(response.Body); }
public async Task <bool> Merged(long repositoryId, int number) { try { var endpoint = ApiUrls.MergePullRequest(repositoryId, number); var response = await Connection.Get <object>(endpoint, null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
public async Task <bool> IsStarred(string id) { Ensure.ArgumentNotNullOrEmptyString(id, nameof(id)); try { var response = await Connection.Get <object>(ApiUrls.StarGist(id), null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
public async Task <bool> CheckAssignee(long repositoryId, string assignee) { Ensure.ArgumentNotNullOrEmptyString(assignee, nameof(assignee)); try { var response = await Connection.Get <object>(ApiUrls.CheckAssignee(repositoryId, assignee), null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
public async Task <bool> IsFollowingForCurrent(string following) { Ensure.ArgumentNotNullOrEmptyString(following, nameof(following)); try { var response = await Connection.Get <object>(ApiUrls.IsFollowing(following), null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
/// <summary> /// Checks if a user is a collaborator on a repository. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The id of the repository</param> /// <param name="user">Username of the prospective collaborator</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public async Task <bool> IsCollaborator(long repositoryId, string user) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); try { var response = await Connection.Get <object>(ApiUrls.RepoCollaborator(repositoryId, user), null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
/// <summary> /// Check if a repository is starred by the current authenticated user. /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <c>bool</c> representing the success of the operation</returns> public async Task <bool> CheckStarred(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); try { var response = await Connection.Get <object>(ApiUrls.Starred(owner, name), null, null).ConfigureAwait(false); return(response.HttpResponse.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Check is a user is publicly a member of the organization. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/orgs/members/#check-public-membership">API documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> /// <param name="user">The login for the user</param> /// <returns></returns> public async Task <bool> CheckMemberPublic(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); try { var response = await Connection.Get <object>(ApiUrls.CheckMemberPublic(org, user), null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
public async Task <bool> Merged(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); try { var endpoint = ApiUrls.MergePullRequest(owner, name, number); var response = await Connection.Get <object>(endpoint, null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
/// <summary> /// Checks to see if a user is an assignee for a repository. /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="assignee">Username of the prospective assignee</param> public async Task <bool> CheckAssignee(string owner, string name, string assignee) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(assignee, "assignee"); try { var response = await Connection.Get <object>(ApiUrls.CheckAssignee(owner, name, assignee), null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
/// <summary> /// Checks if a user is a collaborator on a repository. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information. /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="user">Username of the prospective collaborator</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public async Task <bool> IsCollaborator(string owner, string name, string user) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); try { var response = await Connection.Get <object>(ApiUrls.RepoCollaborator(owner, name, user), null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
/// <summary> /// Checks if a user is a collaborator on a repo /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information. /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns><see cref="bool"/>True if user is a collaborator else false</returns> public async Task <bool> IsCollaborator(string owner, string repo, string user) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repo, "repo"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); var endpoint = "repos/{0}/{1}/collaborators/{2}".FormatUri(owner, repo, user); try { var response = await Connection.Get <object>(endpoint, null, null).ConfigureAwait(false); return(response.HttpResponse.IsTrue()); } catch (NotFoundException) { return(false); } }
/// <summary> /// Check if the authenticated user follows another user /// </summary> /// <param name="following">The login name of the other user</param> /// <remarks> /// See the <a href="http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user">API documentation</a> for more information. /// </remarks> /// <returns>A <c>bool</c> representing the success of the operation.</returns> public async Task <bool> IsFollowingForCurrent(string following) { Ensure.ArgumentNotNullOrEmptyString(following, "following"); try { var response = await Connection.Get <object>(ApiUrls.IsFollowing(following), null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode); } return(response.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Checks to see if a user is an assignee for a repository. /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="assignee">Username of the prospective assignee</param> /// <returns></returns> public async Task <bool> CheckAssignee(string owner, string name, string assignee) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(assignee, "assignee"); try { var response = await Connection.Get <object>(ApiUrls.CheckAssignee(owner, name, assignee), null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode); } return(response.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Get the pull request merge status. /// </summary> /// <remarks>http://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The pull request number</param> /// <returns>True if the operation has been merged, false otherwise</returns> public async Task <bool> Merged(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); try { var response = await Connection.Get <object>(ApiUrls.MergePullRequest(owner, name, number), null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204 or 404", response.StatusCode); } return(response.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Check is a user is publicly a member of the organization. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/orgs/members/#check-public-membership">API documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> /// <param name="user">The login for the user</param> /// <returns></returns> public async Task <bool> CheckMemberPublic(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); try { var response = await Connection.Get <object>(ApiUrls.CheckMemberPublic(org, user), null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode); } return(response.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
public async Task <bool> CheckMember(string org, string user) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); try { var response = await Connection.Get <object>(ApiUrls.CheckMember(org, user), null, null).ConfigureAwait(false); var statusCode = response.HttpResponse.StatusCode; if (statusCode != HttpStatusCode.NotFound && statusCode != HttpStatusCode.NoContent && statusCode != HttpStatusCode.Found) { throw new ApiException("Invalid Status Code returned. Expected a 204, a 302 or a 404", statusCode); } return(statusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Checks if a user is a collaborator on a repo /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information. /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns><see cref="bool"/>True if user is a collaborator else false</returns> public async Task <bool> IsCollaborator(string owner, string repo, string user) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repo, "repo"); Ensure.ArgumentNotNullOrEmptyString(user, "user"); var endpoint = "repos/{0}/{1}/collaborators/{2}".FormatUri(owner, repo, user); try { var response = await Connection.Get <object>(endpoint, null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode); } return(response.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }