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

Add repositoryId overloads to methods on I(Observable)RepositoryForksClient #1356

Merged
65 changes: 60 additions & 5 deletions Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ public interface IObservableRepositoryForksClient
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
IObservable<Repository> GetAll(string owner, string name);

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <returns></returns>
IObservable<Repository> GetAll(int repositoryId);

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
Expand All @@ -30,9 +40,20 @@ public interface IObservableRepositoryForksClient
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
IObservable<Repository> GetAll(string owner, string name, ApiOptions options);

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
IObservable<Repository> GetAll(int repositoryId, ApiOptions options);

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
Expand All @@ -42,9 +63,20 @@ public interface IObservableRepositoryForksClient
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
IObservable<Repository> GetAll(string owner, string name, RepositoryForksListRequest request);

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <returns></returns>
IObservable<Repository> GetAll(int repositoryId, RepositoryForksListRequest request);

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
Expand All @@ -55,9 +87,21 @@ public interface IObservableRepositoryForksClient
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
IObservable<Repository> GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options);

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
IObservable<Repository> GetAll(int repositoryId, RepositoryForksListRequest request, ApiOptions options);

/// <summary>
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
/// </summary>
Expand All @@ -67,7 +111,18 @@ public interface IObservableRepositoryForksClient
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="fork">Used to fork a repository</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/> representing the created fork of specified repository.</returns>
/// <returns></returns>
IObservable<Repository> Create(string owner, string name, NewRepositoryFork fork);

/// <summary>
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#create-a-fork">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="fork">Used to fork a repository</param>
/// <returns></returns>
IObservable<Repository> Create(int repositoryId, NewRepositoryFork fork);
}
}
87 changes: 82 additions & 5 deletions Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ObservableRepositoryForksClient(IGitHubClient client)
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
public IObservable<Repository> GetAll(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -44,6 +44,19 @@ public IObservable<Repository> GetAll(string owner, string name)
return GetAll(owner, name, ApiOptions.None);
}

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <returns></returns>
public IObservable<Repository> GetAll(int repositoryId)
{
return GetAll(repositoryId, ApiOptions.None);
}

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
Expand All @@ -53,7 +66,7 @@ public IObservable<Repository> GetAll(string owner, string name)
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
public IObservable<Repository> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -63,6 +76,22 @@ public IObservable<Repository> GetAll(string owner, string name, ApiOptions opti
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.RepositoryForks(owner, name), options);
}

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
public IObservable<Repository> GetAll(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.RepositoryForks(repositoryId), options);
}

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
Expand All @@ -72,7 +101,7 @@ public IObservable<Repository> GetAll(string owner, string name, ApiOptions opti
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
public IObservable<Repository> GetAll(string owner, string name, RepositoryForksListRequest request)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure.ArgumentNotNull(request, "request")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -81,6 +110,20 @@ public IObservable<Repository> GetAll(string owner, string name, RepositoryForks
return GetAll(owner, name, request, ApiOptions.None);
}

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <returns></returns>
public IObservable<Repository> GetAll(int repositoryId, RepositoryForksListRequest request)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure.ArgumentNotNull(request, "request")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

return GetAll(repositoryId, request, ApiOptions.None);
}

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
Expand All @@ -91,7 +134,7 @@ public IObservable<Repository> GetAll(string owner, string name, RepositoryForks
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <param name="options">Options for changing the API response</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>s representing forks of specified repository.</returns>
/// <returns></returns>
public IObservable<Repository> GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure.ArgumentNotNull(request, "request")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here it would be a breaking change, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow null here for RepositoryForksListRequest? We've been restricting this elsewhere in the codebase, and it feels weird to leave this one here. We can call this out in the release notes if you think that's important...

{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -102,6 +145,24 @@ public IObservable<Repository> GetAll(string owner, string name, RepositoryForks
_connection.GetAndFlattenAllPages<Repository>(ApiUrls.RepositoryForks(owner, name), request.ToParametersDictionary(), options);
}

/// <summary>
/// Gets the list of forks defined for a repository
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#list-forks">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="request">Used to request and filter a list of repository forks</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
public IObservable<Repository> GetAll(int repositoryId, RepositoryForksListRequest request, ApiOptions options)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure.ArgumentNotNull(request, "request")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here it would be a breaking change, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand - this is a new method we're adding here?

Ensure.ArgumentNotNull(options, "options");

return request == null ? _connection.GetAndFlattenAllPages<Repository>(ApiUrls.RepositoryForks(repositoryId), options) :
_connection.GetAndFlattenAllPages<Repository>(ApiUrls.RepositoryForks(repositoryId), request.ToParametersDictionary(), options);
}

/// <summary>
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
/// </summary>
Expand All @@ -111,7 +172,7 @@ public IObservable<Repository> GetAll(string owner, string name, RepositoryForks
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="fork">Used to fork a repository</param>
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/> representing the created fork of specified repository.</returns>
/// <returns></returns>
public IObservable<Repository> Create(string owner, string name, NewRepositoryFork fork)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Expand All @@ -120,5 +181,21 @@ public IObservable<Repository> Create(string owner, string name, NewRepositoryFo

return _client.Create(owner, name, fork).ToObservable();
}

/// <summary>
/// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization.
/// </summary>
/// <remarks>
/// See <a href="http://developer.github.com/v3/repos/forks/#create-a-fork">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The ID of the repository</param>
/// <param name="fork">Used to fork a repository</param>
/// <returns></returns>
public IObservable<Repository> Create(int repositoryId, NewRepositoryFork fork)
{
Ensure.ArgumentNotNull(fork, "fork");

return _client.Create(repositoryId, fork).ToObservable();
}
}
}
Loading