private static ApiConnection CreateApiConnection(string userName, string apiToken) { Credentials credentials; if (string.IsNullOrWhiteSpace(userName)) { credentials = new Credentials(apiToken); } else { credentials = new Credentials(userName, apiToken); } var connection = new Connection(new ProductHeaderValue("Cake.GitHub")) { Credentials = credentials }; var apiConnection = new Octokit.ApiConnection(connection); return(apiConnection); }
/// <summary> /// Uninstalls a GitHub App on a user, organization, or business account (requires GitHubApp auth). /// </summary> /// <remarks>https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app</remarks> /// <param name="installationId">The Id of the GitHub App Installation</param> public Task DeleteInstallationForCurrent(long installationId) { return(ApiConnection.Delete(ApiUrls.Installation(installationId))); }
/// <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)); }
/// <summary> /// Gets the latest <see cref="Release"/> for the specified repository. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/releases/#get-the-latest-release">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public Task <Release> GetLatest(long repositoryId) { var endpoint = ApiUrls.LatestRelease(repositoryId); return(ApiConnection.Get <Release>(endpoint)); }
/// <summary> /// Gets a single event /// </summary> /// <remarks> /// http://developer.github.com/v3/issues/events/#get-a-single-event /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="eventId">The event id</param> public Task <IssueEvent> Get(long repositoryId, long eventId) { return(ApiConnection.Get <IssueEvent>(ApiUrls.IssuesEvent(repositoryId, eventId), null, AcceptHeaders.IssueEventsApiPreview)); }
/// <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)); }
/// <summary> /// Gets all labels for the issue. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#list-labels-on-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The number of the issue</param> /// <param name="options">Options for changing the API response</param> public Task <IReadOnlyList <Label> > GetAllForIssue(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return(ApiConnection.GetAll <Label>(ApiUrls.IssueLabels(repositoryId, number), null, AcceptHeaders.LabelsApiPreview, options)); }
/// <summary> /// Replaces all labels on the specified issues with the provided labels /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The number of the issue</param> /// <param name="labels">The names of the labels to set</param> public Task <IReadOnlyList <Label> > ReplaceAllForIssue(long repositoryId, int number, string[] labels) { Ensure.ArgumentNotNull(labels, nameof(labels)); return(ApiConnection.Put <IReadOnlyList <Label> >(ApiUrls.IssueLabels(repositoryId, number), labels, AcceptHeaders.LabelsApiPreview)); }
/// <summary> /// Retrives a single <see cref="Notification"/> by Id. /// </summary> /// <param name="id">The Id of the notification to retrieve.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#view-a-single-thread</remarks> /// <returns>A <see cref="Notification"/> for the given Id.</returns> public Task <Notification> Get(int id) { return(ApiConnection.Get <Notification>(ApiUrls.Notification(id))); }
/// <summary> /// Marks all notifications as read. /// </summary> /// <param name="markAsReadRequest">The <see cref="MarkAsReadRequest"/> parameter which specifies which notifications to mark.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-as-read</remarks> /// <returns></returns> public Task MarkAsRead(MarkAsReadRequest markAsReadRequest) { Ensure.ArgumentNotNull(markAsReadRequest, "markAsReadRequest"); return(ApiConnection.Put <object>(ApiUrls.Notifications(), markAsReadRequest)); }
/// <summary> /// Marks all notifications as read. /// </summary> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-as-read</remarks> /// <returns></returns> public Task MarkAsRead() { return(ApiConnection.Put(ApiUrls.Notifications())); }
public Task <Installation> GetInstallationForCurrent(long installationId) { return(ApiConnection.Get <Installation>(ApiUrls.Installation(installationId), null, AcceptHeaders.GitHubAppsPreview)); }
public Task <IReadOnlyList <Installation> > GetAllInstallationsForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); return(ApiConnection.GetAll <Installation>(ApiUrls.Installations(), null, AcceptHeaders.GitHubAppsPreview, options)); }
public Task <GitHubApp> GetCurrent() { return(ApiConnection.Get <GitHubApp>(ApiUrls.App(), null, AcceptHeaders.GitHubAppsPreview)); }
public Task <GitHubApp> Get(string slug) { Ensure.ArgumentNotNullOrEmptyString(slug, nameof(slug)); return(ApiConnection.Get <GitHubApp>(ApiUrls.App(slug), null, AcceptHeaders.GitHubAppsPreview)); }
/// <summary> /// Creates a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#create-a-label">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="newLabel">The data for the label to be created</param> public Task <Label> Create(long repositoryId, NewLabel newLabel) { Ensure.ArgumentNotNull(newLabel, nameof(newLabel)); return(ApiConnection.Post <Label>(ApiUrls.Labels(repositoryId), newLabel, AcceptHeaders.LabelsApiPreview)); }
/// <summary> /// Removes a label from an issue /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The number of the issue</param> /// <param name="labelName">The name of the label to remove</param> public Task <IReadOnlyList <Label> > RemoveFromIssue(long repositoryId, int number, string labelName) { Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName)); return(ApiConnection.Delete <IReadOnlyList <Label> >(ApiUrls.IssueLabel(repositoryId, number, labelName), AcceptHeaders.LabelsApiPreview)); }
/// <summary> /// Marks a single notification as read. /// </summary> /// <param name="id">The id of the notification.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read</remarks> /// <returns></returns> public Task MarkAsRead(int id) { return(ApiConnection.Patch(ApiUrls.Notification(id))); }
/// <summary> /// Removes all labels from an issue /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The number of the issue</param> public Task RemoveAllFromIssue(long repositoryId, int number) { return(ApiConnection.Delete(ApiUrls.IssueLabels(repositoryId, number))); }
/// <summary> /// Retrives a <see cref="ThreadSubscription"/> for the provided thread id. /// </summary> /// <param name="id">The Id of the thread to retrieve subscription status.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#get-a-thread-subscription</remarks> /// <returns>A <see cref="ThreadSubscription"/> for the chosen thread.</returns> public Task <ThreadSubscription> GetThreadSubscription(int id) { return(ApiConnection.Get <ThreadSubscription>(ApiUrls.NotificationSubscription(id))); }
/// <summary> /// Delte a team - must have owner permissions to this /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> public Task Delete(int id) { var endpoint = ApiUrls.Teams(id); return(ApiConnection.Delete(endpoint)); }
/// <summary> /// Sets the authenticated user's subscription settings for a given thread. /// </summary> /// <param name="id">The Id of the thread to update.</param> /// <param name="threadSubscription">The subscription parameters to set.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#set-a-thread-subscription</remarks> /// <returns></returns> public Task <ThreadSubscription> SetThreadSubscription(int id, NewThreadSubscription threadSubscription) { Ensure.ArgumentNotNull(threadSubscription, "threadSubscription"); return(ApiConnection.Put <ThreadSubscription>(ApiUrls.NotificationSubscription(id), threadSubscription)); }
public Task <CombinedCommitStatus> GetCombined(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); return(ApiConnection.Get <CombinedCommitStatus>(ApiUrls.CombinedCommitStatus(repositoryId, reference))); }
/// <summary> /// Deletes the authenticated user's subscription to a given thread. /// </summary> /// <param name="id">The Id of the thread to delete subscription from.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#delete-a-thread-subscription</remarks> /// <returns></returns> public Task DeleteThreadSubscription(int id) { return(ApiConnection.Delete(ApiUrls.NotificationSubscription(id))); }
/// <summary> /// Gets a single <see cref="Release"/> for the specified repository. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/releases/#get-a-single-release">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="id">The id of the release</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public Task <Release> Get(long repositoryId, int id) { var endpoint = ApiUrls.Releases(repositoryId, id); return(ApiConnection.Get <Release>(endpoint)); }
/// <summary> /// Retrieves all of the <see cref="Notification"/>s for the current user. /// </summary> /// <param name="options">Options for changing the API response</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns> public Task <IReadOnlyList <Notification> > GetAllForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, "options"); return(ApiConnection.GetAll <Notification>(ApiUrls.Notifications(), options)); }
/// <summary> /// Deletes an existing <see cref="Release"/> for the specified repository. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/releases/#delete-a-release">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="id">The id of the release to delete</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public Task Delete(long repositoryId, int id) { var endpoint = ApiUrls.Releases(repositoryId, id); return(ApiConnection.Delete(endpoint)); }
/// <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, nameof(labelName)); return(ApiConnection.Get <Label>(ApiUrls.Label(repositoryId, labelName), null, AcceptHeaders.LabelsApiPreview)); }
/// <summary> /// Deletes a label. /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#delete-a-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 Delete(long repositoryId, string labelName) { Ensure.ArgumentNotNullOrEmptyString(labelName, nameof(labelName)); return(ApiConnection.Delete(ApiUrls.Label(repositoryId, labelName))); }
public Task <Installation> GetUserInstallationForCurrent(string user) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); return(ApiConnection.Get <Installation>(ApiUrls.UserInstallation(user), null, AcceptHeaders.GitHubAppsPreview)); }