예제 #1
0
        /// <summary>
        /// Check if a repository is watched 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> CheckWatched(string owner, string name)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            try
            {
                var subscription = await ApiConnection.Get <Subscription>(ApiUrls.Watched(owner, name))
                                   .ConfigureAwait(false);

                return(subscription != null);
            }
            catch (NotFoundException)
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Gets whether the user with the given <paramref name="login"/>
        /// is a member of the team with the given <paramref name="id"/>.
        /// </summary>
        /// <param name="id">The team to check.</param>
        /// <param name="login">The user to check.</param>
        /// <returns>A <see cref="TeamMembership"/> result indicating the membership status</returns>
        public async Task <TeamMembership> GetMembership(int id, string login)
        {
            var endpoint = ApiUrls.TeamMember(id, login);

            Dictionary <string, string> response;

            try
            {
                response = await ApiConnection.Get <Dictionary <string, string> >(endpoint);
            }
            catch (NotFoundException)
            {
                return(TeamMembership.NotFound);
            }

            return(response["state"] == "active"
                ? TeamMembership.Active
                : TeamMembership.Pending);
        }
예제 #3
0
        /// <summary>
        /// Gets whether the user with the given <paramref name="login"/>
        /// is a member of the team with the given <paramref name="id"/>.
        /// </summary>
        /// <param name="id">The team to check.</param>
        /// <param name="login">The user to check.</param>
        /// <returns>A <see cref="TeamMembership"/> result indicating the membership status</returns>
        public async Task <TeamMembership> GetMembership(int id, string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");

            var endpoint = ApiUrls.TeamMember(id, login);

            Dictionary <string, string> response;

            try
            {
                response = await ApiConnection.Get <Dictionary <string, string> >(endpoint).ConfigureAwait(false);
            }
            catch (NotFoundException)
            {
                return(TeamMembership.NotFound);
            }

            return(response["state"] == "active"
                ? TeamMembership.Active
                : TeamMembership.Pending);
        }
예제 #4
0
        /// <summary>
        /// Gets the specified <see cref="ReleaseAsset"/> for the specified release of the specified repository.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/releases/#get-a-single-release-asset">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="assetId">The id of the <see cref="ReleaseAsset"/></param>
        public Task <ReleaseAsset> GetAsset(long repositoryId, int assetId)
        {
            var endpoint = ApiUrls.Asset(repositoryId, assetId);

            return(ApiConnection.Get <ReleaseAsset>(endpoint));
        }
예제 #5
0
        /// <summary>
        /// Returns the user specified by the login.
        /// </summary>
        /// <param name="login">The login name for the user</param>
        public Task <User> Get(string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");

            return(ApiConnection.Get <User>(ApiUrls.User(login)));
        }
 /// <summary>
 /// Gets a single Repository Comment by number.
 /// </summary>
 /// <param name="repositoryId">The ID of the repository</param>
 /// <param name="number">The comment id</param>
 /// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
 public Task <CommitComment> Get(int repositoryId, int number)
 {
     return(ApiConnection.Get <CommitComment>(ApiUrls.CommitComment(repositoryId, number)));
 }
예제 #7
0
 /// <summary>
 /// Gets a gist
 /// </summary>
 /// <remarks>
 /// http://developer.github.com/v3/gists/#get-a-single-gist
 /// </remarks>
 /// <param name="id">The id of the gist</param>
 public Task <Gist> Get(string id)
 {
     return(ApiConnection.Get <Gist>(ApiUrls.Gist(id)));
 }
예제 #8
0
 public Task <PullRequest> Get(long repositoryId, int number)
 {
     return(ApiConnection.Get <PullRequest>(ApiUrls.PullRequest(repositoryId, number), null, AcceptHeaders.DraftPullRequestApiPreview));
 }
 /// <summary>
 /// Gets the page metadata for a given repository
 /// </summary>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <remarks>
 /// See the <a href="https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site">API documentation</a> for more information.
 /// </remarks>
 public Task <Page> Get(int repositoryId)
 {
     return(ApiConnection.Get <Page>(ApiUrls.RepositoryPage(repositoryId)));
 }
