mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
[FEAT]: Custom Properties (#2933)
* add custom properties model and clients * observable * observable tests * add search * error CS8370: 'target-typed object creation' * Error CS8370: 'target-typed object creation' * add patch with body that return status code * fixes for failed ConventionTests * working UnitTests * (de)serialization and model tests * Update Repository.cs
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Organization Custom Properties API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See <a href="https://docs.github.com/rest/orgs/custom-properties">Custom Properties API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableOrganizationCustomPropertiesClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get all custom properties for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#get-all-custom-properties-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
IObservable<OrganizationCustomProperty> GetAll(string org);
|
||||
|
||||
/// <summary>
|
||||
/// Get a single custom property by name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#get-a-custom-property-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyName">The name of the custom property</param>
|
||||
IObservable<OrganizationCustomProperty> Get(string org, string propertyName);
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom properties for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-properties-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="properties">The custom properties to create or update</param>
|
||||
IObservable<OrganizationCustomProperty> CreateOrUpdate(string org, UpsertOrganizationCustomProperties properties);
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom property for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#create-or-update-a-custom-property-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyName">The name of the custom property</param>
|
||||
/// <param name="property">The custom property to create or update</param>
|
||||
IObservable<OrganizationCustomProperty> CreateOrUpdate(string org, string propertyName, UpsertOrganizationCustomProperty property);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a custom property that is defined for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#remove-a-custom-property-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyName">The name of the custom property</param>
|
||||
IObservable<Unit> Delete(string org, string propertyName);
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Organization Custom Property Values API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties">Custom Properties API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableOrganizationCustomPropertyValuesClient Values { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Organization Custom Property Values API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See <a href="https://docs.github.com/rest/orgs/custom-properties">Custom Properties API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableOrganizationCustomPropertyValuesClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get all custom property values for repositories an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
IObservable<OrganizationCustomPropertyValues> GetAll(string org);
|
||||
|
||||
/// <summary>
|
||||
/// Get all custom property values for repositories an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="options">Options for changing the API response</param>
|
||||
IObservable<OrganizationCustomPropertyValues> GetAll(string org, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Get all custom property values for repositories an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="repositoryQuery">Finds repositories in the organization with a query containing one or more search keywords and qualifiers.</param>
|
||||
IObservable<OrganizationCustomPropertyValues> GetAll(string org, OrganizationCustomPropertyValuesRequest repositoryQuery);
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom property values for repositories an organization.
|
||||
/// Using a value of null for a custom property will remove or 'unset' the property value from the repository.
|
||||
/// A maximum of 30 repositories can be updated in a single request.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyValues">The custom property values to create or update</param>
|
||||
IObservable<Unit> CreateOrUpdate(string org, UpsertOrganizationCustomPropertyValues propertyValues);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
IObservableOrganizationActionsClient Actions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a client to manage organization custom properties.
|
||||
/// </summary>
|
||||
IObservableOrganizationCustomPropertiesClient CustomProperty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the specified organization.
|
||||
/// </summary>
|
||||
|
||||
@@ -255,6 +255,14 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
IObservableRepositoryCommentsClient Comment { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Custom Property Values API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/custom-properties/">Repository Custom Property API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableRepositoryCustomPropertiesClient CustomProperty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Hooks API.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Custom Property Values API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/repos/custom-properties">Custom Properties API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableRepositoryCustomPropertiesClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Get all custom property values for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="repoName">The name of the repository.</param>
|
||||
IObservable<CustomPropertyValue> GetAll(string owner, string repoName);
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom property values for a repository. Using a value of null for a custom property will remove or 'unset' the property value from the repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/repos/custom-properties#create-or-update-custom-property-values-for-a-repository">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repoName">The name of the repository</param>
|
||||
/// <param name="propertyValues">The custom property values to create or update</param>
|
||||
IObservable<Unit> CreateOrUpdate(string owner, string repoName, UpsertRepositoryCustomPropertyValues propertyValues);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableOrganizationCustomPropertiesClient : IObservableOrganizationCustomPropertiesClient
|
||||
{
|
||||
readonly IOrganizationCustomPropertiesClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableOrganizationCustomPropertiesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
Values = new ObservableOrganizationCustomPropertyValuesClient(client);
|
||||
|
||||
_client = client.Organization.CustomProperty;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all custom properties for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#get-all-custom-properties-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
public IObservable<OrganizationCustomProperty> GetAll(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
|
||||
return _client.GetAll(org).ToObservable().SelectMany(p => p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a single custom property by name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#get-a-custom-property-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyName">The name of the custom property</param>
|
||||
public IObservable<OrganizationCustomProperty> Get(string org, string propertyName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(propertyName, nameof(propertyName));
|
||||
|
||||
return _client.Get(org, propertyName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom properties for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-properties-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="properties">The custom properties to create or update</param>
|
||||
public IObservable<OrganizationCustomProperty> CreateOrUpdate(string org, UpsertOrganizationCustomProperties properties)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNull(properties, nameof(properties));
|
||||
Ensure.ArgumentNotNullOrEmptyEnumerable(properties.Properties, nameof(properties.Properties));
|
||||
|
||||
return _client.CreateOrUpdate(org, properties).ToObservable().SelectMany(p => p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom property for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#create-or-update-a-custom-property-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyName">The name of the custom property</param>
|
||||
/// <param name="property">The custom property to create or update</param>
|
||||
public IObservable<OrganizationCustomProperty> CreateOrUpdate(string org, string propertyName, UpsertOrganizationCustomProperty property)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(propertyName, nameof(propertyName));
|
||||
Ensure.ArgumentNotNull(property, nameof(property));
|
||||
Ensure.ArgumentNotNullOrDefault(property.ValueType, nameof(property.ValueType));
|
||||
|
||||
return _client.CreateOrUpdate(org, propertyName, property).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a custom property that is defined for an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#remove-a-custom-property-for-an-organization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyName">The name of the custom property</param>
|
||||
public IObservable<Unit> Delete(string org, string propertyName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNullOrEmptyString(propertyName, nameof(propertyName));
|
||||
|
||||
return _client.Delete(org, propertyName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Organization Custom Property Values API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties">Custom Properties API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableOrganizationCustomPropertyValuesClient Values { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableOrganizationCustomPropertyValuesClient : IObservableOrganizationCustomPropertyValuesClient
|
||||
{
|
||||
readonly IOrganizationCustomPropertyValuesClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableOrganizationCustomPropertyValuesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Organization.CustomProperty.Values;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all custom property values for repositories an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<OrganizationCustomPropertyValues> GetAll(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
|
||||
return GetAll(org, new OrganizationCustomPropertyValuesRequest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all custom property values for repositories an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="options">Options for changing the API response</param>
|
||||
public IObservable<OrganizationCustomPropertyValues> GetAll(string org, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
var url = ApiUrls.OrganizationCustomPropertyValues(org);
|
||||
|
||||
return _connection.GetAndFlattenAllPages<OrganizationCustomPropertyValues>(url, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all custom property values for repositories an organization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="repositoryQuery">Finds repositories in the organization with a query containing one or more search keywords and qualifiers.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<OrganizationCustomPropertyValues> GetAll(string org, OrganizationCustomPropertyValuesRequest repositoryQuery)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNull(repositoryQuery, nameof(repositoryQuery));
|
||||
|
||||
var url = ApiUrls.OrganizationCustomPropertyValues(org);
|
||||
|
||||
return _connection.GetAndFlattenAllPages<OrganizationCustomPropertyValues>(url, repositoryQuery.Parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom property values for repositories an organization.
|
||||
/// Using a value of null for a custom property will remove or 'unset' the property value from the repository.
|
||||
/// A maximum of 30 repositories can be updated in a single request.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-property-values-for-organization-repositories">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="org">The name of the organization</param>
|
||||
/// <param name="propertyValues">The custom property values to create or update</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<Unit> CreateOrUpdate(string org, UpsertOrganizationCustomPropertyValues propertyValues)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
|
||||
Ensure.ArgumentNotNull(propertyValues, nameof(propertyValues));
|
||||
Ensure.ArgumentNotNullOrEmptyEnumerable(propertyValues.Properties, nameof(propertyValues.Properties));
|
||||
Ensure.ArgumentNotNullOrEmptyEnumerable(propertyValues.RepositoryNames, nameof(propertyValues.RepositoryNames));
|
||||
|
||||
return _client.CreateOrUpdate(org, propertyValues).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ namespace Octokit.Reactive
|
||||
Hook = new ObservableOrganizationHooksClient(client);
|
||||
OutsideCollaborator = new ObservableOrganizationOutsideCollaboratorsClient(client);
|
||||
Actions = new ObservableOrganizationActionsClient(client);
|
||||
CustomProperty = new ObservableOrganizationCustomPropertiesClient(client);
|
||||
|
||||
_client = client.Organization;
|
||||
_connection = client.Connection;
|
||||
@@ -54,6 +55,11 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
public IObservableOrganizationActionsClient Actions { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a client to manage organization custom properties.
|
||||
/// </summary>
|
||||
public IObservableOrganizationCustomPropertiesClient CustomProperty { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the specified organization.
|
||||
/// </summary>
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Octokit.Reactive
|
||||
Branch = new ObservableRepositoryBranchesClient(client);
|
||||
Comment = new ObservableRepositoryCommentsClient(client);
|
||||
Commit = new ObservableRepositoryCommitsClient(client);
|
||||
CustomProperty = new ObservableRepositoryCustomPropertiesClient(client);
|
||||
Release = new ObservableReleasesClient(client);
|
||||
DeployKeys = new ObservableRepositoryDeployKeysClient(client);
|
||||
Content = new ObservableRepositoryContentsClient(client);
|
||||
@@ -380,6 +381,14 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
public IObservableRepositoryCommentsClient Comment { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Custom Property Values API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/custom-properties/">Repository Custom Property API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableRepositoryCustomPropertiesClient CustomProperty { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Hooks API.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Custom Property Values API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/repos/custom-properties">Custom Properties API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ObservableRepositoryCustomPropertiesClient : IObservableRepositoryCustomPropertiesClient
|
||||
{
|
||||
readonly IRepositoryCustomPropertiesClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableRepositoryCustomPropertiesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Repository.CustomProperty;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all custom property values for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="repoName">The name of the repository.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<CustomPropertyValue> GetAll(string owner, string repoName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||
|
||||
return _client.GetAll(owner, repoName).ToObservable().SelectMany(p => p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create new or update existing custom property values for a repository. Using a value of null for a custom property will remove or 'unset' the property value from the repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://docs.github.com/rest/repos/custom-properties#create-or-update-custom-property-values-for-a-repository">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repoName">The name of the repository</param>
|
||||
/// <param name="propertyValues">The custom property values to create or update</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public IObservable<Unit> CreateOrUpdate(string owner, string repoName, UpsertRepositoryCustomPropertyValues propertyValues)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||
Ensure.ArgumentNotNull(propertyValues, nameof(propertyValues));
|
||||
Ensure.ArgumentNotNullOrEmptyEnumerable(propertyValues.Properties, nameof(propertyValues.Properties));
|
||||
|
||||
return _client.CreateOrUpdate(owner, repoName, propertyValues).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user