mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
[feat]: Adds Actions workflow API clients
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Artifacts API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/artifacts/">Actions Artifacts API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsArtifactsClient
|
||||
{
|
||||
}
|
||||
}
|
||||
12
Octokit.Reactive/Clients/IObservableActionsCacheClient.cs
Normal file
12
Octokit.Reactive/Clients/IObservableActionsCacheClient.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Cache API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/cache/">Actions Cache API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsCacheClient
|
||||
{
|
||||
}
|
||||
}
|
||||
41
Octokit.Reactive/Clients/IObservableActionsClient.cs
Normal file
41
Octokit.Reactive/Clients/IObservableActionsClient.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/">Actions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Client for the Artifacts API.
|
||||
/// </summary>
|
||||
IObservableActionsArtifactsClient Artifacts { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Cache API.
|
||||
/// </summary>
|
||||
IObservableActionsCacheClient Cache { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Permissions API.
|
||||
/// </summary>
|
||||
IObservableActionsPermissionsClient Permissions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runner groups API.
|
||||
/// </summary>
|
||||
IObservableActionsSelfHostedRunnerGroupsClient SelfHostedRunnerGroups { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runners API.
|
||||
/// </summary>
|
||||
IObservableActionsSelfHostedRunnersClient SelfHostedRunners { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflows API.
|
||||
/// </summary>
|
||||
IObservableActionsWorkflowsClient Workflows { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Permissions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/permissions/">Actions Permissions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsPermissionsClient
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Self-hosted runner groups API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/self-hosted-runner-groups/">Actions Self-hosted runner groups API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsSelfHostedRunnerGroupsClient
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Self-hosted runners API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/self-hosted-runners/">Actions Self-hosted runners API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsSelfHostedRunnersClient
|
||||
{
|
||||
}
|
||||
}
|
||||
108
Octokit.Reactive/Clients/IObservableActionsWorkflowJobsClient.cs
Normal file
108
Octokit.Reactive/Clients/IObservableActionsWorkflowJobsClient.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflows jobs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-jobs/">Actions Workflows jobs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsWorkflowJobsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Re-runs a specific workflow job in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-job-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
IObservable<Unit> Rerun(string owner, string name, long jobId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific job in a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#get-a-job-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The unique identifier of the job.</param>
|
||||
IObservable<WorkflowJob> Get(string owner, string name, long jobId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plain text log file for a workflow job.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#download-job-logs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
IObservable<string> GetLogs(string owner, string name, long jobId);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<WorkflowJobsResponse> List(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber, ApiOptions options);
|
||||
}
|
||||
}
|
||||
265
Octokit.Reactive/Clients/IObservableActionsWorkflowRunsClient.cs
Normal file
265
Octokit.Reactive/Clients/IObservableActionsWorkflowRunsClient.cs
Normal file
@@ -0,0 +1,265 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflows runs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-runs/">Actions Workflows runs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsWorkflowRunsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
IObservable<WorkflowRunsResponse> List(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
IObservable<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
IObservable<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<WorkflowRun> Get(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a specific workflow run. Anyone with write access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<Unit> Delete(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Get the review history for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-the-review-history-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<EnvironmentApprovals> GetReviewHistory(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Approves a workflow run for a pull request from a public fork of a first time contributor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#approve-a-workflow-run-for-a-fork-pull-request
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<Unit> Approve(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run attempt. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
IObservable<WorkflowRun> GetAttempt(string owner, string name, long runId, long attemptNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-attempt-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
IObservable<byte[]> GetAttemptLogs(string owner, string name, long runId, long attemptNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a workflow run using its Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<Unit> Cancel(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<byte[]> GetLogs(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all logs for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<Unit> DeleteLogs(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Approve or reject pending deployments that are waiting on approval by a required reviewer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#review-pending-deployments-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="review">The review for the pending deployment.</param>
|
||||
IObservable<Deployment> ReviewPendingDeployments(string owner, string name, long runId, PendingDeploymentReview review);
|
||||
|
||||
/// <summary>
|
||||
/// Re-runs a specific workflow run in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<Unit> Rerun(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Re-run all of the failed jobs and their dependent jobs in a workflow run using the Id of the workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-failed-jobs-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<Unit> RerunFailedJobs(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of billable minutes and total run time for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
IObservable<WorkflowRunUsage> GetUsage(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest, ApiOptions options);
|
||||
}
|
||||
}
|
||||
157
Octokit.Reactive/Clients/IObservableActionsWorkflowsClient.cs
Normal file
157
Octokit.Reactive/Clients/IObservableActionsWorkflowsClient.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflows API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflows/">Actions Workflows API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IObservableActionsWorkflowsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
IObservable<Unit> CreateDispatch(string owner, string name, string workflowFileName, CreateWorkflowDispatch createDispatch);
|
||||
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
IObservable<Unit> CreateDispatch(string owner, string name, long workflowId, CreateWorkflowDispatch createDispatch);
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
IObservable<Unit> Disable(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
IObservable<Unit> Disable(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
IObservable<Unit> Enable(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
IObservable<Unit> Enable(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
IObservable<Workflow> Get(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
IObservable<Workflow> Get(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
IObservable<WorkflowUsage> GetUsage(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
IObservable<WorkflowUsage> GetUsage(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
IObservable<WorkflowsResponse> List(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
IObservable<WorkflowsResponse> List(string owner, string name, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow jobs API.
|
||||
/// </summary>
|
||||
IObservableActionsWorkflowJobsClient Jobs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow runs API.
|
||||
/// </summary>
|
||||
IObservableActionsWorkflowRunsClient Runs { get; }
|
||||
}
|
||||
}
|
||||
18
Octokit.Reactive/Clients/ObservableActionsArtifactsClient.cs
Normal file
18
Octokit.Reactive/Clients/ObservableActionsArtifactsClient.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableActionsArtifactsClient : IObservableActionsArtifactsClient
|
||||
{
|
||||
readonly IActionsArtifactsClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Artifacts API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsArtifactsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.Artifacts;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Octokit.Reactive/Clients/ObservableActionsCacheClient.cs
Normal file
18
Octokit.Reactive/Clients/ObservableActionsCacheClient.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableActionsCacheClient : IObservableActionsCacheClient
|
||||
{
|
||||
readonly IActionsCacheClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Cache API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsCacheClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.Cache;
|
||||
}
|
||||
}
|
||||
}
|
||||
57
Octokit.Reactive/Clients/ObservableActionsClient.cs
Normal file
57
Octokit.Reactive/Clients/ObservableActionsClient.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/actions/">Actions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ObservableActionsClient : IObservableActionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
Artifacts = new ObservableActionsArtifactsClient(client);
|
||||
Cache = new ObservableActionsCacheClient(client);
|
||||
Permissions = new ObservableActionsPermissionsClient(client);
|
||||
SelfHostedRunnerGroups = new ObservableActionsSelfHostedRunnerGroupsClient(client);
|
||||
SelfHostedRunners = new ObservableActionsSelfHostedRunnersClient(client);
|
||||
Workflows = new ObservableActionsWorkflowsClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Artifacts API.
|
||||
/// </summary>
|
||||
public IObservableActionsArtifactsClient Artifacts { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Cache API.
|
||||
/// </summary>
|
||||
public IObservableActionsCacheClient Cache { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Permissions API.
|
||||
/// </summary>
|
||||
public IObservableActionsPermissionsClient Permissions { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runner groups API.
|
||||
/// </summary>
|
||||
public IObservableActionsSelfHostedRunnerGroupsClient SelfHostedRunnerGroups { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runners API.
|
||||
/// </summary>
|
||||
public IObservableActionsSelfHostedRunnersClient SelfHostedRunners { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflows API.
|
||||
/// </summary>
|
||||
public IObservableActionsWorkflowsClient Workflows { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableActionsPermissionsClient : IObservableActionsPermissionsClient
|
||||
{
|
||||
readonly IActionsPermissionsClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Permissions API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsPermissionsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.Permissions;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableActionsSelfHostedRunnerGroupsClient : IObservableActionsSelfHostedRunnerGroupsClient
|
||||
{
|
||||
readonly IActionsSelfHostedRunnerGroupsClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Self-hosted runner groups API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsSelfHostedRunnerGroupsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.SelfHostedRunnerGroups;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableActionsSelfHostedRunnersClient : IObservableActionsSelfHostedRunnersClient
|
||||
{
|
||||
readonly IActionsSelfHostedRunnersClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Self-hosted runners API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsSelfHostedRunnersClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.SelfHostedRunners;
|
||||
}
|
||||
}
|
||||
}
|
||||
172
Octokit.Reactive/Clients/ObservableActionsWorkflowJobsClient.cs
Normal file
172
Octokit.Reactive/Clients/ObservableActionsWorkflowJobsClient.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflow jobs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-jobs/">Actions Workflow jobs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ObservableActionsWorkflowJobsClient : IObservableActionsWorkflowJobsClient
|
||||
{
|
||||
readonly IActionsWorkflowJobsClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Workflows jobs API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsWorkflowJobsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.Workflows.Jobs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-runs a specific workflow job in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-job-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
public IObservable<Unit> Rerun(string owner, string name, long jobId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Rerun(owner, name, jobId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific job in a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#get-a-job-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The unique identifier of the job.</param>
|
||||
public IObservable<WorkflowJob> Get(string owner, string name, long jobId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Get(owner, name, jobId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plain text log file for a workflow job.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#download-job-logs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
public IObservable<string> GetLogs(string owner, string name, long jobId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.GetLogs(owner, name, jobId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<WorkflowJobsResponse> List(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.List(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
public IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunJobsRequest, nameof(workflowRunJobsRequest));
|
||||
|
||||
return _client.List(owner, name, runId, workflowRunJobsRequest).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
public IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunJobsRequest, nameof(workflowRunJobsRequest));
|
||||
|
||||
return _client.List(owner, name, runId, workflowRunJobsRequest, options).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
public IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.List(owner, name, runId, attemptNumber).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
public IObservable<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.List(owner, name, runId, attemptNumber, options).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
427
Octokit.Reactive/Clients/ObservableActionsWorkflowRunsClient.cs
Normal file
427
Octokit.Reactive/Clients/ObservableActionsWorkflowRunsClient.cs
Normal file
@@ -0,0 +1,427 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflow runs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-jobs/">Actions Workflow runs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ObservableActionsWorkflowRunsClient : IObservableActionsWorkflowRunsClient
|
||||
{
|
||||
readonly IActionsWorkflowRunsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Workflows runs API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsWorkflowRunsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.Workflows.Runs;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
public IObservable<WorkflowRunsResponse> List(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.List(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
public IObservable<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
|
||||
return _client.List(owner, name, workflowRunsRequest).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
public IObservable<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
return _client.List(owner, name, workflowRunsRequest, options).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<WorkflowRun> Get(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Get(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a specific workflow run. Anyone with write access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<Unit> Delete(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Delete(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the review history for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-the-review-history-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<EnvironmentApprovals> GetReviewHistory(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _connection.GetAndFlattenAllPages<EnvironmentApprovals>(ApiUrls.ActionsWorkflowRunApprovals(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Approves a workflow run for a pull request from a public fork of a first time contributor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#approve-a-workflow-run-for-a-fork-pull-request
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<Unit> Approve(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Approve(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run attempt. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
public IObservable<WorkflowRun> GetAttempt(string owner, string name, long runId, long attemptNumber)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.GetAttempt(owner, name, runId, attemptNumber).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-attempt-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
public IObservable<byte[]> GetAttemptLogs(string owner, string name, long runId, long attemptNumber)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.GetAttemptLogs(owner, name, runId, attemptNumber).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a workflow run using its Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<Unit> Cancel(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Cancel(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<byte[]> GetLogs(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.GetLogs(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all logs for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<Unit> DeleteLogs(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.DeleteLogs(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Approve or reject pending deployments that are waiting on approval by a required reviewer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#review-pending-deployments-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="review">The review for the pending deployment.</param>
|
||||
public IObservable<Deployment> ReviewPendingDeployments(string owner, string name, long runId, PendingDeploymentReview review)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(review, nameof(review));
|
||||
|
||||
return _client.ReviewPendingDeployments(owner, name, runId, review).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-runs a specific workflow run in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<Unit> Rerun(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Rerun(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-run all of the failed jobs and their dependent jobs in a workflow run using the Id of the workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-failed-jobs-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<Unit> RerunFailedJobs(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.RerunFailedJobs(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of billable minutes and total run time for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
public IObservable<WorkflowRunUsage> GetUsage(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.GetUsage(owner, name, runId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
public IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.ListByWorkflow(owner, name, workflowId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
public IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
|
||||
return _client.ListByWorkflow(owner, name, workflowId, workflowRunsRequest).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
public IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
return _client.ListByWorkflow(owner, name, workflowId, workflowRunsRequest, options).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The Id of the workflow.</param>
|
||||
public IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return _client.ListByWorkflow(owner, name, workflowFileName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
public IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
|
||||
return _client.ListByWorkflow(owner, name, workflowFileName, workflowRunsRequest).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
public IObservable<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
return _client.ListByWorkflow(owner, name, workflowFileName, workflowRunsRequest, options).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
248
Octokit.Reactive/Clients/ObservableActionsWorkflowsClient.cs
Normal file
248
Octokit.Reactive/Clients/ObservableActionsWorkflowsClient.cs
Normal file
@@ -0,0 +1,248 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableActionsWorkflowsClient : IObservableActionsWorkflowsClient
|
||||
{
|
||||
readonly IActionsWorkflowsClient _client;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions Workflows API client.
|
||||
/// </summary>
|
||||
/// <param name="client">A GitHub client.</param>
|
||||
public ObservableActionsWorkflowsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, nameof(client));
|
||||
|
||||
_client = client.Actions.Workflows;
|
||||
|
||||
Jobs = new ObservableActionsWorkflowJobsClient(client);
|
||||
Runs = new ObservableActionsWorkflowRunsClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
public IObservable<Unit> CreateDispatch(string owner, string name, string workflowFileName, CreateWorkflowDispatch createDispatch)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
|
||||
|
||||
return _client.CreateDispatch(owner, name, workflowFileName, createDispatch).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
public IObservable<Unit> CreateDispatch(string owner, string name, long workflowId, CreateWorkflowDispatch createDispatch)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
|
||||
|
||||
return _client.CreateDispatch(owner, name, workflowId, createDispatch).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
public IObservable<Unit> Disable(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return _client.Disable(owner, name, workflowFileName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
public IObservable<Unit> Disable(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Disable(owner, name, workflowId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
public IObservable<Unit> Enable(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return _client.Enable(owner, name, workflowFileName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
public IObservable<Unit> Enable(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Enable(owner, name, workflowId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
public IObservable<Workflow> Get(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return _client.Get(owner, name, workflowFileName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
public IObservable<Workflow> Get(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.Get(owner, name, workflowId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
public IObservable<WorkflowUsage> GetUsage(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return _client.GetUsage(owner, name, workflowFileName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
public IObservable<WorkflowUsage> GetUsage(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.GetUsage(owner, name, workflowId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
public IObservable<WorkflowsResponse> List(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return _client.List(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
public IObservable<WorkflowsResponse> List(string owner, string name, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
return _client.List(owner, name, options).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow jobs API.
|
||||
/// </summary>
|
||||
public IObservableActionsWorkflowJobsClient Jobs { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow runs API.
|
||||
/// </summary>
|
||||
public IObservableActionsWorkflowRunsClient Runs { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Org Actions API.
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Actions API.
|
||||
|
||||
@@ -41,5 +41,6 @@ namespace Octokit.Reactive
|
||||
IObservableLicensesClient Licenses { get; }
|
||||
IObservableRateLimitClient RateLimit { get; }
|
||||
IObservableMetaClient Meta { get; }
|
||||
IObservableActionsClient Actions { get; }
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ namespace Octokit.Reactive
|
||||
Licenses = new ObservableLicensesClient(gitHubClient);
|
||||
RateLimit = new ObservableRateLimitClient(gitHubClient);
|
||||
Meta = new ObservableMetaClient(gitHubClient);
|
||||
Actions = new ObservableActionsClient(gitHubClient);
|
||||
}
|
||||
|
||||
public IConnection Connection
|
||||
@@ -102,6 +103,7 @@ namespace Octokit.Reactive
|
||||
public IObservableLicensesClient Licenses { get; private set; }
|
||||
public IObservableRateLimitClient RateLimit { get; private set; }
|
||||
public IObservableMetaClient Meta { get; private set; }
|
||||
public IObservableActionsClient Actions { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the latest API Info - this will be null if no API calls have been made
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>1591;1701;1702;1705</NoWarn>
|
||||
<NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using Xunit;
|
||||
|
||||
public class ActionsWorkflowJobsClientTests
|
||||
{
|
||||
private const string HelloWorldWorkflow = @"
|
||||
name: hello
|
||||
on: [ push, workflow_dispatch ]
|
||||
jobs:
|
||||
world:
|
||||
runs-on: [ ubuntu-latest ]
|
||||
steps:
|
||||
- run: echo ""Hello world.""";
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanListWorkflowJobs()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Jobs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForCompletion(github, context);
|
||||
|
||||
var jobs = await fixture.List(owner, name, runId);
|
||||
|
||||
Assert.NotNull(jobs);
|
||||
Assert.NotEqual(0, jobs.TotalCount);
|
||||
Assert.NotNull(jobs.Jobs);
|
||||
Assert.NotEmpty(jobs.Jobs);
|
||||
|
||||
jobs = await fixture.List(owner, name, runId, new WorkflowRunJobsRequest() { Filter = WorkflowRunJobsFilter.All });
|
||||
|
||||
Assert.NotNull(jobs);
|
||||
Assert.NotEqual(0, jobs.TotalCount);
|
||||
Assert.NotNull(jobs.Jobs);
|
||||
Assert.NotEmpty(jobs.Jobs);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowJob()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Jobs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForCompletion(github, context);
|
||||
|
||||
var jobs = await fixture.List(owner, name, runId);
|
||||
|
||||
Assert.NotNull(jobs);
|
||||
Assert.NotNull(jobs.Jobs);
|
||||
Assert.Single(jobs.Jobs);
|
||||
|
||||
var job = await fixture.Get(owner, name, jobs.Jobs[0].Id);
|
||||
|
||||
Assert.NotNull(job);
|
||||
Assert.Equal(jobs.Jobs[0].Id, job.Id);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanListWorkflowJobsForAttempt()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Jobs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForCompletion(github, context);
|
||||
|
||||
var jobs = await fixture.List(owner, name, runId, 1);
|
||||
|
||||
Assert.NotNull(jobs);
|
||||
Assert.NotEqual(0, jobs.TotalCount);
|
||||
Assert.NotNull(jobs.Jobs);
|
||||
Assert.NotEmpty(jobs.Jobs);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowJobLogs()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Jobs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForCompletion(github, context);
|
||||
|
||||
var jobs = await fixture.List(owner, name, runId);
|
||||
|
||||
Assert.NotNull(jobs);
|
||||
Assert.NotNull(jobs.Jobs);
|
||||
var job = Assert.Single(jobs.Jobs);
|
||||
|
||||
var logs = await fixture.GetLogs(owner, name, job.Id);
|
||||
|
||||
Assert.NotNull(logs);
|
||||
Assert.NotEmpty(logs);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanRerunJob()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Jobs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForCompletion(github, context);
|
||||
|
||||
var jobs = await fixture.List(owner, name, runId);
|
||||
|
||||
Assert.NotNull(jobs);
|
||||
Assert.NotNull(jobs.Jobs);
|
||||
var job = Assert.Single(jobs.Jobs);
|
||||
|
||||
await fixture.Rerun(owner, name, job.Id);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<(string WorkflowFileName, long RunId)> CreateWorkflowAndWaitForCompletion(
|
||||
IGitHubClient github,
|
||||
RepositoryContext context)
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
var workflowFileName = ".github/workflows/hello-world.yml";
|
||||
|
||||
_ = await github.Repository.Content.CreateFile(
|
||||
owner,
|
||||
name,
|
||||
workflowFileName,
|
||||
new CreateFileRequest("Create test workflow", HelloWorldWorkflow));
|
||||
|
||||
var totalTimeout = TimeSpan.FromMinutes(1);
|
||||
var loopDelay = TimeSpan.FromSeconds(2);
|
||||
|
||||
using (var cts = new CancellationTokenSource(totalTimeout))
|
||||
{
|
||||
while (!cts.IsCancellationRequested)
|
||||
{
|
||||
cts.Token.ThrowIfCancellationRequested();
|
||||
|
||||
var runs = await github.Actions.Workflows.Runs.List(owner, name);
|
||||
|
||||
await Task.Delay(loopDelay);
|
||||
|
||||
if (runs.TotalCount > 0 && runs.WorkflowRuns[0].Status == WorkflowRunStatus.Completed)
|
||||
{
|
||||
return (workflowFileName, runs.WorkflowRuns[0].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Timed out waiting for workflow run.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using Xunit;
|
||||
|
||||
public class ActionsWorkflowRunsClientTests
|
||||
{
|
||||
private const string HelloWorldWorkflow = @"
|
||||
name: hello
|
||||
on: [ push, workflow_dispatch ]
|
||||
jobs:
|
||||
world:
|
||||
runs-on: [ ubuntu-latest ]
|
||||
steps:
|
||||
- run: echo ""Hello world.""";
|
||||
|
||||
private const string BrokenWorkflow = @"
|
||||
name: hello
|
||||
on: [ push, workflow_dispatch ]
|
||||
jobs:
|
||||
world:
|
||||
runs-on: [ ubuntu-latest ]
|
||||
steps:
|
||||
- run: exit 1";
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanListWorkflowRuns()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, _) = await CreateWorkflowAndWaitForFirstRun(github, context);
|
||||
|
||||
var runs = await fixture.List(owner, name);
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.NotEqual(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.NotEmpty(runs.WorkflowRuns);
|
||||
|
||||
runs = await fixture.List(owner, name, new WorkflowRunsRequest() { Branch = "main" });
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.NotEqual(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.NotEmpty(runs.WorkflowRuns);
|
||||
|
||||
runs = await fixture.List(owner, name, new WorkflowRunsRequest() { Branch = "not-main" });
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.Equal(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.Empty(runs.WorkflowRuns);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowRun()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context);
|
||||
|
||||
var run = await fixture.Get(owner, name, runId);
|
||||
|
||||
Assert.NotNull(run);
|
||||
Assert.Equal(runId, run.Id);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanDeleteWorkflowRun()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context, WorkflowRunStatus.Completed);
|
||||
|
||||
await fixture.Delete(owner, name, runId);
|
||||
await Assert.ThrowsAsync<NotFoundException>(() => fixture.Get(owner, name, runId));
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanDeleteWorkflowRunLogs()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context, WorkflowRunStatus.Completed);
|
||||
|
||||
await fixture.DeleteLogs(owner, name, runId);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowRunReviewHistory()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context);
|
||||
|
||||
var reviews = await fixture.GetReviewHistory(owner, name, runId);
|
||||
Assert.NotNull(reviews);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowRunAttempt()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context);
|
||||
|
||||
var run = await fixture.GetAttempt(owner, name, runId, 1);
|
||||
|
||||
Assert.NotNull(run);
|
||||
Assert.Equal(runId, run.Id);
|
||||
Assert.Equal(1, run.RunAttempt);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowRunAttemptLogs()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context, WorkflowRunStatus.Completed);
|
||||
|
||||
var logs = await fixture.GetAttemptLogs(owner, name, runId, 1);
|
||||
|
||||
Assert.NotNull(logs);
|
||||
Assert.NotEmpty(logs);
|
||||
|
||||
var tempFile = Path.GetTempFileName();
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(tempFile, logs);
|
||||
|
||||
using (var archive = ZipFile.OpenRead(tempFile))
|
||||
{
|
||||
Assert.NotEmpty(archive.Entries);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(tempFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowRunLogs()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context, WorkflowRunStatus.Completed);
|
||||
|
||||
var logs = await fixture.GetLogs(owner, name, runId);
|
||||
|
||||
Assert.NotNull(logs);
|
||||
Assert.NotEmpty(logs);
|
||||
|
||||
var tempFile = Path.GetTempFileName();
|
||||
|
||||
try
|
||||
{
|
||||
File.WriteAllBytes(tempFile, logs);
|
||||
|
||||
using (var archive = ZipFile.OpenRead(tempFile))
|
||||
{
|
||||
Assert.NotEmpty(archive.Entries);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(tempFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCancelWorkflowRun()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context);
|
||||
|
||||
await fixture.Cancel(owner, name, runId);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanRerunWorkflow()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context, WorkflowRunStatus.Completed);
|
||||
|
||||
await fixture.Rerun(owner, name, runId);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanRerunFailedJobs()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(
|
||||
github,
|
||||
context,
|
||||
WorkflowRunStatus.Completed,
|
||||
BrokenWorkflow);
|
||||
|
||||
await fixture.RerunFailedJobs(owner, name, runId);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowRunUsage()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
|
||||
(var workflowFileName, var runId) = await CreateWorkflowAndWaitForFirstRun(github, context, WorkflowRunStatus.Completed);
|
||||
|
||||
var usage = await fixture.GetUsage(owner, name, runId);
|
||||
|
||||
Assert.NotNull(usage);
|
||||
Assert.NotEqual(0, usage.RunDurationMs);
|
||||
Assert.NotNull(usage.Billable);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanListWorkflowRunsByWorkflow()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows.Runs;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
(var workflowFileName, _) = await CreateWorkflowAndWaitForFirstRun(github, context);
|
||||
|
||||
var runs = await fixture.ListByWorkflow(owner, name, workflowFileName);
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.NotEqual(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.NotEmpty(runs.WorkflowRuns);
|
||||
|
||||
runs = await fixture.ListByWorkflow(owner, name, workflowFileName, new WorkflowRunsRequest() { Branch = "main" });
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.NotEqual(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.NotEmpty(runs.WorkflowRuns);
|
||||
|
||||
runs = await fixture.ListByWorkflow(owner, name, workflowFileName, new WorkflowRunsRequest() { Branch = "not-main" });
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.Equal(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.Empty(runs.WorkflowRuns);
|
||||
|
||||
var workflowId = await GetWorkflowId(github, context, workflowFileName);
|
||||
|
||||
runs = await fixture.ListByWorkflow(owner, name, workflowId);
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.NotEqual(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.NotEmpty(runs.WorkflowRuns);
|
||||
|
||||
runs = await fixture.ListByWorkflow(owner, name, workflowId, new WorkflowRunsRequest() { Branch = "main" });
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.NotEqual(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.NotEmpty(runs.WorkflowRuns);
|
||||
|
||||
runs = await fixture.ListByWorkflow(owner, name, workflowId, new WorkflowRunsRequest() { Branch = "not-main" });
|
||||
|
||||
Assert.NotNull(runs);
|
||||
Assert.Equal(0, runs.TotalCount);
|
||||
Assert.NotNull(runs.WorkflowRuns);
|
||||
Assert.Empty(runs.WorkflowRuns);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<(string WorkflowFileName, long RunId)> CreateWorkflowAndWaitForFirstRun(
|
||||
IGitHubClient github,
|
||||
RepositoryContext context,
|
||||
WorkflowRunStatus? statusToWaitFor = null,
|
||||
string workflowFile = HelloWorldWorkflow)
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
var workflowFileName = ".github/workflows/hello-world.yml";
|
||||
|
||||
_ = await github.Repository.Content.CreateFile(
|
||||
owner,
|
||||
name,
|
||||
workflowFileName,
|
||||
new CreateFileRequest("Create test workflow", workflowFile));
|
||||
|
||||
var totalTimeout = TimeSpan.FromMinutes(1);
|
||||
var loopDelay = TimeSpan.FromSeconds(1);
|
||||
|
||||
using (var cts = new CancellationTokenSource(totalTimeout))
|
||||
{
|
||||
while (!cts.IsCancellationRequested)
|
||||
{
|
||||
cts.Token.ThrowIfCancellationRequested();
|
||||
|
||||
var runs = await github.Actions.Workflows.Runs.List(owner, name);
|
||||
|
||||
await Task.Delay(loopDelay);
|
||||
|
||||
if (runs.TotalCount > 0 && (statusToWaitFor == null || runs.WorkflowRuns[0].Status == statusToWaitFor))
|
||||
{
|
||||
return (workflowFileName, runs.WorkflowRuns[0].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Timed out waiting for workflow run.");
|
||||
}
|
||||
|
||||
private static async Task<long> GetWorkflowId(
|
||||
IGitHubClient github,
|
||||
RepositoryContext context,
|
||||
string workflowFileName)
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
|
||||
var workflow = await github.Actions.Workflows.Get(owner, name, workflowFileName);
|
||||
return workflow.Id;
|
||||
}
|
||||
}
|
||||
195
Octokit.Tests.Integration/Clients/ActionsWorkflowsClientTests.cs
Normal file
195
Octokit.Tests.Integration/Clients/ActionsWorkflowsClientTests.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using Xunit;
|
||||
|
||||
public class ActionsWorkflowsClientTests
|
||||
{
|
||||
private static readonly string HelloWorldWorkflow = @"
|
||||
name: hello
|
||||
on: [ push, workflow_dispatch ]
|
||||
jobs:
|
||||
world:
|
||||
runs-on: [ ubuntu-latest ]
|
||||
steps:
|
||||
- run: echo ""Hello world.""";
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflow()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
var workflowFileName = await CreateWorkflow(github, context);
|
||||
|
||||
var workflowByName = await fixture.Get(owner, name, workflowFileName);
|
||||
Assert.NotNull(workflowByName);
|
||||
Assert.Equal(workflowFileName, workflowByName.Path);
|
||||
|
||||
var workflowById = await fixture.Get(owner, name, workflowByName.Id);
|
||||
Assert.NotNull(workflowById);
|
||||
Assert.Equal(workflowByName.Id, workflowById.Id);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetWorkflowUsage()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
var workflowFileName = await CreateWorkflow(github, context);
|
||||
|
||||
var usage = await fixture.GetUsage(owner, name, workflowFileName);
|
||||
Assert.NotNull(usage);
|
||||
Assert.NotNull(usage.Billable);
|
||||
|
||||
var workflowId = await GetWorkflowId(github, context, workflowFileName);
|
||||
|
||||
usage = await fixture.GetUsage(owner, name, workflowId);
|
||||
Assert.NotNull(usage);
|
||||
Assert.NotNull(usage.Billable);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanListWorkflows()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
|
||||
var workflows = await fixture.List(owner, name);
|
||||
|
||||
Assert.NotNull(workflows);
|
||||
Assert.Equal(0, workflows.TotalCount);
|
||||
Assert.NotNull(workflows.Workflows);
|
||||
Assert.Empty(workflows.Workflows);
|
||||
|
||||
var workflowFileName = await CreateWorkflow(github, context);
|
||||
|
||||
workflows = await fixture.List(owner, name);
|
||||
|
||||
Assert.NotNull(workflows);
|
||||
Assert.Equal(1, workflows.TotalCount);
|
||||
Assert.NotNull(workflows.Workflows);
|
||||
|
||||
var workflow = Assert.Single(workflows.Workflows);
|
||||
|
||||
Assert.NotNull(workflow);
|
||||
Assert.Equal(workflowFileName, workflow.Path);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanDispatchWorkflow()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
var workflowFileName = await CreateWorkflow(github, context);
|
||||
var reference = "main";
|
||||
|
||||
await fixture.CreateDispatch(owner, name, workflowFileName, new CreateWorkflowDispatch(reference));
|
||||
|
||||
var workflowId = await GetWorkflowId(github, context, workflowFileName);
|
||||
|
||||
await fixture.CreateDispatch(owner, name, workflowId, new CreateWorkflowDispatch(reference));
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanEnableAndDisableWorkflow()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var fixture = github.Actions.Workflows;
|
||||
|
||||
using (var context = await github.CreateRepositoryContextWithAutoInit())
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
|
||||
var workflowFileName = await CreateWorkflow(github, context);
|
||||
var workflowId = await AssertWorkflowState(github, context, workflowFileName, "active");
|
||||
|
||||
await fixture.Disable(owner, name, workflowId);
|
||||
|
||||
await AssertWorkflowState(github, context, workflowFileName, "disabled_manually");
|
||||
|
||||
await fixture.Enable(owner, name, workflowId);
|
||||
|
||||
await AssertWorkflowState(github, context, workflowFileName, "active");
|
||||
|
||||
await fixture.Disable(owner, name, workflowFileName);
|
||||
|
||||
await AssertWorkflowState(github, context, workflowFileName, "disabled_manually");
|
||||
|
||||
await fixture.Enable(owner, name, workflowFileName);
|
||||
|
||||
await AssertWorkflowState(github, context, workflowFileName, "active");
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<string> CreateWorkflow(IGitHubClient github, RepositoryContext context)
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
var workflowFileName = ".github/workflows/hello-world.yml";
|
||||
|
||||
_ = await github.Repository.Content.CreateFile(
|
||||
owner,
|
||||
name,
|
||||
workflowFileName,
|
||||
new CreateFileRequest("Create test workflow", HelloWorldWorkflow));
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(1.5));
|
||||
|
||||
return workflowFileName;
|
||||
}
|
||||
|
||||
private static async Task<long> AssertWorkflowState(
|
||||
IGitHubClient github,
|
||||
RepositoryContext context,
|
||||
string workflowFileName,
|
||||
string expected)
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
|
||||
var workflow = await github.Actions.Workflows.Get(owner, name, workflowFileName);
|
||||
Assert.NotNull(workflow);
|
||||
Assert.Equal(expected, workflow.State);
|
||||
|
||||
return workflow.Id;
|
||||
}
|
||||
|
||||
private static async Task<long> GetWorkflowId(
|
||||
IGitHubClient github,
|
||||
RepositoryContext context,
|
||||
string workflowFileName)
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
var name = context.Repository.Name;
|
||||
|
||||
var workflow = await github.Actions.Workflows.Get(owner, name, workflowFileName);
|
||||
return workflow.Id;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Tests.Integration.Clients
|
||||
{
|
||||
public class OrganizationActionsClientTests
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Tests.Integration.Clients
|
||||
{
|
||||
public class RepositoryActionsClientTests
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Tests.Integration.Reactive
|
||||
{
|
||||
public class ObservableOrganizationActionsClientTests
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit.Tests.Integration.Reactive
|
||||
{
|
||||
public class ObservableRepositoryActionsClientTests
|
||||
{
|
||||
}
|
||||
}
|
||||
223
Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs
Normal file
223
Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs
Normal file
@@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class ActionsWorkflowJobsClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ActionsWorkflowJobsClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRerunMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await client.Rerun("fake", "repo", 123);
|
||||
|
||||
connection.Received().Post(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/jobs/123/rerun"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Rerun(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Rerun("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Rerun("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Rerun("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await client.Get("fake", "repo", 123);
|
||||
|
||||
connection.Received().Get<WorkflowJob>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/jobs/123"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await client.GetLogs("fake", "repo", 123);
|
||||
|
||||
connection.Connection.Received().Get<string>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/jobs/123/logs"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetLogs(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetLogs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetLogs("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetLogs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await client.List("fake", "repo", 123);
|
||||
|
||||
connection.Received().GetAll<WorkflowJobsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/jobs"),
|
||||
Args.EmptyDictionary,
|
||||
Args.ApiOptions);
|
||||
|
||||
await client.List("fake", "repo", 123, 456);
|
||||
|
||||
connection.Received().GetAll<WorkflowJobsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/attempts/456/jobs"),
|
||||
null,
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
var request = new WorkflowRunJobsRequest
|
||||
{
|
||||
Filter = WorkflowRunJobsFilter.All,
|
||||
};
|
||||
|
||||
await client.List("fake", "repo", 123, request);
|
||||
|
||||
connection.Received().GetAll<WorkflowJobsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/jobs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 1
|
||||
&& x["filter"] == "all"),
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequestWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
var request = new WorkflowRunJobsRequest { Filter = WorkflowRunJobsFilter.Latest };
|
||||
var options = new ApiOptions { PageSize = 1 };
|
||||
|
||||
await client.List("fake", "repo", 123, request, options);
|
||||
|
||||
connection.Received().GetAll<WorkflowJobsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/jobs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 1
|
||||
&& x["filter"] == "latest"),
|
||||
options);
|
||||
|
||||
await client.List("fake", "repo", 123, 456, options);
|
||||
|
||||
connection.Received().GetAll<WorkflowJobsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/attempts/456/jobs"),
|
||||
null,
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", null, 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List(null, "repo", 123, 456));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", null, 123, 456));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowJobsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("fake", "", 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("", "repo", 123, 456));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("fake", "", 123, 456));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
839
Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs
Normal file
839
Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs
Normal file
@@ -0,0 +1,839 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class ActionsWorkflowRunsClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ActionsWorkflowRunsClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheApproveMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.Approve("fake", "repo", 123);
|
||||
|
||||
connection.Received().Post(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approve"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Approve(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Approve("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Approve("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Approve("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCancelMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.Cancel("fake", "repo", 123);
|
||||
|
||||
connection.Received().Post(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/cancel"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Cancel(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Cancel("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Cancel("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Cancel("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.Delete("fake", "repo", 123);
|
||||
|
||||
connection.Received().Delete(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.DeleteLogs("fake", "repo", 123);
|
||||
|
||||
connection.Received().Delete(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/logs"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteLogs(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteLogs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteLogs("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteLogs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.Get("fake", "repo", 123);
|
||||
|
||||
connection.Received().Get<WorkflowRun>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var headers = new Dictionary<string, string>();
|
||||
var response = TestSetup.CreateResponse(HttpStatusCode.OK, new byte[] { 1, 2, 3, 4 }, headers);
|
||||
var responseTask = Task.FromResult<IApiResponse<byte[]>>(new ApiResponse<byte[]>(response));
|
||||
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetRaw(Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/logs"), null)
|
||||
.Returns(responseTask);
|
||||
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
|
||||
var client = new ActionsWorkflowRunsClient(apiConnection);
|
||||
|
||||
var actual = await client.GetLogs("fake", "repo", 123);
|
||||
|
||||
Assert.Equal(new byte[] { 1, 2, 3, 4 }, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetLogs(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetLogs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetLogs("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetLogs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAttemptMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.GetAttempt("fake", "repo", 123, 456);
|
||||
|
||||
connection.Received().Get<WorkflowRun>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/attempts/456"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAttempt(null, "repo", 123, 456));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAttempt("fake", null, 123, 456));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAttempt("", "repo", 123, 456));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAttempt("fake", "", 123, 456));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAttemptLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var headers = new Dictionary<string, string>();
|
||||
var response = TestSetup.CreateResponse(HttpStatusCode.OK, new byte[] { 1, 2, 3, 4 }, headers);
|
||||
var responseTask = Task.FromResult<IApiResponse<byte[]>>(new ApiResponse<byte[]>(response));
|
||||
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetRaw(Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/attempts/456/logs"), null)
|
||||
.Returns(responseTask);
|
||||
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
|
||||
var client = new ActionsWorkflowRunsClient(apiConnection);
|
||||
|
||||
var actual = await client.GetAttemptLogs("fake", "repo", 123, 456);
|
||||
|
||||
Assert.Equal(new byte[] { 1, 2, 3, 4 }, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAttemptLogs(null, "repo", 123, 456));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAttemptLogs("fake", null, 123, 456));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAttemptLogs("", "repo", 123, 456));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAttemptLogs("fake", "", 123, 456));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetReviewHistoryMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.GetReviewHistory("fake", "repo", 123);
|
||||
|
||||
connection.Received().GetAll<EnvironmentApprovals>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approvals"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var workflowRunsRequest = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetReviewHistory(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetReviewHistory("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var workflowRunsRequest = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetReviewHistory("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetReviewHistory("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetUsageMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.GetUsage("fake", "repo", 123);
|
||||
|
||||
connection.Received().Get<WorkflowRunUsage>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/timing"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetUsage(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetUsage("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetUsage("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetUsage("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.List("fake", "repo");
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs"),
|
||||
Args.EmptyDictionary,
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest
|
||||
{
|
||||
Actor = "octocat",
|
||||
Branch = "main",
|
||||
CheckSuiteId = 42,
|
||||
Created = "2020-2022",
|
||||
Event = "push",
|
||||
ExcludePullRequests = true,
|
||||
Status = CheckRunStatusFilter.InProgress,
|
||||
};
|
||||
|
||||
await client.List("fake", "repo", request);
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 7
|
||||
&& x["actor"] == "octocat"
|
||||
&& x["branch"] == "main"
|
||||
&& x["check_suite_id"] == "42"
|
||||
&& x["created"] == "2020-2022"
|
||||
&& x["event"] == "push"
|
||||
&& x["branch"] == "main"
|
||||
&& x["exclude_pull_requests"] == "true"
|
||||
&& x["status"] == "in_progress"),
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequestWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest { Branch = "main", CheckSuiteId = 42, Status = CheckRunStatusFilter.InProgress };
|
||||
var options = new ApiOptions { PageSize = 1 };
|
||||
|
||||
await client.List("fake", "repo", request, options);
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 3
|
||||
&& x["branch"] == "main"
|
||||
&& x["status"] == "in_progress"
|
||||
&& x["check_suite_id"] == "42"),
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var workflowRunsRequest = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List(null, "repo"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List(null, "repo", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", null, workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", "repo", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List(null, "repo", workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", null, workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", "repo", null, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", "repo", workflowRunsRequest, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var workflowRunsRequest = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("", "repo"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("fake", ""));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("", "repo", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("fake", "", workflowRunsRequest));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("", "repo", workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("fake", "", workflowRunsRequest, options));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListByWorkflowMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.ListByWorkflow("fake", "repo", 123);
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/runs"),
|
||||
Args.EmptyDictionary,
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithName()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await client.ListByWorkflow("fake", "repo", "main.yml");
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yml/runs"),
|
||||
Args.EmptyDictionary,
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithIdWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest
|
||||
{
|
||||
Actor = "octocat",
|
||||
Branch = "main",
|
||||
CheckSuiteId = 42,
|
||||
Created = "2020-2022",
|
||||
Event = "push",
|
||||
ExcludePullRequests = true,
|
||||
Status = CheckRunStatusFilter.InProgress,
|
||||
};
|
||||
|
||||
await client.ListByWorkflow("fake", "repo", 123, request);
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/runs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 7
|
||||
&& x["actor"] == "octocat"
|
||||
&& x["branch"] == "main"
|
||||
&& x["check_suite_id"] == "42"
|
||||
&& x["created"] == "2020-2022"
|
||||
&& x["event"] == "push"
|
||||
&& x["branch"] == "main"
|
||||
&& x["exclude_pull_requests"] == "true"
|
||||
&& x["status"] == "in_progress"),
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithNameWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest
|
||||
{
|
||||
Actor = "octocat",
|
||||
Branch = "main",
|
||||
CheckSuiteId = 42,
|
||||
Created = "2020-2022",
|
||||
Event = "push",
|
||||
ExcludePullRequests = true,
|
||||
Status = CheckRunStatusFilter.InProgress,
|
||||
};
|
||||
|
||||
await client.ListByWorkflow("fake", "repo", "main.yml", request);
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yml/runs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 7
|
||||
&& x["actor"] == "octocat"
|
||||
&& x["branch"] == "main"
|
||||
&& x["check_suite_id"] == "42"
|
||||
&& x["created"] == "2020-2022"
|
||||
&& x["event"] == "push"
|
||||
&& x["branch"] == "main"
|
||||
&& x["exclude_pull_requests"] == "true"
|
||||
&& x["status"] == "in_progress"),
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithIdWithRequestWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest { Branch = "main", CheckSuiteId = 42, Status = CheckRunStatusFilter.InProgress };
|
||||
var options = new ApiOptions { PageSize = 1 };
|
||||
|
||||
await client.ListByWorkflow("fake", "repo", 123, request, options);
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/runs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 3
|
||||
&& x["branch"] == "main"
|
||||
&& x["status"] == "in_progress"
|
||||
&& x["check_suite_id"] == "42"),
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithNameWithRequestWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest { Branch = "main", CheckSuiteId = 42, Status = CheckRunStatusFilter.InProgress };
|
||||
var options = new ApiOptions { PageSize = 1 };
|
||||
|
||||
await client.ListByWorkflow("fake", "repo", "main.yml", request, options);
|
||||
|
||||
connection.Received().GetAll<WorkflowRunsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yml/runs"),
|
||||
Arg.Is<Dictionary<string, string>>(x =>
|
||||
x.Count == 3
|
||||
&& x["branch"] == "main"
|
||||
&& x["status"] == "in_progress"
|
||||
&& x["check_suite_id"] == "42"),
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var workflowRunsRequest = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", null, 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", "main.yml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", null, "main.yml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", 123, workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", null, 123, workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", 123, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", "main.yml", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", null, "main.yml", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", null, workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", "main.yml", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", 123, workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", null, 123, workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", 123, null, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", 123, workflowRunsRequest, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", "main.yml", workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", null, "main.yml", workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", null, workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", "main.yml", null, options));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", "main.yml", workflowRunsRequest, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var workflowRunsRequest = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "", 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("", "repo", "main.yml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "", "main.yml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "repo", ""));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("", "repo", 123, workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "", 123, workflowRunsRequest));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("", "repo", "main.yml", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "", "main.yml", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "repo", "", workflowRunsRequest));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("", "repo", "main.yml", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "", "main.yml", workflowRunsRequest));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "repo", "", workflowRunsRequest));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("", "repo", "main.yml", workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "", "main.yml", workflowRunsRequest, options));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ListByWorkflow("fake", "repo", "", workflowRunsRequest, options));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRerunMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
await client.Rerun("fake", "repo", 123);
|
||||
|
||||
connection.Received().Post(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/rerun"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Rerun(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Rerun("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Rerun("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Rerun("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRerunFailedJobsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
await client.RerunFailedJobs("fake", "repo", 123);
|
||||
|
||||
connection.Received().Post(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/rerun-failed-jobs"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RerunFailedJobs(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.RerunFailedJobs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RerunFailedJobs("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.RerunFailedJobs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheReviewFailedJobsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var review = new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, "");
|
||||
|
||||
await client.ReviewPendingDeployments("fake", "repo", 123, review);
|
||||
|
||||
connection.Received().Post<Deployment>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/pending_deployments"),
|
||||
review);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var review = new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, "Ship it!");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ReviewPendingDeployments(null, "repo", 123, review));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ReviewPendingDeployments("fake", null, 123, review));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ReviewPendingDeployments("fake", "repo", 123, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowRunsClient(connection);
|
||||
|
||||
var review = new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, "Ship it!");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ReviewPendingDeployments("", "repo", 123, review));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.ReviewPendingDeployments("fake", "", 123, review));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
383
Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs
Normal file
383
Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs
Normal file
@@ -0,0 +1,383 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class ActionsWorkflowsClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ActionsWorkflowsClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheClientProperties
|
||||
{
|
||||
[Fact]
|
||||
public void AreNotNull()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.NotNull(client.Jobs);
|
||||
Assert.NotNull(client.Runs);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateDispatchMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
await client.CreateDispatch("fake", "repo", 123, createDispatch);
|
||||
|
||||
connection.Received().Post<object>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/dispatches"),
|
||||
createDispatch);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
await client.CreateDispatch("fake", "repo", "main.yaml", createDispatch);
|
||||
|
||||
connection.Received().Post<object>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/dispatches"),
|
||||
createDispatch);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateDispatch(null, "repo", 123, createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateDispatch("fake", null, 123, createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateDispatch("fake", "repo", 123, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateDispatch(null, "repo", "main.yaml", createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateDispatch("fake", null, "main.yaml", createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateDispatch("fake", "repo", null, createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateDispatch("fake", "repo", "main.yaml", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateDispatch("", "repo", 123, createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateDispatch("fake", "", 123, createDispatch));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateDispatch("", "repo", "main.yaml", createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateDispatch("fake", "", "main.yaml", createDispatch));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.CreateDispatch("fake", "repo", "", createDispatch));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDisableMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.Disable("fake", "repo", 123);
|
||||
|
||||
connection.Received().Put(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/disable"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.Disable("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Put(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/disable"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Disable(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Disable("fake", null, 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Disable(null, "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Disable("fake", null, "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Disable("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Disable("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Disable("fake", "", 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Disable("", "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Disable("fake", "", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Disable("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheEnableMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.Enable("fake", "repo", 123);
|
||||
|
||||
connection.Received().Put(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/enable"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.Enable("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Put(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/enable"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Enable(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Enable("fake", null, 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Enable(null, "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Enable("fake", null, "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Enable("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Enable("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Enable("fake", "", 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Enable("", "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Enable("fake", "", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Enable("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.Get("fake", "repo", 123);
|
||||
|
||||
connection.Received().Get<Workflow>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.Get("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Get<Workflow>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("fake", null, 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("fake", null, "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("fake", "", 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("fake", "", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Get("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetUsageMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.GetUsage("fake", "repo", 123);
|
||||
|
||||
connection.Received().Get<WorkflowUsage>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/timing"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.GetUsage("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Get<WorkflowUsage>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/timing"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetUsage(null, "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetUsage("fake", null, 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetUsage(null, "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetUsage("fake", null, "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetUsage("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetUsage("", "repo", 123));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetUsage("fake", "", 123));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetUsage("", "repo", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetUsage("fake", "", "main.yaml"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetUsage("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await client.List("fake", "repo");
|
||||
|
||||
connection.Received().GetAll<WorkflowsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows"),
|
||||
null,
|
||||
Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequestWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
var options = new ApiOptions { PageSize = 1 };
|
||||
|
||||
await client.List("fake", "repo", options);
|
||||
|
||||
connection.Received().GetAll<WorkflowsResponse>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows"),
|
||||
null,
|
||||
options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List(null, "repo"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List(null, "repo", ApiOptions.None));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", null, ApiOptions.None));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.List("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ActionsWorkflowsClient(connection);
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("", "repo"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("fake", ""));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("", "repo", ApiOptions.None));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.List("fake", "", ApiOptions.None));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
Octokit.Tests/Models/CreateWorkflowDispatchTests.cs
Normal file
55
Octokit.Tests/Models/CreateWorkflowDispatchTests.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class CreateWorkflowDispatchTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new CreateWorkflowDispatch(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonEmptyArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new CreateWorkflowDispatch(""));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanBeSerialized()
|
||||
{
|
||||
var item = new CreateWorkflowDispatch("main");
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Serialize(item);
|
||||
|
||||
Assert.Equal(@"{""ref"":""main""}", payload);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanBeSerializedWithInputs()
|
||||
{
|
||||
var item = new CreateWorkflowDispatch("main");
|
||||
|
||||
item.Inputs = new Dictionary<string, object>()
|
||||
{
|
||||
["foo"] = 1,
|
||||
["bar"] = "qux",
|
||||
};
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Serialize(item);
|
||||
|
||||
Assert.Equal(@"{""ref"":""main"",""inputs"":{""foo"":1,""bar"":""qux""}}", payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Octokit.Tests/Models/EnvironmentApprovalTests.cs
Normal file
70
Octokit.Tests/Models/EnvironmentApprovalTests.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class EnvironmentApprovalTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""state"": ""approved"",
|
||||
""comment"": ""Ship it!"",
|
||||
""environments"": [
|
||||
{
|
||||
""id"": 161088068,
|
||||
""node_id"": ""MDExOkVudmlyb25tZW50MTYxMDg4MDY4"",
|
||||
""name"": ""staging"",
|
||||
""url"": ""https://api.github.com/repos/github/hello-world/environments/staging"",
|
||||
""html_url"": ""https://github.com/github/hello-world/deployments/activity_log?environments_filter=staging"",
|
||||
""created_at"": ""2020-11-23T22:00:40Z"",
|
||||
""updated_at"": ""2020-11-23T22:00:41Z""
|
||||
}
|
||||
],
|
||||
""user"": {
|
||||
""login"": ""octocat"",
|
||||
""id"": 1,
|
||||
""node_id"": ""MDQ6VXNlcjE="",
|
||||
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
|
||||
""gravatar_id"": """",
|
||||
""url"": ""https://api.github.com/users/octocat"",
|
||||
""html_url"": ""https://github.com/octocat"",
|
||||
""followers_url"": ""https://api.github.com/users/octocat/followers"",
|
||||
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
|
||||
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
|
||||
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
|
||||
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
|
||||
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
|
||||
""repos_url"": ""https://api.github.com/users/octocat/repos"",
|
||||
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
|
||||
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
|
||||
""type"": ""User"",
|
||||
""site_admin"": false
|
||||
}
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<EnvironmentApprovals>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal("approved", payload.State);
|
||||
Assert.Equal("Ship it!", payload.Comment);
|
||||
Assert.NotNull(payload.User);
|
||||
Assert.NotNull(payload.Environments);
|
||||
|
||||
var approval = Assert.Single(payload.Environments);
|
||||
|
||||
Assert.NotNull(approval);
|
||||
Assert.Equal(161088068, approval.Id);
|
||||
Assert.Equal("MDExOkVudmlyb25tZW50MTYxMDg4MDY4", approval.NodeId);
|
||||
Assert.Equal("staging", approval.Name);
|
||||
Assert.Equal("https://api.github.com/repos/github/hello-world/environments/staging", approval.Url);
|
||||
Assert.Equal("https://github.com/github/hello-world/deployments/activity_log?environments_filter=staging", approval.HtmlUrl);
|
||||
Assert.Equal(new DateTimeOffset(2020, 11, 23, 22, 00, 40, TimeSpan.Zero), approval.CreatedAt);
|
||||
Assert.Equal(new DateTimeOffset(2020, 11, 23, 22, 00, 41, TimeSpan.Zero), approval.UpdatedAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Octokit.Tests/Models/PendingDeploymentReviewTests.cs
Normal file
37
Octokit.Tests/Models/PendingDeploymentReviewTests.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class PendingDeploymentReviewTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new PendingDeploymentReview(null, PendingDeploymentReviewState.Approved, ""));
|
||||
Assert.Throws<ArgumentNullException>(() => new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonEmptyArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new PendingDeploymentReview(new long[0], PendingDeploymentReviewState.Approved, ""));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanBeSerialized()
|
||||
{
|
||||
var item = new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, "Ship it!");
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Serialize(item);
|
||||
|
||||
Assert.Equal(@"{""environment_ids"":[1],""state"":""approved"",""comment"":""Ship it!""}", payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Octokit.Tests/Models/WorkflowJobStepTests.cs
Normal file
34
Octokit.Tests/Models/WorkflowJobStepTests.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowJobStepTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""name"": ""Set up job"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 1,
|
||||
""started_at"": ""2020-01-20T09:42:40.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:41.000-08:00""
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowJobStep>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal("Set up job", payload.Name);
|
||||
Assert.Equal(WorkflowJobStatus.Completed, payload.Status);
|
||||
Assert.Equal(WorkflowJobConclusion.Success, payload.Conclusion);
|
||||
Assert.Equal(1, payload.Number);
|
||||
Assert.Equal(new DateTimeOffset(2020, 01, 20, 09, 42, 40, TimeSpan.FromHours(-8)), payload.StartedAt);
|
||||
Assert.Equal(new DateTimeOffset(2020, 01, 20, 09, 42, 41, TimeSpan.FromHours(-8)), payload.CompletedAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
146
Octokit.Tests/Models/WorkflowJobTests.cs
Normal file
146
Octokit.Tests/Models/WorkflowJobTests.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowJobTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""id"": 399444496,
|
||||
""run_id"": 29679449,
|
||||
""run_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/29679449"",
|
||||
""node_id"": ""MDEyOldvcmtmbG93IEpvYjM5OTQ0NDQ5Ng=="",
|
||||
""head_sha"": ""f83a356604ae3c5d03e1b46ef4d1ca77d64a90b0"",
|
||||
""url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/jobs/399444496"",
|
||||
""html_url"": ""https://github.com/octo-org/octo-repo/runs/399444496"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""started_at"": ""2020-01-20T17:42:40Z"",
|
||||
""completed_at"": ""2020-01-20T17:44:39Z"",
|
||||
""name"": ""build"",
|
||||
""steps"": [
|
||||
{
|
||||
""name"": ""Set up job"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 1,
|
||||
""started_at"": ""2020-01-20T09:42:40.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:41.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Run actions/checkout@v2"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 2,
|
||||
""started_at"": ""2020-01-20T09:42:41.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:45.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Set up Ruby"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 3,
|
||||
""started_at"": ""2020-01-20T09:42:45.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:45.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Run actions/cache@v3"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 4,
|
||||
""started_at"": ""2020-01-20T09:42:45.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:48.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Install Bundler"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 5,
|
||||
""started_at"": ""2020-01-20T09:42:48.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:52.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Install Gems"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 6,
|
||||
""started_at"": ""2020-01-20T09:42:52.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:53.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Run Tests"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 7,
|
||||
""started_at"": ""2020-01-20T09:42:53.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:59.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Deploy to Heroku"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 8,
|
||||
""started_at"": ""2020-01-20T09:42:59.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:44:39.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Post actions/cache@v3"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 16,
|
||||
""started_at"": ""2020-01-20T09:44:39.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:44:39.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Complete job"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 17,
|
||||
""started_at"": ""2020-01-20T09:44:39.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:44:39.000-08:00""
|
||||
}
|
||||
],
|
||||
""check_run_url"": ""https://api.github.com/repos/octo-org/octo-repo/check-runs/399444496"",
|
||||
""labels"": [
|
||||
""self-hosted"",
|
||||
""foo"",
|
||||
""bar""
|
||||
],
|
||||
""runner_id"": 1,
|
||||
""runner_name"": ""my runner"",
|
||||
""runner_group_id"": 2,
|
||||
""runner_group_name"": ""my runner group""
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowJob>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal(399444496, payload.Id);
|
||||
Assert.Equal("https://api.github.com/repos/octo-org/octo-repo/actions/runs/29679449", payload.RunUrl);
|
||||
Assert.Equal("MDEyOldvcmtmbG93IEpvYjM5OTQ0NDQ5Ng==", payload.NodeId);
|
||||
Assert.Equal("f83a356604ae3c5d03e1b46ef4d1ca77d64a90b0", payload.HeadSha);
|
||||
Assert.Equal("https://api.github.com/repos/octo-org/octo-repo/actions/jobs/399444496", payload.Url);
|
||||
Assert.Equal("https://github.com/octo-org/octo-repo/runs/399444496", payload.HtmlUrl);
|
||||
Assert.Equal(WorkflowJobStatus.Completed, payload.Status);
|
||||
Assert.Equal(WorkflowJobConclusion.Success, payload.Conclusion);
|
||||
Assert.Equal(new DateTimeOffset(2020, 01, 20, 17, 42, 40, TimeSpan.Zero), payload.StartedAt);
|
||||
Assert.Equal(new DateTimeOffset(2020, 01, 20, 17, 44, 39, TimeSpan.Zero), payload.CompletedAt);
|
||||
Assert.Equal("build", payload.Name);
|
||||
Assert.NotNull(payload.Steps);
|
||||
Assert.NotEmpty(payload.Steps);
|
||||
Assert.Equal(10, payload.Steps.Count);
|
||||
Assert.Equal("https://api.github.com/repos/octo-org/octo-repo/check-runs/399444496", payload.CheckRunUrl);
|
||||
Assert.Equal(new[] { "self-hosted", "foo", "bar" }, payload.Labels);
|
||||
Assert.Equal(1, payload.RunnerId);
|
||||
Assert.Equal("my runner", payload.RunnerName);
|
||||
Assert.Equal(2, payload.RunnerGroupId);
|
||||
Assert.Equal("my runner group", payload.RunnerGroupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Octokit.Tests/Models/WorkflowJobsResponseTests.cs
Normal file
134
Octokit.Tests/Models/WorkflowJobsResponseTests.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowJobsResponseTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""total_count"": 1,
|
||||
""jobs"": [
|
||||
{
|
||||
""id"": 399444496,
|
||||
""run_id"": 29679449,
|
||||
""run_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/29679449"",
|
||||
""node_id"": ""MDEyOldvcmtmbG93IEpvYjM5OTQ0NDQ5Ng=="",
|
||||
""head_sha"": ""f83a356604ae3c5d03e1b46ef4d1ca77d64a90b0"",
|
||||
""url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/jobs/399444496"",
|
||||
""html_url"": ""https://github.com/octo-org/octo-repo/runs/399444496"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""started_at"": ""2020-01-20T17:42:40Z"",
|
||||
""completed_at"": ""2020-01-20T17:44:39Z"",
|
||||
""name"": ""build"",
|
||||
""steps"": [
|
||||
{
|
||||
""name"": ""Set up job"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 1,
|
||||
""started_at"": ""2020-01-20T09:42:40.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:41.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Run actions/checkout@v2"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 2,
|
||||
""started_at"": ""2020-01-20T09:42:41.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:45.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Set up Ruby"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 3,
|
||||
""started_at"": ""2020-01-20T09:42:45.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:45.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Run actions/cache@v3"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 4,
|
||||
""started_at"": ""2020-01-20T09:42:45.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:48.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Install Bundler"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 5,
|
||||
""started_at"": ""2020-01-20T09:42:48.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:52.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Install Gems"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 6,
|
||||
""started_at"": ""2020-01-20T09:42:52.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:53.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Run Tests"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 7,
|
||||
""started_at"": ""2020-01-20T09:42:53.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:42:59.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Deploy to Heroku"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 8,
|
||||
""started_at"": ""2020-01-20T09:42:59.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:44:39.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Post actions/cache@v3"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 16,
|
||||
""started_at"": ""2020-01-20T09:44:39.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:44:39.000-08:00""
|
||||
},
|
||||
{
|
||||
""name"": ""Complete job"",
|
||||
""status"": ""completed"",
|
||||
""conclusion"": ""success"",
|
||||
""number"": 17,
|
||||
""started_at"": ""2020-01-20T09:44:39.000-08:00"",
|
||||
""completed_at"": ""2020-01-20T09:44:39.000-08:00""
|
||||
}
|
||||
],
|
||||
""check_run_url"": ""https://api.github.com/repos/octo-org/octo-repo/check-runs/399444496"",
|
||||
""labels"": [
|
||||
""self-hosted"",
|
||||
""foo"",
|
||||
""bar""
|
||||
],
|
||||
""runner_id"": 1,
|
||||
""runner_name"": ""my runner"",
|
||||
""runner_group_id"": 2,
|
||||
""runner_group_name"": ""my runner group""
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowJobsResponse>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal(1, payload.TotalCount);
|
||||
Assert.NotNull(payload.Jobs);
|
||||
Assert.NotEmpty(payload.Jobs);
|
||||
Assert.Equal(1, payload.Jobs.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Octokit.Tests/Models/WorkflowReferenceTests.cs
Normal file
27
Octokit.Tests/Models/WorkflowReferenceTests.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowReferenceTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""path"": ""octocat/Hello-World/.github/workflows/deploy.yml@main"",
|
||||
""sha"": ""86e8bc9ecf7d38b1ed2d2cfb8eb87ba9b35b01db"",
|
||||
""ref"": ""refs/heads/main""
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowReference>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal("octocat/Hello-World/.github/workflows/deploy.yml@main", payload.Path);
|
||||
Assert.Equal("86e8bc9ecf7d38b1ed2d2cfb8eb87ba9b35b01db", payload.Sha);
|
||||
Assert.Equal("refs/heads/main", payload.Ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
257
Octokit.Tests/Models/WorkflowRunTests.cs
Normal file
257
Octokit.Tests/Models/WorkflowRunTests.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowRunTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""id"": 30433642,
|
||||
""name"": ""Build"",
|
||||
""node_id"": ""MDEyOldvcmtmbG93IFJ1bjI2OTI4OQ=="",
|
||||
""check_suite_id"": 42,
|
||||
""check_suite_node_id"": ""MDEwOkNoZWNrU3VpdGU0Mg=="",
|
||||
""head_branch"": ""master"",
|
||||
""head_sha"": ""acb5820ced9479c074f688cc328bf03f341a511d"",
|
||||
""path"": "".github/workflows/build.yml@main"",
|
||||
""run_number"": 562,
|
||||
""event"": ""push"",
|
||||
""display_title"": ""Update README.md"",
|
||||
""status"": ""queued"",
|
||||
""conclusion"": null,
|
||||
""workflow_id"": 159038,
|
||||
""url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642"",
|
||||
""html_url"": ""https://github.com/octo-org/octo-repo/actions/runs/30433642"",
|
||||
""pull_requests"": [],
|
||||
""created_at"": ""2020-01-22T19:33:08Z"",
|
||||
""updated_at"": ""2020-01-22T19:33:08Z"",
|
||||
""actor"": {
|
||||
""login"": ""octocat"",
|
||||
""id"": 1,
|
||||
""node_id"": ""MDQ6VXNlcjE="",
|
||||
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
|
||||
""gravatar_id"": """",
|
||||
""url"": ""https://api.github.com/users/octocat"",
|
||||
""html_url"": ""https://github.com/octocat"",
|
||||
""followers_url"": ""https://api.github.com/users/octocat/followers"",
|
||||
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
|
||||
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
|
||||
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
|
||||
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
|
||||
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
|
||||
""repos_url"": ""https://api.github.com/users/octocat/repos"",
|
||||
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
|
||||
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
|
||||
""type"": ""User"",
|
||||
""site_admin"": false
|
||||
},
|
||||
""run_attempt"": 1,
|
||||
""referenced_workflows"": [
|
||||
{
|
||||
""path"": ""octocat/Hello-World/.github/workflows/deploy.yml@main"",
|
||||
""sha"": ""86e8bc9ecf7d38b1ed2d2cfb8eb87ba9b35b01db"",
|
||||
""ref"": ""refs/heads/main""
|
||||
},
|
||||
{
|
||||
""path"": ""octo-org/octo-repo/.github/workflows/report.yml@v2"",
|
||||
""sha"": ""79e9790903e1c3373b1a3e3a941d57405478a232"",
|
||||
""ref"": ""refs/tags/v2""
|
||||
},
|
||||
{
|
||||
""path"": ""octo-org/octo-repo/.github/workflows/secure.yml@1595d4b6de6a9e9751fb270a41019ce507d4099e"",
|
||||
""sha"": ""1595d4b6de6a9e9751fb270a41019ce507d4099e""
|
||||
}
|
||||
],
|
||||
""run_started_at"": ""2020-01-22T19:33:08Z"",
|
||||
""triggering_actor"": {
|
||||
""login"": ""octocat"",
|
||||
""id"": 1,
|
||||
""node_id"": ""MDQ6VXNlcjE="",
|
||||
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
|
||||
""gravatar_id"": """",
|
||||
""url"": ""https://api.github.com/users/octocat"",
|
||||
""html_url"": ""https://github.com/octocat"",
|
||||
""followers_url"": ""https://api.github.com/users/octocat/followers"",
|
||||
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
|
||||
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
|
||||
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
|
||||
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
|
||||
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
|
||||
""repos_url"": ""https://api.github.com/users/octocat/repos"",
|
||||
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
|
||||
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
|
||||
""type"": ""User"",
|
||||
""site_admin"": false
|
||||
},
|
||||
""jobs_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/jobs"",
|
||||
""logs_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/logs"",
|
||||
""check_suite_url"": ""https://api.github.com/repos/octo-org/octo-repo/check-suites/414944374"",
|
||||
""artifacts_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/artifacts"",
|
||||
""cancel_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/cancel"",
|
||||
""rerun_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/rerun"",
|
||||
""workflow_url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/workflows/159038"",
|
||||
""head_commit"": {
|
||||
""id"": ""acb5820ced9479c074f688cc328bf03f341a511d"",
|
||||
""tree_id"": ""d23f6eedb1e1b9610bbc754ddb5197bfe7271223"",
|
||||
""message"": ""Create linter.yaml"",
|
||||
""timestamp"": ""2020-01-22T19:33:05Z"",
|
||||
""author"": {
|
||||
""name"": ""Octo Cat"",
|
||||
""email"": ""octocat@github.com""
|
||||
},
|
||||
""committer"": {
|
||||
""name"": ""GitHub"",
|
||||
""email"": ""noreply@github.com""
|
||||
}
|
||||
},
|
||||
""repository"": {
|
||||
""id"": 1296269,
|
||||
""node_id"": ""MDEwOlJlcG9zaXRvcnkxMjk2MjY5"",
|
||||
""name"": ""Hello-World"",
|
||||
""full_name"": ""octocat/Hello-World"",
|
||||
""owner"": {
|
||||
""login"": ""octocat"",
|
||||
""id"": 1,
|
||||
""node_id"": ""MDQ6VXNlcjE="",
|
||||
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
|
||||
""gravatar_id"": """",
|
||||
""url"": ""https://api.github.com/users/octocat"",
|
||||
""html_url"": ""https://github.com/octocat"",
|
||||
""followers_url"": ""https://api.github.com/users/octocat/followers"",
|
||||
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
|
||||
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
|
||||
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
|
||||
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
|
||||
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
|
||||
""repos_url"": ""https://api.github.com/users/octocat/repos"",
|
||||
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
|
||||
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
|
||||
""type"": ""User"",
|
||||
""site_admin"": false
|
||||
},
|
||||
""private"": false,
|
||||
""html_url"": ""https://github.com/octocat/Hello-World"",
|
||||
""description"": ""This your first repo!"",
|
||||
""fork"": false,
|
||||
""url"": ""https://api.github.com/repos/octocat/Hello-World"",
|
||||
""archive_url"": ""https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}"",
|
||||
""assignees_url"": ""https://api.github.com/repos/octocat/Hello-World/assignees{/user}"",
|
||||
""blobs_url"": ""https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}"",
|
||||
""branches_url"": ""https://api.github.com/repos/octocat/Hello-World/branches{/branch}"",
|
||||
""collaborators_url"": ""https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}"",
|
||||
""comments_url"": ""https://api.github.com/repos/octocat/Hello-World/comments{/number}"",
|
||||
""commits_url"": ""https://api.github.com/repos/octocat/Hello-World/commits{/sha}"",
|
||||
""compare_url"": ""https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}"",
|
||||
""contents_url"": ""https://api.github.com/repos/octocat/Hello-World/contents/{+path}"",
|
||||
""contributors_url"": ""https://api.github.com/repos/octocat/Hello-World/contributors"",
|
||||
""deployments_url"": ""https://api.github.com/repos/octocat/Hello-World/deployments"",
|
||||
""downloads_url"": ""https://api.github.com/repos/octocat/Hello-World/downloads"",
|
||||
""events_url"": ""https://api.github.com/repos/octocat/Hello-World/events"",
|
||||
""forks_url"": ""https://api.github.com/repos/octocat/Hello-World/forks"",
|
||||
""git_commits_url"": ""https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}"",
|
||||
""git_refs_url"": ""https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}"",
|
||||
""git_tags_url"": ""https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}"",
|
||||
""git_url"": ""git:github.com/octocat/Hello-World.git"",
|
||||
""issue_comment_url"": ""https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}"",
|
||||
""issue_events_url"": ""https://api.github.com/repos/octocat/Hello-World/issues/events{/number}"",
|
||||
""issues_url"": ""https://api.github.com/repos/octocat/Hello-World/issues{/number}"",
|
||||
""keys_url"": ""https://api.github.com/repos/octocat/Hello-World/keys{/key_id}"",
|
||||
""labels_url"": ""https://api.github.com/repos/octocat/Hello-World/labels{/name}"",
|
||||
""languages_url"": ""https://api.github.com/repos/octocat/Hello-World/languages"",
|
||||
""merges_url"": ""https://api.github.com/repos/octocat/Hello-World/merges"",
|
||||
""milestones_url"": ""https://api.github.com/repos/octocat/Hello-World/milestones{/number}"",
|
||||
""notifications_url"": ""https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}"",
|
||||
""pulls_url"": ""https://api.github.com/repos/octocat/Hello-World/pulls{/number}"",
|
||||
""releases_url"": ""https://api.github.com/repos/octocat/Hello-World/releases{/id}"",
|
||||
""ssh_url"": ""git@github.com:octocat/Hello-World.git"",
|
||||
""stargazers_url"": ""https://api.github.com/repos/octocat/Hello-World/stargazers"",
|
||||
""statuses_url"": ""https://api.github.com/repos/octocat/Hello-World/statuses/{sha}"",
|
||||
""subscribers_url"": ""https://api.github.com/repos/octocat/Hello-World/subscribers"",
|
||||
""subscription_url"": ""https://api.github.com/repos/octocat/Hello-World/subscription"",
|
||||
""tags_url"": ""https://api.github.com/repos/octocat/Hello-World/tags"",
|
||||
""teams_url"": ""https://api.github.com/repos/octocat/Hello-World/teams"",
|
||||
""trees_url"": ""https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}"",
|
||||
""hooks_url"": ""http://api.github.com/repos/octocat/Hello-World/hooks""
|
||||
},
|
||||
""head_repository"": {
|
||||
""id"": 217723378,
|
||||
""node_id"": ""MDEwOlJlcG9zaXRvcnkyMTc3MjMzNzg="",
|
||||
""name"": ""octo-repo"",
|
||||
""full_name"": ""octo-org/octo-repo"",
|
||||
""private"": true,
|
||||
""owner"": {
|
||||
""login"": ""octocat"",
|
||||
""id"": 1,
|
||||
""node_id"": ""MDQ6VXNlcjE="",
|
||||
""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"",
|
||||
""gravatar_id"": """",
|
||||
""url"": ""https://api.github.com/users/octocat"",
|
||||
""html_url"": ""https://github.com/octocat"",
|
||||
""followers_url"": ""https://api.github.com/users/octocat/followers"",
|
||||
""following_url"": ""https://api.github.com/users/octocat/following{/other_user}"",
|
||||
""gists_url"": ""https://api.github.com/users/octocat/gists{/gist_id}"",
|
||||
""starred_url"": ""https://api.github.com/users/octocat/starred{/owner}{/repo}"",
|
||||
""subscriptions_url"": ""https://api.github.com/users/octocat/subscriptions"",
|
||||
""organizations_url"": ""https://api.github.com/users/octocat/orgs"",
|
||||
""repos_url"": ""https://api.github.com/users/octocat/repos"",
|
||||
""events_url"": ""https://api.github.com/users/octocat/events{/privacy}"",
|
||||
""received_events_url"": ""https://api.github.com/users/octocat/received_events"",
|
||||
""type"": ""User"",
|
||||
""site_admin"": false
|
||||
},
|
||||
""html_url"": ""https://github.com/octo-org/octo-repo"",
|
||||
""description"": null,
|
||||
""fork"": false,
|
||||
""url"": ""https://api.github.com/repos/octo-org/octo-repo"",
|
||||
""forks_url"": ""https://api.github.com/repos/octo-org/octo-repo/forks"",
|
||||
""keys_url"": ""https://api.github.com/repos/octo-org/octo-repo/keys{/key_id}"",
|
||||
""collaborators_url"": ""https://api.github.com/repos/octo-org/octo-repo/collaborators{/collaborator}"",
|
||||
""teams_url"": ""https://api.github.com/repos/octo-org/octo-repo/teams"",
|
||||
""hooks_url"": ""https://api.github.com/repos/octo-org/octo-repo/hooks"",
|
||||
""issue_events_url"": ""https://api.github.com/repos/octo-org/octo-repo/issues/events{/number}"",
|
||||
""events_url"": ""https://api.github.com/repos/octo-org/octo-repo/events"",
|
||||
""assignees_url"": ""https://api.github.com/repos/octo-org/octo-repo/assignees{/user}"",
|
||||
""branches_url"": ""https://api.github.com/repos/octo-org/octo-repo/branches{/branch}"",
|
||||
""tags_url"": ""https://api.github.com/repos/octo-org/octo-repo/tags"",
|
||||
""blobs_url"": ""https://api.github.com/repos/octo-org/octo-repo/git/blobs{/sha}"",
|
||||
""git_tags_url"": ""https://api.github.com/repos/octo-org/octo-repo/git/tags{/sha}"",
|
||||
""git_refs_url"": ""https://api.github.com/repos/octo-org/octo-repo/git/refs{/sha}"",
|
||||
""trees_url"": ""https://api.github.com/repos/octo-org/octo-repo/git/trees{/sha}"",
|
||||
""statuses_url"": ""https://api.github.com/repos/octo-org/octo-repo/statuses/{sha}"",
|
||||
""languages_url"": ""https://api.github.com/repos/octo-org/octo-repo/languages"",
|
||||
""stargazers_url"": ""https://api.github.com/repos/octo-org/octo-repo/stargazers"",
|
||||
""contributors_url"": ""https://api.github.com/repos/octo-org/octo-repo/contributors"",
|
||||
""subscribers_url"": ""https://api.github.com/repos/octo-org/octo-repo/subscribers"",
|
||||
""subscription_url"": ""https://api.github.com/repos/octo-org/octo-repo/subscription"",
|
||||
""commits_url"": ""https://api.github.com/repos/octo-org/octo-repo/commits{/sha}"",
|
||||
""git_commits_url"": ""https://api.github.com/repos/octo-org/octo-repo/git/commits{/sha}"",
|
||||
""comments_url"": ""https://api.github.com/repos/octo-org/octo-repo/comments{/number}"",
|
||||
""issue_comment_url"": ""https://api.github.com/repos/octo-org/octo-repo/issues/comments{/number}"",
|
||||
""contents_url"": ""https://api.github.com/repos/octo-org/octo-repo/contents/{+path}"",
|
||||
""compare_url"": ""https://api.github.com/repos/octo-org/octo-repo/compare/{base}...{head}"",
|
||||
""merges_url"": ""https://api.github.com/repos/octo-org/octo-repo/merges"",
|
||||
""archive_url"": ""https://api.github.com/repos/octo-org/octo-repo/{archive_format}{/ref}"",
|
||||
""downloads_url"": ""https://api.github.com/repos/octo-org/octo-repo/downloads"",
|
||||
""issues_url"": ""https://api.github.com/repos/octo-org/octo-repo/issues{/number}"",
|
||||
""pulls_url"": ""https://api.github.com/repos/octo-org/octo-repo/pulls{/number}"",
|
||||
""milestones_url"": ""https://api.github.com/repos/octo-org/octo-repo/milestones{/number}"",
|
||||
""notifications_url"": ""https://api.github.com/repos/octo-org/octo-repo/notifications{?since,all,participating}"",
|
||||
""labels_url"": ""https://api.github.com/repos/octo-org/octo-repo/labels{/name}"",
|
||||
""releases_url"": ""https://api.github.com/repos/octo-org/octo-repo/releases{/id}"",
|
||||
""deployments_url"": ""https://api.github.com/repos/octo-org/octo-repo/deployments""
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowRun>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
87
Octokit.Tests/Models/WorkflowRunUsageTests.cs
Normal file
87
Octokit.Tests/Models/WorkflowRunUsageTests.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowRunUsageTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""billable"": {
|
||||
""UBUNTU"": {
|
||||
""total_ms"": 180000,
|
||||
""jobs"": 1,
|
||||
""job_runs"": [
|
||||
{
|
||||
""job_id"": 1,
|
||||
""duration_ms"": 180000
|
||||
}
|
||||
]
|
||||
},
|
||||
""MACOS"": {
|
||||
""total_ms"": 240000,
|
||||
""jobs"": 4,
|
||||
""job_runs"": [
|
||||
{
|
||||
""job_id"": 2,
|
||||
""duration_ms"": 60000
|
||||
},
|
||||
{
|
||||
""job_id"": 3,
|
||||
""duration_ms"": 60000
|
||||
},
|
||||
{
|
||||
""job_id"": 4,
|
||||
""duration_ms"": 60000
|
||||
},
|
||||
{
|
||||
""job_id"": 5,
|
||||
""duration_ms"": 60000
|
||||
}
|
||||
]
|
||||
},
|
||||
""WINDOWS"": {
|
||||
""total_ms"": 300000,
|
||||
""jobs"": 2,
|
||||
""job_runs"": [
|
||||
{
|
||||
""job_id"": 6,
|
||||
""duration_ms"": 150000
|
||||
},
|
||||
{
|
||||
""job_id"": 7,
|
||||
""duration_ms"": 150000
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
""run_duration_ms"": 500000
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowRunUsage>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal(500000, payload.RunDurationMs);
|
||||
Assert.NotNull(payload.Billable);
|
||||
Assert.NotNull(payload.Billable.Ubuntu);
|
||||
Assert.NotNull(payload.Billable.MacOS);
|
||||
Assert.NotNull(payload.Billable.Windows);
|
||||
Assert.Equal(180000, payload.Billable.Ubuntu.TotalMs);
|
||||
Assert.Equal(1, payload.Billable.Ubuntu.Jobs);
|
||||
Assert.NotNull(payload.Billable.Ubuntu.JobRuns);
|
||||
Assert.Equal(1, payload.Billable.Ubuntu.JobRuns.Count);
|
||||
Assert.Equal(240000, payload.Billable.MacOS.TotalMs);
|
||||
Assert.Equal(4, payload.Billable.MacOS.Jobs);
|
||||
Assert.NotNull(payload.Billable.MacOS.JobRuns);
|
||||
Assert.Equal(4, payload.Billable.MacOS.JobRuns.Count);
|
||||
Assert.Equal(300000, payload.Billable.Windows.TotalMs);
|
||||
Assert.Equal(2, payload.Billable.Windows.Jobs);
|
||||
Assert.NotNull(payload.Billable.Windows.JobRuns);
|
||||
Assert.Equal(2, payload.Billable.Windows.JobRuns.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Octokit.Tests/Models/WorkflowTests.cs
Normal file
42
Octokit.Tests/Models/WorkflowTests.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""id"": 161335,
|
||||
""node_id"": ""MDg6V29ya2Zsb3cxNjEzMzU="",
|
||||
""name"": ""CI"",
|
||||
""path"": "".github/workflows/blank.yaml"",
|
||||
""state"": ""active"",
|
||||
""created_at"": ""2020-01-08T23:48:37.000-08:00"",
|
||||
""updated_at"": ""2020-01-08T23:50:21.000-08:00"",
|
||||
""url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/workflows/161335"",
|
||||
""html_url"": ""https://github.com/octo-org/octo-repo/blob/master/.github/workflows/161335"",
|
||||
""badge_url"": ""https://github.com/octo-org/octo-repo/workflows/CI/badge.svg""
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<Workflow>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal(161335, payload.Id);
|
||||
Assert.Equal("MDg6V29ya2Zsb3cxNjEzMzU=", payload.NodeId);
|
||||
Assert.Equal("CI", payload.Name);
|
||||
Assert.Equal(".github/workflows/blank.yaml", payload.Path);
|
||||
Assert.Equal("active", payload.State);
|
||||
Assert.Equal(new DateTimeOffset(2020, 01, 08, 23, 48, 37, TimeSpan.FromHours(-8)), payload.CreatedAt);
|
||||
Assert.Equal(new DateTimeOffset(2020, 01, 08, 23, 50, 21, TimeSpan.FromHours(-8)), payload.UpdatedAt);
|
||||
Assert.Equal("https://api.github.com/repos/octo-org/octo-repo/actions/workflows/161335", payload.Url);
|
||||
Assert.Equal("https://github.com/octo-org/octo-repo/blob/master/.github/workflows/161335", payload.HtmlUrl);
|
||||
Assert.Equal("https://github.com/octo-org/octo-repo/workflows/CI/badge.svg", payload.BadgeUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Octokit.Tests/Models/WorkflowUsageTests.cs
Normal file
39
Octokit.Tests/Models/WorkflowUsageTests.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowUsageTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""billable"": {
|
||||
""UBUNTU"": {
|
||||
""total_ms"": 180000
|
||||
},
|
||||
""MACOS"": {
|
||||
""total_ms"": 240000
|
||||
},
|
||||
""WINDOWS"": {
|
||||
""total_ms"": 300000
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowUsage>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.NotNull(payload.Billable);
|
||||
Assert.NotNull(payload.Billable.Ubuntu);
|
||||
Assert.NotNull(payload.Billable.MacOS);
|
||||
Assert.NotNull(payload.Billable.Windows);
|
||||
Assert.Equal(180000, payload.Billable.Ubuntu.TotalMs);
|
||||
Assert.Equal(240000, payload.Billable.MacOS.TotalMs);
|
||||
Assert.Equal(300000, payload.Billable.Windows.TotalMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Octokit.Tests/Models/WorkflowsResponseTests.cs
Normal file
52
Octokit.Tests/Models/WorkflowsResponseTests.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Models
|
||||
{
|
||||
public class WorkflowsResponseTests
|
||||
{
|
||||
[Fact]
|
||||
public void CanBeDeserialized()
|
||||
{
|
||||
const string json = @"{
|
||||
""total_count"": 2,
|
||||
""workflows"": [
|
||||
{
|
||||
""id"": 161335,
|
||||
""node_id"": ""MDg6V29ya2Zsb3cxNjEzMzU="",
|
||||
""name"": ""CI"",
|
||||
""path"": "".github/workflows/blank.yaml"",
|
||||
""state"": ""active"",
|
||||
""created_at"": ""2020-01-08T23:48:37.000-08:00"",
|
||||
""updated_at"": ""2020-01-08T23:50:21.000-08:00"",
|
||||
""url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/workflows/161335"",
|
||||
""html_url"": ""https://github.com/octo-org/octo-repo/blob/master/.github/workflows/161335"",
|
||||
""badge_url"": ""https://github.com/octo-org/octo-repo/workflows/CI/badge.svg""
|
||||
},
|
||||
{
|
||||
""id"": 269289,
|
||||
""node_id"": ""MDE4OldvcmtmbG93IFNlY29uZGFyeTI2OTI4OQ=="",
|
||||
""name"": ""Linter"",
|
||||
""path"": "".github/workflows/linter.yaml"",
|
||||
""state"": ""active"",
|
||||
""created_at"": ""2020-01-08T23:48:37.000-08:00"",
|
||||
""updated_at"": ""2020-01-08T23:50:21.000-08:00"",
|
||||
""url"": ""https://api.github.com/repos/octo-org/octo-repo/actions/workflows/269289"",
|
||||
""html_url"": ""https://github.com/octo-org/octo-repo/blob/master/.github/workflows/269289"",
|
||||
""badge_url"": ""https://github.com/octo-org/octo-repo/workflows/Linter/badge.svg""
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
var serializer = new SimpleJsonSerializer();
|
||||
|
||||
var payload = serializer.Deserialize<WorkflowsResponse>(json);
|
||||
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal(2, payload.TotalCount);
|
||||
Assert.NotNull(payload.Workflows);
|
||||
Assert.NotEmpty(payload.Workflows);
|
||||
Assert.Equal(2, payload.Workflows.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableActionsWorkflowJobsClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ObservableActionsWorkflowJobsClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRerunMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallRerunOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
client.Rerun("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.Rerun("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Rerun(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Rerun("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Rerun("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Rerun("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallGetOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
client.Get("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.Get("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Get("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallGetLogsOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
client.GetLogs("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.GetLogs("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetLogs(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetLogs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetLogs("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.GetLogs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallListOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
client.List("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.List("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallListOnClientWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
var workflowRunJobsRequest = new WorkflowRunJobsRequest();
|
||||
|
||||
client.List("fake", "repo", 123, workflowRunJobsRequest);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.List("fake", "repo", 123, workflowRunJobsRequest);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallListOnClientWithRequestAndOptions()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
var workflowRunJobsRequest = new WorkflowRunJobsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
client.List("fake", "repo", 123, workflowRunJobsRequest, options);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.List("fake", "repo", 123, workflowRunJobsRequest, options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallListOnClientForAttempt()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
|
||||
client.List("fake", "repo", 123, 456);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.List("fake", "repo", 123, 456);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallListOnClientForAttemptWithOptions()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
var options = new ApiOptions();
|
||||
|
||||
client.List("fake", "repo", 123, 456, options);
|
||||
|
||||
connection.Received().Actions.Workflows.Jobs.List("fake", "repo", 123, 456, options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
var workflowRunJobsRequest = new WorkflowRunJobsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null, 123));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo", 123, workflowRunJobsRequest));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null, 123, workflowRunJobsRequest));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", "repo", 123, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo", 123, workflowRunJobsRequest, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null, 123, workflowRunJobsRequest, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", "repo", 123, null, options));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowJobsClient(connection);
|
||||
var workflowRunJobsRequest = new WorkflowRunJobsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", "", 123));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo", 123, workflowRunJobsRequest));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", "", 123, workflowRunJobsRequest));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo", 123, workflowRunJobsRequest, options));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", "", 123, workflowRunJobsRequest, options));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,700 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableActionsWorkflowRunsClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ObservableActionsWorkflowRunsClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheApproveMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsApproveOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.Approve("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.Approve("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Approve(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Approve("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Approve("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Approve("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCancelMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsCancelOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.Cancel("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.Cancel("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Cancel(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Cancel("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Cancel("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Cancel("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsDeleteOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.Delete("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.Delete("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Delete(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Delete("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Delete("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Delete("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsDeleteLogsOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.DeleteLogs("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.DeleteLogs("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.DeleteLogs(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.DeleteLogs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.DeleteLogs("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.DeleteLogs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsListOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.List("fake", "repo");
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.List("fake", "repo");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallsListOnClientWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
|
||||
client.List("fake", "repo", request);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.List("fake", "repo", request);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallsListOnClientWithRequestWithOptions()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
client.List("fake", "repo", request, options);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.List("fake", "repo", request, options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo", request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null, request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", "repo", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo", request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null, request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", "repo", null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", "repo", request, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo"));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", ""));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo", request));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", "", request));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo", request, options));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", "", request, options));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsGetOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.Get("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.Get("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Get("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsGetLogsOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.GetLogs("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.GetLogs("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetLogs(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetLogs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetLogs("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.GetLogs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAttemptMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsGetAttemptOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.GetAttempt("fake", "repo", 123, 456);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.GetAttempt("fake", "repo", 123, 456);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAttempt(null, "repo", 123, 456));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAttempt("fake", null, 123, 456));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAttempt("", "repo", 123, 456));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAttempt("fake", "", 123, 456));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAttemptLogsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsGetAttemptLogsOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.GetAttemptLogs("fake", "repo", 123, 456);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.GetAttemptLogs("fake", "repo", 123, 456);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAttemptLogs(null, "repo", 123, 456));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAttemptLogs("fake", null, 123, 456));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAttemptLogs("", "repo", 123, 456));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAttemptLogs("fake", "", 123, 456));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetReviewHistoryMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsGetReviewHistoryOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.GetReviewHistory("fake", "repo", 123);
|
||||
|
||||
connection.Connection.Received().Get<List<EnvironmentApprovals>>(Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approvals"),
|
||||
null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetReviewHistory(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetReviewHistory("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetReviewHistory("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.GetReviewHistory("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetUsageMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsGetUsageOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.GetUsage("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.GetUsage("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetUsage(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetUsage("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetUsage("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.GetUsage("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRerunMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsRerunOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.Rerun("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.Rerun("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Rerun(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Rerun("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Rerun("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Rerun("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRerunFailedJobsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsRerunFailedJobsOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.RerunFailedJobs("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.RerunFailedJobs("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.RerunFailedJobs(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.RerunFailedJobs("fake", null, 123));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.RerunFailedJobs("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.RerunFailedJobs("fake", "", 123));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheReviewPendingDeploymentsMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsReviewPendingDeploymentsOnClient()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var review = new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, "");
|
||||
|
||||
client.ReviewPendingDeployments("fake", "repo", 123, review);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.ReviewPendingDeployments("fake", "repo", 123, review);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var review = new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, "");
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ReviewPendingDeployments(null, "repo", 123, review));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ReviewPendingDeployments("fake", null, 123, review));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ReviewPendingDeployments("fake", "repo", 123, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var review = new PendingDeploymentReview(new[] { 1L }, PendingDeploymentReviewState.Approved, "");
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ReviewPendingDeployments("", "repo", 123, review));
|
||||
Assert.Throws<ArgumentException>(() => client.ReviewPendingDeployments("fake", "", 123, review));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListByWorkflowMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsListByWorkflowOnClientById()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.ListByWorkflow("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.ListByWorkflow("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallsListByWorkflowOnClientByName()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
client.ListByWorkflow("fake", "repo", "main.yml");
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.ListByWorkflow("fake", "repo", "main.yml");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallsListByWorkflowOnClientByIdWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
|
||||
client.ListByWorkflow("fake", "repo", 123, request);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.ListByWorkflow("fake", "repo", 123, request);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallsListByWorkflowOnClientByNameWithRequest()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
|
||||
client.ListByWorkflow("fake", "repo", "main.yml", request);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.ListByWorkflow("fake", "repo", "main.yml", request);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallsListByWorkflowOnClientByIdWithRequestWithOptions()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
client.ListByWorkflow("fake", "repo", 123, request, options);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.ListByWorkflow("fake", "repo", 123, request, options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CallsListByWorkflowOnClientByNameWithRequestWithOptions()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
client.ListByWorkflow("fake", "repo", "main.yml", request, options);
|
||||
|
||||
connection.Received().Actions.Workflows.Runs.ListByWorkflow("fake", "repo", "main.yml", request, options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", null, 123));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", "main.yml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", null, "main.yml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", 123, request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", null, 123, request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", 123, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", "main.yml", request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", null, "main.yml", request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", null, request));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", "main.yml", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", 123, request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", null, 123, request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", 123, null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", 123, request, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow(null, "repo", "main.yml", request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", null, "main.yml", request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", null, request, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", "main.yml", null, options));
|
||||
Assert.Throws<ArgumentNullException>(() => client.ListByWorkflow("fake", "repo", "main.yml", request, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowRunsClient(connection);
|
||||
|
||||
var request = new WorkflowRunsRequest();
|
||||
var options = new ApiOptions();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "", 123));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("", "repo", "main.yml"));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "", "main.yml"));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "repo", ""));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("", "repo", 123, request));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "", 123, request));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("", "repo", "main.yml", request));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "", "main.yml", request));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "repo", "", request));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("", "repo", 123, request, options));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "", 123, request, options));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("", "repo", "main.yml", request, options));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "", "main.yml", request, options));
|
||||
Assert.Throws<ArgumentException>(() => client.ListByWorkflow("fake", "repo", "", request, options));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
362
Octokit.Tests/Reactive/ObservableActionsWorkflowsClientTests.cs
Normal file
362
Octokit.Tests/Reactive/ObservableActionsWorkflowsClientTests.cs
Normal file
@@ -0,0 +1,362 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableActionsWorkflowsClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ObservableActionsWorkflowsClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheClientProperties
|
||||
{
|
||||
[Fact]
|
||||
public void AreNotNull()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.NotNull(client.Jobs);
|
||||
Assert.NotNull(client.Runs);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateDispatchMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
client.CreateDispatch("fake", "repo", 123, createDispatch);
|
||||
|
||||
connection.Received().Actions.Workflows.CreateDispatch("fake", "repo", 123, createDispatch);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
client.CreateDispatch("fake", "repo", "main.yaml", createDispatch);
|
||||
|
||||
connection.Received().Actions.Workflows.CreateDispatch("fake", "repo", "main.yaml", createDispatch);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.CreateDispatch(null, "repo", 123, createDispatch));
|
||||
Assert.Throws<ArgumentNullException>(() => client.CreateDispatch("fake", null, 123, createDispatch));
|
||||
Assert.Throws<ArgumentNullException>(() => client.CreateDispatch("fake", "repo", 123, null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.CreateDispatch(null, "repo", "main.yaml", createDispatch));
|
||||
Assert.Throws<ArgumentNullException>(() => client.CreateDispatch("fake", null, "main.yaml", createDispatch));
|
||||
Assert.Throws<ArgumentNullException>(() => client.CreateDispatch("fake", "repo", null, createDispatch));
|
||||
Assert.Throws<ArgumentNullException>(() => client.CreateDispatch("fake", "repo", "main.yaml", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
var createDispatch = new CreateWorkflowDispatch("ref");
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.CreateDispatch("", "repo", 123, createDispatch));
|
||||
Assert.Throws<ArgumentException>(() => client.CreateDispatch("fake", "", 123, createDispatch));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.CreateDispatch("", "repo", "main.yaml", createDispatch));
|
||||
Assert.Throws<ArgumentException>(() => client.CreateDispatch("fake", "", "main.yaml", createDispatch));
|
||||
Assert.Throws<ArgumentException>(() => client.CreateDispatch("fake", "repo", "", createDispatch));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDisableMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.Disable("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Disable("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.Disable("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Actions.Workflows.Disable("fake", "repo", "main.yaml");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Disable(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Disable("fake", null, 123));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Disable(null, "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Disable("fake", null, "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Disable("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Disable("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Disable("fake", "", 123));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Disable("", "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.Disable("fake", "", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.Disable("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheEnableMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.Enable("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Enable("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.Enable("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Actions.Workflows.Enable("fake", "repo", "main.yaml");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Enable(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Enable("fake", null, 123));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Enable(null, "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Enable("fake", null, "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Enable("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Enable("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Enable("fake", "", 123));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Enable("", "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.Enable("fake", "", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.Enable("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.Get("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.Get("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.Get("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Actions.Workflows.Get("fake", "repo", "main.yaml");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("fake", null, 123));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get(null, "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("fake", null, "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Get("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("fake", "", 123));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.Get("", "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("fake", "", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.Get("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetUsageMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowId()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.GetUsage("fake", "repo", 123);
|
||||
|
||||
connection.Received().Actions.Workflows.GetUsage("fake", "repo", 123);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlByWorkflowFileName()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.GetUsage("fake", "repo", "main.yaml");
|
||||
|
||||
connection.Received().Actions.Workflows.GetUsage("fake", "repo", "main.yaml");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetUsage(null, "repo", 123));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetUsage("fake", null, 123));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetUsage(null, "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetUsage("fake", null, "main.yaml"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetUsage("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetUsage("", "repo", 123));
|
||||
Assert.Throws<ArgumentException>(() => client.GetUsage("fake", "", 123));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetUsage("", "repo", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.GetUsage("fake", "", "main.yaml"));
|
||||
Assert.Throws<ArgumentException>(() => client.GetUsage("fake", "repo", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheListMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
client.List("fake", "repo");
|
||||
|
||||
connection.Received().Actions.Workflows.List("fake", "repo");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequestWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
var options = new ApiOptions { PageSize = 1 };
|
||||
|
||||
client.List("fake", "repo", options);
|
||||
|
||||
connection.Received().Actions.Workflows.List("fake", "repo", options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.List(null, "repo", ApiOptions.None));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", null, ApiOptions.None));
|
||||
Assert.Throws<ArgumentNullException>(() => client.List("fake", "repo", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonEmptyArguments()
|
||||
{
|
||||
var connection = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableActionsWorkflowsClient(connection);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo"));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", ""));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.List("", "repo", ApiOptions.None));
|
||||
Assert.Throws<ArgumentException>(() => client.List("fake", "", ApiOptions.None));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using Octokit.Reactive;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Octokit.Reactive;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
|
||||
19
Octokit/Clients/ActionsArtifactsClient.cs
Normal file
19
Octokit/Clients/ActionsArtifactsClient.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Artifacts API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/artifacts/">Actions Artifacts API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsArtifactsClient : ApiClient, IActionsArtifactsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Artifacts API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsArtifactsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Octokit/Clients/ActionsCacheClient.cs
Normal file
19
Octokit/Clients/ActionsCacheClient.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Cache API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/cache/">Actions Cache API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsCacheClient : ApiClient, IActionsCacheClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Cache API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsCacheClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
56
Octokit/Clients/ActionsClient.cs
Normal file
56
Octokit/Clients/ActionsClient.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/actions/">Actions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsClient : ApiClient, IActionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiate a new GitHub Actions API client.
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection.</param>
|
||||
public ActionsClient(IApiConnection apiConnection)
|
||||
: base(apiConnection)
|
||||
{
|
||||
Artifacts = new ActionsArtifactsClient(apiConnection);
|
||||
Cache = new ActionsCacheClient(apiConnection);
|
||||
Permissions = new ActionsPermissionsClient(apiConnection);
|
||||
SelfHostedRunnerGroups = new ActionsSelfHostedRunnerGroupsClient(apiConnection);
|
||||
SelfHostedRunners = new ActionsSelfHostedRunnersClient(apiConnection);
|
||||
Workflows = new ActionsWorkflowsClient(apiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Artifacts API.
|
||||
/// </summary>
|
||||
public IActionsArtifactsClient Artifacts { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Cache API.
|
||||
/// </summary>
|
||||
public IActionsCacheClient Cache { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Permissions API.
|
||||
/// </summary>
|
||||
public IActionsPermissionsClient Permissions { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runner groups API.
|
||||
/// </summary>
|
||||
public IActionsSelfHostedRunnerGroupsClient SelfHostedRunnerGroups { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runners API.
|
||||
/// </summary>
|
||||
public IActionsSelfHostedRunnersClient SelfHostedRunners { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflows API.
|
||||
/// </summary>
|
||||
public IActionsWorkflowsClient Workflows { get; private set; }
|
||||
}
|
||||
}
|
||||
19
Octokit/Clients/ActionsPermissionsClient.cs
Normal file
19
Octokit/Clients/ActionsPermissionsClient.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Permissions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/permissions/">Actions Permissions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsPermissionsClient : ApiClient, IActionsPermissionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Permissions API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsPermissionsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs
Normal file
19
Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Self-hosted runner groups API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/self-hosted-runner-groups/">Actions Self-hosted runner groups API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsSelfHostedRunnerGroupsClient : ApiClient, IActionsSelfHostedRunnerGroupsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Self-hosted runner groups API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsSelfHostedRunnerGroupsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Octokit/Clients/ActionsSelfHostedRunnersClient.cs
Normal file
19
Octokit/Clients/ActionsSelfHostedRunnersClient.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Self-hosted runners API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/self-hosted-runners/">Actions Self-hosted runners API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsSelfHostedRunnersClient : ApiClient, IActionsSelfHostedRunnersClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Self-hosted runners API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsSelfHostedRunnersClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
173
Octokit/Clients/ActionsWorkflowJobsClient.cs
Normal file
173
Octokit/Clients/ActionsWorkflowJobsClient.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflows jobs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-jobs/">Actions Workflows jobs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsWorkflowJobsClient : ApiClient, IActionsWorkflowJobsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Workflows jobs API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsWorkflowJobsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-runs a specific workflow job in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-job-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/jobs/{job_id}/rerun")]
|
||||
public Task Rerun(string owner, string name, long jobId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Post(ApiUrls.ActionsRerunWorkflowJob(owner, name, jobId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific job in a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#get-a-job-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The unique identifier of the job.</param>
|
||||
[ManualRoute("GET", "\n/repos/{owner}/{repo}/actions/jobs/{job_id}")]
|
||||
public Task<WorkflowJob> Get(string owner, string name, long jobId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Get<WorkflowJob>(ApiUrls.ActionsGetWorkflowJob(owner, name, jobId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plain text log file for a workflow job.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#download-job-logs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/jobs/{job_id}/logs")]
|
||||
public async Task<string> GetLogs(string owner, string name, long jobId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
var response = await Connection.Get<string>(ApiUrls.ActionsGetWorkflowJobLogs(owner, name, jobId), null).ConfigureAwait(false);
|
||||
return response.Body;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/jobs")]
|
||||
public Task<WorkflowJobsResponse> List(string owner, string name, long runId)
|
||||
{
|
||||
return List(owner, name, runId, new WorkflowRunJobsRequest(), ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/jobs")]
|
||||
public Task<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest)
|
||||
{
|
||||
return List(owner, name, runId, workflowRunJobsRequest, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/jobs")]
|
||||
public async Task<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunJobsRequest, nameof(workflowRunJobsRequest));
|
||||
|
||||
var results = await ApiConnection.GetAll<WorkflowJobsResponse>(ApiUrls.ActionsListWorkflowJobs(owner, name, runId), workflowRunJobsRequest.ToParametersDictionary(), options).ConfigureAwait(false);
|
||||
|
||||
return new WorkflowJobsResponse(
|
||||
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
|
||||
results.SelectMany(x => x.Jobs).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs")]
|
||||
public Task<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber)
|
||||
{
|
||||
return List(owner, name, runId, attemptNumber, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs")]
|
||||
public async Task<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
var results = await ApiConnection.GetAll<WorkflowJobsResponse>(ApiUrls.ActionsListWorkflowJobs(owner, name, runId, attemptNumber), null, options).ConfigureAwait(false);
|
||||
|
||||
return new WorkflowJobsResponse(
|
||||
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
|
||||
results.SelectMany(x => x.Jobs).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
432
Octokit/Clients/ActionsWorkflowRunsClient.cs
Normal file
432
Octokit/Clients/ActionsWorkflowRunsClient.cs
Normal file
@@ -0,0 +1,432 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflows runs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-runs/">Actions Workflows runs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsWorkflowRunsClient : ApiClient, IActionsWorkflowRunsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Workflows runs API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsWorkflowRunsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs")]
|
||||
public Task<WorkflowRunsResponse> List(string owner, string name)
|
||||
{
|
||||
return List(owner, name, new WorkflowRunsRequest(), ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs")]
|
||||
public Task<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest)
|
||||
{
|
||||
return List(owner, name, workflowRunsRequest, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs")]
|
||||
public async Task<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsWorkflowRuns(owner, name), workflowRunsRequest.ToParametersDictionary(), options).ConfigureAwait(false);
|
||||
|
||||
return new WorkflowRunsResponse(
|
||||
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
|
||||
results.SelectMany(x => x.WorkflowRuns).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}")]
|
||||
public Task<WorkflowRun> Get(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Get<WorkflowRun>(ApiUrls.ActionsWorkflowRun(owner, name, runId), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a specific workflow run. Anyone with write access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("DELETE", "/repos/{owner}/{repo}/actions/runs/{run_id}")]
|
||||
public Task Delete(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.ActionsWorkflowRun(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the review history for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-the-review-history-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/approvals")]
|
||||
public Task<IReadOnlyList<EnvironmentApprovals>> GetReviewHistory(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.GetAll<EnvironmentApprovals>(ApiUrls.ActionsWorkflowRunApprovals(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Approves a workflow run for a pull request from a public fork of a first time contributor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#approve-a-workflow-run-for-a-fork-pull-request
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/runs/{run_id}/approve")]
|
||||
public Task Approve(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Post(ApiUrls.ActionsApproveWorkflowRun(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run attempt. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}")]
|
||||
public Task<WorkflowRun> GetAttempt(string owner, string name, long runId, long attemptNumber)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Get<WorkflowRun>(ApiUrls.ActionsWorkflowRunAttempt(owner, name, runId, attemptNumber), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-attempt-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}")]
|
||||
public async Task<byte[]> GetAttemptLogs(string owner, string name, long runId, long attemptNumber)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
var response = await Connection.GetRaw(ApiUrls.ActionsGetWorkflowRunAttemptLogs(owner, name, runId, attemptNumber), null).ConfigureAwait(false);
|
||||
return response.Body;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a workflow run using its Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/runs/{run_id}/cancel")]
|
||||
public Task Cancel(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Post(ApiUrls.ActionsCancelWorkflowRun(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/logs")]
|
||||
public async Task<byte[]> GetLogs(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
var response = await Connection.GetRaw(ApiUrls.ActionsGetWorkflowRunLogs(owner, name, runId), null).ConfigureAwait(false);
|
||||
return response.Body;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all logs for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("DELETE", "/repos/{owner}/{repo}/actions/runs/{run_id}/logs")]
|
||||
public Task DeleteLogs(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.ActionsGetWorkflowRunLogs(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Approve or reject pending deployments that are waiting on approval by a required reviewer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#review-pending-deployments-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="review">The review for the pending deployment.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments")]
|
||||
public Task<Deployment> ReviewPendingDeployments(string owner, string name, long runId, PendingDeploymentReview review)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(review, nameof(review));
|
||||
|
||||
return ApiConnection.Post<Deployment>(ApiUrls.ActionsWorkflowRunPendingDeployments(owner, name, runId), review);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-runs your workflow run using its Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/runs/{run_id}/rerun")]
|
||||
public Task Rerun(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Post(ApiUrls.ActionsRerunWorkflowRun(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-run all of the failed jobs and their dependent jobs in a workflow run using the Id of the workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-failed-jobs-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs")]
|
||||
public Task RerunFailedJobs(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Post(ApiUrls.ActionsRerunWorkflowRunFailedJobs(owner, name, runId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of billable minutes and total run time for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/runs/{run_id}/timing")]
|
||||
public Task<WorkflowRunUsage> GetUsage(string owner, string name, long runId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Get<WorkflowRunUsage>(ApiUrls.ActionsGetWorkflowRunUsage(owner, name, runId), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs")]
|
||||
public Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId)
|
||||
{
|
||||
return ListByWorkflow(owner, name, workflowId, new WorkflowRunsRequest(), ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs")]
|
||||
public Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest)
|
||||
{
|
||||
return ListByWorkflow(owner, name, workflowId, workflowRunsRequest, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs")]
|
||||
public async Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsListWorkflowRuns(owner, name, workflowId), workflowRunsRequest.ToParametersDictionary(), options).ConfigureAwait(false);
|
||||
|
||||
return new WorkflowRunsResponse(
|
||||
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
|
||||
results.SelectMany(x => x.WorkflowRuns).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The Id of the workflow.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs")]
|
||||
public Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName)
|
||||
{
|
||||
return ListByWorkflow(owner, name, workflowFileName, new WorkflowRunsRequest(), ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs")]
|
||||
public Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest)
|
||||
{
|
||||
return ListByWorkflow(owner, name, workflowFileName, workflowRunsRequest, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs")]
|
||||
public async Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
Ensure.ArgumentNotNull(workflowRunsRequest, nameof(workflowRunsRequest));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
var results = await ApiConnection.GetAll<WorkflowRunsResponse>(ApiUrls.ActionsListWorkflowRuns(owner, name, workflowFileName), workflowRunsRequest.ToParametersDictionary(), options).ConfigureAwait(false);
|
||||
|
||||
return new WorkflowRunsResponse(
|
||||
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
|
||||
results.SelectMany(x => x.WorkflowRuns).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
263
Octokit/Clients/ActionsWorkflowsClient.cs
Normal file
263
Octokit/Clients/ActionsWorkflowsClient.cs
Normal file
@@ -0,0 +1,263 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflows API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflows/">Actions Workflows API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public class ActionsWorkflowsClient : ApiClient, IActionsWorkflowsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub Actions Workflows API client
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public ActionsWorkflowsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
Jobs = new ActionsWorkflowJobsClient(apiConnection);
|
||||
Runs = new ActionsWorkflowRunsClient(apiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by file name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches")]
|
||||
public Task CreateDispatch(string owner, string name, string workflowFileName, CreateWorkflowDispatch createDispatch)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
|
||||
|
||||
return ApiConnection.Post<object>(ApiUrls.ActionsDispatchWorkflow(owner, name, workflowFileName), createDispatch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
[ManualRoute("POST", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches")]
|
||||
public Task CreateDispatch(string owner, string name, long workflowId, CreateWorkflowDispatch createDispatch)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
|
||||
|
||||
return ApiConnection.Post<object>(ApiUrls.ActionsDispatchWorkflow(owner, name, workflowId), createDispatch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by file name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
[ManualRoute("PUT", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable")]
|
||||
public Task Disable(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return ApiConnection.Put(ApiUrls.ActionsDisableWorkflow(owner, name, workflowFileName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
[ManualRoute("PUT", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable")]
|
||||
public Task Disable(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Put(ApiUrls.ActionsDisableWorkflow(owner, name, workflowId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by file name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
[ManualRoute("PUT", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable")]
|
||||
public Task Enable(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return ApiConnection.Put(ApiUrls.ActionsEnableWorkflow(owner, name, workflowFileName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
[ManualRoute("PUT", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable")]
|
||||
public Task Enable(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Put(ApiUrls.ActionsEnableWorkflow(owner, name, workflowId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by file name. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}")]
|
||||
public Task<Workflow> Get(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return ApiConnection.Get<Workflow>(ApiUrls.ActionsGetWorkflow(owner, name, workflowFileName), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}")]
|
||||
public Task<Workflow> Get(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Get<Workflow>(ApiUrls.ActionsGetWorkflow(owner, name, workflowId), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by file name. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing")]
|
||||
public Task<WorkflowUsage> GetUsage(string owner, string name, string workflowFileName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
|
||||
|
||||
return ApiConnection.Get<WorkflowUsage>(ApiUrls.ActionsGetWorkflowUsage(owner, name, workflowFileName), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing")]
|
||||
public Task<WorkflowUsage> GetUsage(string owner, string name, long workflowId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return ApiConnection.Get<WorkflowUsage>(ApiUrls.ActionsGetWorkflowUsage(owner, name, workflowId), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows")]
|
||||
public Task<WorkflowsResponse> List(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
|
||||
return List(owner, name, ApiOptions.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
[ManualRoute("GET", "/repos/{owner}/{repo}/actions/workflows")]
|
||||
public async Task<WorkflowsResponse> List(string owner, string name, ApiOptions options)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
|
||||
Ensure.ArgumentNotNull(options, nameof(options));
|
||||
|
||||
var results = await ApiConnection.GetAll<WorkflowsResponse>(ApiUrls.ActionsListWorkflows(owner, name), null, options).ConfigureAwait(false);
|
||||
|
||||
return new WorkflowsResponse(
|
||||
results.Count > 0 ? results.Max(x => x.TotalCount) : 0,
|
||||
results.SelectMany(x => x.Workflows).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow jobs API.
|
||||
/// </summary>
|
||||
public IActionsWorkflowJobsClient Jobs { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow runs API.
|
||||
/// </summary>
|
||||
public IActionsWorkflowRunsClient Runs { get; private set; }
|
||||
}
|
||||
}
|
||||
15
Octokit/Clients/IActionsArtifactsClient.cs
Normal file
15
Octokit/Clients/IActionsArtifactsClient.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Artifacts API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/artifacts/">Actions Artifacts API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsArtifactsClient
|
||||
{
|
||||
}
|
||||
}
|
||||
15
Octokit/Clients/IActionsCacheClient.cs
Normal file
15
Octokit/Clients/IActionsCacheClient.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Cache API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/cache/">Actions Cache API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsCacheClient
|
||||
{
|
||||
}
|
||||
}
|
||||
41
Octokit/Clients/IActionsClient.cs
Normal file
41
Octokit/Clients/IActionsClient.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/">Actions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Client for the Artifacts API.
|
||||
/// </summary>
|
||||
IActionsArtifactsClient Artifacts { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Cache API.
|
||||
/// </summary>
|
||||
IActionsCacheClient Cache { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Permissions API.
|
||||
/// </summary>
|
||||
IActionsPermissionsClient Permissions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runner groups API.
|
||||
/// </summary>
|
||||
IActionsSelfHostedRunnerGroupsClient SelfHostedRunnerGroups { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Self-hosted runners API.
|
||||
/// </summary>
|
||||
IActionsSelfHostedRunnersClient SelfHostedRunners { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflows API.
|
||||
/// </summary>
|
||||
IActionsWorkflowsClient Workflows { get; }
|
||||
}
|
||||
}
|
||||
15
Octokit/Clients/IActionsPermissionsClient.cs
Normal file
15
Octokit/Clients/IActionsPermissionsClient.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Permissions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/permissions/">Actions Permissions API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsPermissionsClient
|
||||
{
|
||||
}
|
||||
}
|
||||
15
Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs
Normal file
15
Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Self-hosted runner groups API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/self-hosted-runner-groups/">Actions Self-hosted runner groups API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsSelfHostedRunnerGroupsClient
|
||||
{
|
||||
}
|
||||
}
|
||||
15
Octokit/Clients/IActionsSelfHostedRunnersClient.cs
Normal file
15
Octokit/Clients/IActionsSelfHostedRunnersClient.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Self-hosted runners API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/self-hosted-runners/">Actions Self-hosted runners API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsSelfHostedRunnersClient
|
||||
{
|
||||
}
|
||||
}
|
||||
107
Octokit/Clients/IActionsWorkflowJobsClient.cs
Normal file
107
Octokit/Clients/IActionsWorkflowJobsClient.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflow jobs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-jobs/">Actions Workflow jobs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsWorkflowJobsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Re-runs a specific workflow job in a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-job-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
Task Rerun(string owner, string name, long jobId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific job in a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#get-a-job-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The unique identifier of the job.</param>
|
||||
Task<WorkflowJob> Get(string owner, string name, long jobId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plain text log file for a workflow job.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-jobs/#download-job-logs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
Task<string> GetLogs(string owner, string name, long jobId);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task<WorkflowJobsResponse> List(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
Task<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="workflowRunJobsRequest">Details to filter the request, such as by when completed.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
Task<WorkflowJobsResponse> List(string owner, string name, long runId, WorkflowRunJobsRequest workflowRunJobsRequest, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
Task<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Lists jobs for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-jobs-for-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
Task<WorkflowJobsResponse> List(string owner, string name, long runId, int attemptNumber, ApiOptions options);
|
||||
}
|
||||
}
|
||||
267
Octokit/Clients/IActionsWorkflowRunsClient.cs
Normal file
267
Octokit/Clients/IActionsWorkflowRunsClient.cs
Normal file
@@ -0,0 +1,267 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflow runs API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflow-runs/">Actions Workflow runs API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsWorkflowRunsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
Task<WorkflowRunsResponse> List(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
Task<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-repository
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
Task<WorkflowRunsResponse> List(string owner, string name, WorkflowRunsRequest workflowRunsRequest, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task<WorkflowRun> Get(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a specific workflow run. Anyone with write access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task Delete(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Get the review history for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-the-review-history-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
[ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 30/03/2022)")]
|
||||
[ExcludeFromPaginationNamingConventionTest("Pagination not supported by GitHub API (tested 30/03/2022)")]
|
||||
Task<IReadOnlyList<EnvironmentApprovals>> GetReviewHistory(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Approve or reject pending deployments that are waiting on approval by a required reviewer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#review-pending-deployments-for-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="review">The review for the pending deployment.</param>
|
||||
Task<Deployment> ReviewPendingDeployments(string owner, string name, long runId, PendingDeploymentReview review);
|
||||
|
||||
/// <summary>
|
||||
/// Approves a workflow run for a pull request from a public fork of a first time contributor.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#approve-a-workflow-run-for-a-fork-pull-request
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task Approve(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow run attempt. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run-attempt
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
Task<WorkflowRun> GetAttempt(string owner, string name, long runId, long attemptNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a specific workflow run attempt.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-attempt-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
Task<byte[]> GetAttemptLogs(string owner, string name, long runId, long attemptNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a workflow run using its Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task Cancel(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array containing an archive of log files for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task<byte[]> GetLogs(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all logs for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task DeleteLogs(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Re-runs your workflow run using its Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task Rerun(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Re-run all of the failed jobs and their dependent jobs in a workflow run using the Id of the workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#re-run-failed-jobs-from-a-workflow-run
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task RerunFailedJobs(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of billable minutes and total run time for a specific workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
Task<WorkflowRunUsage> GetUsage(string owner, string name, long runId);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, long workflowId, WorkflowRunsRequest workflowRunsRequest, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// List all workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-for-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="workflowRunsRequest">Details to filter the request, such as by check suite Id.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
Task<WorkflowRunsResponse> ListByWorkflow(string owner, string name, string workflowFileName, WorkflowRunsRequest workflowRunsRequest, ApiOptions options);
|
||||
}
|
||||
}
|
||||
156
Octokit/Clients/IActionsWorkflowsClient.cs
Normal file
156
Octokit/Clients/IActionsWorkflowsClient.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Actions Workflows API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/actions/workflows/">Actions Workflows API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public interface IActionsWorkflowsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
Task CreateDispatch(string owner, string name, string workflowFileName, CreateWorkflowDispatch createDispatch);
|
||||
|
||||
/// <summary>
|
||||
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
|
||||
Task CreateDispatch(string owner, string name, long workflowId, CreateWorkflowDispatch createDispatch);
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
Task Disable(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Disables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
Task Disable(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
Task Enable(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Enables a specific workflow in a repository by Id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
Task Enable(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
Task<Workflow> Get(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
Task<Workflow> Get(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
Task<WorkflowUsage> GetUsage(string owner, string name, string workflowFileName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets useage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
Task<WorkflowUsage> GetUsage(string owner, string name, long workflowId);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
Task<WorkflowsResponse> List(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <param name="options">Options to change the API response.</param>
|
||||
Task<WorkflowsResponse> List(string owner, string name, ApiOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow jobs API.
|
||||
/// </summary>
|
||||
IActionsWorkflowJobsClient Jobs { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for the Workflow runs API.
|
||||
/// </summary>
|
||||
IActionsWorkflowRunsClient Runs { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Org Actions API.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -9,7 +8,7 @@ namespace Octokit
|
||||
/// A client for GitHub's Repositories API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <https://docs.github.com/en/rest/reference/repos">Repositories API documentation</a> for more details.
|
||||
/// See the <a href="https://docs.github.com/en/rest/reference/repos">Repositories API documentation</a> for more details.
|
||||
/// </remarks>
|
||||
public interface IRepositoriesClient
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Actions API.
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Org Actions API.
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Octokit
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Actions API.
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace Octokit
|
||||
Licenses = new LicensesClient(apiConnection);
|
||||
RateLimit = new RateLimitClient(apiConnection);
|
||||
Meta = new MetaClient(apiConnection);
|
||||
Actions = new ActionsClient(apiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -368,6 +369,14 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
public IMarkdownClient Markdown { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Access GitHub's Actions API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Refer to the API documentation for more information: https://developer.github.com/v3/actions/
|
||||
/// </remarks>
|
||||
public IActionsClient Actions { get; private set; }
|
||||
|
||||
static Uri FixUpBaseUri(Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Octokit
|
||||
public static partial class ApiUrls
|
||||
{
|
||||
static readonly Uri _currentUserRepositoriesUrl = new Uri("user/repos", UriKind.Relative);
|
||||
static readonly Uri _currentUserOrganizationsUrl = new Uri("user/orgs", UriKind.Relative);
|
||||
static readonly Uri _currentUserSshKeys = new Uri("user/keys", UriKind.Relative);
|
||||
static readonly Uri _currentUserGpgKeys = new Uri("user/gpg_keys", UriKind.Relative);
|
||||
static readonly Uri _currentUserStars = new Uri("user/starred", UriKind.Relative);
|
||||
@@ -4776,5 +4775,366 @@ namespace Octokit
|
||||
{
|
||||
return "/users/{0}/packages/{1}/{2}/versions/{3}/restore".FormatUri(username, packageType.ToParameter(), packageName, packageVersionId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that disables an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsDispatchWorkflow(string owner, string repo, long workflowId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/dispatches".FormatUri(owner, repo, workflowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that disables an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsDispatchWorkflow(string owner, string repo, string workflowFileName)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/dispatches".FormatUri(owner, repo, workflowFileName.UriEncode());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that disables an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsDisableWorkflow(string owner, string repo, string workflowFileName)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/disable".FormatUri(owner, repo, workflowFileName.UriEncode());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that disables an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsDisableWorkflow(string owner, string repo, long workflowId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/disable".FormatUri(owner, repo, workflowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that enables an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsEnableWorkflow(string owner, string repo, string workflowFileName)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/enable".FormatUri(owner, repo, workflowFileName.UriEncode());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that enables an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsEnableWorkflow(string owner, string repo, long workflowId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/enable".FormatUri(owner, repo, workflowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflow(string owner, string repo, string workflowFileName)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}".FormatUri(owner, repo, workflowFileName.UriEncode());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets an Actions workflow for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflow(string owner, string repo, long workflowId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}".FormatUri(owner, repo, workflowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets an Actions workflow'usage for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflowUsage(string owner, string repo, string workflowFileName)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/timing".FormatUri(owner, repo, workflowFileName.UriEncode());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets an Actions workflow's usage for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflowUsage(string owner, string repo, long workflowId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/timing".FormatUri(owner, repo, workflowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions workflows for the repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <returns>The <see cref="Uri"/> that handles the Actions workflows for the repository.</returns>
|
||||
public static Uri ActionsListWorkflows(string owner, string repo)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows".FormatUri(owner, repo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that re-runs an Actions workflow job for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsRerunWorkflowJob(string owner, string repo, long jobId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/jobs/{2}/rerun".FormatUri(owner, repo, jobId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that re-runs an Actions workflow job for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflowJob(string owner, string repo, long jobId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/jobs/{2}".FormatUri(owner, repo, jobId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets the logs an Actions workflow job for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="jobId">The Id of the workflow job.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow job for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflowJobLogs(string owner, string repo, long jobId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/jobs/{2}/logs".FormatUri(owner, repo, jobId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions jobs for a workflow run.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <returns>The <see cref="Uri"/> that handles the Actions workflows runs for a workflow.</returns>
|
||||
public static Uri ActionsListWorkflowJobs(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/jobs".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions jobs for a workflow run.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow job.</param>
|
||||
/// <returns>The <see cref="Uri"/> that handles the Actions workflows runs for a workflow.</returns>
|
||||
public static Uri ActionsListWorkflowJobs(string owner, string repo, long runId, int attemptNumber)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/attempts/{3}/jobs".FormatUri(owner, repo, runId, attemptNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets Actions workflow runs for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets Actions workflow runs for a repository.</returns>
|
||||
public static Uri ActionsWorkflowRuns(string owner, string repo)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs".FormatUri(owner, repo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets an Actions workflow run for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow run for a repository.</returns>
|
||||
public static Uri ActionsWorkflowRun(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets an Actions workflow run attempt for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow run for a repository.</returns>
|
||||
public static Uri ActionsWorkflowRunAttempt(string owner, string repo, long runId, long attemptNumber)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/attempts/{3}".FormatUri(owner, repo, runId, attemptNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that approves an Actions workflow run for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <returns>The <see cref="Uri"/> that approves an Actions workflow run for a repository.</returns>
|
||||
public static Uri ActionsApproveWorkflowRun(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/approve".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that cancels an Actions workflow run for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <returns>The <see cref="Uri"/> that cancels an Actions workflow run for a repository.</returns>
|
||||
public static Uri ActionsCancelWorkflowRun(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/cancel".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets the logs an Actions workflow run attempt for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow run for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflowRunLogs(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/logs".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets the logs an Actions workflow run attempt for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow run.</param>
|
||||
/// <param name="attemptNumber">The attempt number of the workflow run.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow run for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflowRunAttemptLogs(string owner, string repo, long runId, long attemptNumber)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/attempts/{3}/logs".FormatUri(owner, repo, runId, attemptNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that re-runs an Actions workflow run for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow job.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsRerunWorkflowRun(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/rerun".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that re-runs failed jobs of an Actions workflow run for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow job.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsRerunWorkflowRunFailedJobs(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/rerun-failed-jobs".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets an Actions workflow's usage for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets an Actions workflow for a repository.</returns>
|
||||
public static Uri ActionsGetWorkflowRunUsage(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/timing".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets Actions workflow run approvals for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets Actions workflow run approvals for a repository.</returns>
|
||||
public static Uri ActionsWorkflowRunApprovals(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/approvals".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that gets Actions workflow run pending deployments for a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="runId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that gets Actions workflow run pending deployments for a repository.</returns>
|
||||
public static Uri ActionsWorkflowRunPendingDeployments(string owner, string repo, long runId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/runs/{2}/pending_deployments".FormatUri(owner, repo, runId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowId">The Id of the workflow.</param>
|
||||
/// <returns>The <see cref="Uri"/> that handles the Actions workflows runs for a workflow.</returns>
|
||||
public static Uri ActionsListWorkflowRuns(string owner, string repo, long workflowId)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/runs".FormatUri(owner, repo, workflowId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that handles the Actions workflow runs for a workflow.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of repo</param>
|
||||
/// <param name="repo">The name of repo</param>
|
||||
/// <param name="workflowFileName">The workflow file name.</param>
|
||||
/// <returns>The <see cref="Uri"/> that handles the Actions workflows runs for a workflow.</returns>
|
||||
public static Uri ActionsListWorkflowRuns(string owner, string repo, string workflowFileName)
|
||||
{
|
||||
return "/repos/{0}/{1}/actions/workflows/{2}/runs".FormatUri(owner, repo, workflowFileName.UriEncode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,14 @@ namespace Octokit
|
||||
public static string ToRubyCase(this string propertyName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(propertyName, nameof(propertyName));
|
||||
|
||||
// If the entire property is already all upper case, then do not split it across
|
||||
// word boundaries. For example, "UBUNTU" should not be changed to "u_b_u_n_t_u".
|
||||
if (string.Equals(propertyName, propertyName.ToUpperInvariant(), StringComparison.Ordinal))
|
||||
{
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
return string.Join("_", propertyName.SplitUpperCase()).ToLowerInvariant();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,14 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
IActivitiesClient Activity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access GitHub's Actions API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Refer to the API documentation for more information: https://developer.github.com/v3/actions/
|
||||
/// </remarks>
|
||||
IActionsClient Actions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access GitHub's Application API.
|
||||
/// </summary>
|
||||
|
||||
34
Octokit/Models/Request/CheckRunStatusFilter.cs
Normal file
34
Octokit/Models/Request/CheckRunStatusFilter.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public enum CheckRunStatusFilter
|
||||
{
|
||||
[Parameter(Value = "success")]
|
||||
Success,
|
||||
[Parameter(Value = "failure")]
|
||||
Failure,
|
||||
[Parameter(Value = "neutral")]
|
||||
Neutral,
|
||||
[Parameter(Value = "cancelled")]
|
||||
Cancelled,
|
||||
[Parameter(Value = "timed_out")]
|
||||
TimedOut,
|
||||
[Parameter(Value = "action_required")]
|
||||
ActionRequired,
|
||||
[Parameter(Value = "stale")]
|
||||
Stale,
|
||||
[Parameter(Value = "requested")]
|
||||
Requested,
|
||||
[Parameter(Value = "in_progress")]
|
||||
InProgress,
|
||||
[Parameter(Value = "completed")]
|
||||
Completed,
|
||||
[Parameter(Value = "queued")]
|
||||
Queued,
|
||||
[Parameter(Value = "waiting")]
|
||||
Waiting,
|
||||
[Parameter(Value = "skipped")]
|
||||
Skipped,
|
||||
}
|
||||
}
|
||||
41
Octokit/Models/Request/CreateWorkflowDispatch.cs
Normal file
41
Octokit/Models/Request/CreateWorkflowDispatch.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the values used to create a workflow dispatch event.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class CreateWorkflowDispatch
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new workflow dispatch event.
|
||||
/// </summary>
|
||||
/// <param name="ref">Required. The git reference for the workflow. The reference can be a branch or tag name.</param>
|
||||
public CreateWorkflowDispatch(string @ref)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(@ref, nameof(@ref));
|
||||
Ref = @ref;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The git reference for the workflow. The reference can be a branch or tag name.
|
||||
/// </summary>
|
||||
public string Ref { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Input keys and values configured in the workflow file.
|
||||
/// </summary>
|
||||
public IDictionary<string, object> Inputs { get; set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Ref: {0}", Ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Octokit/Models/Request/PendingDeploymentReview.cs
Normal file
40
Octokit/Models/Request/PendingDeploymentReview.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class PendingDeploymentReview
|
||||
{
|
||||
public PendingDeploymentReview(IList<long> environmentIds, PendingDeploymentReviewState state, string comment)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyEnumerable(environmentIds, nameof(environmentIds));
|
||||
Ensure.ArgumentNotNull(comment, nameof(comment));
|
||||
|
||||
EnvironmentIds = environmentIds;
|
||||
State = state;
|
||||
Comment = comment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The list of environment Ids to approve or reject.
|
||||
/// </summary>
|
||||
public IList<long> EnvironmentIds { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to approve or reject deployment to the specified environments.
|
||||
/// </summary>
|
||||
public StringEnum<PendingDeploymentReviewState> State { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A comment to accompany the deployment review.
|
||||
/// </summary>
|
||||
public string Comment { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get { return string.Format(CultureInfo.InvariantCulture, "EnvironmentIds: {0}, State: {1}, Comment: {2}", EnvironmentIds, State, Comment); }
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Octokit/Models/Request/PendingDeploymentReviewState.cs
Normal file
12
Octokit/Models/Request/PendingDeploymentReviewState.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public enum PendingDeploymentReviewState
|
||||
{
|
||||
[Parameter(Value = "approved")]
|
||||
Approved,
|
||||
[Parameter(Value = "rejected")]
|
||||
Rejected,
|
||||
}
|
||||
}
|
||||
22
Octokit/Models/Request/WorkflowRunJobsRequest.cs
Normal file
22
Octokit/Models/Request/WorkflowRunJobsRequest.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Details to filter a workflow run jobs request, such as by the latest attempt.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowRunJobsRequest : RequestParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// Filters jobs by their <c>completed_at</c> timestamp.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowRunJobsFilter> Filter { get; set; }
|
||||
|
||||
internal string DebuggerDisplay => string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Filter: {0}",
|
||||
Filter);
|
||||
}
|
||||
}
|
||||
68
Octokit/Models/Request/WorkflowRunsRequest.cs
Normal file
68
Octokit/Models/Request/WorkflowRunsRequest.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Details to filter a workflow runs request, such as by branch or check suite Id.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowRunsRequest : RequestParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns someone's workflow runs.
|
||||
/// </summary>
|
||||
public string Actor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns workflow runs associated with a branch.
|
||||
/// </summary>
|
||||
public string Branch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns workflow run triggered by the event you specify.
|
||||
/// </summary>
|
||||
public string Event { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Only returns workflow runs that are associated with the specified head SHA.
|
||||
/// </summary>
|
||||
[Parameter(Key = "head_sha")]
|
||||
public string HeadSha { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns workflow runs with the check run status or conclusion that you specify.
|
||||
/// </summary>
|
||||
public StringEnum<CheckRunStatusFilter> Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns workflow runs created within the given date-time range.
|
||||
/// </summary>
|
||||
public string Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true pull requests are omitted from the response.
|
||||
/// </summary>
|
||||
[Parameter(Key = "exclude_pull_requests")]
|
||||
public bool? ExcludePullRequests { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns workflow runs with the check_suite_id that you specify.
|
||||
/// </summary>
|
||||
[Parameter(Key = "check_suite_id")]
|
||||
public long? CheckSuiteId { get; set; }
|
||||
|
||||
internal string DebuggerDisplay => string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Actor: {0}, Branch: {1}, Event: {2}, Status: {3}, Created: {4}, ExcludePullRequests: {5}, CheckSuiteId: {6}, HeadSha: {7}",
|
||||
Actor,
|
||||
Branch,
|
||||
Event,
|
||||
Status,
|
||||
Created,
|
||||
ExcludePullRequests,
|
||||
CheckSuiteId,
|
||||
HeadSha);
|
||||
}
|
||||
}
|
||||
69
Octokit/Models/Response/EnvironmentApproval.cs
Normal file
69
Octokit/Models/Response/EnvironmentApproval.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an environment for a deployment approval.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class EnvironmentApproval
|
||||
{
|
||||
public EnvironmentApproval() { }
|
||||
|
||||
public EnvironmentApproval(long id, string nodeId, string name, string url, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt)
|
||||
{
|
||||
Id = id;
|
||||
NodeId = nodeId;
|
||||
Name = name;
|
||||
Url = url;
|
||||
HtmlUrl = htmlUrl;
|
||||
CreatedAt = createdAt;
|
||||
UpdatedAt = updatedAt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Id of the environment.
|
||||
/// </summary>
|
||||
public long Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// GraphQL Node Id.
|
||||
/// </summary>
|
||||
public string NodeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the environment.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this environment.
|
||||
/// </summary>
|
||||
public string Url { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for the HTML view of this environment.
|
||||
/// </summary>
|
||||
public string HtmlUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the environment was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the environment was last updated.
|
||||
/// </summary>
|
||||
public DateTimeOffset UpdatedAt { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Id: {0}, Name: {1}", Id, Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Octokit/Models/Response/EnvironmentApprovalState.cs
Normal file
12
Octokit/Models/Response/EnvironmentApprovalState.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public enum EnvironmentApprovalState
|
||||
{
|
||||
[Parameter(Value = "approved")]
|
||||
Approved,
|
||||
[Parameter(Value = "rejected")]
|
||||
Rejected,
|
||||
}
|
||||
}
|
||||
51
Octokit/Models/Response/EnvironmentApprovals.cs
Normal file
51
Octokit/Models/Response/EnvironmentApprovals.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an environment for a deployment approval.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class EnvironmentApprovals
|
||||
{
|
||||
public EnvironmentApprovals() { }
|
||||
|
||||
public EnvironmentApprovals(IReadOnlyList<EnvironmentApproval> environments, User user, EnvironmentApprovalState state, string comment)
|
||||
{
|
||||
Environments = environments;
|
||||
User = user;
|
||||
State = state;
|
||||
Comment = comment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The list of environments that were approved or rejected.
|
||||
/// </summary>
|
||||
public IReadOnlyList<EnvironmentApproval> Environments { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user that approved or rejected the deployments.
|
||||
/// </summary>
|
||||
public User User { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether deployment to the environment(s) was approved or rejected.
|
||||
/// </summary>
|
||||
public StringEnum<EnvironmentApprovalState> State { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The comment submitted with the deployment review.
|
||||
/// </summary>
|
||||
public string Comment { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "State: {0}, Comment: {1}", State, Comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
90
Octokit/Models/Response/Workflow.cs
Normal file
90
Octokit/Models/Response/Workflow.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class Workflow
|
||||
{
|
||||
public Workflow() { }
|
||||
|
||||
public Workflow(long id, string nodeId, string name, string path, WorkflowState state, DateTimeOffset createdAt, DateTimeOffset updatedAt, string url, string htmlUrl, string badgeUrl, DateTimeOffset? deletedAt)
|
||||
{
|
||||
Id = id;
|
||||
NodeId = nodeId;
|
||||
Name = name;
|
||||
Path = path;
|
||||
State = state;
|
||||
CreatedAt = createdAt;
|
||||
UpdatedAt = updatedAt;
|
||||
Url = url;
|
||||
HtmlUrl = htmlUrl;
|
||||
BadgeUrl = badgeUrl;
|
||||
DeletedAt = deletedAt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Id for this workflow.
|
||||
/// </summary>
|
||||
public long Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// GraphQL Node Id.
|
||||
/// </summary>
|
||||
public string NodeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the workflow.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The path of the workflow file.
|
||||
/// </summary>
|
||||
public string Path { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The state of the workflow.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowState> State { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the workflow was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the workflow was last updated.
|
||||
/// </summary>
|
||||
public DateTimeOffset UpdatedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow.
|
||||
/// </summary>
|
||||
public string Url { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for the HTML view of this workflow.
|
||||
/// </summary>
|
||||
public string HtmlUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL of the badge image for this workflow.
|
||||
/// </summary>
|
||||
public string BadgeUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the workflow was deleted.
|
||||
/// </summary>
|
||||
public DateTimeOffset? DeletedAt { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Id: {0} Name: {1}", Id, Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Octokit/Models/Response/WorkflowBillable.cs
Normal file
45
Octokit/Models/Response/WorkflowBillable.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowBillable
|
||||
{
|
||||
public WorkflowBillable() { }
|
||||
|
||||
public WorkflowBillable(WorkflowBillableTiming ubuntu, WorkflowBillableTiming macOS, WorkflowBillableTiming windows)
|
||||
{
|
||||
Ubuntu = ubuntu;
|
||||
MacOS = macOS;
|
||||
Windows = windows;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Ubuntu billable timing.
|
||||
/// </summary>
|
||||
[Parameter(Key = "UBUNTU")]
|
||||
public WorkflowBillableTiming Ubuntu { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The macOS billable timing.
|
||||
/// </summary>
|
||||
[Parameter(Key = "MACOS")]
|
||||
public WorkflowBillableTiming MacOS { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Windows billable timing.
|
||||
/// </summary>
|
||||
[Parameter(Key = "WINDOWS")]
|
||||
public WorkflowBillableTiming Windows { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Ubuntu: {0}, macOS: {1}, Windows: {2}", Ubuntu, MacOS, Windows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Octokit/Models/Response/WorkflowBillableTiming.cs
Normal file
29
Octokit/Models/Response/WorkflowBillableTiming.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowBillableTiming
|
||||
{
|
||||
public WorkflowBillableTiming() { }
|
||||
|
||||
public WorkflowBillableTiming(long totalMs)
|
||||
{
|
||||
TotalMs = totalMs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The total billable milliseconds.
|
||||
/// </summary>
|
||||
public long TotalMs { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "TotalMs: {0}", TotalMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
139
Octokit/Models/Response/WorkflowJob.cs
Normal file
139
Octokit/Models/Response/WorkflowJob.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowJob
|
||||
{
|
||||
public WorkflowJob() { }
|
||||
|
||||
public WorkflowJob(long id, long runId, string runUrl, string nodeId, string headSha, string url, string htmlUrl, WorkflowJobStatus status, WorkflowJobConclusion? conclusion, DateTimeOffset startedAt, DateTimeOffset? completedAt, string name, IReadOnlyList<WorkflowJobStep> steps, string checkRunUrl, IReadOnlyList<string> labels, long runnerId, string runnerName, long runnerGroupId, string runnerGroupName)
|
||||
{
|
||||
Id = id;
|
||||
RunId = runId;
|
||||
RunUrl = runUrl;
|
||||
NodeId = nodeId;
|
||||
HeadSha = headSha;
|
||||
Url = url;
|
||||
HtmlUrl = htmlUrl;
|
||||
Status = status;
|
||||
Conclusion = conclusion;
|
||||
StartedAt = startedAt;
|
||||
CompletedAt = completedAt;
|
||||
Name = name;
|
||||
Steps = steps;
|
||||
CheckRunUrl = checkRunUrl;
|
||||
Labels = labels;
|
||||
RunnerId = runnerId;
|
||||
RunnerName = runnerName;
|
||||
RunnerGroupId = runnerGroupId;
|
||||
RunnerGroupName = runnerGroupName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Id of the job.
|
||||
/// </summary>
|
||||
public long Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Id of the associated workflow run.
|
||||
/// </summary>
|
||||
public long RunId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The run URL for this job.
|
||||
/// </summary>
|
||||
public string RunUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The SHA of the commit that is being run.
|
||||
/// </summary>
|
||||
public string HeadSha { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this job.
|
||||
/// </summary>
|
||||
public string Url { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for the HTML view of this job.
|
||||
/// </summary>
|
||||
public string HtmlUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// GraphQL Node Id.
|
||||
/// </summary>
|
||||
public string NodeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The phase of the lifecycle that the job is currently in.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowJobStatus> Status { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The outcome of the job.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowJobConclusion>? Conclusion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the job started.
|
||||
/// </summary>
|
||||
public DateTimeOffset StartedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the job finished.
|
||||
/// </summary>
|
||||
public DateTimeOffset? CompletedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of the workflow job.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Steps in this job.
|
||||
/// </summary>
|
||||
public IReadOnlyList<WorkflowJobStep> Steps { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for the check run for the job.
|
||||
/// </summary>
|
||||
public string CheckRunUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Labels for the workflow job.
|
||||
/// </summary>
|
||||
public IReadOnlyList<string> Labels { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Id of the runner to which this job has been assigned.
|
||||
/// </summary>
|
||||
public long RunnerId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the runner to which this job has been assigned.
|
||||
/// </summary>
|
||||
public string RunnerName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Id of the runner group to which this job has been assigned.
|
||||
/// </summary>
|
||||
public long RunnerGroupId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the runner group to which this job has been assigned.
|
||||
/// </summary>
|
||||
public string RunnerGroupName { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Id: {0} Name: {1}", Id, Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Octokit/Models/Response/WorkflowJobConclusion.cs
Normal file
22
Octokit/Models/Response/WorkflowJobConclusion.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public enum WorkflowJobConclusion
|
||||
{
|
||||
[Parameter(Value = "success")]
|
||||
Success,
|
||||
[Parameter(Value = "failure")]
|
||||
Failure,
|
||||
[Parameter(Value = "neutral")]
|
||||
Neutral,
|
||||
[Parameter(Value = "cancelled")]
|
||||
Cancelled,
|
||||
[Parameter(Value = "skipped")]
|
||||
Skipped,
|
||||
[Parameter(Value = "timed_out")]
|
||||
TimedOut,
|
||||
[Parameter(Value = "action_required")]
|
||||
ActionRequired,
|
||||
}
|
||||
}
|
||||
14
Octokit/Models/Response/WorkflowJobStatus.cs
Normal file
14
Octokit/Models/Response/WorkflowJobStatus.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public enum WorkflowJobStatus
|
||||
{
|
||||
[Parameter(Value = "queued")]
|
||||
Queued,
|
||||
[Parameter(Value = "in_progress")]
|
||||
InProgress,
|
||||
[Parameter(Value = "completed")]
|
||||
Completed,
|
||||
}
|
||||
}
|
||||
60
Octokit/Models/Response/WorkflowJobStep.cs
Normal file
60
Octokit/Models/Response/WorkflowJobStep.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowJobStep
|
||||
{
|
||||
public WorkflowJobStep() { }
|
||||
|
||||
public WorkflowJobStep(string name, WorkflowJobStatus status, WorkflowJobConclusion conclusion, int number, DateTimeOffset? startedAt, DateTimeOffset? completedAt)
|
||||
{
|
||||
Name = name;
|
||||
Status = status;
|
||||
Conclusion = conclusion;
|
||||
Number = number;
|
||||
StartedAt = startedAt;
|
||||
CompletedAt = completedAt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the step.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of the step.
|
||||
/// </summary>
|
||||
public int Number { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The phase of the lifecycle that the job is currently in.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowJobStatus> Status { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The outcome of the job.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowJobConclusion>? Conclusion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the step started.
|
||||
/// </summary>
|
||||
public DateTimeOffset? StartedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the step finished.
|
||||
/// </summary>
|
||||
public DateTimeOffset? CompletedAt { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Number: {0} Name: {1}", Number, Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Octokit/Models/Response/WorkflowJobsResponse.cs
Normal file
32
Octokit/Models/Response/WorkflowJobsResponse.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowJobsResponse
|
||||
{
|
||||
public WorkflowJobsResponse()
|
||||
{
|
||||
}
|
||||
|
||||
public WorkflowJobsResponse(int totalCount, IReadOnlyList<WorkflowJob> jobs)
|
||||
{
|
||||
TotalCount = totalCount;
|
||||
Jobs = jobs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The total number of workflow runs.
|
||||
/// </summary>
|
||||
public int TotalCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The retrieved workflow runs.
|
||||
/// </summary>
|
||||
public IReadOnlyList<WorkflowJob> Jobs { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, Jobs: {1}", TotalCount, Jobs.Count);
|
||||
}
|
||||
}
|
||||
41
Octokit/Models/Response/WorkflowReference.cs
Normal file
41
Octokit/Models/Response/WorkflowReference.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowReference
|
||||
{
|
||||
public WorkflowReference() { }
|
||||
|
||||
public WorkflowReference(string path, string sha, string @ref)
|
||||
{
|
||||
Path = path;
|
||||
Sha = sha;
|
||||
Ref = @ref;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The path of the workflow file.
|
||||
/// </summary>
|
||||
public string Path { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The SHA of the workflow file.
|
||||
/// </summary>
|
||||
public string Sha { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The reference of the workflow file.
|
||||
/// </summary>
|
||||
public string Ref { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Path: {0} SHA: {1}", Path, Sha);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
241
Octokit/Models/Response/WorkflowRun.cs
Normal file
241
Octokit/Models/Response/WorkflowRun.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowRun
|
||||
{
|
||||
public WorkflowRun() { }
|
||||
|
||||
public WorkflowRun(long id, string name, string nodeId, long checkSuiteId, string checkSuiteNodeId, string headBranch, string headSha, string path, long runNumber, string @event, string displayTitle, WorkflowRunStatus status, WorkflowRunConclusion? conclusion, long workflowId, string url, string htmlUrl, IReadOnlyList<PullRequest> pullRequests, DateTimeOffset createdAt, DateTimeOffset updatedAt, User actor, long runAttempt, IReadOnlyList<WorkflowReference> referencedWorkflows, DateTimeOffset runStartedAt, User triggeringActor, string jobsUrl, string logsUrl, string checkSuiteUrl, string artifactsUrl, string cancelUrl, string rerunUrl, string previousAttemptUrl, string workflowUrl, Commit headCommit, Repository repository, Repository headRepository, long headRepositoryId)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
NodeId = nodeId;
|
||||
CheckSuiteId = checkSuiteId;
|
||||
CheckSuiteNodeId = checkSuiteNodeId;
|
||||
HeadBranch = headBranch;
|
||||
HeadSha = headSha;
|
||||
Path = path;
|
||||
RunNumber = runNumber;
|
||||
Event = @event;
|
||||
DisplayTitle = displayTitle;
|
||||
Status = status;
|
||||
Conclusion = conclusion;
|
||||
WorkflowId = workflowId;
|
||||
Url = url;
|
||||
HtmlUrl = htmlUrl;
|
||||
PullRequests = pullRequests;
|
||||
CreatedAt = createdAt;
|
||||
UpdatedAt = updatedAt;
|
||||
Actor = actor;
|
||||
RunAttempt = runAttempt;
|
||||
ReferencedWorkflows = referencedWorkflows;
|
||||
RunStartedAt = runStartedAt;
|
||||
TriggeringActor = triggeringActor;
|
||||
JobsUrl = jobsUrl;
|
||||
LogsUrl = logsUrl;
|
||||
CheckSuiteUrl = checkSuiteUrl;
|
||||
ArtifactsUrl = artifactsUrl;
|
||||
CancelUrl = cancelUrl;
|
||||
RerunUrl = rerunUrl;
|
||||
PreviousAttemptUrl = previousAttemptUrl;
|
||||
WorkflowUrl = workflowUrl;
|
||||
HeadCommit = headCommit;
|
||||
Repository = repository;
|
||||
HeadRepository = headRepository;
|
||||
HeadRepositoryId = headRepositoryId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the workflow run.
|
||||
/// </summary>
|
||||
public long Id { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the workflow run.
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// GraphQL Node Id.
|
||||
/// </summary>
|
||||
public string NodeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the associated check suite.
|
||||
/// </summary>
|
||||
public long CheckSuiteId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The node ID of the associated check suite.
|
||||
/// </summary>
|
||||
public string CheckSuiteNodeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The head branch.
|
||||
/// </summary>
|
||||
public string HeadBranch { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The SHA of the head commit that points to the version of the workflow being run.
|
||||
/// </summary>
|
||||
public string HeadSha { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full path of the workflow.
|
||||
/// </summary>
|
||||
public string Path { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The auto incrementing run number for the workflow run.
|
||||
/// </summary>
|
||||
public long RunNumber { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The event that triggered the workflow run.
|
||||
/// </summary>
|
||||
public string Event { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The event-specific title associated with the run or the run-name if set.
|
||||
/// </summary>
|
||||
public string DisplayTitle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The status of the the workflow run.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowRunStatus> Status { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The conclusion of the the workflow run.
|
||||
/// </summary>
|
||||
public StringEnum<WorkflowRunConclusion>? Conclusion { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the parent workflow.
|
||||
/// </summary>
|
||||
public long WorkflowId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow run.
|
||||
/// </summary>
|
||||
public string Url { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for the HTML view of this workflow run.
|
||||
/// </summary>
|
||||
public string HtmlUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Any associated pull requests.
|
||||
/// </summary>
|
||||
public IReadOnlyList<PullRequest> PullRequests { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the workflow run was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the workflow run was last updated.
|
||||
/// </summary>
|
||||
public DateTimeOffset UpdatedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The actor associated with the workflow run.
|
||||
/// </summary>
|
||||
public User Actor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Attempt number of the run, 1 for first attempt and higher if the workflow was re-run.
|
||||
/// </summary>
|
||||
public long RunAttempt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Any associated pull requests.
|
||||
/// </summary>
|
||||
public IReadOnlyList<WorkflowReference> ReferencedWorkflows { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time that the workflow run started.
|
||||
/// </summary>
|
||||
public DateTimeOffset RunStartedAt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The actor that triggered the workflow run.
|
||||
/// </summary>
|
||||
public User TriggeringActor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow run's job.
|
||||
/// </summary>
|
||||
public string JobsUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow run's logs.
|
||||
/// </summary>
|
||||
public string LogsUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow run's check suite.
|
||||
/// </summary>
|
||||
public string CheckSuiteUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow run's artifacts.
|
||||
/// </summary>
|
||||
public string ArtifactsUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL to cancel this workflow run.
|
||||
/// </summary>
|
||||
public string CancelUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL to re-run this workflow run.
|
||||
/// </summary>
|
||||
public string RerunUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow run's previous run.
|
||||
/// </summary>
|
||||
public string PreviousAttemptUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this workflow run's workflow.
|
||||
/// </summary>
|
||||
public string WorkflowUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The head commit of the workflow run.
|
||||
/// </summary>
|
||||
public Commit HeadCommit { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The repository associated with the workflow run.
|
||||
/// </summary>
|
||||
public Repository Repository { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The head repository associated with the workflow run.
|
||||
/// </summary>
|
||||
public Repository HeadRepository { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the head repository.
|
||||
/// </summary>
|
||||
public long HeadRepositoryId { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Id: {0} Name: {1}", Id, Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Octokit/Models/Response/WorkflowRunBillable.cs
Normal file
45
Octokit/Models/Response/WorkflowRunBillable.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowRunBillable
|
||||
{
|
||||
public WorkflowRunBillable() { }
|
||||
|
||||
public WorkflowRunBillable(WorkflowRunBillableTiming ubuntu, WorkflowRunBillableTiming macOS, WorkflowRunBillableTiming windows)
|
||||
{
|
||||
Ubuntu = ubuntu;
|
||||
MacOS = macOS;
|
||||
Windows = windows;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Ubuntu billable timing.
|
||||
/// </summary>
|
||||
[Parameter(Key = "UBUNTU")]
|
||||
public WorkflowRunBillableTiming Ubuntu { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The macOS billable timing.
|
||||
/// </summary>
|
||||
[Parameter(Key = "MACOS")]
|
||||
public WorkflowRunBillableTiming MacOS { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Windows billable timing.
|
||||
/// </summary>
|
||||
[Parameter(Key = "WINDOWS")]
|
||||
public WorkflowRunBillableTiming Windows { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Ubuntu: {0}, macOS: {1}, Windows: {2}", Ubuntu, MacOS, Windows);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Octokit/Models/Response/WorkflowRunBillableTiming.cs
Normal file
42
Octokit/Models/Response/WorkflowRunBillableTiming.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class WorkflowRunBillableTiming
|
||||
{
|
||||
public WorkflowRunBillableTiming() { }
|
||||
|
||||
public WorkflowRunBillableTiming(long totalMs, long jobs, IReadOnlyList<WorkflowRunTiming> jobRuns)
|
||||
{
|
||||
TotalMs = totalMs;
|
||||
Jobs = jobs;
|
||||
JobRuns = jobRuns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The total billable milliseconds.
|
||||
/// </summary>
|
||||
public long TotalMs { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total number of jobs.
|
||||
/// </summary>
|
||||
public long Jobs { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The billable job runs.
|
||||
/// </summary>
|
||||
public IReadOnlyList<WorkflowRunTiming> JobRuns { get; private set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "TotalMs: {0}, Jobs: {1}", TotalMs, Jobs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Octokit/Models/Response/WorkflowRunConclusion.cs
Normal file
22
Octokit/Models/Response/WorkflowRunConclusion.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public enum WorkflowRunConclusion
|
||||
{
|
||||
[Parameter(Value = "success")]
|
||||
Success,
|
||||
[Parameter(Value = "failure")]
|
||||
Failure,
|
||||
[Parameter(Value = "neutral")]
|
||||
Neutral,
|
||||
[Parameter(Value = "cancelled")]
|
||||
Cancelled,
|
||||
[Parameter(Value = "timed_out")]
|
||||
TimedOut,
|
||||
[Parameter(Value = "action_required")]
|
||||
ActionRequired,
|
||||
[Parameter(Value = "stale")]
|
||||
Stale,
|
||||
}
|
||||
}
|
||||
24
Octokit/Models/Response/WorkflowRunJobsFilter.cs
Normal file
24
Octokit/Models/Response/WorkflowRunJobsFilter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Filter jobs for a workflow run.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See https://developer.github.com/v3/actions/workflow-jobs/#list-jobs-for-a-workflow-run for details.
|
||||
/// </remarks>
|
||||
public enum WorkflowRunJobsFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns jobs from the most recent execution of the workflow run.
|
||||
/// </summary>
|
||||
[Parameter(Value = "latest")]
|
||||
Latest,
|
||||
/// <summary>
|
||||
/// Returns all jobs for a workflow run, including from old executions of the workflow run.
|
||||
/// </summary>
|
||||
[Parameter(Value = "all")]
|
||||
All,
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user