mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 22:25:12 +00:00
[feat]: Adding repository variables
This commit is contained in:
@@ -19,5 +19,13 @@ namespace Octokit.Reactive
|
|||||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IObservableRepositorySecretsClient Secrets { get; }
|
IObservableRepositorySecretsClient Secrets { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client for GitHub's Repository Actions API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||||
|
/// </remarks>
|
||||||
|
IObservableRepositoryVariablesClient Variables { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Octokit.Reactive
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A client for GitHub's Repository Variables API.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28">Repository Variables API documentation</a> for more details.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IObservableRepositoryVariablesClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// List the organization variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-organization-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
IObservable<RepositoryVariablesCollection> GetAllOrganization(string owner, string repoName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List the variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
IObservable<RepositoryVariablesCollection> GetAll(string owner, string repoName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a variable from a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository secret.</returns>
|
||||||
|
IObservable<RepositoryVariable> Get(string owner, string repoName, string variableName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable">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="newVariable">The variable to create</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was created.</returns>
|
||||||
|
IObservable<RepositoryVariable> Create(string owner, string repoName, Variable newVariable);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable">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="variable">The variable to update</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was updated.</returns>
|
||||||
|
IObservable<RepositoryVariable> Update(string owner, string repoName, Variable variable);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
IObservable<Unit> Delete(string owner, string repoName, string variableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
_connection = client.Connection;
|
_connection = client.Connection;
|
||||||
|
|
||||||
Secrets = new ObservableRepositorySecretsClient(client);
|
Secrets = new ObservableRepositorySecretsClient(client);
|
||||||
|
Variables = new ObservableRepositoryVariablesClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -28,5 +29,13 @@
|
|||||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public IObservableRepositorySecretsClient Secrets { get; private set; }
|
public IObservableRepositorySecretsClient Secrets { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client for GitHub's Repository Actions API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||||
|
/// </remarks>
|
||||||
|
public IObservableRepositoryVariablesClient Variables { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
148
Octokit.Reactive/Clients/ObservableRepositoryVariablesClient.cs
Normal file
148
Octokit.Reactive/Clients/ObservableRepositoryVariablesClient.cs
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
using Octokit.Reactive.Internal;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Threading.Tasks;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Octokit.Reactive
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A client for GitHub's Repository Variables API.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28">Repository Variables API documentation</a> for more details.
|
||||||
|
/// </remarks>
|
||||||
|
public class ObservableRepositoryVariablesClient : IObservableRepositoryVariablesClient
|
||||||
|
{
|
||||||
|
readonly IRepositoryVariablesClient _client;
|
||||||
|
readonly IConnection _connection;
|
||||||
|
|
||||||
|
public ObservableRepositoryVariablesClient(IGitHubClient client)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNull(client, nameof(client));
|
||||||
|
|
||||||
|
_client = client.Repository.Actions.Variables;
|
||||||
|
_connection = client.Connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List the organization variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-organization-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
public IObservable<RepositoryVariablesCollection> GetAllOrganization(string owner, string repoName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
|
||||||
|
return _client.GetAll(owner, repoName).ToObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List the variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
public IObservable<RepositoryVariablesCollection> GetAll(string owner, string repoName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
|
||||||
|
return _client.GetAll(owner, repoName).ToObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a variable from a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository secret.</returns>
|
||||||
|
public IObservable<RepositoryVariable> Get(string owner, string repoName, string variableName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variableName, nameof(variableName));
|
||||||
|
|
||||||
|
return _client.Get(owner, repoName, variableName).ToObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable">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="newVariable">The variable to create</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was created.</returns>
|
||||||
|
public IObservable<RepositoryVariable> Create(string owner, string repoName, Variable newVariable)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrDefault(newVariable, nameof(newVariable));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(newVariable.Name, nameof(newVariable.Name));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(newVariable.Value, nameof(newVariable.Value));
|
||||||
|
|
||||||
|
return _client.Create(owner, repoName, newVariable).ToObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable">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="variable">The variable to update</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was updated.</returns>
|
||||||
|
public IObservable<RepositoryVariable> Update(string owner, string repoName, Variable variable)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrDefault(variable, nameof(variable));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variable.Name, nameof(variable.Name));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variable.Value, nameof(variable.Value));
|
||||||
|
|
||||||
|
return _client.Update(owner, repoName, variable).ToObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
public IObservable<Unit> Delete(string owner, string repoName, string variableName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variableName, nameof(variableName));
|
||||||
|
|
||||||
|
return _client.Delete(owner, repoName, variableName).ToObservable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
201
Octokit.Tests/Clients/RepositoryVariablesClientTests.cs
Normal file
201
Octokit.Tests/Clients/RepositoryVariablesClientTests.cs
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
using NSubstitute;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Octokit.Tests.Clients
|
||||||
|
{
|
||||||
|
public class RepositoryVariablesClientTests
|
||||||
|
{
|
||||||
|
public class TheCtor
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new RepositoryVariablesClient(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllOrganizationMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task RequestsTheCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoryVariablesClient(connection);
|
||||||
|
|
||||||
|
await client.GetAllOrganization("owner", "repo");
|
||||||
|
|
||||||
|
connection.Received()
|
||||||
|
.Get<RepositoryVariablesCollection>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/organization-variables"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoryVariablesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllOrganization(null, "repo"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllOrganization("owner", null));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllOrganization("", "repo"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllOrganization("owner", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetAllMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task RequestsTheCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoryVariablesClient(connection);
|
||||||
|
|
||||||
|
await client.GetAll("owner", "repo");
|
||||||
|
|
||||||
|
connection.Received()
|
||||||
|
.Get<RepositoryVariablesCollection>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/variables"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoryVariablesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "repo"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "repo"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task RequestsTheCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoryVariablesClient(connection);
|
||||||
|
|
||||||
|
await client.Get("owner", "repo", "variableName");
|
||||||
|
|
||||||
|
connection.Received()
|
||||||
|
.Get<RepositoryVariable>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/variables/variableName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoryVariablesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", "repo", null));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "repo", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task PostsTheCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoryVariablesClient(connection);
|
||||||
|
var newVariable = new Variable("variableName", "variableValue");
|
||||||
|
|
||||||
|
await client.Create("owner", "repo", newVariable);
|
||||||
|
|
||||||
|
connection.Received()
|
||||||
|
.Post<RepositoryVariable>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/variables"), newVariable);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoryVariablesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
var updatedVariable = new Variable("variableName", "variableValue");
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "repo", updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "repo", null));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "repo", new Variable(null, "variableValue")));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "repo", new Variable("variableName", null)));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "repo", updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "repo", new Variable("", "variableValue")));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "repo", new Variable("variableName", "")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UpdateMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task PostsTheCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoryVariablesClient(connection);
|
||||||
|
var variable = new Variable("variableName", "variableValue");
|
||||||
|
|
||||||
|
await client.Update("owner", "repo", variable);
|
||||||
|
|
||||||
|
connection.Received()
|
||||||
|
.Patch<RepositoryVariable>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/variables/variableName"), variable);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoryVariablesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
var updatedVariable = new Variable("variableName", "variableValue");
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "repo", updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", null, updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "repo", null));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "repo", new Variable(null, "value")));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "repo", new Variable("name", null)));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "repo", updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", updatedVariable));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "repo", new Variable("", "value")));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "repo", new Variable("name", "")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DeleteMethod
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public async Task DeletesTheCorrectUrl()
|
||||||
|
{
|
||||||
|
var connection = Substitute.For<IApiConnection>();
|
||||||
|
var client = new RepositoryVariablesClient(connection);
|
||||||
|
|
||||||
|
await client.Delete("owner", "repo", "variableName");
|
||||||
|
|
||||||
|
connection.Received()
|
||||||
|
.Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/variables/variableName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnsuresNonNullArguments()
|
||||||
|
{
|
||||||
|
var client = new RepositoryVariablesClient(Substitute.For<IApiConnection>());
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "repo", "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", "repo", null));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "repo", "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", "variableName"));
|
||||||
|
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "repo", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,5 +15,13 @@
|
|||||||
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
IRepositorySecretsClient Secrets { get; }
|
IRepositorySecretsClient Secrets { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client for GitHub's Repository Actions API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details
|
||||||
|
/// </remarks>
|
||||||
|
IRepositoryVariablesClient Variables { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
89
Octokit/Clients/IRepositoryVariablesClient.cs
Normal file
89
Octokit/Clients/IRepositoryVariablesClient.cs
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Octokit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A client for GitHub's Repository Variables API.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28">Repository Variables API documentation</a> for more details.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IRepositoryVariablesClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// List the organization variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-organization-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
Task<RepositoryVariablesCollection> GetAllOrganization(string owner, string repoName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List the variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
Task<RepositoryVariablesCollection> GetAll(string owner, string repoName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a variable from a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository secret.</returns>
|
||||||
|
Task<RepositoryVariable> Get(string owner, string repoName, string variableName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable">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="newVariable">The variable to create</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was created.</returns>
|
||||||
|
Task<RepositoryVariable> Create(string owner, string repoName, Variable newVariable);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable">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="variable">The variable to update</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was updated.</returns>
|
||||||
|
Task<RepositoryVariable> Update(string owner, string repoName, Variable variable);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
Task Delete(string owner, string repoName, string variableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
public RepositoryActionsClient(IApiConnection apiConnection) : base(apiConnection)
|
public RepositoryActionsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||||
{
|
{
|
||||||
Secrets = new RepositorySecretsClient(apiConnection);
|
Secrets = new RepositorySecretsClient(apiConnection);
|
||||||
|
Variables = new RepositoryVariablesClient(apiConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -24,5 +25,13 @@
|
|||||||
/// See the <a href="https://docs.github.com/v3/actions#secrets">Deployments API documentation</a> for more details
|
/// See the <a href="https://docs.github.com/v3/actions#secrets">Deployments API documentation</a> for more details
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public IRepositorySecretsClient Secrets { get; set; }
|
public IRepositorySecretsClient Secrets { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client for GitHub's Repository Actions API
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/free-pro-team@latest/rest/actions/variables?apiVersion=2022-11-28">Deployments API documentation</a> for more details
|
||||||
|
/// </remarks>
|
||||||
|
public IRepositoryVariablesClient Variables { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
159
Octokit/Clients/RepositoryVariablesClient.cs
Normal file
159
Octokit/Clients/RepositoryVariablesClient.cs
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Octokit
|
||||||
|
{
|
||||||
|
public class RepositoryVariablesClient : ApiClient, IRepositoryVariablesClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new GitHub Repository Branches API client.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="apiConnection">An API connection</param>
|
||||||
|
public RepositoryVariablesClient(IApiConnection apiConnection) : base(apiConnection)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List the organization variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-organization-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/organization-variables")]
|
||||||
|
public Task<RepositoryVariablesCollection> GetAllOrganization(string owner, string repoName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
|
||||||
|
var url = ApiUrls.RepositoryOrganizationVariables(owner, repoName);
|
||||||
|
|
||||||
|
return ApiConnection.Get<RepositoryVariablesCollection>(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List the variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-variables">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>
|
||||||
|
/// <returns>A <see cref="RepositoryVariablesCollection"/> instance for the list of repository variables.</returns>
|
||||||
|
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/variables")]
|
||||||
|
public Task<RepositoryVariablesCollection> GetAll(string owner, string repoName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
|
||||||
|
var url = ApiUrls.RepositoryVariables(owner, repoName);
|
||||||
|
|
||||||
|
return ApiConnection.Get<RepositoryVariablesCollection>(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a variable from a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository secret.</returns>
|
||||||
|
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/variables/{variableName}")]
|
||||||
|
public Task<RepositoryVariable> Get(string owner, string repoName, string variableName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variableName, nameof(variableName));
|
||||||
|
|
||||||
|
var url = ApiUrls.RepositoryVariable(owner, repoName, variableName);
|
||||||
|
|
||||||
|
return ApiConnection.Get<RepositoryVariable>(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable">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="newVariable">The variable to create</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was created.</returns>
|
||||||
|
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/variables")]
|
||||||
|
public async Task<RepositoryVariable> Create(string owner, string repoName, Variable newVariable)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrDefault(newVariable, nameof(newVariable));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(newVariable.Name, nameof(newVariable.Name));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(newVariable.Value, nameof(newVariable.Value));
|
||||||
|
|
||||||
|
var url = ApiUrls.RepositoryVariables(owner, repoName);
|
||||||
|
|
||||||
|
await ApiConnection.Post<RepositoryVariable>(url, newVariable);
|
||||||
|
|
||||||
|
return await Get(owner, repoName, newVariable.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable">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="variable">The variable to update</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
/// <returns>A <see cref="RepositoryVariable"/> instance for the repository variable that was updated.</returns>
|
||||||
|
[ManualRoute("PATCH", "/repos/{owner}/{repo}/actions/variables/{variable.Name}")]
|
||||||
|
public async Task<RepositoryVariable> Update(string owner, string repoName, Variable variable)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrDefault(variable, nameof(variable));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variable.Name, nameof(variable.Name));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variable.Value, nameof(variable.Value));
|
||||||
|
|
||||||
|
var url = ApiUrls.RepositoryVariable(owner, repoName, variable.Name);
|
||||||
|
|
||||||
|
await ApiConnection.Patch<RepositoryVariable>(url, variable);
|
||||||
|
|
||||||
|
return await Get(owner, repoName, variable.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a variable in a repository.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// See the <a href="https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable">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="variableName">The name of the variable</param>
|
||||||
|
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||||
|
[ManualRoute("DELETE", "/repos/{owner}/{repo}/actions/variables/{variableName}")]
|
||||||
|
public Task Delete(string owner, string repoName, string variableName)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName));
|
||||||
|
Ensure.ArgumentNotNullOrEmptyString(variableName, nameof(variableName));
|
||||||
|
|
||||||
|
var url = ApiUrls.RepositoryVariable(owner, repoName, variableName);
|
||||||
|
|
||||||
|
return ApiConnection.Delete(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4585,6 +4585,40 @@ namespace Octokit
|
|||||||
return "repos/{0}/{1}/actions/secrets/public-key".FormatUri(owner, repo);
|
return "repos/{0}/{1}/actions/secrets/public-key".FormatUri(owner, repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the <see cref="Uri"/> that handles the repository variables for the repository
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner">The owner of the repo</param>
|
||||||
|
/// <param name="repo">The name of the repo</param>
|
||||||
|
/// <param name="variable">The name of the variable</param>
|
||||||
|
/// <returns>The <see cref="Uri"/> that handles the repository variables for the repository</returns>
|
||||||
|
public static Uri RepositoryVariable(string owner, string repo, string variable)
|
||||||
|
{
|
||||||
|
return "repos/{0}/{1}/actions/variables/{2}".FormatUri(owner, repo, variable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the <see cref="Uri"/> that handles the repository variables for the repository
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner">The owner of the repo</param>
|
||||||
|
/// <param name="repo">The name of the repo</param>
|
||||||
|
/// <returns>The <see cref="Uri"/> that handles the repository variables for the repository</returns>
|
||||||
|
public static Uri RepositoryVariables(string owner, string repo)
|
||||||
|
{
|
||||||
|
return "repos/{0}/{1}/actions/variables".FormatUri(owner, repo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the <see cref="Uri"/> that handles the organization variables for the repository
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner">The owner of the repo</param>
|
||||||
|
/// <param name="repo">The name of the repo</param>
|
||||||
|
/// <returns>The <see cref="Uri"/> that handles the organization variables for the repository</returns>
|
||||||
|
public static Uri RepositoryOrganizationVariables(string owner, string repo)
|
||||||
|
{
|
||||||
|
return "repos/{0}/{1}/actions/organization-variables".FormatUri(owner, repo);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="Uri"/> that returns all emojis in
|
/// Returns the <see cref="Uri"/> that returns all emojis in
|
||||||
/// response to a GET request.
|
/// response to a GET request.
|
||||||
|
|||||||
38
Octokit/Models/Request/Variable.cs
Normal file
38
Octokit/Models/Request/Variable.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace Octokit
|
||||||
|
{
|
||||||
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
|
public class Variable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Variable"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name of the variable.</param>
|
||||||
|
/// <param name="value">The value of the variable.</param>
|
||||||
|
public Variable(string name, string value)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required. Gets or sets the name of the variable.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required. Gets or sets the value of the variable.
|
||||||
|
/// </summary>
|
||||||
|
public string Value { get; set; }
|
||||||
|
|
||||||
|
internal string DebuggerDisplay
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(CultureInfo.InvariantCulture, "Name: {0}, Value: {1}", Name, Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
Octokit/Models/Response/RepositoryVariable.cs
Normal file
55
Octokit/Models/Response/RepositoryVariable.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using Octokit.Internal;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace Octokit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a repository variable.
|
||||||
|
/// </summary>
|
||||||
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
|
public class RepositoryVariable
|
||||||
|
{
|
||||||
|
public RepositoryVariable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RepositoryVariable(string name, string value, DateTimeOffset createdAt, DateTimeOffset? updatedAt)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Value = value;
|
||||||
|
CreatedAt = createdAt;
|
||||||
|
UpdatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the repository variable
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The value of the repository variable
|
||||||
|
/// </summary>
|
||||||
|
public string Value { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The date and time that the variable was created
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset CreatedAt { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The date and time the variable was last updated
|
||||||
|
/// </summary>
|
||||||
|
public DateTimeOffset? UpdatedAt { get; protected set; }
|
||||||
|
|
||||||
|
internal string DebuggerDisplay
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format(CultureInfo.InvariantCulture,
|
||||||
|
"RepositoryVariable: Name: {0}", Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
Octokit/Models/Response/RepositoryVariablesCollection.cs
Normal file
36
Octokit/Models/Response/RepositoryVariablesCollection.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using Octokit.Internal;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace Octokit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents response of variables for a repository.
|
||||||
|
/// </summary>
|
||||||
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||||
|
public class RepositoryVariablesCollection
|
||||||
|
{
|
||||||
|
public RepositoryVariablesCollection()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RepositoryVariablesCollection(int totalCount, IReadOnlyList<RepositoryVariable> variables)
|
||||||
|
{
|
||||||
|
TotalCount = totalCount;
|
||||||
|
Variables = variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total count of variables for the repository
|
||||||
|
/// </summary>
|
||||||
|
public int TotalCount { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The list of variables for the repository
|
||||||
|
/// </summary>
|
||||||
|
public IReadOnlyList<RepositoryVariable> Variables { get; private set; }
|
||||||
|
|
||||||
|
internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "RepositoryVariablesCollection: Count: {0}", TotalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user