Skip to content
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
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Octokit.Reactive/Clients/IObservableOrganizationHooksClient.cs
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);
}
}
10 changes: 8 additions & 2 deletions Octokit.Reactive/Clients/IObservableOrganizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ public interface IObservableOrganizationsClient
/// </summary>
IObservableTeamsClient Team { get; }

/// <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>
IObservableOrganizationHooksClient Hook { get; }

/// <summary>
/// Returns the specified organization.
/// </summary>
Expand Down Expand Up @@ -42,10 +48,10 @@ public interface IObservableOrganizationsClient
/// <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>
IObservable<Organization> Update(string organizationName, OrganizationUpdate updateRequest);
IObservable<Organization> Update(string org, OrganizationUpdate updateRequest);
}
}
4 changes: 2 additions & 2 deletions Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface IObservableRepositoryHooksClient
/// <summary>
/// Gets the list of hooks defined for a repository
/// </summary>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#list">API documentation</a> for more information.</remarks>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#list-hooks">API documentation</a> for more information.</remarks>
/// <returns></returns>
IObservable<RepositoryHook> GetAll(string owner, string repositoryName);

Expand Down Expand Up @@ -47,7 +47,7 @@ public interface IObservableRepositoryHooksClient
/// <summary>
/// This will trigger a ping event to be sent to the hook.
/// </summary>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#ping-a-hook">API documentation</a> for more information.</remarks>
/// <returns></returns>
IObservable<Unit> Ping(string owner, string repositoryName, int hookId);

Expand Down
98 changes: 98 additions & 0 deletions Octokit.Reactive/Clients/ObservableOrganizationHooksClient.cs
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.Hook;
_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();
}
}
}
14 changes: 11 additions & 3 deletions Octokit.Reactive/Clients/ObservableOrganizationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public ObservableOrganizationsClient(IGitHubClient client)

Member = new ObservableOrganizationMembersClient(client);
Team = new ObservableTeamsClient(client);
Hook = new ObservableOrganizationHooksClient(client);

_client = client.Organization;
_connection = client.Connection;
Expand All @@ -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 Hook { get; private set; }

/// <summary>
/// Returns the specified organization.
/// </summary>
Expand Down Expand Up @@ -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();
}

}
}
4 changes: 2 additions & 2 deletions Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ObservableRepositoryHooksClient(IGitHubClient client)
/// <summary>
/// Gets the list of hooks defined for a repository
/// </summary>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#list">API documentation</a> for more information.</remarks>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#list-hooks">API documentation</a> for more information.</remarks>
/// <returns></returns>
public IObservable<RepositoryHook> GetAll(string owner, string repositoryName)
{
Expand Down Expand Up @@ -90,7 +90,7 @@ public IObservable<Unit> Test(string owner, string repositoryName, int hookId)
/// <summary>
/// This will trigger a ping event to be sent to the hook.
/// </summary>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#edit-a-hook">API documentation</a> for more information.</remarks>
/// <remarks>See <a href="http://developer.github.com/v3/repos/hooks/#ping-a-hook">API documentation</a> for more information.</remarks>
/// <returns></returns>
public IObservable<Unit> Ping(string owner, string repositoryName, int hookId)
{
Expand Down
2 changes: 2 additions & 0 deletions Octokit.Reactive/Octokit.Reactive-Mono.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\IObservableOrganizationHooksClient.cs" />
<Compile Include="Clients\ObservableOrganizationHooksClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\IObservableOrganizationHooksClient.cs" />
<Compile Include="Clients\ObservableOrganizationHooksClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@
<Compile Include="Clients\Enterprise\ObservableEnterpriseSearchIndexingClient.cs" />
<Compile Include="Clients\Enterprise\IObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\Enterprise\ObservableEnterpriseLdapClient.cs" />
<Compile Include="Clients\IObservableOrganizationHooksClient.cs" />
<Compile Include="Clients\ObservableOrganizationHooksClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Octokit.Reactive/Octokit.Reactive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="Clients\IObservableOauthClient.cs" />
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
<Compile Include="Clients\IObservableRepositoryDeployKeysClient.cs" />
<Compile Include="Clients\IObservableOrganizationHooksClient.cs" />
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
<Compile Include="Clients\IObservableUserAdministrationClient.cs" />
<Compile Include="Clients\IObservableUserKeysClient.cs" />
Expand All @@ -119,6 +120,7 @@
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
<Compile Include="Clients\ObservableRepositoryCommitsClients.cs" />
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
<Compile Include="Clients\ObservableOrganizationHooksClient.cs" />
<Compile Include="Clients\ObservableRepositoryPagesClient.cs" />
<Compile Include="Clients\ObservableSearchClient.cs" />
<Compile Include="Clients\IObservableBlobsClient.cs" />
Expand Down
Loading