예제 #10
0
        /// <summary>
        /// Gets a single Label by name.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/issues/labels/#get-a-single-label">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="labelName">The name of the label</param>
        public Task <Label> Get(long repositoryId, string labelName)
        {
            Ensure.ArgumentNotNullOrEmptyString(labelName, "labelName");

            return(ApiConnection.Get <Label>(ApiUrls.Label(repositoryId, labelName)));
        }
예제 #11
0
        public Task <Label> Get(long repositoryId, string labelName)
        {
            Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName));

            return(ApiConnection.Get <Label>(ApiUrls.Label(repositoryId, labelName), null, AcceptHeaders.LabelsApiPreview));
        }
예제 #12
0
        /// <summary>
        /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or
        /// a tag name.
        /// </summary>
        /// <remarks>
        /// https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The reference (SHA, branch name, or tag name) to list commits for</param>
        public Task <CombinedCommitStatus> GetCombined(long repositoryId, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");

            return(ApiConnection.Get <CombinedCommitStatus>(ApiUrls.CombinedCommitStatus(repositoryId, reference)));
        }
예제 #13
0
        /// <summary>
        /// Gets a Tree Response for a given SHA.
        /// </summary>
        /// <remarks>
        /// https://developer.github.com/v3/git/trees/#get-a-tree-recursively
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The SHA that references the tree</param>
        public Task <TreeResponse> GetRecursive(long repositoryId, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");

            return(ApiConnection.Get <TreeResponse>(ApiUrls.TreeRecursive(repositoryId, reference)));
        }
예제 #14
0
        /// <summary>
        /// Get the total number of views and breakdown per day or week for the last 14 days
        /// </summary>
        /// <remarks>https://developer.github.com/v3/repos/traffic/#views</remarks>
        /// <param name="repositoryId">The owner of the repository</param>
        /// <param name="per">Breakdown per day or week</param>
        public Task <RepositoryTrafficViewSummary> GetViews(long repositoryId, RepositoryTrafficRequest per)
        {
            Ensure.ArgumentNotNull(per, "per");

            return(ApiConnection.Get <RepositoryTrafficViewSummary>(ApiUrls.RepositoryTrafficViews(repositoryId), per.ToParametersDictionary(), AcceptHeaders.RepositoryTrafficApiPreview));
        }
예제 #15
0
 public Task <SearchLabelsResult> SearchLabels(SearchLabelsRequest search)
 {
     Ensure.ArgumentNotNull(search, nameof(search));
     return(ApiConnection.Get <SearchLabelsResult>(ApiUrls.SearchLabels(), search.Parameters));
 }
예제 #16
0
        /// <summary>
        /// Gets a reference for a given repository by reference name
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/git/refs/#get-a-reference
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The name of the reference</param>
        /// <returns></returns>
        public Task <Reference> Get(long repositoryId, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");

            return(ApiConnection.Get <Reference>(ApiUrls.Reference(repositoryId, reference)));
        }
 /// <summary>
 /// Gets the build metadata for the last build for a given repository
 /// </summary>
 /// <param name="repositoryId">The Id of the repository</param>
 ///  <remarks>
 /// See the <a href="https://developer.github.com/v3/repos/pages/#list-latest-pages-build">API documentation</a> for more information.
 /// </remarks>
 public Task <PagesBuild> GetLatest(int repositoryId)
 {
     return(ApiConnection.Get <PagesBuild>(ApiUrls.RepositoryPageBuildsLatest(repositoryId)));
 }
예제 #18
0
        public Task <GitTag> Get(long repositoryId, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));

            return(ApiConnection.Get <GitTag>(ApiUrls.Tag(repositoryId, reference)));
        }
예제 #19
0
        /// <summary>
        /// Gets a single Blob by SHA.
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/git/blobs/#get-a-blob
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The SHA of the blob</param>
        public Task <Blob> Get(int repositoryId, string reference)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");

            return(ApiConnection.Get <Blob>(ApiUrls.Blob(repositoryId, reference)));
        }
예제 #20
0
        public Task <PullRequestReview> Get(long repositoryId, int number, long reviewId)
        {
            var endpoint = ApiUrls.PullRequestReview(repositoryId, number, reviewId);

            return(ApiConnection.Get <PullRequestReview>(endpoint));
        }
