-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Org webhooks #1028 #1144
Closed
Closed
Org webhooks #1028 #1144
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e27c2ac
Merge remote-tracking branch 'refs/remotes/octokit/master'
nubby109 eb32a88
Merge remote-tracking branch 'refs/remotes/octokit/master'
nubby109 481dcea
Added organization webhooks
nubby109 7fa37e1
resolving conflicts from octokit.net merge
nubby109 f372061
Merge remote-tracking branch 'refs/remotes/octokit/master' into org-w…
nubby109 7106944
1. Changed organizationName to org
nubby109 2cbc808
Removed extra parameter in description of delete function in Observab…
nubby109 948c3cd
Making it more consistent
nubby109 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Octokit.Reactive/Clients/IObservableOrganizationHooksClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reactive; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public interface IObservableOrganizationHooksClient | ||
{ | ||
/// <summary> | ||
/// Gets the list of hooks defined for a organization | ||
/// </summary> | ||
/// <remarks>See <a href="https://developer.github.com/v3/orgs/hooks/#list-hooks">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<OrganizationHook> GetAll(string org); | ||
|
||
/// <summary> | ||
/// Gets a single hook defined for a organization by id | ||
/// </summary> | ||
/// <remarks>See <a href="https://developer.github.com/v3/orgs/hooks/#get-single-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "This is ok; we're matching HTTP verbs not keyworks")] | ||
IObservable<OrganizationHook> Get(string org, int hookId); | ||
|
||
/// <summary> | ||
/// Creates a hook for a organization | ||
/// </summary> | ||
/// <remarks>See <a href="https://developer.github.com/v3/orgs/hooks/#create-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<OrganizationHook> Create(string org, NewOrganizationHook hook); | ||
|
||
/// <summary> | ||
/// Edits a hook for a organization | ||
/// </summary> | ||
/// <remarks>See <a href="https://developer.github.com/v3/orgs/hooks/#edit-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<OrganizationHook> Edit(string org, int hookId, EditOrganizationHook hook); | ||
|
||
/// <summary> | ||
/// This will trigger a ping event to be sent to the hook. | ||
/// </summary> | ||
/// <remarks>See <a href="https://developer.github.com/v3/orgs/hooks/#ping-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<Unit> Ping(string org, int hookId); | ||
|
||
/// <summary> | ||
/// Deletes a hook for a organization | ||
/// </summary> | ||
/// <param name="org"></param> | ||
/// <param name="hookId"></param> | ||
/// <remarks>See <a href="https://developer.github.com/v3/orgs/hooks/#delete-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
IObservable<Unit> Delete(string org, int hookId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
Octokit.Reactive/Clients/ObservableOrganizationHooksClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.Reactive; | ||
using System.Reactive.Threading.Tasks; | ||
using Octokit.Reactive.Internal; | ||
|
||
namespace Octokit.Reactive | ||
{ | ||
public class ObservableOrganizationHooksClient : IObservableOrganizationHooksClient | ||
{ | ||
readonly IOrganizationHooksClient _client; | ||
readonly IConnection _connection; | ||
|
||
public ObservableOrganizationHooksClient(IGitHubClient client) | ||
{ | ||
Ensure.ArgumentNotNull(client, "client"); | ||
|
||
_client = client.Organization.Hooks; | ||
_connection = client.Connection; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the list of hooks defined for a organization | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/orgs/hooks/#list-hooks">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<OrganizationHook> GetAll(string org) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(org, "org"); | ||
|
||
|
||
return _connection.GetAndFlattenAllPages<OrganizationHook>(ApiUrls.OrganizationHooks(org)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets a single hook defined for a organization by id | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/orgs/hooks/#get-single-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<OrganizationHook> Get(string org, int hookId) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(org, "org"); | ||
|
||
return _client.Get(org, hookId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a hook for a organization | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/orgs/hooks/#create-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<OrganizationHook> Create(string org, NewOrganizationHook hook) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(org, "org"); | ||
Ensure.ArgumentNotNull(hook, "hook"); | ||
|
||
return _client.Create(org, hook).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Edits a hook for a organization | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/orgs/hooks/#edit-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<OrganizationHook> Edit(string org, int hookId, EditOrganizationHook hook) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(org, "org"); | ||
Ensure.ArgumentNotNull(hook, "hook"); | ||
|
||
return _client.Edit(org, hookId, hook).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// This will trigger a ping event to be sent to the hook. | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/orgs/hooks/#ping-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<Unit> Ping(string org, int hookId) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(org, "org"); | ||
|
||
return _client.Ping(org, hookId).ToObservable(); | ||
} | ||
|
||
/// <summary> | ||
/// Deletes a hook for a organization | ||
/// </summary> | ||
/// <param name="org"></param> | ||
/// <param name="hookId"></param> | ||
/// <remarks>See <a href="http://developer.github.com/v3/orgs/hooks/#delete-a-hook">API documentation</a> for more information.</remarks> | ||
/// <returns></returns> | ||
public IObservable<Unit> Delete(string org, int hookId) | ||
{ | ||
Ensure.ArgumentNotNullOrEmptyString(org, "org"); | ||
|
||
return _client.Delete(org, hookId).ToObservable(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ public ObservableOrganizationsClient(IGitHubClient client) | |
|
||
Member = new ObservableOrganizationMembersClient(client); | ||
Team = new ObservableTeamsClient(client); | ||
Hooks = new ObservableOrganizationHooksClient(client); | ||
|
||
_client = client.Organization; | ||
_connection = client.Connection; | ||
|
@@ -34,6 +35,12 @@ public ObservableOrganizationsClient(IGitHubClient client) | |
/// </summary> | ||
public IObservableTeamsClient Team { get; private set; } | ||
|
||
/// <summary> | ||
/// A client for GitHub's Organization Hooks API. | ||
/// </summary> | ||
/// <remarks>See <a href="http://developer.github.com/v3/orgs/hooks/">Hooks API documentation</a> for more information.</remarks> | ||
public IObservableOrganizationHooksClient Hooks { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be in the singular - Hook to be consistent with the other sub-client properties (will flow from a refactor of the interface but figured I'd mention it here also) |
||
|
||
/// <summary> | ||
/// Returns the specified organization. | ||
/// </summary> | ||
|
@@ -70,13 +77,14 @@ public IObservable<Organization> GetAll(string user) | |
/// <summary> | ||
/// Update the specified organization with data from <see cref="OrganizationUpdate"/>. | ||
/// </summary> | ||
/// <param name="organizationName">The name of the organization to update.</param> | ||
/// <param name="org">The name of the organization to update.</param> | ||
/// <param name="updateRequest"></param> | ||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> | ||
/// <returns>A <see cref="Organization"/></returns> | ||
public IObservable<Organization> Update(string organizationName, OrganizationUpdate updateRequest) | ||
public IObservable<Organization> Update(string org, OrganizationUpdate updateRequest) | ||
{ | ||
return _client.Update(organizationName, updateRequest).ToObservable(); | ||
return _client.Update(org, updateRequest).ToObservable(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in the singular -
Hook
to be consistent with the other sub-client propertiesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these properties based on the iobservablerepositoriesclient, it was 'Hooks' there. I thought that is how it should be named here too. I'll change it if you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryangribble is the master of consistency around here, but I believe that (in a separate PR) IObservableRepositoriesClient (and probably IRepositoriesClient) would need to be changed also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, there has been a move towards ensuring all property names for clients are singular (#53 #1035 #1036 #375 #1038),
so I agree these should be
IOrganizationHooksClient Hook { get; private set; }
It also makes me realise we have quite a few other clients that still need to get resolved!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #1207 to go into this a bit more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done