예제 #21
0
 /// <summary>
 /// Gets a single Issue Comment by id.
 /// </summary>
 /// <remarks>http://developer.github.com/v3/issues/comments/#get-a-single-comment</remarks>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <param name="id">The issue comment id</param>
 public Task <IssueComment> Get(long repositoryId, int id)
 {
     return(ApiConnection.Get <IssueComment>(ApiUrls.IssueComment(repositoryId, id), null, AcceptHeaders.ReactionsPreview));
 }
예제 #22
0
 public Task <Milestone> Get(long repositoryId, int number)
 {
     return(ApiConnection.Get <Milestone>(ApiUrls.Milestone(repositoryId, number)));
 }
예제 #23
0
 public Task <ProjectColumn> Get(int id)
 {
     return(ApiConnection.Get <ProjectColumn>(ApiUrls.ProjectColumn(id), null, AcceptHeaders.ProjectsApiPreview));
 }
예제 #24
0
 /// <summary>
 /// Gets a specific <see cref="Authorization"/> for the authenticated user.
 /// </summary>
 /// <remarks>
 /// This method requires authentication.
 /// See the <a href="http://developer.github.com/v3/oauth/#get-a-single-authorization">API documentation</a> for more information.
 /// </remarks>
 /// <param name="id">The ID of the <see cref="Authorization"/> to get</param>
 /// <exception cref="AuthorizationException">
 /// Thrown when the current user does not have permission to make this request.
 /// </exception>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 /// <returns>The specified <see cref="Authorization"/>.</returns>
 public Task <Authorization> Get(int id)
 {
     return(ApiConnection.Get <Authorization>(ApiUrls.Authorizations(id), null));
 }
예제 #25
0
        /// <summary>
        /// Gets a single <see cref="Team"/> by identifier.
        /// </summary>
        /// <remarks>
        /// https://developer.github.com/v3/orgs/teams/#get-team
        /// </remarks>
        /// <param name="id">The team identifier.</param>
        /// <returns>The <see cref="Team"/> with the given identifier.</returns>
        public Task <Team> Get(int id)
        {
            var endpoint = ApiUrls.Teams(id);

            return(ApiConnection.Get <Team>(endpoint));
        }
예제 #26
0
 /// <summary>
 /// Retrieves the <see cref="PublicKey"/> for the specified id.
 /// </summary>
 /// <remarks>
 /// https://developer.github.com/v3/users/keys/#get-a-single-public-key
 /// </remarks>
 /// <param name="id">The Id of the SSH key</param>
 /// <returns></returns>
 public Task <PublicKey> Get(int id)
 {
     return(ApiConnection.Get <PublicKey>(ApiUrls.Keys(id)));
 }
예제 #27
0
        /// <summary>
        /// Returns the specified <see cref="Organization"/>.
        /// </summary>
        /// <param name="org">login of the organization to get</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>The specified <see cref="Organization"/>.</returns>
        public Task <Organization> Get(string org)
        {
            Ensure.ArgumentNotNullOrEmptyString(org, "org");

            return(ApiConnection.Get <Organization>(ApiUrls.Organization(org)));
        }
예제 #28
0
 /// <summary>
 /// Gets a single Issue by number.
 /// </summary>
 /// <remarks>
 /// http://developer.github.com/v3/issues/#get-a-single-issue
 /// </remarks>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <param name="number">The issue number</param>
 public Task <Issue> Get(int repositoryId, int number)
 {
     return(ApiConnection.Get <Issue>(ApiUrls.Issue(repositoryId, number), null, AcceptHeaders.ReactionsPreview));
 }
예제 #29
0
 /// <summary>
 /// Returns a <see cref="User"/> for the current authenticated user.
 /// </summary>
 /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
 /// <returns>A <see cref="User"/></returns>
 public Task <User> Current()
 {
     return(ApiConnection.Get <User>(_userEndpoint));
 }
예제 #30
0
 /// <summary>
 /// Get a single deploy key by number for a repository.
 /// </summary>
 /// <remarks>
 /// See the <a href="https://developer.github.com/v3/repos/keys/#get"> API documentation</a> for more information.
 /// </remarks>
 /// <param name="repositoryId">The Id of the repository.</param>
 /// <param name="number">The id of the deploy key.</param>
 public Task <DeployKey> Get(int repositoryId, int number)
 {
     return(ApiConnection.Get <DeployKey>(ApiUrls.RepositoryDeployKey(repositoryId, number)));
 }