From a7b6ab32954fcfe840f4bc4dd751471f1cfa17a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2020 08:55:01 -0400 Subject: [PATCH 001/209] Bump Microsoft.NET.Test.Sdk from 16.7.1 to 16.8.0 (#2269) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.7.1 to 16.8.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.7.1...v16.8.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 55e8b61f06..1adcc2d3d5 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index e247afce1a..32c46d0e35 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -36,7 +36,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index c0f5078c74..a39c193f21 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -36,7 +36,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> From c544317384acfbdc38ce3026e3fb39e990386c2f Mon Sep 17 00:00:00 2001 From: Liri Sokol <liri@apiiro.com> Date: Sun, 6 Dec 2020 17:10:03 +0200 Subject: [PATCH 002/209] Added nuget setup --- .../Octokit.Reactive.csproj.DotSettings | 6 ++++++ Octokit.sln.DotSettings | 1 + Octokit/Octokit.csproj | 6 +++--- Octokit/Octokit.csproj.DotSettings | 14 ++++++++++++++ README.md | 8 ++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 Octokit.Reactive/Octokit.Reactive.csproj.DotSettings create mode 100644 Octokit/Octokit.csproj.DotSettings diff --git a/Octokit.Reactive/Octokit.Reactive.csproj.DotSettings b/Octokit.Reactive/Octokit.Reactive.csproj.DotSettings new file mode 100644 index 0000000000..cb862a7d30 --- /dev/null +++ b/Octokit.Reactive/Octokit.Reactive.csproj.DotSettings @@ -0,0 +1,6 @@ +<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=clients/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=images/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helpers/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=clients_005Centerprise/@EntryIndexedValue">True</s:Boolean> +</wpf:ResourceDictionary> \ No newline at end of file diff --git a/Octokit.sln.DotSettings b/Octokit.sln.DotSettings index 50852c97ec..7f9262b459 100644 --- a/Octokit.sln.DotSettings +++ b/Octokit.sln.DotSettings @@ -269,6 +269,7 @@ II.2.12 <HandlesEvent />
 <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index dec9fb55d9..832a703246 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,13 +4,13 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>0.0.0-dev</Version> + <Version>1.0.0</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> - <PackageId>Octokit</PackageId> + <PackageId>Apiiro.Octokit</PackageId> <DebugType>embedded</DebugType> <RepositoryUrl>https://github.com/octokit/octokit.net</RepositoryUrl> - <PackageProjectUrl>https://github.com/octokit/octokit.net</PackageProjectUrl> + <PackageProjectUrl>https://github.com/apiiro/octokit.net</PackageProjectUrl> <PackageIconUrl>https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png</PackageIconUrl> <PackageIcon>octokit.png</PackageIcon> <PackageLicenseExpression>MIT</PackageLicenseExpression> diff --git a/Octokit/Octokit.csproj.DotSettings b/Octokit/Octokit.csproj.DotSettings new file mode 100644 index 0000000000..c672791e64 --- /dev/null +++ b/Octokit/Octokit.csproj.DotSettings @@ -0,0 +1,14 @@ +<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=images/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=helpers/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=authentication/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=exceptions/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=http/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=models/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=clients/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=properties/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=clients_005Centerprise/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=models_005Crequest/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=models_005Ccommon/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=models_005Cresponse/@EntryIndexedValue">True</s:Boolean> +</wpf:ResourceDictionary> \ No newline at end of file diff --git a/README.md b/README.md index ec43715d1c..1109d08239 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,14 @@ ![logo](octokit-dotnet_2.png) +To push to apiiro nuget package: + +```bash +cd Octokit +dotnet pack --configuration Release +dotnet nuget push bin/Release/Apiiro.Octokit.*.nupkg --source "github" --skip-duplicate --no-symbols true +``` + Octokit is a client library targeting .NET Framework 4.5+ and .NET Standard 1+ and above that provides an easy way to interact with the [GitHub API](http://developer.github.com/v3/). From 7b24f26ad9cef60b9ad95fcef183813c296240ad Mon Sep 17 00:00:00 2001 From: Liri Sokol <liri@apiiro.com> Date: Sun, 6 Dec 2020 17:19:24 +0200 Subject: [PATCH 003/209] Fixed repo url --- Octokit/Octokit.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 832a703246..a99dfaa278 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -9,7 +9,7 @@ <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> <DebugType>embedded</DebugType> - <RepositoryUrl>https://github.com/octokit/octokit.net</RepositoryUrl> + <RepositoryUrl>https://github.com/apiiro/octokit.net</RepositoryUrl> <PackageProjectUrl>https://github.com/apiiro/octokit.net</PackageProjectUrl> <PackageIconUrl>https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png</PackageIconUrl> <PackageIcon>octokit.png</PackageIcon> From 9e9077237286e92e09231fcf98a0db1a2ab60f22 Mon Sep 17 00:00:00 2001 From: Liri Sokol <liri@apiiro.com> Date: Sun, 6 Dec 2020 17:29:35 +0200 Subject: [PATCH 004/209] Used ConcurrentDictionary in the not ThreadSafeDictionary --- Octokit/Octokit.csproj | 2 +- Octokit/SimpleJson.cs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a99dfaa278..e72e86f8b6 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.0</Version> + <Version>1.0.1</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> diff --git a/Octokit/SimpleJson.cs b/Octokit/SimpleJson.cs index 74fe0c7d6c..09b111e5d3 100644 --- a/Octokit/SimpleJson.cs +++ b/Octokit/SimpleJson.cs @@ -52,6 +52,7 @@ using System; using System.CodeDom.Compiler; using System.Collections; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; @@ -2122,7 +2123,7 @@ public sealed class ThreadSafeDictionary<TKey, TValue> : IDictionary<TKey, TValu { private readonly object _lock = new object(); private readonly ThreadSafeDictionaryValueFactory<TKey, TValue> _valueFactory; - private Dictionary<TKey, TValue> _dictionary; + private ConcurrentDictionary<TKey, TValue> _dictionary; public ThreadSafeDictionary(ThreadSafeDictionaryValueFactory<TKey, TValue> valueFactory) { @@ -2146,7 +2147,7 @@ private TValue AddValue(TKey key) { if (_dictionary == null) { - _dictionary = new Dictionary<TKey, TValue>(); + _dictionary = new ConcurrentDictionary<TKey, TValue>(); _dictionary[key] = value; } else @@ -2154,7 +2155,7 @@ private TValue AddValue(TKey key) TValue val; if (_dictionary.TryGetValue(key, out val)) return val; - Dictionary<TKey, TValue> dict = new Dictionary<TKey, TValue>(_dictionary); + var dict = new ConcurrentDictionary<TKey, TValue>(_dictionary); dict[key] = value; _dictionary = dict; } From f504167f4afd42141a26c22f72851f29635fb878 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:06:02 -0800 Subject: [PATCH 005/209] build(dependabot): disable by removing configuration I'm taking a break. I'll enable automated dependency updates when I'm back in 2021. But probably not with Dependabot, but Renovate. --- .github/dependabot.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 94a8e17a79..0000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: 2 -updates: -- package-ecosystem: nuget - directory: "/" - schedule: - interval: weekly - open-pull-requests-limit: 10 - ignore: - - dependency-name: Microsoft.NET.Test.Sdk - versions: - - ">= 16.3.a, < 16.4" -- package-ecosystem: nuget - directory: "/build" - schedule: - interval: weekly - open-pull-requests-limit: 10 From 24a1628b84a5496944834a65c3c6d8fd6b196718 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Wed, 16 Dec 2020 12:12:59 -0800 Subject: [PATCH 006/209] Revert "build(dependabot): disable by removing configuration" This reverts commit f504167f4afd42141a26c22f72851f29635fb878. Sorry I missed to filter out this repository when I run my script :( --- .github/dependabot.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..94a8e17a79 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: +- package-ecosystem: nuget + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + ignore: + - dependency-name: Microsoft.NET.Test.Sdk + versions: + - ">= 16.3.a, < 16.4" +- package-ecosystem: nuget + directory: "/build" + schedule: + interval: weekly + open-pull-requests-limit: 10 From 70a380a4d0879eeadc4d2703ce38ab281fd47a91 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson <matkar@wcom.se> Date: Sat, 13 Feb 2021 20:40:41 +0100 Subject: [PATCH 007/209] (build) Updated Cake Frosting to version 1.0.0 (#2289) --- .github/workflows/netcore.yml | 5 ++--- appveyor.yml | 1 - build/Build.csproj | 3 ++- build/Lifetime.cs | 8 +++++++- build/Program.cs | 23 ++++++----------------- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index d5632a9ad8..0871ccba27 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -20,9 +20,8 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup .NET Core - uses: actions/setup-dotnet@v1.4.0 - with: - dotnet-version: 3.1.201 + uses: actions/setup-dotnet@v1 + - name: Build with dotnet run: ./build.sh --linksources=true --verbosity=verbose shell: bash diff --git a/appveyor.yml b/appveyor.yml index f064973ae6..8b4197b5c1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,6 @@ init: build_script: - dotnet --info - - dotnet tool install --global coverlet.console - ps: .\build.ps1 -LinkSources -Verbosity Verbose test: off diff --git a/build/Build.csproj b/build/Build.csproj index 962e1be8c4..87d7344ee4 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -3,11 +3,12 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp3.1</TargetFramework> + <RunWorkingDirectory>$(MSBuildProjectDirectory)/..</RunWorkingDirectory> </PropertyGroup> <ItemGroup> <PackageReference Include="Cake.Coverlet" Version="2.5.1" /> - <PackageReference Include="Cake.Frosting" Version="0.38.5" /> + <PackageReference Include="Cake.Frosting" Version="1.0.0" /> <PackageReference Include="Cake.Codecov" Version="0.9.1" /> <PackageReference Include="Codecov" Version="1.12.3" /> </ItemGroup> diff --git a/build/Lifetime.cs b/build/Lifetime.cs index e8ecaf7c26..4d3ff41317 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -4,6 +4,7 @@ using Cake.Common.Diagnostics; using Cake.Frosting; using Cake.Core.Diagnostics; +using Cake.Core; public class Lifetime : FrostingLifetime<Context> { @@ -51,7 +52,8 @@ public override void Setup(Context context) new Project { Name = "Octokit.Tests.Integration", Path = "./Octokit.Tests.Integration/Octokit.Tests.Integration.csproj", IntegrationTests = true } }; - context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.1.3", "dotnet-gitversion"); + context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.6.5", "dotnet-gitversion"); + ToolInstaller.DotNetCoreToolInstall(context, "coverlet.console", "1.7.2", "coverlet"); // Calculate semantic version. context.Version = BuildVersion.Calculate(context); @@ -82,4 +84,8 @@ private static string GetEnvironmentValueOrArgument(Context context, string envi } return arg; } + + public override void Teardown(Context context, ITeardownContext info) + { + } } diff --git a/build/Program.cs b/build/Program.cs index a5c08a1052..a729cfc239 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -1,24 +1,13 @@ -using Cake.Core; using Cake.Frosting; -public class Program : IFrostingStartup +public class Program { public static int Main(string[] args) { - // Create the host. - var host = new CakeHostBuilder() - .WithArguments(args) - .UseStartup<Program>() - .Build(); - - // Run the host. - return host.Run(); - } - - public void Configure(ICakeServices services) - { - services.UseContext<Context>(); - services.UseLifetime<Lifetime>(); - services.UseWorkingDirectory(".."); + return new CakeHost() + .UseContext<Context>() + .UseLifetime<Lifetime>() + .Run(args); +; } } \ No newline at end of file From dec5e6d88a751bde269fd41276c5de945e88cce9 Mon Sep 17 00:00:00 2001 From: Phil Haack <haacked@gmail.com> Date: Sat, 13 Feb 2021 11:50:04 -0800 Subject: [PATCH 008/209] Update the README to link to NuGet (#2288) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec43715d1c..f5ccdf8662 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,16 @@ Console.WriteLine(user.Followers + " folks love the half ogre!"); ## Getting Started -Octokit is a GitHub API client library for .NET and is available on NuGet: +Octokit is a GitHub API client library for .NET and is [available on NuGet](https://www.nuget.org/packages/Octokit/): ``` -Install-Package Octokit +dotnet add package Octokit ``` There is also an IObservable based GitHub API client library for .NET using Reactive Extensions: ``` -Install-Package Octokit.Reactive +dotnet add package Octokit.Reactive ``` From b5fb60bba8103336159340b689618729bab9063d Mon Sep 17 00:00:00 2001 From: David Nelson <eatdrinksleepcode@gmail.com> Date: Sat, 13 Feb 2021 13:53:39 -0600 Subject: [PATCH 009/209] Update 'up-for-grabs' link in CONSTRIBUTING.md (#2280) The previous link redirected to https://github.com/octokit/octokit.net/issues?q=label%3Aup-for-grabs, which would also show closed issues; the new link only shows open issues. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5c4ede774e..9b948f5020 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ to ensure everything builds and the tests pass. ## How can I get involved? -We have an [`up-for-grabs`](https://github.com/octokit/octokit.net/issues/labels/up-for-grabs) +We have an [`up-for-grabs`](https://github.com/octokit/octokit.net/labels/up-for-grabs) tag on our issue tracker to indicate tasks which contributors can pick up. If you've found something you'd like to contribute to, leave a comment in the issue From 4ca8ea03af1bc8e0066da8f98714999ab0955a39 Mon Sep 17 00:00:00 2001 From: Bipin Paul <iambipinpaul@outlook.com> Date: Sun, 14 Feb 2021 01:42:09 +0545 Subject: [PATCH 010/209] Update README.md (#2279) Update supported .NET Framework and .NET Standard text --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5ccdf8662..432a4d48f1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ![logo](octokit-dotnet_2.png) -Octokit is a client library targeting .NET Framework 4.5+ and .NET Standard 1+ +Octokit is a client library targeting .NET Framework 4.6 or greater and .NET Standard 2.0 and above that provides an easy way to interact with the [GitHub API](http://developer.github.com/v3/). From 20549430e5a8062e9e97a1038b94b7d0dab094bd Mon Sep 17 00:00:00 2001 From: Eric Carlson <Michael.Carlson2@extendhealth.com> Date: Sat, 13 Feb 2021 13:28:32 -0700 Subject: [PATCH 011/209] Add support for multi users and orgs in SearchCodeRequest (#2291) --- .../Clients/SearchClientTests.cs | 23 ++++- Octokit.Tests/Clients/SearchClientTests.cs | 84 ++++++++++++++++++- Octokit/Models/Request/SearchCodeRequest.cs | 25 ++++-- docs/search.md | 13 +-- 4 files changed, 124 insertions(+), 21 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index 9d1e90d184..6b931d1904 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -82,9 +82,10 @@ public async Task SearchForFunctionInCode() [IntegrationTest] public async Task SearchForFilesInOrganization() { + var orgs = new[] { "octokit", "github" }; var request = new SearchCodeRequest() { - Organization = "octokit", + Organizations = orgs, FileName = "readme.md" }; @@ -92,7 +93,25 @@ public async Task SearchForFilesInOrganization() foreach (var searchResult in searchResults.Items) { - Assert.Equal("octokit", searchResult.Repository.Owner.Login); + Assert.Contains(searchResult.Repository.Owner.Login, orgs); + } + } + + [IntegrationTest] + public async Task SearchForFilesInUsers() + { + var users = new[] { "octokit", "github" }; + var request = new SearchCodeRequest() + { + Users = users, + FileName = "readme.md" + }; + + var searchResults = await _gitHubClient.Search.SearchCode(request); + + foreach (var searchResult in searchResults.Items) + { + Assert.Contains(searchResult.Repository.Owner.Login, users); } } diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index e9fc20ac93..1ead16ebf1 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -1850,8 +1850,10 @@ public void TestingTheUserQualifier() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); - var request = new SearchCodeRequest("something"); - request.User = "alfhenrik"; + var request = new SearchCodeRequest("something") + { + Users = new[] { "alfhenrik" } + }; client.SearchCode(request); @@ -1860,6 +1862,23 @@ public void TestingTheUserQualifier() Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+user:alfhenrik")); } + [Fact] + public void TestingTheUserQualifier_Multiple() + { + var connection = Substitute.For<IApiConnection>(); + var client = new SearchClient(connection); + var request = new SearchCodeRequest("something") + { + Users = new[] { "johnDoe", "janeDoe" } + }; + + client.SearchCode(request); + + connection.Received().Get<SearchCodeResult>( + Arg.Is<Uri>(u => u.ToString() == "search/code"), + Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+user:johnDoe+user:janeDoe")); + } + [Fact] public void TestingTheRepoQualifier() { @@ -1879,8 +1898,10 @@ public void TestingTheOrgQualifier() { var connection = Substitute.For<IApiConnection>(); var client = new SearchClient(connection); - var request = new SearchCodeRequest("something"); - request.Organization = "octokit"; + var request = new SearchCodeRequest("something") + { + Organizations = new[] { "octokit" } + }; client.SearchCode(request); @@ -1889,6 +1910,23 @@ public void TestingTheOrgQualifier() Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+org:octokit")); } + [Fact] + public void TestingTheOrgQualifier_Multiple() + { + var connection = Substitute.For<IApiConnection>(); + var client = new SearchClient(connection); + var request = new SearchCodeRequest("something") + { + Organizations = new[] { "octokit", "dotnet" } + }; + + client.SearchCode(request); + + connection.Received().Get<SearchCodeResult>( + Arg.Is<Uri>(u => u.ToString() == "search/code"), + Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+org:octokit+org:dotnet")); + } + [Fact] public void TestingTheRepoAndPathAndExtensionQualifiers() { @@ -1908,6 +1946,44 @@ public void TestingTheRepoAndPathAndExtensionQualifiers() d["q"] == "something+path:tools/FAKE.core+extension:fs+extension:cs+repo:octokit/octokit.net")); } + [Fact] + public void TestingTheRepoAndPathAndUsersQualifiers() + { + var connection = Substitute.For<IApiConnection>(); + var client = new SearchClient(connection); + var request = new SearchCodeRequest("something", "octokit", "octokit.net") + { + Users = new[] { "johnDoe", "janeDoe" } + }; + request.Path = "tools/FAKE.core"; + + client.SearchCode(request); + + connection.Received().Get<SearchCodeResult>( + Arg.Is<Uri>(u => u.ToString() == "search/code"), + Arg.Is<Dictionary<string, string>>(d => + d["q"] == "something+path:tools/FAKE.core+user:johnDoe+user:janeDoe+repo:octokit/octokit.net")); + } + + [Fact] + public void TestingTheRepoAndPathAndOrganizationsQualifiers() + { + var connection = Substitute.For<IApiConnection>(); + var client = new SearchClient(connection); + var request = new SearchCodeRequest("something", "octokit", "octokit.net") + { + Organizations = new[] { "johnDoe", "janeDoe" } + }; + request.Path = "tools/FAKE.core"; + + client.SearchCode(request); + + connection.Received().Get<SearchCodeResult>( + Arg.Is<Uri>(u => u.ToString() == "search/code"), + Arg.Is<Dictionary<string, string>>(d => + d["q"] == "something+path:tools/FAKE.core+repo:octokit/octokit.net+org:johnDoe+org:janeDoe")); + } + [Fact] public async Task ErrorOccursWhenSpecifyingInvalidFormatForRepos() { diff --git a/Octokit/Models/Request/SearchCodeRequest.cs b/Octokit/Models/Request/SearchCodeRequest.cs index 9c4795fa67..bc9574c8f6 100644 --- a/Octokit/Models/Request/SearchCodeRequest.cs +++ b/Octokit/Models/Request/SearchCodeRequest.cs @@ -116,7 +116,7 @@ public IEnumerable<CodeInQualifier> In public string Path { get; set; } /// <summary> - /// Matches files with a certain extensions. + /// Matches files with certain extensions. /// </summary> /// <remarks> /// https://help.github.com/articles/searching-code#extension @@ -132,20 +132,20 @@ public IEnumerable<CodeInQualifier> In public string FileName { get; set; } /// <summary> - /// Limits searches to a specific user. + /// Limits searches to specific users. /// </summary> /// <remarks> /// https://help.github.com/articles/searching-code#users-organizations-and-repositories /// </remarks> - public string User { get; set; } + public IEnumerable<string> Users { get; set; } = new List<string>(); /// <summary> - /// Limits searches to a specific organization. + /// Limits searches to specific organizations. /// </summary> /// <remarks> /// https://help.github.com/articles/searching-code/#search-within-a-users-or-organizations-repositories /// </remarks> - public string Organization { get; set; } + public IEnumerable<string> Organizations { get; set; } = new List<string>(); /// <summary> /// Limits searches to a specific repository. @@ -202,9 +202,13 @@ public override IReadOnlyList<string> MergedQualifiers() parameters.Add(string.Format(CultureInfo.InvariantCulture, "filename:{0}", FileName)); } - if (User.IsNotBlank()) + + if (Users.Any()) { - parameters.Add(string.Format(CultureInfo.InvariantCulture, "user:{0}", User)); + foreach (var user in Users) + { + parameters.Add(string.Format(CultureInfo.InvariantCulture, "user:{0}", user)); + } } if (Repos.Any()) @@ -219,9 +223,12 @@ public override IReadOnlyList<string> MergedQualifiers() string.Join("+", Repos.Select(x => "repo:" + x))); } - if (Organization.IsNotBlank()) + if (Organizations.Any()) { - parameters.Add(string.Format(CultureInfo.InvariantCulture, "org:{0}", Organization)); + foreach (var org in Organizations) + { + parameters.Add(string.Format(CultureInfo.InvariantCulture, "org:{0}", org)); + } } return new ReadOnlyCollection<string>(parameters); diff --git a/docs/search.md b/docs/search.md index bead98bcb8..1c3e1c7f90 100644 --- a/docs/search.md +++ b/docs/search.md @@ -198,10 +198,10 @@ var request = new SearchCodeRequest("auth") { // we can restrict search to the file, path or search both In = new[] { CodeInQualifier.File, CodeInQualifier.Path }, - + // how about we find a file based on a certain language Language = Language.JavaScript, - + // do we want to search forks too? Forks = true, @@ -210,15 +210,16 @@ var request = new SearchCodeRequest("auth") // we may want to restrict the search to the path of a file Path = "app/assets", - + // we may want to restrict the file based on file extension Extensions = new[] { "json", "sql" }, - + // restrict search to a specific file name FileName = "app.json", - + // search within a users or orgs repo - User = "dhh" + Users = new[] { "johnDoe", "janeDoe" } + Organizations = new[] { "johnDoe", "janeDoe" } }; ``` From 46787d2cb87498d9a970de966c5ff3d2c2094e05 Mon Sep 17 00:00:00 2001 From: Sam Cackett <samcackett@gmail.com> Date: Sat, 13 Feb 2021 20:29:09 +0000 Subject: [PATCH 012/209] Add DeleteBranchOnMerge option for repositories (#2268) --- .../Clients/RepositoriesClientTests.cs | 81 +++++++++++++++++++ Octokit/Models/Request/NewRepository.cs | 2 + Octokit/Models/Request/RepositoryUpdate.cs | 2 + Octokit/Models/Response/Repository.cs | 5 +- 4 files changed, 89 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index a32576499b..7b048cce60 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -219,6 +219,21 @@ public async Task CreatesARepositoryWithALicenseTemplate() } } + [IntegrationTest] + public async Task CreatesARepositoryWithDeleteBranchOnMergeEnabled() + { + var github = Helper.GetAuthenticatedClient(); + var repoName = Helper.MakeNameWithTimestamp("repo-with-delete-branch-on-merge"); + + using (var context = await github.CreateRepositoryContext(new NewRepository(repoName) { DeleteBranchOnMerge = true })) + { + var createdRepository = context.Repository; + + Assert.True(createdRepository.DeleteBranchOnMerge); + var repository = await github.Repository.Get(Helper.UserName, repoName); + Assert.True(repository.DeleteBranchOnMerge); + } + } [IntegrationTest] public async Task ThrowsInvalidGitIgnoreExceptionForInvalidTemplateNames() @@ -612,6 +627,46 @@ public async Task UpdatesMergeMethodWithRepositoryId() Assert.False(repository.AllowRebaseMerge); } } + + [IntegrationTest] + public async Task UpdatesDeleteBranchOnMergeMethod() + { + var github = Helper.GetAuthenticatedClient(); + + using (var context = await github.CreateRepositoryContext("public-repo")) + { + var updateRepository = new RepositoryUpdate(context.RepositoryName) + { + DeleteBranchOnMerge = true + }; + + var editedRepository = await github.Repository.Edit(context.RepositoryOwner, context.RepositoryName, updateRepository); + Assert.True(editedRepository.DeleteBranchOnMerge); + + var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); + Assert.True(repository.DeleteBranchOnMerge); + } + } + + [IntegrationTest] + public async Task UpdatesDeleteBranchOnMergeMethodWithRepositoryId() + { + var github = Helper.GetAuthenticatedClient(); + + using (var context = await github.CreateRepositoryContext("public-repo")) + { + var updateRepository = new RepositoryUpdate(context.RepositoryName) + { + DeleteBranchOnMerge = true + }; + + var editedRepository = await github.Repository.Edit(context.RepositoryId, updateRepository); + Assert.True(editedRepository.DeleteBranchOnMerge); + + var repository = await github.Repository.Get(context.RepositoryId); + Assert.True(repository.DeleteBranchOnMerge); + } + } public void Dispose() { @@ -790,6 +845,32 @@ public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() Assert.Equal("mit", repository.License.Key); Assert.Equal("MIT License", repository.License.Name); } + + [IntegrationTest] + public async Task ReturnsRepositoryDeleteBranchOnMergeOptions() + { + var github = Helper.GetAuthenticatedClient(); + + using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + { + var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); + + Assert.NotNull(repository.DeleteBranchOnMerge); + } + } + + [IntegrationTest] + public async Task ReturnsRepositoryDeleteBranchOnMergeOptionsWithRepositoryId() + { + var github = Helper.GetAuthenticatedClient(); + + using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + { + var repository = await github.Repository.Get(context.RepositoryId); + + Assert.NotNull(repository.DeleteBranchOnMerge); + } + } } public class TheGetAllPublicMethod diff --git a/Octokit/Models/Request/NewRepository.cs b/Octokit/Models/Request/NewRepository.cs index a081fd4eae..5c7da588e2 100644 --- a/Octokit/Models/Request/NewRepository.cs +++ b/Octokit/Models/Request/NewRepository.cs @@ -81,6 +81,8 @@ public NewRepository(string name) /// Optional. Gets or sets the Id of the team to grant access to this repository. This is only valid when creating a repository for an organization. /// </summary> public int? TeamId { get; set; } + + public bool? DeleteBranchOnMerge { get; set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Request/RepositoryUpdate.cs b/Octokit/Models/Request/RepositoryUpdate.cs index 1ee0dd748b..86abfe52e7 100644 --- a/Octokit/Models/Request/RepositoryUpdate.cs +++ b/Octokit/Models/Request/RepositoryUpdate.cs @@ -77,6 +77,8 @@ public RepositoryUpdate(string name) /// Optional. Allows the "Create a merge commit" merge method to be used. /// </summary> public bool? AllowMergeCommit { get; set; } + + public bool? DeleteBranchOnMerge { get; set; } /// <summary> /// Optional. True to archive this repository. Note: you cannot unarchive repositories through the API. diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 7b6836c964..f288a6d845 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -14,7 +14,7 @@ public Repository(long id) Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge) { Url = url; HtmlUrl = htmlUrl; @@ -56,6 +56,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st AllowMergeCommit = allowMergeCommit; Archived = archived; WatchersCount = watchersCount; + DeleteBranchOnMerge = deleteBranchOnMerge; } public string Url { get; protected set; } @@ -142,6 +143,8 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public bool Archived { get; protected set; } + public bool? DeleteBranchOnMerge { get; protected set; } + internal string DebuggerDisplay { get From 36829cba3a8722fee2d1d6b8c4d7fe0cad8758ad Mon Sep 17 00:00:00 2001 From: Miguel Ventura <miguel.ventura@gmail.com> Date: Sat, 13 Feb 2021 20:33:35 +0000 Subject: [PATCH 013/209] Fix property types in PullRequestCommit (#2224) PullRequestCommit Author and Committer fields were mistakenly typed with Committer when they should be of type User. Previously the types of properties were: * `PullRequestCommit.Author/Committer`: `Committer` * `Commit.Author/Committer`: `Committer` Correct types should be: * `PullRequestCommit.Author/Committer`: `User` * `Commit.Author/Committer`: `Committer` These fields always fail to deserialize in the API calls but produce no errors, only objects with default values. --- .../Models/PullRequestCommitTests.cs | 102 ++++++++++++++++++ Octokit/Models/Response/PullRequestCommit.cs | 6 +- 2 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 Octokit.Tests/Models/PullRequestCommitTests.cs diff --git a/Octokit.Tests/Models/PullRequestCommitTests.cs b/Octokit.Tests/Models/PullRequestCommitTests.cs new file mode 100644 index 0000000000..0fa4a9ec9a --- /dev/null +++ b/Octokit.Tests/Models/PullRequestCommitTests.cs @@ -0,0 +1,102 @@ +using System.Collections.Generic; +using System.Linq; +using Octokit; +using Octokit.Internal; +using Xunit; + +public class PullRequestCommitTests { + // the following JSON is taken from the documentation available at https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request + + const string jsonPayload = @" + [ + { + ""url"": ""https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e"", + ""sha"": ""6dcb09b5b57875f334f61aebed695e2e4193db5e"", + ""node_id"": ""MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ=="", + ""html_url"": ""https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e"", + ""comments_url"": ""https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments"", + ""commit"": { + ""url"": ""https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e"", + ""author"": { + ""name"": ""Monalisa Octocat"", + ""email"": ""support@github.com"", + ""date"": ""2011-04-14T16:00:49Z"" + }, + ""committer"": { + ""name"": ""Monalisa Octocat"", + ""email"": ""support@github.com"", + ""date"": ""2011-04-14T16:00:49Z"" + }, + ""message"": ""Fix all the bugs"", + ""tree"": { + ""url"": ""https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e"", + ""sha"": ""6dcb09b5b57875f334f61aebed695e2e4193db5e"" + }, + ""comment_count"": 0, + ""verification"": { + ""verified"": false, + ""reason"": ""unsigned"", + ""signature"": null, + ""payload"": null + } + }, + ""author"": { + ""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 + }, + ""committer"": { + ""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 + }, + ""parents"": [ + { + ""url"": ""https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e"", + ""sha"": ""6dcb09b5b57875f334f61aebed695e2e4193db5e"" + } + ] + } +] +"; + + [Fact] + public void AuthorAndCommitterDeserializedCorrectly() { + var serializer = new SimpleJsonSerializer(); + var commits = serializer.Deserialize<List<PullRequestCommit>>(jsonPayload); + + Assert.Equal("octocat", commits.Single().Author.Login); + Assert.Equal("support@github.com", commits.Single().Commit.Author.Email); + } + +} diff --git a/Octokit/Models/Response/PullRequestCommit.cs b/Octokit/Models/Response/PullRequestCommit.cs index d25c561cb4..e032c309e3 100644 --- a/Octokit/Models/Response/PullRequestCommit.cs +++ b/Octokit/Models/Response/PullRequestCommit.cs @@ -11,7 +11,7 @@ public class PullRequestCommit { public PullRequestCommit() { } - public PullRequestCommit(string nodeId, Committer author, string commentsUrl, Commit commit, Committer committer, string htmlUrl, IEnumerable<GitReference> parents, string sha, string url) + public PullRequestCommit(string nodeId, User author, string commentsUrl, Commit commit, User committer, string htmlUrl, IEnumerable<GitReference> parents, string sha, string url) { Ensure.ArgumentNotNull(parents, nameof(parents)); @@ -31,13 +31,13 @@ public PullRequestCommit(string nodeId, Committer author, string commentsUrl, Co /// </summary> public string NodeId { get; protected set; } - public Committer Author { get; protected set; } + public User Author { get; protected set; } public string CommentsUrl { get; protected set; } public Commit Commit { get; protected set; } - public Committer Committer { get; protected set; } + public User Committer { get; protected set; } public string HtmlUrl { get; protected set; } From 67555533e3599c0749ef3cfbedf19db006baf95a Mon Sep 17 00:00:00 2001 From: Fredi Kats <inredikawb@gmail.com> Date: Sat, 13 Feb 2021 22:34:02 +0200 Subject: [PATCH 014/209] feat: add missed props for organization (#2239) --- Octokit/Models/Response/Organization.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Organization.cs b/Octokit/Models/Response/Organization.cs index 9a0ad5dc25..06de89cf86 100644 --- a/Octokit/Models/Response/Organization.cs +++ b/Octokit/Models/Response/Organization.cs @@ -10,10 +10,21 @@ public class Organization : Account { public Organization() { } - public Organization(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string nodeId, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, string url, string billingAddress) + public Organization(string avatarUrl, string bio, string blog, int collaborators, string company, DateTimeOffset createdAt, int diskUsage, string email, int followers, int following, bool? hireable, string htmlUrl, int totalPrivateRepos, int id, string nodeId, string location, string login, string name, int ownedPrivateRepos, Plan plan, int privateGists, int publicGists, int publicRepos, string url, string billingAddress, string reposUrl, string eventsUrl, string hooksUrl, string issuesUrl, string membersUrl, string publicMembersUrl, string description, bool isVerified, bool hasOrganizationProjects, bool hasRepositoryProjects, DateTimeOffset updatedAt) : base(avatarUrl, bio, blog, collaborators, company, createdAt, diskUsage, email, followers, following, hireable, htmlUrl, totalPrivateRepos, id, location, login, name, nodeId, ownedPrivateRepos, plan, privateGists, publicGists, publicRepos, AccountType.Organization, url) { BillingAddress = billingAddress; + ReposUrl = reposUrl; + EventsUrl = eventsUrl; + HooksUrl = hooksUrl; + IssuesUrl = issuesUrl; + MembersUrl = membersUrl; + PublicMembersUrl = publicMembersUrl; + Description = description; + IsVerified = isVerified; + HasOrganizationProjects = hasOrganizationProjects; + HasRepositoryProjects = hasRepositoryProjects; + UpdatedAt = updatedAt; } /// <summary> @@ -21,6 +32,18 @@ public Organization(string avatarUrl, string bio, string blog, int collaborators /// an organization. /// </summary> public string BillingAddress { get; protected set; } + public string ReposUrl { get; protected set; } + public string EventsUrl { get; protected set; } + public string HooksUrl { get; protected set; } + public string IssuesUrl { get; protected set; } + public string MembersUrl { get; protected set; } + public string PublicMembersUrl { get; protected set; } + public string Description { get; protected set; } + public bool IsVerified { get; protected set; } + public bool HasOrganizationProjects { get; protected set; } + public bool HasRepositoryProjects { get; protected set; } + public DateTimeOffset UpdatedAt { get; protected set; } + internal string DebuggerDisplay { From 7400420c92fa8034f1a2921a329fca601cdb5565 Mon Sep 17 00:00:00 2001 From: Samantha Houts <samhouts@users.noreply.github.com> Date: Sat, 13 Feb 2021 12:34:36 -0800 Subject: [PATCH 015/209] Add "project" to the IssueNoMetadataQualifier (#2227) Allows you to search for issues with no project. --- Octokit/Models/Request/SearchIssuesRequest.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index 5b5508a34a..acb33c6f47 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -33,7 +33,7 @@ public SearchIssuesRequest(string term) : base(term) } /// <summary> - /// Optional Sort field. One of comments, created, updated or merged + /// Optional Sort field. One of comments, created, updated or merged /// If not provided, results are sorted by best match. /// </summary> /// <remarks> @@ -56,7 +56,7 @@ public override string Sort public IssueTypeQualifier? Type { get; set; } /// <summary> - /// Qualifies which fields are searched. With this qualifier you can restrict + /// Qualifies which fields are searched. With this qualifier you can restrict /// the search to just the title, body, comments, or any combination of these. /// </summary> /// <remarks> @@ -108,7 +108,7 @@ public IEnumerable<IssueInQualifier> In public string Commenter { get; set; } /// <summary> - /// Finds issues that were either created by a certain user, assigned to that user, + /// Finds issues that were either created by a certain user, assigned to that user, /// mention that user, or were commented on by that user. /// </summary> /// <remarks> @@ -499,7 +499,9 @@ public enum IssueNoMetadataQualifier [Parameter(Value = "milestone")] Milestone, [Parameter(Value = "assignee")] - Assignee + Assignee, + [Parameter(Value = "project")] + Project } [DebuggerDisplay("{DebuggerDisplay,nq}")] From 8124bd4e8030136cc3cc4ce6dd0bfb48f34fce55 Mon Sep 17 00:00:00 2001 From: Brendan Forster <github@brendanforster.com> Date: Sat, 13 Feb 2021 16:53:15 -0400 Subject: [PATCH 016/209] tidy up workflow to address new restrictions (#2299) --- .github/workflows/publish.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c23f50bc72..3633058eab 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,9 +13,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup .NET Core - uses: actions/setup-dotnet@v1.4.0 - with: - dotnet-version: 3.1.201 + uses: actions/setup-dotnet@v1 - name: Build with dotnet run: ./build.sh --linksources=true --verbosity=verbose From 9cbe8acd1f2c44a1741e3a93bf20c1c2c75e7222 Mon Sep 17 00:00:00 2001 From: Brendan Forster <github@brendanforster.com> Date: Sat, 13 Feb 2021 16:54:55 -0400 Subject: [PATCH 017/209] tidy up unused dependabot ignore rule (#2300) --- .github/dependabot.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 94a8e17a79..ccd0ec66a0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,10 +5,6 @@ updates: schedule: interval: weekly open-pull-requests-limit: 10 - ignore: - - dependency-name: Microsoft.NET.Test.Sdk - versions: - - ">= 16.3.a, < 16.4" - package-ecosystem: nuget directory: "/build" schedule: From 66f0676dc3b6d1775951976ecf5348fdfcd0f82c Mon Sep 17 00:00:00 2001 From: Brendan Forster <github@brendanforster.com> Date: Sat, 13 Feb 2021 17:36:16 -0400 Subject: [PATCH 018/209] enable windows target for building on Actions (#2302) * enable windows target for building * workaround IGNORE_NORMALISATION_GIT_HEAD_MOVE reported by GitVersion --- .github/workflows/netcore.yml | 2 +- appveyor.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index 0871ccba27..4bd498fc8e 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - platform: [ubuntu-latest, macos-latest] + platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} diff --git a/appveyor.yml b/appveyor.yml index 8b4197b5c1..43a442608a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,8 @@ image: Visual Studio 2019 +environment: + IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1 + branches: only: - main From a28002a8df8f33a22764b9b3f837f78194667101 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Feb 2021 17:54:35 -0400 Subject: [PATCH 019/209] Bump Cake.Codecov from 0.9.1 to 1.0.0 in /build (#2301) Bumps [Cake.Codecov](https://github.com/cake-contrib/Cake.Codecov) from 0.9.1 to 1.0.0. - [Release notes](https://github.com/cake-contrib/Cake.Codecov/releases) - [Changelog](https://github.com/cake-contrib/Cake.Codecov/blob/develop/GitReleaseManager.yaml) - [Commits](https://github.com/cake-contrib/Cake.Codecov/compare/0.9.1...1.0.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/Build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.csproj b/build/Build.csproj index 87d7344ee4..02ea863db2 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -9,7 +9,7 @@ <ItemGroup> <PackageReference Include="Cake.Coverlet" Version="2.5.1" /> <PackageReference Include="Cake.Frosting" Version="1.0.0" /> - <PackageReference Include="Cake.Codecov" Version="0.9.1" /> + <PackageReference Include="Cake.Codecov" Version="1.0.0" /> <PackageReference Include="Codecov" Version="1.12.3" /> </ItemGroup> From 9e2618f6d1af590d1911bf6abeaa9425c5954c69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Feb 2021 17:55:15 -0400 Subject: [PATCH 020/209] Bump Microsoft.NET.Test.Sdk from 16.8.0 to 16.8.3 (#2276) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.8.0 to 16.8.3. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.8.0...v16.8.3) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 1adcc2d3d5..3fed22f278 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 32c46d0e35..2ca99adb24 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -36,7 +36,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index a39c193f21..779227af70 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -36,7 +36,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> From 4fbbe4ca2c5952cc1f9515f76380f7496ee9d3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kato=20St=C3=B8len?= <kato.stoelen@gmail.com> Date: Sun, 21 Feb 2021 22:08:30 +0100 Subject: [PATCH 021/209] Add cancellation token support for release assets uploading (#2267) --- .../Clients/IObservableReleasesClient.cs | 4 +- .../Clients/ObservableReleasesClient.cs | 6 ++- Octokit.Tests/Clients/ReleasesClientTests.cs | 38 +++++++++++++++ Octokit/Clients/IReleasesClient.cs | 4 +- Octokit/Clients/ReleasesClient.cs | 10 ++-- Octokit/Http/ApiConnection.cs | 34 ++++++++------ Octokit/Http/Connection.cs | 46 ++++++++++++------- Octokit/Http/IApiConnection.cs | 21 ++++++--- Octokit/Http/IConnection.cs | 27 ++++++++--- 9 files changed, 139 insertions(+), 51 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableReleasesClient.cs b/Octokit.Reactive/Clients/IObservableReleasesClient.cs index b4a2b2a200..7320f5addd 100644 --- a/Octokit.Reactive/Clients/IObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/IObservableReleasesClient.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Reactive; +using System.Threading; namespace Octokit.Reactive { @@ -250,8 +251,9 @@ public interface IObservableReleasesClient /// </remarks> /// <param name="release">The <see cref="Release"/> to attach the uploaded asset to</param> /// <param name="data">Description of the asset with its data</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - IObservable<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data); + IObservable<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data, CancellationToken cancellationToken = default); /// <summary> /// Gets the specified <see cref="ReleaseAsset"/> for the specified release of the specified repository. diff --git a/Octokit.Reactive/Clients/ObservableReleasesClient.cs b/Octokit.Reactive/Clients/ObservableReleasesClient.cs index b9568e56dc..644269643b 100644 --- a/Octokit.Reactive/Clients/ObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReleasesClient.cs @@ -1,6 +1,7 @@ using System; using System.Reactive; using System.Reactive.Threading.Tasks; +using System.Threading; using Octokit.Reactive.Internal; namespace Octokit.Reactive @@ -400,13 +401,14 @@ public IObservable<ReleaseAsset> GetAsset(long repositoryId, int assetId) /// </remarks> /// <param name="release">The <see cref="Release"/> to attach the uploaded asset to</param> /// <param name="data">Description of the asset with its data</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - public IObservable<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data) + public IObservable<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(release, nameof(release)); Ensure.ArgumentNotNull(data, nameof(data)); - return _client.UploadAsset(release, data).ToObservable(); + return _client.UploadAsset(release, data, cancellationToken).ToObservable(); } /// <summary> diff --git a/Octokit.Tests/Clients/ReleasesClientTests.cs b/Octokit.Tests/Clients/ReleasesClientTests.cs index db25679e88..742c8e8912 100644 --- a/Octokit.Tests/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests/Clients/ReleasesClientTests.cs @@ -1,7 +1,9 @@ using System; using System.IO; +using System.Threading; using System.Threading.Tasks; using NSubstitute; +using Octokit.Internal; using Xunit; namespace Octokit.Tests.Clients @@ -484,6 +486,42 @@ public async Task OverrideDefaultTimeout() apiConnection.Received().Post<ReleaseAsset>(Arg.Any<Uri>(), uploadData.RawData, Arg.Any<string>(), uploadData.ContentType, newTimeout); } + + [Fact] + public async Task CanBeCancelled() + { + var httpClient = new CancellationTestHttpClient(); + var connection = new Connection(new ProductHeaderValue("TEST"), httpClient); + var apiConnection = new ApiConnection(connection); + + var fixture = new ReleasesClient(apiConnection); + + var release = new Release("https://uploads.github.com/anything"); + var uploadData = new ReleaseAssetUpload("good", "good/good", Stream.Null, null); + + using (var cts = new CancellationTokenSource()) + { + var uploadTask = fixture.UploadAsset(release, uploadData, cts.Token); + + cts.Cancel(); + + await Assert.ThrowsAsync<TaskCanceledException>(() => uploadTask); + } + } + + private class CancellationTestHttpClient : IHttpClient + { + public async Task<IResponse> Send(IRequest request, CancellationToken cancellationToken) + { + await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken); + + throw new Exception("HTTP operation was not cancelled"); + } + + public void Dispose() { } + + public void SetRequestTimeout(TimeSpan timeout) { } + } } public class TheGetAssetMethod diff --git a/Octokit/Clients/IReleasesClient.cs b/Octokit/Clients/IReleasesClient.cs index 56a700a23c..d8ef30bb33 100644 --- a/Octokit/Clients/IReleasesClient.cs +++ b/Octokit/Clients/IReleasesClient.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Threading; using System.Threading.Tasks; namespace Octokit @@ -250,8 +251,9 @@ public interface IReleasesClient /// </remarks> /// <param name="release">The <see cref="Release"/> to attach the uploaded asset to</param> /// <param name="data">Description of the asset with its data</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - Task<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data); + Task<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data, CancellationToken cancellationToken = default); /// <summary> /// Gets the specified <see cref="ReleaseAsset"/> for the specified release of the specified repository. diff --git a/Octokit/Clients/ReleasesClient.cs b/Octokit/Clients/ReleasesClient.cs index d1e6e0d3c0..dd1b360eb6 100644 --- a/Octokit/Clients/ReleasesClient.cs +++ b/Octokit/Clients/ReleasesClient.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using System.Collections.Generic; +using System.Threading; namespace Octokit { @@ -398,9 +399,10 @@ public Task<IReadOnlyList<ReleaseAsset>> GetAllAssets(long repositoryId, int id, /// </remarks> /// <param name="release">The <see cref="Release"/> to attach the uploaded asset to</param> /// <param name="data">Description of the asset with its data</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> [ManualRoute("POST", "{server}/repos/{owner}/{repo}/releases/{release_id}/assets")] - public Task<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data) + public Task<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(release, nameof(release)); Ensure.ArgumentNotNull(data, nameof(data)); @@ -414,14 +416,16 @@ public Task<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data) data.RawData, AcceptHeaders.StableVersion, data.ContentType, - data.Timeout.GetValueOrDefault()); + data.Timeout.GetValueOrDefault(), + cancellationToken); } return ApiConnection.Post<ReleaseAsset>( endpoint, data.RawData, AcceptHeaders.StableVersion, - data.ContentType); + data.ContentType, + cancellationToken); } /// <summary> diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 5a477db6e0..1a5694271c 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -216,13 +216,14 @@ public Task<IReadOnlyList<T>> GetAll<T>(Uri uri, IDictionary<string, string> par /// Creates a new API resource in the list at the specified URI. /// </summary> /// <param name="uri">URI endpoint to send request to</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="HttpStatusCode"/>Representing the received HTTP response</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - public Task Post(Uri uri) + public Task Post(Uri uri, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); - return Connection.Post(uri); + return Connection.Post(uri, cancellationToken); } /// <summary> @@ -230,13 +231,14 @@ public Task Post(Uri uri) /// </summary> /// <typeparam name="T">The API resource's type.</typeparam> /// <param name="uri">URI of the API resource to get</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - public async Task<T> Post<T>(Uri uri) + public async Task<T> Post<T>(Uri uri, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); - var response = await Connection.Post<T>(uri).ConfigureAwait(false); + var response = await Connection.Post<T>(uri, cancellationToken).ConfigureAwait(false); return response.Body; } @@ -246,14 +248,15 @@ public async Task<T> Post<T>(Uri uri) /// <typeparam name="T">The API resource's type.</typeparam> /// <param name="uri">URI of the API resource to get</param> /// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - public Task<T> Post<T>(Uri uri, object data) + public Task<T> Post<T>(Uri uri, object data, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(data, nameof(data)); - return Post<T>(uri, data, null, null); + return Post<T>(uri, data, null, null, cancellationToken); } /// <summary> @@ -263,11 +266,12 @@ public Task<T> Post<T>(Uri uri, object data) /// <param name="uri">URI of the API resource to get</param> /// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param> /// <param name="accepts">Accept header to use for the API request</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - public Task<T> Post<T>(Uri uri, object data, string accepts) + public Task<T> Post<T>(Uri uri, object data, string accepts, CancellationToken cancellationToken = default) { - return Post<T>(uri, data, accepts, null); + return Post<T>(uri, data, accepts, null, cancellationToken); } /// <summary> @@ -278,14 +282,15 @@ public Task<T> Post<T>(Uri uri, object data, string accepts) /// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param> /// <param name="accepts">Accept header to use for the API request</param> /// <param name="contentType">Content type of the API request</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - public async Task<T> Post<T>(Uri uri, object data, string accepts, string contentType) + public async Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(data, nameof(data)); - var response = await Connection.Post<T>(uri, data, accepts, contentType).ConfigureAwait(false); + var response = await Connection.Post<T>(uri, data, accepts, contentType, cancellationToken: cancellationToken).ConfigureAwait(false); return response.Body; } @@ -298,25 +303,26 @@ public async Task<T> Post<T>(Uri uri, object data, string accepts, string conten /// <param name="accepts">Accept header to use for the API request</param> /// <param name="contentType">Content type of the API request</param> /// <param name="twoFactorAuthenticationCode">Two Factor Authentication Code</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - public async Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, string twoFactorAuthenticationCode) + public async Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, string twoFactorAuthenticationCode, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(data, nameof(data)); Ensure.ArgumentNotNull(twoFactorAuthenticationCode, nameof(twoFactorAuthenticationCode)); - var response = await Connection.Post<T>(uri, data, accepts, contentType, twoFactorAuthenticationCode).ConfigureAwait(false); + var response = await Connection.Post<T>(uri, data, accepts, contentType, twoFactorAuthenticationCode, cancellationToken).ConfigureAwait(false); return response.Body; } - public async Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, TimeSpan timeout) + public async Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(data, nameof(data)); - var response = await Connection.Post<T>(uri, data, accepts, contentType, timeout).ConfigureAwait(false); + var response = await Connection.Post<T>(uri, data, accepts, contentType, timeout, cancellationToken).ConfigureAwait(false); return response.Body; } diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 6c2c7560cd..81759fdc2a 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -251,44 +251,51 @@ public Task<IApiResponse<T>> Patch<T>(Uri uri, object body, string accepts) /// Performs an asynchronous HTTP POST request. /// </summary> /// <param name="uri">URI endpoint to send request to</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> - public async Task<HttpStatusCode> Post(Uri uri) + public async Task<HttpStatusCode> Post(Uri uri, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); - var response = await SendData<object>(uri, HttpMethod.Post, null, null, null, CancellationToken.None).ConfigureAwait(false); + var response = await SendData<object>(uri, HttpMethod.Post, null, null, null, cancellationToken).ConfigureAwait(false); return response.HttpResponse.StatusCode; } - public async Task<HttpStatusCode> Post(Uri uri, object body, string accepts) + public async Task<HttpStatusCode> Post(Uri uri, object body, string accepts, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); - var response = await SendData<object>(uri, HttpMethod.Post, body, accepts, null, CancellationToken.None).ConfigureAwait(false); + var response = await SendData<object>(uri, HttpMethod.Post, body, accepts, null, cancellationToken).ConfigureAwait(false); return response.HttpResponse.StatusCode; } - public Task<IApiResponse<T>> Post<T>(Uri uri) + public Task<IApiResponse<T>> Post<T>(Uri uri, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); - return SendData<T>(uri, HttpMethod.Post, null, null, null, CancellationToken.None); + return SendData<T>(uri, HttpMethod.Post, null, null, null, cancellationToken); } - public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType) + public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(body, nameof(body)); - return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None); + return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, cancellationToken); } - public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, IDictionary<string, string> parameters) + public Task<IApiResponse<T>> Post<T>( + Uri uri, + object body, + string accepts, + string contentType, + IDictionary<string, string> parameters, + CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(body, nameof(body)); - return SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Post, body, accepts, contentType, CancellationToken.None); + return SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Post, body, accepts, contentType, cancellationToken); } /// <summary> @@ -301,30 +308,37 @@ public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, strin /// <param name="accepts">Specifies accepted response media types.</param> /// <param name="contentType">Specifies the media type of the request body</param> /// <param name="twoFactorAuthenticationCode">Two Factor Authentication Code</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> - public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode) + public Task<IApiResponse<T>> Post<T>( + Uri uri, + object body, + string accepts, + string contentType, + string twoFactorAuthenticationCode, + CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(body, nameof(body)); Ensure.ArgumentNotNullOrEmptyString(twoFactorAuthenticationCode, nameof(twoFactorAuthenticationCode)); - return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, twoFactorAuthenticationCode); + return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, cancellationToken, twoFactorAuthenticationCode); } - public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout) + public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(body, nameof(body)); - return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, timeout, CancellationToken.None); + return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, timeout, cancellationToken); } - public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress) + public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress, CancellationToken cancellationToken = default) { Ensure.ArgumentNotNull(uri, nameof(uri)); Ensure.ArgumentNotNull(body, nameof(body)); - return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, baseAddress: baseAddress); + return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, cancellationToken, baseAddress: baseAddress); } public Task<IApiResponse<T>> Put<T>(Uri uri, object body) diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 976d6c9b61..730cd2f5d8 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -148,18 +148,20 @@ public interface IApiConnection /// Creates a new API resource in the list at the specified URI. /// </summary> /// <param name="uri">URI endpoint to send request to</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="HttpStatusCode"/>Representing the received HTTP response</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - Task Post(Uri uri); + Task Post(Uri uri, CancellationToken cancellationToken = default); /// <summary> /// Creates a new API resource in the list at the specified URI. /// </summary> /// <typeparam name="T">The API resource's type.</typeparam> /// <param name="uri">URI endpoint to send request to</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - Task<T> Post<T>(Uri uri); + Task<T> Post<T>(Uri uri, CancellationToken cancellationToken = default); /// <summary> /// Creates a new API resource in the list at the specified URI. @@ -167,9 +169,10 @@ public interface IApiConnection /// <typeparam name="T">The API resource's type.</typeparam> /// <param name="uri">URI of the API resource to get</param> /// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - Task<T> Post<T>(Uri uri, object data); + Task<T> Post<T>(Uri uri, object data, CancellationToken cancellationToken = default); /// <summary> /// Creates a new API resource in the list at the specified URI. @@ -178,9 +181,10 @@ public interface IApiConnection /// <param name="uri">URI of the API resource to get</param> /// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param> /// <param name="accepts">Accept header to use for the API request</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - Task<T> Post<T>(Uri uri, object data, string accepts); + Task<T> Post<T>(Uri uri, object data, string accepts, CancellationToken cancellationToken = default); /// <summary> /// Creates a new API resource in the list at the specified URI. @@ -190,9 +194,10 @@ public interface IApiConnection /// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body</param> /// <param name="accepts">Accept header to use for the API request</param> /// <param name="contentType">Content type of the API request</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - Task<T> Post<T>(Uri uri, object data, string accepts, string contentType); + Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, CancellationToken cancellationToken = default); /// <summary> /// Creates a new API resource in the list at the specified URI. @@ -203,9 +208,10 @@ public interface IApiConnection /// <param name="accepts">Accept header to use for the API request</param> /// <param name="contentType">Content type of the API request</param> /// <param name="twoFactorAuthenticationCode">Two Factor Authentication Code</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, string twoFactorAuthenticationCode); + Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, string twoFactorAuthenticationCode, CancellationToken cancellationToken = default); /// <summary> /// Creates a new API resource in the list at the specified URI. @@ -216,9 +222,10 @@ public interface IApiConnection /// <param name="accepts">Accept header to use for the API request</param> /// <param name="contentType">Content type of the API request</param> /// <param name="timeout">Timeout for the request</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> - Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, TimeSpan timeout); + Task<T> Post<T>(Uri uri, object data, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken = default); /// <summary> /// Creates or replaces the API resource at the specified URI diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 920b871d9b..73594c3441 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -105,8 +105,9 @@ public interface IConnection : IApiInfoProvider /// Performs an asynchronous HTTP POST request. /// </summary> /// <param name="uri">URI endpoint to send request to</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The returned <seealso cref="HttpStatusCode"/></returns> - Task<HttpStatusCode> Post(Uri uri); + Task<HttpStatusCode> Post(Uri uri, CancellationToken cancellationToken = default); /// <summary> /// Performs an asynchronous HTTP POST request. @@ -114,8 +115,9 @@ public interface IConnection : IApiInfoProvider /// <param name="uri">URI endpoint to send request to</param> /// <param name="body">The object to serialize as the body of the request</param> /// <param name="accepts">Specifies accepted response media types.</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns>The returned <seealso cref="HttpStatusCode"/></returns> - Task<HttpStatusCode> Post(Uri uri, object body, string accepts); + Task<HttpStatusCode> Post(Uri uri, object body, string accepts, CancellationToken cancellationToken = default); /// <summary> /// Performs an asynchronous HTTP POST request. @@ -123,8 +125,9 @@ public interface IConnection : IApiInfoProvider /// </summary> /// <typeparam name="T">The type to map the response to</typeparam> /// <param name="uri">URI endpoint to send request to</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> - Task<IApiResponse<T>> Post<T>(Uri uri); + Task<IApiResponse<T>> Post<T>(Uri uri, CancellationToken cancellationToken = default); /// <summary> /// Performs an asynchronous HTTP POST request. @@ -136,8 +139,15 @@ public interface IConnection : IApiInfoProvider /// <param name="accepts">Specifies accepted response media types.</param> /// <param name="contentType">Specifies the media type of the request body</param> /// <param name="parameters">Extra parameters for authentication.</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> - Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, IDictionary<string, string> parameters = null); + Task<IApiResponse<T>> Post<T>( + Uri uri, + object body, + string accepts, + string contentType, + IDictionary<string, string> parameters = null, + CancellationToken cancellationToken = default); /// <summary> /// Performs an asynchronous HTTP POST request. @@ -149,8 +159,9 @@ public interface IConnection : IApiInfoProvider /// <param name="accepts">Specifies accepted response media types.</param> /// <param name="contentType">Specifies the media type of the request body</param> /// <param name="twoFactorAuthenticationCode">Two Factor Authentication Code</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> - Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode); + Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode, CancellationToken cancellationToken = default); /// <summary> /// Performs an asynchronous HTTP POST request. @@ -162,8 +173,9 @@ public interface IConnection : IApiInfoProvider /// <param name="accepts">Specifies accepted response media types.</param> /// <param name="contentType">Specifies the media type of the request body</param> /// <param name="timeout"></param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> - Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout); + Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken = default); /// <summary> @@ -180,8 +192,9 @@ public interface IConnection : IApiInfoProvider /// <param name="accepts">Specifies accepted response media types.</param> /// <param name="contentType">Specifies the media type of the request body</param> /// <param name="baseAddress">Allows overriding the base address for a post.</param> + /// <param name="cancellationToken">An optional token to monitor for cancellation requests</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> - Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress); + Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress, CancellationToken cancellationToken = default); /// <summary> /// Performs an asynchronous HTTP PUT request. From 8b0fb136851f39ce833579679a2685167ca0adcf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 21 Feb 2021 17:10:51 -0400 Subject: [PATCH 022/209] Bump Codecov from 1.12.3 to 1.12.4 in /build (#2285) * Bump Codecov from 1.12.3 to 1.12.4 in /build Bumps [Codecov](https://github.com/codecov/codecov-exe) from 1.12.3 to 1.12.4. - [Release notes](https://github.com/codecov/codecov-exe/releases) - [Changelog](https://github.com/codecov/codecov-exe/blob/master/Changelog.md) - [Commits](https://github.com/codecov/codecov-exe/compare/1.12.3...1.12.4) Signed-off-by: dependabot[bot] <support@github.com> * fix path to codecov executable Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Brendan Forster <github@brendanforster.com> --- build/Build.csproj | 2 +- build/Tasks/CodeCoverage.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/Build.csproj b/build/Build.csproj index 02ea863db2..e255cbb8eb 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -10,7 +10,7 @@ <PackageReference Include="Cake.Coverlet" Version="2.5.1" /> <PackageReference Include="Cake.Frosting" Version="1.0.0" /> <PackageReference Include="Cake.Codecov" Version="1.0.0" /> - <PackageReference Include="Codecov" Version="1.12.3" /> + <PackageReference Include="Codecov" Version="1.12.4" /> </ItemGroup> </Project> diff --git a/build/Tasks/CodeCoverage.cs b/build/Tasks/CodeCoverage.cs index 74f1aaba61..a771e32dee 100644 --- a/build/Tasks/CodeCoverage.cs +++ b/build/Tasks/CodeCoverage.cs @@ -51,7 +51,7 @@ public override void Run(Context context) var userProfilePath = context.EnvironmentVariable("USERPROFILE"); var codecovPath = new DirectoryPath(userProfilePath) - .CombineWithFilePath(".nuget\\packages\\codecov\\1.12.3\\tools\\codecov.exe"); + .CombineWithFilePath(".nuget\\packages\\codecov\\1.12.4\\tools\\codecov.exe"); context.Tools.RegisterFile(codecovPath); From e40c792e27342efad55b9c90e36a8968978a0e22 Mon Sep 17 00:00:00 2001 From: Phil Haack <haacked@gmail.com> Date: Sun, 21 Feb 2021 13:11:51 -0800 Subject: [PATCH 023/209] Change Payload to a Dictionary<string, string> (#2303) When serializing the `NewDeployment` type, the `Payload` is serialized as an escaped string because JSON.NET doesn't know it's meant to be JSON. This causes a problem when you call the API because the Payload is supposed to be a JSON dictionary that's just part of the overall payload. It's not supposed to be an escaped string. That's why the JSON deserializer fails on it. Not only that, any deployments created using the current Octokit.net will create an invalid payload. This PR fixes it by changing the type of `Payload` to a dictionary. THIS IS A BREAKING CHANGE, but the old behavior was broken so it forces a new correct behavior. Fixes #2250 --- Octokit.Tests/Models/DeploymentTests.cs | 12 ++++++++++++ Octokit/Models/Request/NewDeployment.cs | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Models/DeploymentTests.cs b/Octokit.Tests/Models/DeploymentTests.cs index d60c9b117d..dab6b66842 100644 --- a/Octokit.Tests/Models/DeploymentTests.cs +++ b/Octokit.Tests/Models/DeploymentTests.cs @@ -8,6 +8,18 @@ namespace Octokit.Tests.Models { public class DeploymentTests { + [Fact] + public void CanSerialize() + { + var deployment = new NewDeployment("ref") + { + Payload = new Dictionary<string, string> {{"environment", "production"}} + }; + var deserialized = new SimpleJsonSerializer().Serialize(deployment); + + Assert.Equal(@"{""ref"":""ref"",""task"":""deploy"",""payload"":{""environment"":""production""}}", deserialized); + } + [Fact] public void CanDeserialize() { diff --git a/Octokit/Models/Request/NewDeployment.cs b/Octokit/Models/Request/NewDeployment.cs index b844ceffc1..7fdf30d4ba 100644 --- a/Octokit/Models/Request/NewDeployment.cs +++ b/Octokit/Models/Request/NewDeployment.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -59,7 +60,7 @@ public NewDeployment(string @ref) /// <summary> /// JSON payload with extra information about the deployment. /// </summary> - public string Payload { get; set; } + public Dictionary<string, string> Payload { get; set; } /// <summary> /// Optional name for the target deployment environment (e.g., production, staging, qa). Default: "production" From 6105a9deaf5bb10b7053b336b37f9c3b713375f0 Mon Sep 17 00:00:00 2001 From: Ivan Josipovic <9521987+IvanJosipovic@users.noreply.github.com> Date: Sun, 21 Feb 2021 14:38:00 -0800 Subject: [PATCH 024/209] preview support for repository visibility (#2217) --- .../Clients/RepositoriesClientTests.cs | 43 +++++++++++++------ .../Models/RepositoryRequestTests.cs | 2 +- Octokit/Clients/RepositoriesClient.cs | 24 ++++++++--- Octokit/Helpers/AcceptHeaders.cs | 2 + Octokit/Models/Request/NewRepository.cs | 34 ++++++++++++++- Octokit/Models/Request/RepositoryRequest.cs | 16 ++++--- Octokit/Models/Request/RepositoryUpdate.cs | 5 +++ Octokit/Models/Response/Repository.cs | 5 ++- 8 files changed, 101 insertions(+), 30 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 56de5a76cf..1bc89b7b26 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -40,7 +40,9 @@ public void UsesTheUserReposUrl() client.Create(new NewRepository("aName")); - connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Any<NewRepository>()); + connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), + Arg.Any<NewRepository>(), + "application/vnd.github.nebula-preview+json"); } [Fact] @@ -52,7 +54,7 @@ public void TheNewRepositoryDescription() client.Create(newRepository); - connection.Received().Post<Repository>(Args.Uri, newRepository); + connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json"); } [Fact] @@ -68,7 +70,7 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentU var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); connection.Connection.Credentials.Returns(credentials); - connection.Post<Repository>(Args.Uri, newRepository) + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -95,7 +97,7 @@ public async Task ThrowsExceptionWhenPrivateRepositoryQuotaExceeded() var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); connection.Connection.Credentials.Returns(credentials); - connection.Post<Repository>(Args.Uri, newRepository) + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -127,7 +129,8 @@ public async Task UsesTheOrganizationsReposUrl() connection.Received().Post<Repository>( Arg.Is<Uri>(u => u.ToString() == "orgs/theLogin/repos"), - Args.NewRepository); + Args.NewRepository, + "application/vnd.github.nebula-preview+json"); } [Fact] @@ -139,7 +142,7 @@ public async Task TheNewRepositoryDescription() await client.Create("aLogin", newRepository); - connection.Received().Post<Repository>(Args.Uri, newRepository); + connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json"); } [Fact] @@ -153,7 +156,7 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForSpecifie + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Post<Repository>(Args.Uri, newRepository) + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -178,7 +181,7 @@ public async Task ThrowsValidationException() + @"""http://developer.github.com/v3/repos/#create"",""errors"":[]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Post<Repository>(Args.Uri, newRepository) + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -199,7 +202,7 @@ public async Task ThrowsRepositoryExistsExceptionForEnterpriseInstance() + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(new Uri("https://example.com")); - connection.Post<Repository>(Args.Uri, newRepository) + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -402,7 +405,9 @@ public async Task RequestsCorrectUrl() await client.Get("owner", "name"); connection.Received() - .Get<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name")); + .Get<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name"), + null, + "application/vnd.github.nebula-preview+json"); } [Fact] @@ -483,7 +488,10 @@ public async Task RequestsTheCorrectUrlAndReturnsRepositories() await client.GetAllForCurrent(); connection.Received() - .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), Args.ApiOptions); + .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), + null, + "application/vnd.github.nebula-preview+json", + Args.ApiOptions); } [Fact] @@ -503,6 +511,7 @@ public async Task CanFilterByType() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["type"] == "all"), + "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -524,6 +533,7 @@ public async Task CanFilterBySort() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["type"] == "private" && d["sort"] == "full_name"), + "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -546,6 +556,7 @@ public async Task CanFilterBySortDirection() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["type"] == "member" && d["sort"] == "updated" && d["direction"] == "asc"), + "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -557,7 +568,7 @@ public async Task CanFilterByVisibility() var request = new RepositoryRequest { - Visibility = RepositoryVisibility.Private + Visibility = RepositoryRequestVisibility.Private }; await client.GetAllForCurrent(request); @@ -566,6 +577,7 @@ public async Task CanFilterByVisibility() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["visibility"] == "private"), + "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -587,6 +599,7 @@ public async Task CanFilterByAffiliation() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "owner" && d["sort"] == "full_name"), + "application/vnd.github.nebula-preview+json", Args.ApiOptions); } } @@ -631,7 +644,7 @@ public async Task RequestsTheCorrectUrl() await client.GetAllForOrg("orgname"); connection.Received() - .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgname/repos"), Args.ApiOptions); + .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgname/repos"), null, "application/vnd.github.nebula-preview+json", Args.ApiOptions); } [Fact] @@ -1063,7 +1076,9 @@ public void PatchesCorrectUrl() client.Edit("owner", "repo", update); connection.Received() - .Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo"), Arg.Any<RepositoryUpdate>()); + .Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo"), + Arg.Any<RepositoryUpdate>(), + "application/vnd.github.nebula-preview+json"); } [Fact] diff --git a/Octokit.Tests/Models/RepositoryRequestTests.cs b/Octokit.Tests/Models/RepositoryRequestTests.cs index e5d89562fc..74471d7ed2 100644 --- a/Octokit.Tests/Models/RepositoryRequestTests.cs +++ b/Octokit.Tests/Models/RepositoryRequestTests.cs @@ -26,7 +26,7 @@ public void ContainsSetValues() request = new RepositoryRequest { Affiliation = RepositoryAffiliation.All, - Visibility = RepositoryVisibility.Public + Visibility = RepositoryRequestVisibility.Public }; parameters = request.ToParametersDictionary(); diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index d067ddcf43..44a7ab700a 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -50,6 +50,7 @@ public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/> instance for the created repository.</returns> + [Preview("nebula")] [ManualRoute("POST", "/user/repos")] public Task<Repository> Create(NewRepository newRepository) { @@ -68,6 +69,7 @@ public Task<Repository> Create(NewRepository newRepository) /// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/> instance for the created repository</returns> + [Preview("nebula")] [ManualRoute("POST", "/orgs/{org}/repos")] public Task<Repository> Create(string organizationLogin, NewRepository newRepository) { @@ -83,7 +85,7 @@ async Task<Repository> Create(Uri url, string organizationLogin, NewRepository n { try { - return await ApiConnection.Post<Repository>(url, newRepository).ConfigureAwait(false); + return await ApiConnection.Post<Repository>(url, newRepository, AcceptHeaders.VisibilityPreview).ConfigureAwait(false); } catch (ApiValidationException e) { @@ -211,6 +213,7 @@ public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositor /// <param name="name">The name of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> + [Preview("nebula")] [ManualRoute("PATCH", "/repos/{owner}/{repo}")] public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) { @@ -219,7 +222,7 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) Ensure.ArgumentNotNull(update, nameof(update)); Ensure.ArgumentNotNull(update.Name, nameof(update.Name)); - return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update); + return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.VisibilityPreview); } /// <summary> @@ -246,13 +249,14 @@ public Task<Repository> Edit(long repositoryId, RepositoryUpdate update) /// <param name="name">The name of the repository</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/></returns> + [Preview("nebula")] [ManualRoute("GET", "/repos/{owner}/{repo}")] public Task<Repository> Get(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<Repository>(ApiUrls.Repository(owner, name)); + return ApiConnection.Get<Repository>(ApiUrls.Repository(owner, name), null, AcceptHeaders.VisibilityPreview); } /// <summary> @@ -279,7 +283,7 @@ public Task<Repository> Get(long repositoryId) /// </remarks> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> [ManualRoute("GET", "/repositories")] public Task<IReadOnlyList<Repository>> GetAllPublic() { @@ -317,6 +321,7 @@ public Task<IReadOnlyList<Repository>> GetAllPublic(PublicRepositoryRequest requ /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + [Preview("nebula")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent() { @@ -333,12 +338,13 @@ public Task<IReadOnlyList<Repository>> GetAllForCurrent() /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + [Preview("nebula")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), options); + return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), null, AcceptHeaders.VisibilityPreview, options); } /// <summary> @@ -352,6 +358,7 @@ public Task<IReadOnlyList<Repository>> GetAllForCurrent(ApiOptions options) /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + [Preview("nebula")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent(RepositoryRequest request) { @@ -372,13 +379,14 @@ public Task<IReadOnlyList<Repository>> GetAllForCurrent(RepositoryRequest reques /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + [Preview("nebula")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent(RepositoryRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), request.ToParametersDictionary(), options); + return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), request.ToParametersDictionary(), AcceptHeaders.VisibilityPreview, options); } /// <summary> @@ -427,6 +435,7 @@ public Task<IReadOnlyList<Repository>> GetAllForUser(string login, ApiOptions op /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + [Preview("nebula")] [ManualRoute("GET", "/orgs/{org}/repos")] public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization) { @@ -445,13 +454,14 @@ public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization) /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + [Preview("nebula")] [ManualRoute("GET", "/orgs/{org}/repos")] public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization), options); + return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization), null, AcceptHeaders.VisibilityPreview, options); } /// <summary> diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 9d0848cee8..eaca8811f6 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -50,6 +50,8 @@ public static class AcceptHeaders public const string OAuthApplicationsPreview = "application/vnd.github.doctor-strange-preview+json"; + public const string VisibilityPreview = "application/vnd.github.nebula-preview+json"; + /// <summary> /// Combines multiple preview headers. GitHub API supports Accept header with multiple /// values separated by comma. diff --git a/Octokit/Models/Request/NewRepository.cs b/Octokit/Models/Request/NewRepository.cs index 5c7da588e2..3942d53ed6 100644 --- a/Octokit/Models/Request/NewRepository.cs +++ b/Octokit/Models/Request/NewRepository.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using Octokit.Internal; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -81,9 +82,14 @@ public NewRepository(string name) /// Optional. Gets or sets the Id of the team to grant access to this repository. This is only valid when creating a repository for an organization. /// </summary> public int? TeamId { get; set; } - + public bool? DeleteBranchOnMerge { get; set; } + /// <summary> + /// Optional. Gets or sets whether the new repository is public, private, or internal. A value provided here overrides any value set in the existing private field. + /// </summary> + public RepositoryVisibility? Visibility { get; set; } + internal string DebuggerDisplay { get @@ -92,4 +98,28 @@ internal string DebuggerDisplay } } } + + /// <summary> + /// The properties that repositories can be visible by. + /// </summary> + public enum RepositoryVisibility + { + /// <summary> + /// Sets repository visibility to public + /// </summary> + [Parameter(Value = "public")] + Public, + + /// <summary> + /// Sets repository visibility to private + /// </summary> + [Parameter(Value = "private")] + Private, + + /// <summary> + /// Sets repository visibility to internal + /// </summary> + [Parameter(Value = "internal")] + Internal, + } } diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index fd8868155d..cd583f4898 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -43,7 +43,7 @@ public class RepositoryRequest : RequestParameters /// <value> /// The visibility. /// </value> - public RepositoryVisibility? Visibility { get; set; } + public RepositoryRequestVisibility? Visibility { get; set; } /// <summary> /// Gets or sets the affiliation property. @@ -143,17 +143,17 @@ public enum RepositorySort /// <summary> /// The properties that repositories can be visible by. /// </summary> - public enum RepositoryVisibility + public enum RepositoryRequestVisibility { /// <summary> /// Returns only public repositories - /// </summary> + /// </summary> [Parameter(Value = "public")] Public, /// <summary> /// Returns only private repositories - /// </summary> + /// </summary> [Parameter(Value = "private")] Private, @@ -161,7 +161,13 @@ public enum RepositoryVisibility /// Return both public and private repositories /// </summary> [Parameter(Value = "all")] - All + All, + + /// <summary> + /// Returns only internal repositories + /// </summary> + [Parameter(Value = "internal")] + Internal, } /// <summary> diff --git a/Octokit/Models/Request/RepositoryUpdate.cs b/Octokit/Models/Request/RepositoryUpdate.cs index 86abfe52e7..8801787950 100644 --- a/Octokit/Models/Request/RepositoryUpdate.cs +++ b/Octokit/Models/Request/RepositoryUpdate.cs @@ -85,6 +85,11 @@ public RepositoryUpdate(string name) /// </summary> public bool? Archived { get; set; } + /// <summary> + /// Optional. Gets or sets whether the new repository is public, private, or internal. A value provided here overrides any value set in the existing private field. + /// </summary> + public RepositoryVisibility? Visibility { get; set; } + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index f288a6d845..23eab039b0 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -14,7 +14,7 @@ public Repository(long id) Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility) { Url = url; HtmlUrl = htmlUrl; @@ -57,6 +57,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st Archived = archived; WatchersCount = watchersCount; DeleteBranchOnMerge = deleteBranchOnMerge; + Visibility = visibility; } public string Url { get; protected set; } @@ -145,6 +146,8 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public bool? DeleteBranchOnMerge { get; protected set; } + public RepositoryVisibility? Visibility { get; protected set; } + internal string DebuggerDisplay { get From 375c20e49a1cc125f52bf8609c79bd880fe4253a Mon Sep 17 00:00:00 2001 From: Phil Haack <haacked@gmail.com> Date: Sun, 21 Feb 2021 14:48:53 -0800 Subject: [PATCH 025/209] Move the build to .net 5 (#2294) * Move the build to .net 5 .NET 5 is fine for building projects that target older versions of .NET. This also should fix the AppVeyor build which fails because the latest `coverlet.console` only supports .NET 5. * Some things need .NET core 3.1 available Co-authored-by: Brendan Forster <github@brendanforster.com> --- .github/workflows/netcore.yml | 7 ++++++- .github/workflows/publish.yml | 2 ++ global.json | 6 ------ 3 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 global.json diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index 4bd498fc8e..5f924b9ed9 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -19,9 +19,14 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* - name: Setup .NET Core uses: actions/setup-dotnet@v1 - + with: + dotnet-version: 3.1.* - name: Build with dotnet run: ./build.sh --linksources=true --verbosity=verbose shell: bash diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3633058eab..79a36c5bf2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,6 +14,8 @@ jobs: - uses: actions/checkout@v1 - name: Setup .NET Core uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* - name: Build with dotnet run: ./build.sh --linksources=true --verbosity=verbose diff --git a/global.json b/global.json deleted file mode 100644 index 14afd189a9..0000000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sdk": { - "version": "3.1.200", - "rollForward": "latestMinor" - } -} From 618215cf7ea59359997fad992e6f3f9540e62448 Mon Sep 17 00:00:00 2001 From: Brendan Forster <github@brendanforster.com> Date: Sun, 21 Feb 2021 18:57:48 -0400 Subject: [PATCH 026/209] restore 3.1.x for publish script --- .github/workflows/publish.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 79a36c5bf2..82203bd62c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,11 +12,17 @@ jobs: steps: - uses: actions/checkout@v1 - - name: Setup .NET Core + + - name: Setup .NET 5 uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.* + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + - name: Build with dotnet run: ./build.sh --linksources=true --verbosity=verbose shell: bash From 2e5fb685185111461e9e6fa15d9646ff2f3889f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Feb 2021 08:23:51 -0400 Subject: [PATCH 027/209] Bump Cake.Coverlet from 2.5.1 to 2.5.4 in /build (#2305) Bumps [Cake.Coverlet](https://github.com/romanx/Cake.Coverlet) from 2.5.1 to 2.5.4. - [Release notes](https://github.com/romanx/Cake.Coverlet/releases) - [Commits](https://github.com/romanx/Cake.Coverlet/compare/v2.5.1...v2.5.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/Build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.csproj b/build/Build.csproj index e255cbb8eb..5f3bdc558f 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -7,7 +7,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Cake.Coverlet" Version="2.5.1" /> + <PackageReference Include="Cake.Coverlet" Version="2.5.4" /> <PackageReference Include="Cake.Frosting" Version="1.0.0" /> <PackageReference Include="Cake.Codecov" Version="1.0.0" /> <PackageReference Include="Codecov" Version="1.12.4" /> From 57fe2ce19374c66e782b302dd98e0b26869fe639 Mon Sep 17 00:00:00 2001 From: Sean Killeen <SeanKilleen@gmail.com> Date: Thu, 25 Feb 2021 09:40:25 -0500 Subject: [PATCH 028/209] Add repository topics support (#2246) --- .../Clients/IObservableRepositoriesClient.cs | 74 +++++++++++ .../Clients/ObservableRepositoriesClient.cs | 91 +++++++++++++ .../Clients/RepositoriesClientTests.cs | 98 ++++++++++++++ .../Clients/SearchClientTests.cs | 20 +++ .../Clients/RepositoriesClientTests.cs | 111 ++++++++++++++++ Octokit.Tests/Clients/SearchClientTests.cs | 36 +++++ Octokit.Tests/Models/RepositoryTopicsTests.cs | 46 +++++++ Octokit.sln.DotSettings | 1 + Octokit/Clients/IRepositoriesClient.cs | 72 ++++++++++ Octokit/Clients/RepositoriesClient.cs | 124 ++++++++++++++++++ Octokit/Clients/RepositoryForksClient.cs | 2 + Octokit/Helpers/AcceptHeaders.cs | 2 + Octokit/Helpers/ApiUrls.cs | 21 +++ .../Request/SearchRepositoriesRequest.cs | 19 +++ Octokit/Models/Response/Repository.cs | 8 +- Octokit/Models/Response/RepositoryTopics.cs | 33 +++++ 16 files changed, 757 insertions(+), 1 deletion(-) create mode 100644 Octokit.Tests/Models/RepositoryTopicsTests.cs create mode 100644 Octokit/Models/Response/RepositoryTopics.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 7d3218e884..ff3c79ff43 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reactive; +using System.Threading.Tasks; namespace Octokit.Reactive { @@ -556,5 +558,77 @@ public interface IObservableRepositoriesClient /// Refer to the API documentation for more information: https://developer.github.com/v3/repos/projects/ /// </remarks> IObservableProjectsClient Project { get; } + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + IObservable<RepositoryTopics> GetAllTopics(string owner, string name, ApiOptions options); + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>All topics associated with the repository.</returns> + IObservable<RepositoryTopics> GetAllTopics(string owner, string name); + + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + IObservable<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions options); + + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <returns>All topics associated with the repository.</returns> + IObservable<RepositoryTopics> GetAllTopics(long repositoryId); + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + IObservable<RepositoryTopics> ReplaceAllTopics(long repositoryId, RepositoryTopics topics); + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + IObservable<RepositoryTopics> ReplaceAllTopics(string owner, string name, RepositoryTopics topics); + } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index ddeb1338bc..6b835c29e1 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Reactive; using System.Reactive.Linq; using System.Reactive.Threading.Tasks; +using System.Threading.Tasks; using Octokit.Reactive.Clients; using Octokit.Reactive.Internal; @@ -821,5 +823,94 @@ public IObservable<CompareResult> Compare(string owner, string name, string @bas /// Refer to the API documentation for more information: https://developer.github.com/v3/repos/projects/ /// </remarks> public IObservableProjectsClient Project { get; private set; } + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + public IObservable<RepositoryTopics> GetAllTopics(string owner, string name, ApiOptions options) + { + return _client.GetAllTopics(owner, name, options).ToObservable(); + } + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>All topics associated with the repository.</returns> + public IObservable<RepositoryTopics> GetAllTopics(string owner, string name) + { + return GetAllTopics(owner, name, ApiOptions.None); + } + + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + public IObservable<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions options) + { + return _client.GetAllTopics(repositoryId, options).ToObservable(); + } + + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <returns>All topics associated with the repository.</returns> + public IObservable<RepositoryTopics> GetAllTopics(long repositoryId) + { + return GetAllTopics(repositoryId, ApiOptions.None); + } + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + public IObservable<RepositoryTopics> ReplaceAllTopics(long repositoryId, RepositoryTopics topics) + { + return _client.ReplaceAllTopics(repositoryId, topics).ToObservable(); + } + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + public IObservable<RepositoryTopics> ReplaceAllTopics(string owner, string name, RepositoryTopics topics) + { + return _client.ReplaceAllTopics(owner, name, topics).ToObservable(); + } } } diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 7b048cce60..432deb99c3 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -1452,6 +1452,104 @@ public async Task GetsEmptyLanguagesWhenNoneWithRepositoryId() } } + public class TheReplaceAllTopicsMethod : IDisposable + { + readonly IGitHubClient _github = Helper.GetAuthenticatedClient(); + private readonly RepositoryTopics _defaultTopics = new RepositoryTopics(new List<string> { "blog", "ruby", "jekyll" }); + private readonly RepositoryContext _context; + private readonly string _theRepository; + private readonly string _theRepoOwner; + + public TheReplaceAllTopicsMethod() + { + _theRepoOwner = Helper.Organization; + _theRepository = Helper.MakeNameWithTimestamp("topics"); + _context = _github.CreateRepositoryContext(_theRepoOwner, new NewRepository(_theRepository)).Result; + var defaultTopicAssignmentResult = _github.Repository.ReplaceAllTopics(_context.RepositoryId, _defaultTopics).Result; + } + + [IntegrationTest] + public async Task ClearsTopicsWithAnEmptyList() + { + var result = await _github.Repository.ReplaceAllTopics(_theRepoOwner, _theRepository, new RepositoryTopics()); + Assert.Empty(result.Names); + + var doubleCheck = await _github.Repository.GetAllTopics(_theRepoOwner, _theRepository); + Assert.Empty((doubleCheck.Names)); + } + + [IntegrationTest] + public async Task ClearsTopicsWithAnEmptyListWhenUsingRepoId() + { + var repo = await _github.Repository.Get(_theRepoOwner, _theRepository); + var result = await _github.Repository.ReplaceAllTopics(repo.Id, new RepositoryTopics()); + Assert.Empty(result.Names); + + var doubleCheck = await _github.Repository.GetAllTopics(_theRepoOwner, _theRepository); + Assert.Empty((doubleCheck.Names)); + } + + [IntegrationTest] + public async Task ReplacesTopicsWithAList() + { + var defaultTopicsList = new RepositoryTopics(_defaultTopics.Names); + var result = await _github.Repository.ReplaceAllTopics(_theRepoOwner, _theRepository, defaultTopicsList); + + Assert.NotEmpty(result.Names); + Assert.Contains(result.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); + + var doubleCheck = await _github.Repository.GetAllTopics(_theRepoOwner, _theRepository); + Assert.Contains(doubleCheck.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); + } + + [IntegrationTest] + public async Task ReplacesTopicsWithAListWhenUsingRepoId() + { + var defaultTopicsList = new RepositoryTopics(_defaultTopics.Names); + var repo = await _github.Repository.Get(_theRepoOwner, _theRepository); + var result = await _github.Repository.ReplaceAllTopics(repo.Id, defaultTopicsList); + + Assert.NotEmpty(result.Names); + Assert.Contains(result.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); + + var doubleCheck = await _github.Repository.GetAllTopics(_theRepoOwner, _theRepository); + Assert.Contains(doubleCheck.Names, item => _defaultTopics.Names.Contains(item, StringComparer.InvariantCultureIgnoreCase)); + } + + public void Dispose() + { + _context.Dispose(); + } + } + public class TheGetAllTopicsMethod + { + private readonly string _repoOwner = "SeanKilleen"; + private readonly string _repoName = "seankilleen.github.io"; + + [IntegrationTest] + public async Task GetsTopicsByOwnerAndName() + { + var github = Helper.GetAnonymousClient(); + var result = await github.Repository.GetAllTopics(_repoOwner, _repoName); + + Assert.Contains("blog", result.Names); + Assert.Contains("ruby", result.Names); + Assert.Contains("jekyll", result.Names); + } + + [IntegrationTest] + public async Task GetsTopicsByRepoID() + { + var github = Helper.GetAnonymousClient(); + var repo = await github.Repository.Get(_repoOwner, _repoName); + var result = await github.Repository.GetAllTopics(repo.Id); + + Assert.Contains("blog", result.Names); + Assert.Contains("ruby", result.Names); + Assert.Contains("jekyll", result.Names); + } + } + public class TheGetAllTagsMethod { [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index 6b931d1904..506da6f7e6 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -24,6 +24,26 @@ public async Task SearchForCSharpRepositories() Assert.NotEmpty(repos.Items); } + [IntegrationTest] + public async Task SearchForSingleTopic() + { + var request = new SearchRepositoriesRequest { Topic = "csharp" }; + + var repos = await _gitHubClient.Search.SearchRepo(request); + + Assert.NotEmpty(repos.Items); + } + + [IntegrationTest] + public async Task SearchForMoreThan2Topics() + { + var request = new SearchRepositoriesRequest { Topics = Octokit.Range.GreaterThanOrEquals(2) }; + + var repos = await _gitHubClient.Search.SearchRepo(request); + + Assert.NotEmpty(repos.Items); + } + [IntegrationTest] public async Task SearchForCSharpRepositoriesUpdatedIn2020() { diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 1bc89b7b26..c518b7152c 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -1251,5 +1251,116 @@ public void RequestsTheCorrectUrl() .Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits/reference"), null, "application/vnd.github.v3.sha"); } } + + public class TheGetAllTopicsMethod + { + readonly RepositoriesClient _client = new RepositoriesClient(Substitute.For<IApiConnection>()); + + [Fact] + public async Task EnsuresNonNullArguments() + { + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.GetAllTopics(123, null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.GetAllTopics("owner", "repo", null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.GetAllTopics(null, "repo", ApiOptions.None)); + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.GetAllTopics("owner", null, ApiOptions.None)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + await Assert.ThrowsAsync<ArgumentException>(() => _client.GetAllTopics(string.Empty, "repo", ApiOptions.None)); + await Assert.ThrowsAsync<ArgumentException>(() => _client.GetAllTopics("owner", string.Empty, ApiOptions.None)); + } + + [Fact] + public void RequestsTheCorrectUrlForOwnerAndRepo() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoriesClient(connection); + + client.GetAllTopics("owner", "name"); + + connection.Received() + .Get<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), null, "application/vnd.github.mercy-preview+json"); + } + + [Fact] + public void RequestsTheCorrectUrlForRepoId() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoriesClient(connection); + + client.GetAllTopics(1234); + + connection.Received() + .Get<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), null, "application/vnd.github.mercy-preview+json"); + } + } + + public class TheReplaceAllTopicsMethod + { + private readonly RepositoryTopics _emptyTopics = new RepositoryTopics(); + private readonly RepositoryTopics _listOfTopics = new RepositoryTopics(new List<string> { "one", "two", "three" }); + private readonly IApiConnection _connection; + private readonly RepositoriesClient _client; + + public TheReplaceAllTopicsMethod() + { + _connection = Substitute.For<IApiConnection>(); + _client = new RepositoriesClient(_connection); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.ReplaceAllTopics("owner", "repo", null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.ReplaceAllTopics(123, null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.ReplaceAllTopics(null, "repo", _emptyTopics)); + await Assert.ThrowsAsync<ArgumentNullException>(() => _client.ReplaceAllTopics("owner", null, _emptyTopics)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + await Assert.ThrowsAsync<ArgumentException>(() => _client.ReplaceAllTopics(string.Empty, "repo", _emptyTopics)); + await Assert.ThrowsAsync<ArgumentException>(() => _client.ReplaceAllTopics("owner", string.Empty, _emptyTopics)); + } + + [Fact] + public async Task RequestsTheCorrectUrlForOwnerAndRepoWithEmptyTopics() + { + await _client.ReplaceAllTopics("owner", "name", _emptyTopics); + + _connection.Received() + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null,"application/vnd.github.mercy-preview+json"); + } + + [Fact] + public async Task RequestsTheCorrectUrlForOwnerAndRepoWithListOfTopics() + { + await _client.ReplaceAllTopics("owner", "name", _listOfTopics); + + _connection.Received() + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics,null, "application/vnd.github.mercy-preview+json"); + } + + [Fact] + public async Task RequestsTheCorrectUrlForRepoIdWithEmptyTopics() + { + await _client.ReplaceAllTopics(1234, _emptyTopics); + + _connection.Received() + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _emptyTopics, null, "application/vnd.github.mercy-preview+json"); + } + + [Fact] + public async Task RequestsTheCorrectUrlForRepoIdWithListOfTopics() + { + await _client.ReplaceAllTopics(1234,_listOfTopics); + + _connection.Received() + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics,null, "application/vnd.github.mercy-preview+json"); + } + } } } diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index 1ead16ebf1..d6a481766e 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -702,6 +702,42 @@ public void TestingTheSearchParameter() Arg.Is<Dictionary<string, string>>(d => string.IsNullOrEmpty(d["q"]))); } + + [Fact] + public async Task TestingTheTopicQualifier() + { + var request = new SearchRepositoriesRequest("github"); + request.Topic = "TheTopic"; + + Assert.Contains("topic:thetopic", request.MergedQualifiers()); + } + + [Fact] + public void TestingTheTopicsQualifierWithGreaterThanOneTopic() + { + var request = new SearchRepositoriesRequest("github"); + request.Topics = Range.GreaterThan(1); + + Assert.Contains("topics:>1", request.MergedQualifiers()); + } + + [Fact] + public void TestingTheTopicsQualifierWithExactlyOneTopic() + { + var request = new SearchRepositoriesRequest("github"); + request.Topics = new Range(1); + + Assert.Contains("topics:1", request.MergedQualifiers()); + } + + [Fact] + public void TestingTheTopicsQualifierWithTwoOrLessTopics() + { + var request = new SearchRepositoriesRequest("github"); + request.Topics = Range.LessThanOrEquals(2); + + Assert.Contains("topics:<=2", request.MergedQualifiers()); + } } public class TheSearchIssuesMethod diff --git a/Octokit.Tests/Models/RepositoryTopicsTests.cs b/Octokit.Tests/Models/RepositoryTopicsTests.cs new file mode 100644 index 0000000000..08c53a27e9 --- /dev/null +++ b/Octokit.Tests/Models/RepositoryTopicsTests.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using Xunit; + +namespace Octokit.Tests.Models +{ + public class RepositoryTopicsTests + { + public class Ctor + { + [Fact] + public void EmptyListWhenCtorEmpty() + { + var result = new RepositoryTopics(); + Assert.NotNull(result.Names); + Assert.Empty(result.Names); + } + + [Fact] + public void EmptyListWhenCtorListIsEmpty() + { + var result = new RepositoryTopics(new List<string>()); + Assert.NotNull(result.Names); + Assert.Empty(result.Names); + } + + [Fact] + public void EmptyListWhenCtorIsNull() + { + var result = new RepositoryTopics(null); + Assert.NotNull(result.Names); + Assert.Empty(result.Names); + } + + [Fact] + public void SetsListWhenListProvided() + { + var theItems = new List<string> {"one", "two", "three"}; + var result = new RepositoryTopics(theItems); + + Assert.Contains("one", result.Names); + Assert.Contains("two", result.Names); + Assert.Contains("three", result.Names); + } + } + } +} diff --git a/Octokit.sln.DotSettings b/Octokit.sln.DotSettings index 50852c97ec..7f9262b459 100644 --- a/Octokit.sln.DotSettings +++ b/Octokit.sln.DotSettings @@ -269,6 +269,7 @@ II.2.12 <HandlesEvent />
 <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean> + <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean> diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index ab9e31fb94..dd291cfd1e 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -621,5 +621,77 @@ public interface IRepositoriesClient /// Refer to the API documentation for more information: https://developer.github.com/v3/repos/projects/ /// </remarks> IProjectsClient Project { get; } + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + Task<RepositoryTopics> GetAllTopics(string owner, string name, ApiOptions options); + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>All topics associated with the repository.</returns> + Task<RepositoryTopics> GetAllTopics(string owner, string name); + + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + Task<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions options); + + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <returns>All topics associated with the repository.</returns> + Task<RepositoryTopics> GetAllTopics(long repositoryId); + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + Task<RepositoryTopics> ReplaceAllTopics(long repositoryId, RepositoryTopics topics); + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + Task<RepositoryTopics> ReplaceAllTopics(string owner, string name, RepositoryTopics topics); + } } diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 44a7ab700a..256b24fbd9 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -179,6 +179,7 @@ public Task Delete(long repositoryId) /// <param name="name">The name of the repository</param> /// <param name="repositoryTransfer">Repository transfer information</param> /// <returns>A <see cref="Repository"/></returns> + [Preview("mercy")] [ManualRoute("POST", "/repos/{owner}/{repo}/transfer")] public Task<Repository> Transfer(string owner, string name, RepositoryTransfer repositoryTransfer) { @@ -198,6 +199,7 @@ public Task<Repository> Transfer(string owner, string name, RepositoryTransfer r /// <param name="repositoryId">The id of the repository</param> /// <param name="repositoryTransfer">Repository transfer information</param> /// <returns>A <see cref="Repository"/></returns> + [Preview("mercy")] [ManualRoute("POST", "/repositories/{id}/transfer")] public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositoryTransfer) { @@ -231,6 +233,7 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) /// <param name="repositoryId">The Id of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> + [Preview("mercy")] [ManualRoute("PATCH", "/repositories/{id}")] public Task<Repository> Edit(long repositoryId, RepositoryUpdate update) { @@ -268,6 +271,7 @@ public Task<Repository> Get(string owner, string name) /// <param name="repositoryId">The Id of the repository</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/></returns> + [Preview("mercy")] [ManualRoute("GET", "/repositories/{id}")] public Task<Repository> Get(long repositoryId) { @@ -727,6 +731,126 @@ public Task<IReadOnlyList<RepositoryContributor>> GetAllContributors(long reposi return ApiConnection.GetAll<RepositoryContributor>(ApiUrls.RepositoryContributors(repositoryId), parameters, options); } + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + [ManualRoute("GET", "/repositories/{id}/topics")] + public async Task<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + var endpoint = ApiUrls.RepositoryTopics(repositoryId); + var data = await ApiConnection.Get<RepositoryTopics>(endpoint,null,AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + + return data ?? new RepositoryTopics(); + } + + /// <summary> + /// Gets all topics for the specified repository ID. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <returns>All topics associated with the repository.</returns> + [ManualRoute("GET", "/repositories/{id}/topics")] + + public Task<RepositoryTopics> GetAllTopics(long repositoryId) + { + return GetAllTopics(repositoryId, ApiOptions.None); + } + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>All topics associated with the repository.</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/topics")] + public async Task<RepositoryTopics> GetAllTopics(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(options, nameof(options)); + + var endpoint = ApiUrls.RepositoryTopics(owner, name); + var data = await ApiConnection.Get<RepositoryTopics>(endpoint, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + + return data ?? new RepositoryTopics(); + } + + /// <summary> + /// Gets all topics for the specified owner and repository name. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>All topics associated with the repository.</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/topics")] + + public Task<RepositoryTopics> GetAllTopics(string owner, string name) + { + return GetAllTopics(owner, name, ApiOptions.None); + } + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + [ManualRoute("PUT", "/repos/{owner}/{repo}/topics")] + public async Task<RepositoryTopics> ReplaceAllTopics(string owner, string name, RepositoryTopics topics) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(topics, nameof(topics)); + + var endpoint = ApiUrls.RepositoryTopics(owner, name); + var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics,null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + + return data ?? new RepositoryTopics(); + } + + /// <summary> + /// Replaces all topics for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// + /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. + /// </remarks> + /// <param name="repositoryId">The ID of the repository</param> + /// <param name="topics">The list of topics to associate with the repository</param> + /// <returns>All topics now associated with the repository.</returns> + [ManualRoute("PUT", "/repositories/{id}/topics")] + public async Task<RepositoryTopics> ReplaceAllTopics(long repositoryId, RepositoryTopics topics) + { + Ensure.ArgumentNotNull(topics, nameof(topics)); + + var endpoint = ApiUrls.RepositoryTopics(repositoryId); + var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + + return data ?? new RepositoryTopics(); + } + /// <summary> /// Gets all languages for the specified repository. /// </summary> diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs index 3a32b59b70..89496dddab 100644 --- a/Octokit/Clients/RepositoryForksClient.cs +++ b/Octokit/Clients/RepositoryForksClient.cs @@ -168,6 +168,7 @@ public Task<IReadOnlyList<Repository>> GetAll(long repositoryId, RepositoryForks /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="fork">Used to fork a repository</param> + [Preview("mercy")] [ManualRoute("POST", "/repos/{owner}/{repo}/forks")] public Task<Repository> Create(string owner, string name, NewRepositoryFork fork) { @@ -186,6 +187,7 @@ public Task<Repository> Create(string owner, string name, NewRepositoryFork fork /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="fork">Used to fork a repository</param> + [Preview("mercy")] [ManualRoute("POST", "/repositories/{id}/forks")] public Task<Repository> Create(long repositoryId, NewRepositoryFork fork) { diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index eaca8811f6..09826011e3 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -50,6 +50,8 @@ public static class AcceptHeaders public const string OAuthApplicationsPreview = "application/vnd.github.doctor-strange-preview+json"; + public const string RepositoryTopicsPreview = "application/vnd.github.mercy-preview+json"; + public const string VisibilityPreview = "application/vnd.github.nebula-preview+json"; /// <summary> diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 252eedcc61..74f0ff3f9c 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1902,6 +1902,27 @@ public static Uri RepositoryContributors(string owner, string name) return "repos/{0}/{1}/contributors".FormatUri(owner, name); } + /// <summary> + /// Returns the <see cref="Uri"/> for repository topics. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>the <see cref="Uri"/> for repository topics.</returns> + public static Uri RepositoryTopics(string owner, string name) + { + return "repos/{0}/{1}/topics".FormatUri(owner, name); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for repository topics. + /// </summary> + /// <param name="repositoryId">The ID of the repository</param> + /// <returns>the <see cref="Uri"/> for repository topics.</returns> + public static Uri RepositoryTopics(long repositoryId) + { + return "repositories/{0}/topics".FormatUri(repositoryId); + } + /// <summary> /// Returns the <see cref="Uri"/> for repository languages. /// </summary> diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index 21769fdbd8..9e1869713f 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -123,6 +123,16 @@ public IEnumerable<InQualifier> In /// </summary> public bool? Archived { get; set; } + /// <summary> + /// Filters on whether repositories are tagged with the given topic. + /// </summary> + public string Topic { get; set; } + + /// <summary> + /// Filters on the number of topics that a repository is associated with. + /// </summary> + public Range Topics { get; set; } + public override IReadOnlyList<string> MergedQualifiers() { var parameters = new List<string>(); @@ -177,6 +187,15 @@ public override IReadOnlyList<string> MergedQualifiers() parameters.Add(string.Format(CultureInfo.InvariantCulture, "archived:{0}", Archived.ToString().ToLower())); } + if (Topic != null) + { + parameters.Add(string.Format(CultureInfo.InvariantCulture, "topic:{0}", Topic.ToLower())); + } + + if (Topics != null) + { + parameters.Add(string.Format(CultureInfo.InvariantCulture, "topics:{0}", Topics.ToString().ToLower())); + } if (License != null) { parameters.Add(string.Format(CultureInfo.InvariantCulture, "license:{0}", License.ToParameter())); diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 23eab039b0..504d98b330 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -1,6 +1,9 @@ using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; +using System.Linq; namespace Octokit { @@ -14,7 +17,7 @@ public Repository(long id) Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable<string> topics) { Url = url; HtmlUrl = htmlUrl; @@ -56,6 +59,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st AllowMergeCommit = allowMergeCommit; Archived = archived; WatchersCount = watchersCount; + Topics = topics.ToList(); DeleteBranchOnMerge = deleteBranchOnMerge; Visibility = visibility; } @@ -144,6 +148,8 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public bool Archived { get; protected set; } + public IReadOnlyList<string> Topics { get; protected set; } + public bool? DeleteBranchOnMerge { get; protected set; } public RepositoryVisibility? Visibility { get; protected set; } diff --git a/Octokit/Models/Response/RepositoryTopics.cs b/Octokit/Models/Response/RepositoryTopics.cs new file mode 100644 index 0000000000..93af0fd073 --- /dev/null +++ b/Octokit/Models/Response/RepositoryTopics.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Linq; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositoryTopics + { + public RepositoryTopics() { Names = new List<string>(); } + + public RepositoryTopics(IEnumerable<string> names) + { + var initialItems = names?.ToList() ?? new List<string>(); + Names = new ReadOnlyCollection<string>(initialItems); + } + + public IReadOnlyList<string> Names { get; protected set; } + + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, + "RepositoryTopics: Names: {0}", string.Join(", ", Names)); + } + } + } +} From 4eebade5d68dc6cff4285f3799e7ba93a70392f5 Mon Sep 17 00:00:00 2001 From: Brendan Forster <github@brendanforster.com> Date: Thu, 25 Feb 2021 15:24:11 -0400 Subject: [PATCH 029/209] cleanup some mentions of master branch in codebase (#2306) --- Octokit/Helpers/ReferenceExtensions.cs | 2 ++ README.md | 12 ++++----- ReleaseNotes.md | 36 +++++++++++++------------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Octokit/Helpers/ReferenceExtensions.cs b/Octokit/Helpers/ReferenceExtensions.cs index 97c5ba8205..1c4bd887d2 100644 --- a/Octokit/Helpers/ReferenceExtensions.cs +++ b/Octokit/Helpers/ReferenceExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Globalization; +using System.Linq; using System.Threading.Tasks; namespace Octokit.Helpers @@ -40,6 +41,7 @@ public static async Task<Reference> CreateBranch(this IReferencesClient referenc /// <param name="owner">The owner of the repository.</param> /// <param name="name">The name of the repository.</param> /// <param name="branchName">The new branch name</param> + [Obsolete("This function is hard-coded to master branch, which is no longer a valid assumption for the base branch. Instead of making a second request to figure out the default branch, this extension method will be removed in a future release. Please check the default branch on the repository and use a different overload")] public static async Task<Reference> CreateBranch(this IReferencesClient referencesClient, string owner, string name, string branchName) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); diff --git a/README.md b/README.md index 432a4d48f1..4d4accdcf9 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -# Octokit - GitHub API Client Library for .NET +# Octokit - GitHub API Client Library for .NET ![Build status](https://github.com/octokit/octokit.net/workflows/CI%20Build/badge.svg) -[![Build status](https://ci.appveyor.com/api/projects/status/cego2g42yw26th26/branch/master?svg=true)](https://ci.appveyor.com/project/github-windows/octokit-net/branch/master) -[![codecov](https://codecov.io/gh/octokit/octokit.net/branch/master/graph/badge.svg)](https://codecov.io/gh/octokit/octokit.net) +[![Build status](https://ci.appveyor.com/api/projects/status/cego2g42yw26th26/branch/main?svg=true)](https://ci.appveyor.com/project/github-windows/octokit-net/branch/main) +[![codecov](https://codecov.io/gh/octokit/octokit.net/branch/main/graph/badge.svg)](https://codecov.io/gh/octokit/octokit.net) [![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![NuGet](http://img.shields.io/nuget/v/Octokit.svg)](https://www.nuget.org/packages/Octokit) [![NuGet](http://img.shields.io/nuget/v/Octokit.Reactive.svg)](https://www.nuget.org/packages/Octokit.Reactive) ![logo](octokit-dotnet_2.png) -Octokit is a client library targeting .NET Framework 4.6 or greater and .NET Standard 2.0 +Octokit is a client library targeting .NET Framework 4.6 or greater and .NET Standard 2.0 and above that provides an easy way to interact with the [GitHub API](http://developer.github.com/v3/). @@ -57,7 +57,7 @@ Documentation is available at http://octokitnet.readthedocs.io/en/latest/. Octokit is a single assembly designed to be easy to deploy anywhere. -To clone and build it locally click the "Clone in Desktop" button above or run the +To clone and build it locally click the "Clone in Desktop" button above or run the following git commands. ``` @@ -97,7 +97,7 @@ problem. ## Related Projects - - [ScriptCs.OctoKit](https://github.com/hnrkndrssn/ScriptCs.OctoKit) - a [script pack](https://github.com/scriptcs/scriptcs/wiki/Script-Packs) to use Octokit in scriptcs + - [ScriptCs.OctoKit](https://github.com/hnrkndrssn/ScriptCs.OctoKit) - a [script pack](https://github.com/scriptcs/scriptcs/wiki/Script-Packs) to use Octokit in scriptcs - [ScriptCs.OctokitLibrary](https://github.com/ryanrousseau/ScriptCs.OctokitLibrary) - a [script library](https://github.com/scriptcs/scriptcs/wiki/Script-Libraries) to use Octokit in scriptcs ## Copyright and License diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 284613ea5b..fbdb2f26b6 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -253,9 +253,9 @@ Response Models - Octokit.net has been ported to dotnetcore :tada: providing libraries targetting `netstandard1.1` and `net45` frameworks -- `Enum` fields in Octokit response classes are now wrapped in an `StringEnum<TEnum>` helper class, to provide more robustness in dealing with unknown API values for these fields. Whilst the changes are backwards compatible, please consult the guidance on [working with Enums](https://github.com/octokit/octokit.net/blob/master/docs/working-with-enums.md) for more information +- `Enum` fields in Octokit response classes are now wrapped in an `StringEnum<TEnum>` helper class, to provide more robustness in dealing with unknown API values for these fields. Whilst the changes are backwards compatible, please consult the guidance on [working with Enums](https://github.com/octokit/octokit.net/blob/main/docs/working-with-enums.md) for more information -- `IncludeAdmins` field is no longer present in `BranchProtectionRequiredStatusChecks` and `BranchProtectionRequiredStatusChecksUpdate` classes, instead use the new `EnforceAdmins` field on `BranchProtectionSettingsUpdate` or the [new explicit methods](https://github.com/octokit/octokit.net/blob/master/Octokit/Clients/IRepositoryBranchesClient.cs#L304-L365) for configuring Admin Enforcement on protected branches. This was an [upstream API breaking change](https://developer.github.com/changes/2017-05-02-adoption-of-admin-enforced/) so we couldn't follow our normal deprecation schedule +- `IncludeAdmins` field is no longer present in `BranchProtectionRequiredStatusChecks` and `BranchProtectionRequiredStatusChecksUpdate` classes, instead use the new `EnforceAdmins` field on `BranchProtectionSettingsUpdate` or the [new explicit methods](https://github.com/octokit/octokit.net/blob/main/Octokit/Clients/IRepositoryBranchesClient.cs#L304-L365) for configuring Admin Enforcement on protected branches. This was an [upstream API breaking change](https://developer.github.com/changes/2017-05-02-adoption-of-admin-enforced/) so we couldn't follow our normal deprecation schedule ## Release Notes @@ -350,18 +350,18 @@ Response Models **Breaking Changes** - - Creating and Editing Issues (and PullRequests) using `NewIssue` and `IssueUpdate` requests -should now use the `Assignees` collection rather than the now deprecated 'Assignee` field. -Both fields can't be specified on the same request, so any code still using `Assignee` will + - Creating and Editing Issues (and PullRequests) using `NewIssue` and `IssueUpdate` requests +should now use the `Assignees` collection rather than the now deprecated 'Assignee` field. +Both fields can't be specified on the same request, so any code still using `Assignee` will need to explicitly set `Assignees` to `null` to avoid Api validation errors. - - `OrganizationsClient.GetAll(string user)` has been marked obsolete in favour of + - `OrganizationsClient.GetAll(string user)` has been marked obsolete in favour of `OrganizationsClient.GetAllForUser(string user)` - `PullRequest.Comment` has been marked obsolete in favour of `PullRequest.ReviewComment` -- Several `EventsClient` methods previously returned the incorrect `Activity` response class. -This has been corrected to `IssueEvent` which although is now correct could break calling +- Several `EventsClient` methods previously returned the incorrect `Activity` response class. +This has been corrected to `IssueEvent` which although is now correct could break calling code that was written assuming this previous incorrect return type. ### New in 0.23.0 (released 07/10/2016) @@ -413,7 +413,7 @@ you want to change the merge behaviour when merging a pull request. **Breaking Changes** -The new Branches client added in #1437 means that existing methods on +The new Branches client added in #1437 means that existing methods on I(Observable)RepositoryClient are now marked as obsolete. Please update your usages to the new endpoints as these will be removed in a future release: @@ -421,13 +421,13 @@ usages to the new endpoints as these will be removed in a future release: - `client.Repository.GetAllBranches()` => `client.Repository.Branch.GetAll()` - `client.Repository.EditBranch()` => `client.Repository.Branch.Edit()` -There is also a change in how branch protection works with the API, due to +There is also a change in how branch protection works with the API, due to upstream changes. The existing methods have been marked as obsolete, but for the sake of brevity here are the details about what you should be doing today. The process for inspecting branch protection is now two steps: - - first, check the branch returned by `client.Repository.Branch.Get()` or + - first, check the branch returned by `client.Repository.Branch.Get()` or `client.Repository.Branch.GetAll()` has it's `Protected` property set to `true`. - then, a call to `client.Repository.Branch.GetBranchProtection()` will return @@ -441,7 +441,7 @@ The process for inspecting branch protection is now two steps: Due to a programming error in the tool to generate these release notes, additional features were not properly documented for the previous release: - - Reactions preview API support for issues, issue comments, commit comments and PR comments - #1335, #1341, #1405 via @maddin2016, @alfhenrik + - Reactions preview API support for issues, issue comments, commit comments and PR comments - #1335, #1341, #1405 via @maddin2016, @alfhenrik - Repository Invitation preview API support - #1410 via @maddin2016 - Added new fields for signature verification to Git Data Commit API - #1398 via @Sarmad93 @@ -484,7 +484,7 @@ exist in other parts of the API surface: - `I(Observable)GitHubClient.Repository.RepoCollaborators` - `I(Observable)GitHubClient.Repository.Commits` -This method is no longer supported through the API and has been removed from Octokit.net.: +This method is no longer supported through the API and has been removed from Octokit.net.: - `I(Observable)GitHubClient.Authorization.RevokeAllApplicationAuthentications()` @@ -510,12 +510,12 @@ documentation: http://octokitnet.readthedocs.io/en/latest/extensibility/#paginat - Add additional methods to `IEventsClient` - #1288 via @drasticactions - Add Organization Permissions preview API - #1342 via @ryangribble - Add GPG Keys preview API - #1343 via @alfhenrik - + **Fixes** - Renamed `IUserKeysClient.GetAll()` to `IUserKeysClient.GetAllForCurrent()` - #1139 via @M-Zuber - Add `ItemStateFilter` enum to differentiate between search and list endpoints - #1140 via @prayankmathur - - `RepositoriesClient.GetAllPublic()` fails for Enterprise instanes due to URI structure - #1204 via @ryangribble + - `RepositoriesClient.GetAllPublic()` fails for Enterprise instanes due to URI structure - #1204 via @ryangribble - `ConfigureAwait(false)` usages added, eliminating deadlocks - #1248 via @shiftkey - Renamed `CompareResult.MergedBaseCommit` to fix serialization issue - #1265 via @kivancmuslu - Activity Feed now returns issues and repository events - #1288 via @drasticactions @@ -525,11 +525,11 @@ documentation: http://octokitnet.readthedocs.io/en/latest/extensibility/#paginat - Add `ClosedBy` property to `Issue` - #1353 via @maddin2016 **Other** - + - Deleting now-obsolete code - #1224 via @M-Zuber - Centralize and cleanup the `Uri`s created in Octokit - #1287, #1290 via @dampir - - Updated documentation links - #1289 via @radu-matei, #1250 via @SamTheDev - + - Updated documentation links - #1289 via @radu-matei, #1250 via @SamTheDev + **Breaking Changes** - `IUserKeysClient.GetAll()` was named incorrectly when it was originally implemented From cd0dc8935eeba8de7430b7883391d6b2f2548cf3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Mar 2021 08:39:00 -0400 Subject: [PATCH 030/209] Bump Cake.Frosting from 1.0.0 to 1.1.0 in /build (#2313) Bumps [Cake.Frosting](https://github.com/cake-build/cake) from 1.0.0 to 1.1.0. - [Release notes](https://github.com/cake-build/cake/releases) - [Changelog](https://github.com/cake-build/cake/blob/develop/ReleaseNotes.md) - [Commits](https://github.com/cake-build/cake/compare/v1.0.0...v1.1.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/Build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.csproj b/build/Build.csproj index 5f3bdc558f..7afb2e61df 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -8,7 +8,7 @@ <ItemGroup> <PackageReference Include="Cake.Coverlet" Version="2.5.4" /> - <PackageReference Include="Cake.Frosting" Version="1.0.0" /> + <PackageReference Include="Cake.Frosting" Version="1.1.0" /> <PackageReference Include="Cake.Codecov" Version="1.0.0" /> <PackageReference Include="Codecov" Version="1.12.4" /> </ItemGroup> From 356588288e2d07fb4844911f6e03ef129540b124 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Mar 2021 10:36:29 -0300 Subject: [PATCH 031/209] Bump Cake.Codecov from 1.0.0 to 1.0.1 in /build (#2316) Bumps [Cake.Codecov](https://github.com/cake-contrib/Cake.Codecov) from 1.0.0 to 1.0.1. - [Release notes](https://github.com/cake-contrib/Cake.Codecov/releases) - [Changelog](https://github.com/cake-contrib/Cake.Codecov/blob/develop/GitReleaseManager.yaml) - [Commits](https://github.com/cake-contrib/Cake.Codecov/compare/1.0.0...1.0.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/Build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.csproj b/build/Build.csproj index 7afb2e61df..878cc226e9 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -9,7 +9,7 @@ <ItemGroup> <PackageReference Include="Cake.Coverlet" Version="2.5.4" /> <PackageReference Include="Cake.Frosting" Version="1.1.0" /> - <PackageReference Include="Cake.Codecov" Version="1.0.0" /> + <PackageReference Include="Cake.Codecov" Version="1.0.1" /> <PackageReference Include="Codecov" Version="1.12.4" /> </ItemGroup> From 15887d92cf32fc730de2fef95a7b47153a43c9c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Apr 2021 09:37:46 -0300 Subject: [PATCH 032/209] Bump Microsoft.NET.Test.Sdk from 16.8.3 to 16.9.4 (#2318) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.8.3 to 16.9.4. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.8.3...v16.9.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 3fed22f278..94b433bdc9 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 2ca99adb24..b26c47bba4 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -36,7 +36,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 779227af70..cbcbe39600 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -36,7 +36,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> From 9558604273544ad45c143aed7427e1279d77192f Mon Sep 17 00:00:00 2001 From: Brendan Forster <github@brendanforster.com> Date: Tue, 20 Apr 2021 08:09:54 -0300 Subject: [PATCH 033/209] drop Appveyor and Codecov (#2321) --- appveyor.yml | 21 ----------- build/Build.csproj | 2 - build/Context.cs | 2 - build/Lifetime.cs | 1 - build/Tasks/Clean.cs | 5 +-- build/Tasks/CodeCoverage.cs | 75 ------------------------------------- build/Tasks/Package.cs | 1 - 7 files changed, 2 insertions(+), 105 deletions(-) delete mode 100644 appveyor.yml delete mode 100644 build/Tasks/CodeCoverage.cs diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 43a442608a..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,21 +0,0 @@ -image: Visual Studio 2019 - -environment: - IGNORE_NORMALISATION_GIT_HEAD_MOVE: 1 - -branches: - only: - - main - -init: - - git config --global core.autocrlf input - -build_script: - - dotnet --info - - ps: .\build.ps1 -LinkSources -Verbosity Verbose - -test: off - -artifacts: -- path: 'packaging\octokit*.nupkg' - name: OctokitPackages diff --git a/build/Build.csproj b/build/Build.csproj index 878cc226e9..d30897b482 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -9,8 +9,6 @@ <ItemGroup> <PackageReference Include="Cake.Coverlet" Version="2.5.4" /> <PackageReference Include="Cake.Frosting" Version="1.1.0" /> - <PackageReference Include="Cake.Codecov" Version="1.0.1" /> - <PackageReference Include="Codecov" Version="1.12.4" /> </ItemGroup> </Project> diff --git a/build/Context.cs b/build/Context.cs index 16c925a665..e0af2ff004 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -14,8 +14,6 @@ public class Context : FrostingContext public BuildVersion Version { get; set; } public DirectoryPath Artifacts { get; set; } - public DirectoryPath CodeCoverage { get; set; } - public bool IsLocalBuild { get; set; } public bool IsPullRequest { get; set; } public bool IsOriginalRepo { get; set; } diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 4d3ff41317..a28729bb13 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -16,7 +16,6 @@ public override void Setup(Context context) context.FormatCode = context.Argument("formatCode", false); context.Artifacts = "./packaging/"; - context.CodeCoverage = "./coverage-results/"; // Build system information. var buildSystem = context.BuildSystem(); diff --git a/build/Tasks/Clean.cs b/build/Tasks/Clean.cs index f0a82f1473..4737ef3bd9 100644 --- a/build/Tasks/Clean.cs +++ b/build/Tasks/Clean.cs @@ -13,12 +13,11 @@ public override void Run(Context context) var directories = context.GetDirectories("./**/bin", globberSettings) + context.GetDirectories("./**/obj", globberSettings) - + context.Artifacts - + context.CodeCoverage; + + context.Artifacts; foreach (var directory in directories) { context.CleanDirectory(directory); } } -} \ No newline at end of file +} diff --git a/build/Tasks/CodeCoverage.cs b/build/Tasks/CodeCoverage.cs deleted file mode 100644 index a771e32dee..0000000000 --- a/build/Tasks/CodeCoverage.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Cake.Codecov; -using Cake.Common; -using Cake.Common.Build; -using Cake.Common.Diagnostics; -using Cake.Core.IO; -using Cake.Frosting; - -[Dependency(typeof(Build))] -public sealed class CodeCoverage : FrostingTask<Context> -{ - public override void Run(Context context) - { - var coverageFiles = new List<FilePath>(); - - if (context.AppVeyor) - { - foreach (var project in context.Projects.Where(x => x.UnitTests)) - { - context.Information("Executing Code Coverage for Project {0}...", project.Name); - - var dotNetCoreCoverage = context.CodeCoverage - .CombineWithFilePath(project.Name + "-netcoreapp3.1.xml"); - coverageFiles.Add(dotNetCoreCoverage); - - context.Coverlet(project, new CoverletToolSettings() - { - Configuration = context.Configuration, - Framework = "netcoreapp3.1", - Output = dotNetCoreCoverage.FullPath - }); - - if (context.IsRunningOnWindows()) - { - var dotNetFrameworkCoverage = context.CodeCoverage - .CombineWithFilePath(project.Name + "-net46.xml"); - coverageFiles.Add(dotNetFrameworkCoverage); - - context.Coverlet(project, new CoverletToolSettings - { - Configuration = context.Configuration, - Framework = "net46", - Output = dotNetFrameworkCoverage.FullPath - }); - } - - context.Information("Uploading Coverage Files: {0}", string.Join(",", coverageFiles.Select(path => path.GetFilename().ToString()))); - - var buildVersion = $"{context.Version.FullSemVer}.build.{context.EnvironmentVariable("APPVEYOR_BUILD_NUMBER")}"; - - var userProfilePath = context.EnvironmentVariable("USERPROFILE"); - var codecovPath = new DirectoryPath(userProfilePath) - .CombineWithFilePath(".nuget\\packages\\codecov\\1.12.4\\tools\\codecov.exe"); - - context.Tools.RegisterFile(codecovPath); - - foreach (var coverageFile in coverageFiles) - { - var settings = new CodecovSettings - { - Files = new[] { coverageFile.MakeAbsolute(context.Environment).FullPath }, - Verbose = true, - EnvironmentVariables = new Dictionary<string, string>() - { - { "APPVEYOR_BUILD_VERSION", buildVersion} - } - }; - - context.Codecov(settings); - } - } - } - } -} diff --git a/build/Tasks/Package.cs b/build/Tasks/Package.cs index 6562842685..a2988a4b4d 100644 --- a/build/Tasks/Package.cs +++ b/build/Tasks/Package.cs @@ -6,7 +6,6 @@ [Dependency(typeof(UnitTests))] [Dependency(typeof(ConventionTests))] -[Dependency(typeof(CodeCoverage))] [Dependency(typeof(ValidateLINQPadSamples))] public sealed class Package : FrostingTask<Context> { From e9fbe84657976326c8caed7289c0150e38c8adea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 May 2021 08:41:21 -0300 Subject: [PATCH 034/209] Bump Microsoft.NETFramework.ReferenceAssemblies from 1.0.0 to 1.0.2 (#2325) Bumps [Microsoft.NETFramework.ReferenceAssemblies](https://github.com/Microsoft/dotnet) from 1.0.0 to 1.0.2. - [Release notes](https://github.com/Microsoft/dotnet/releases) - [Commits](https://github.com/Microsoft/dotnet/commits) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Reactive/Octokit.Reactive.csproj | 2 +- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- Octokit/Octokit.csproj | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 6df3941d18..aeb9b429da 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -48,7 +48,7 @@ <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> <Reference Include="System" /> <Reference Include="Microsoft.CSharp" /> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> </ItemGroup> </Project> diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 94b433bdc9..655993ea4a 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -39,7 +39,7 @@ </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> </ItemGroup> <ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index b26c47bba4..3636ad8f79 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -51,7 +51,7 @@ </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> </ItemGroup> </Project> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index cbcbe39600..e78142f902 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -45,7 +45,7 @@ <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> <Reference Include="System" /> <Reference Include="Microsoft.CSharp" /> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> </ItemGroup> <ItemGroup> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index d15ddb5ab5..ee3e1bffeb 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -36,7 +36,7 @@ <Reference Include="System.Net.Http" /> <Reference Include="System" /> <Reference Include="Microsoft.CSharp" /> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> </ItemGroup> <ItemGroup> From 28226ea7852f4d4ce1d0a00ff1b7ec3cb4013db1 Mon Sep 17 00:00:00 2001 From: or <or@apiiro.com> Date: Wed, 28 Jul 2021 14:47:15 +0300 Subject: [PATCH 035/209] . --- Octokit/Models/Response/AccountType.cs | 8 +++++++- Octokit/Octokit.csproj | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/AccountType.cs b/Octokit/Models/Response/AccountType.cs index 98f8695dab..584986c6aa 100644 --- a/Octokit/Models/Response/AccountType.cs +++ b/Octokit/Models/Response/AccountType.cs @@ -20,6 +20,12 @@ public enum AccountType /// Bot account /// </summary> [Parameter(Value = "Bot")] - Bot + Bot, + + /// <summary> + /// Mannequin (imported) account + /// </summary> + [Parameter(Value = "Mannequin")] + Mannequin } } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index e72e86f8b6..a134ed0db9 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.1</Version> + <Version>1.0.2</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From f17932d5c1aa124decaf78f3c29a163497bcb3de Mon Sep 17 00:00:00 2001 From: Liri Sokol <liri@apiiro.com> Date: Wed, 28 Jul 2021 16:28:58 +0300 Subject: [PATCH 036/209] Migrated to dotnet 5 --- Octokit.Reactive/Octokit.Reactive.csproj | 2 +- Octokit/Octokit.csproj | 16 ++++------------ global.json | 6 ------ 3 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 global.json diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 6df3941d18..240d790153 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -6,7 +6,7 @@ <Authors>GitHub</Authors> <Version>0.0.0-dev</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> - <TargetFrameworks>netstandard2.0;net46</TargetFrameworks> + <TargetFramework>net5.0</TargetFramework> <AssemblyName>Octokit.Reactive</AssemblyName> <PackageId>Octokit.Reactive</PackageId> <DebugType>embedded</DebugType> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a134ed0db9..8c30f01b39 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -16,20 +16,12 @@ <PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageTags>GitHub API Octokit linqpad-samples dotnetcore</PackageTags> <Copyright>Copyright GitHub 2017</Copyright> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net5.0</TargetFramework> + <LangVersion>9</LangVersion> </PropertyGroup> - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <DefineConstants>$(DefineConstants);HAS_TYPEINFO;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> - <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> - </PropertyGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'net46' "> - <DefineConstants>$(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;HAS_SERVICEPOINTMANAGER</DefineConstants> - </PropertyGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' "> - <DefineConstants>$(DefineConstants);SIMPLE_JSON_READONLY_COLLECTIONS</DefineConstants> + <PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' "> + <DefineConstants>$(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;HAS_SERVICEPOINTMANAGERS</DefineConstants> </PropertyGroup> <PropertyGroup> diff --git a/global.json b/global.json deleted file mode 100644 index 14afd189a9..0000000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sdk": { - "version": "3.1.200", - "rollForward": "latestMinor" - } -} From 2315ef762cc75279803c47e4307209aff53a3e72 Mon Sep 17 00:00:00 2001 From: Sean Killeen <SeanKilleen@gmail.com> Date: Mon, 23 Aug 2021 08:26:15 -0400 Subject: [PATCH 037/209] Master --> main text in README (#2345) --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4d4accdcf9..3232bc2cd2 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ dotnet add package Octokit.Reactive ### Beta packages ### -Unstable NuGet packages that track the master branch of this repository are available at +Unstable NuGet packages that track the `main` branch of this repository are available at [https://ci.appveyor.com/nuget/octokit-net](https://ci.appveyor.com/nuget/octokit-net) In Xamarin Studio you can find this option under the project's context menu: **Add | Add Packages...***. @@ -73,9 +73,9 @@ Linux/OSX: `./build.sh` ## Contribute -Visit the [Contributor Guidelines](https://github.com/octokit/octokit.net/blob/master/CONTRIBUTING.md) +Visit the [Contributor Guidelines](https://github.com/octokit/octokit.net/blob/main/CONTRIBUTING.md) for more details. All contributors are expected to follow our -[Code of Conduct](https://github.com/octokit/octokit.net/blob/master/CODE_OF_CONDUCT.md). +[Code of Conduct](https://github.com/octokit/octokit.net/blob/main/CODE_OF_CONDUCT.md). ## Problems? @@ -104,4 +104,4 @@ problem. Copyright 2017 GitHub, Inc. -Licensed under the [MIT License](https://github.com/octokit/octokit.net/blob/master/LICENSE.txt) +Licensed under the [MIT License](https://github.com/octokit/octokit.net/blob/main/LICENSE.txt) From b829a8443e3de9594687a720eb9c09a8dac1f5fd Mon Sep 17 00:00:00 2001 From: Pedro Brito <pedromacieirabrito@gmail.com> Date: Mon, 23 Aug 2021 13:27:09 +0100 Subject: [PATCH 038/209] Add Swift language (#2344) Co-authored-by: Pedro Brito <Pedro.Brito@checkmarx.com> --- Octokit/Models/Request/SearchRepositoriesRequest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index 9e1869713f..3a13b9dba3 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -840,6 +840,8 @@ public enum Language [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "SuperCollider")] [Parameter(Value = "SuperCollider")] SuperCollider, + [Parameter(Value = "Swift")] + Swift, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Tcl")] Tcl, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Tcsh")] From e52e6d71b750a43b7382806d75ae25c2ebec0502 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Aug 2021 09:28:14 -0300 Subject: [PATCH 039/209] Bump GitHubJwt from 0.0.4 to 0.0.5 (#2348) Bumps [GitHubJwt](https://github.com/adriangodong/githubjwt) from 0.0.4 to 0.0.5. - [Release notes](https://github.com/adriangodong/githubjwt/releases) - [Commits](https://github.com/adriangodong/githubjwt/compare/0.0.4...0.0.5) --- updated-dependencies: - dependency-name: GitHubJwt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 3636ad8f79..b4b9e19a42 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -47,7 +47,7 @@ </ItemGroup> <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'"> - <PackageReference Include="GitHubJwt" Version="0.0.4" /> + <PackageReference Include="GitHubJwt" Version="0.0.5" /> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> From b4d7fb09784f5695fb1360ca40d88262e9bc519f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Aug 2021 09:28:25 -0300 Subject: [PATCH 040/209] Bump Microsoft.NET.Test.Sdk from 16.9.4 to 16.11.0 (#2350) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.9.4 to 16.11.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.9.4...v16.11.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 655993ea4a..9677af5ae3 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index b4b9e19a42..739074bca8 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -36,7 +36,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index e78142f902..514a5c79c6 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -36,7 +36,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> From 77213430f1a1fd87bae61b6339d2fa3bb1802bc4 Mon Sep 17 00:00:00 2001 From: Union Palenshus <palenshus@users.noreply.github.com> Date: Wed, 20 Apr 2022 14:29:10 -0700 Subject: [PATCH 041/209] Adding support for the Device Flow Oauth authentication pattern (#2310) Adding support for the Device Flow Oauth authentication pattern --- .../Clients/IObservableOauthClient.cs | 22 ++++++ .../Clients/ObservableOauthClient.cs | 28 ++++++++ Octokit.Tests/Clients/OauthClientTests.cs | 66 ++++++++++++++++- Octokit/Clients/IOAuthClient.cs | 22 ++++++ Octokit/Clients/OAuthClient.cs | 71 +++++++++++++++++++ Octokit/Helpers/ApiUrls.cs | 9 +++ .../Models/Request/OauthDeviceFlowRequest.cs | 54 ++++++++++++++ .../Request/OauthTokenRequestForDeviceFlow.cs | 55 ++++++++++++++ .../Response/OauthDeviceFlowResponse.cs | 61 ++++++++++++++++ Octokit/Models/Response/OauthToken.cs | 42 ++++++++--- 10 files changed, 418 insertions(+), 12 deletions(-) create mode 100644 Octokit/Models/Request/OauthDeviceFlowRequest.cs create mode 100644 Octokit/Models/Request/OauthTokenRequestForDeviceFlow.cs create mode 100644 Octokit/Models/Response/OauthDeviceFlowResponse.cs diff --git a/Octokit.Reactive/Clients/IObservableOauthClient.cs b/Octokit.Reactive/Clients/IObservableOauthClient.cs index 2afa944c00..88c7a3547d 100644 --- a/Octokit.Reactive/Clients/IObservableOauthClient.cs +++ b/Octokit.Reactive/Clients/IObservableOauthClient.cs @@ -24,5 +24,27 @@ public interface IObservableOauthClient /// <param name="request"></param> /// <returns></returns> IObservable<OauthToken> CreateAccessToken(OauthTokenRequest request); + + /// <summary> + /// Makes a request to initiate the device flow authentication. + /// </summary> + /// <remarks> + /// Returns a user verification code and verification URL that the you will use to prompt the user to authenticate. + /// This request also returns a device verification code that you must use to receive an access token to check the status of user authentication. + /// </remarks> + /// <param name="request"></param> + /// <returns></returns> + IObservable<OauthDeviceFlowResponse> InitiateDeviceFlow(OauthDeviceFlowRequest request); + + /// <summary> + /// Makes a request to get an access token using the response from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/>. + /// </summary> + /// <remarks> + /// Will poll the access token endpoint, until the device and user codes expire or the user has successfully authorized the app with a valid user code. + /// </remarks> + /// <param name="clientId">The client Id you received from GitHub when you registered the application.</param> + /// <param name="deviceFlowResponse">The response you received from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/></param> + /// <returns></returns> + IObservable<OauthToken> CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse); } } diff --git a/Octokit.Reactive/Clients/ObservableOauthClient.cs b/Octokit.Reactive/Clients/ObservableOauthClient.cs index 62cce34790..fb51cd5c4d 100644 --- a/Octokit.Reactive/Clients/ObservableOauthClient.cs +++ b/Octokit.Reactive/Clients/ObservableOauthClient.cs @@ -40,5 +40,33 @@ public IObservable<OauthToken> CreateAccessToken(OauthTokenRequest request) { return _client.Oauth.CreateAccessToken(request).ToObservable(); } + + /// <summary> + /// Makes a request to initiate the device flow authentication. + /// </summary> + /// <remarks> + /// Returns a user verification code and verification URL that the you will use to prompt the user to authenticate. + /// This request also returns a device verification code that you must use to receive an access token to check the status of user authentication. + /// </remarks> + /// <param name="request"></param> + /// <returns></returns> + public IObservable<OauthDeviceFlowResponse> InitiateDeviceFlow(OauthDeviceFlowRequest request) + { + return _client.Oauth.InitiateDeviceFlow(request).ToObservable(); + } + + /// <summary> + /// Makes a request to get an access token using the response from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/>. + /// </summary> + /// <remarks> + /// Will poll the access token endpoint, until the device and user codes expire or the user has successfully authorized the app with a valid user code. + /// </remarks> + /// <param name="clientId">The client Id you received from GitHub when you registered the application.</param> + /// <param name="deviceFlowResponse">The response you received from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/></param> + /// <returns></returns> + public IObservable<OauthToken> CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse) + { + return _client.Oauth.CreateAccessTokenForDeviceFlow(clientId, deviceFlowResponse).ToObservable(); + } } } diff --git a/Octokit.Tests/Clients/OauthClientTests.cs b/Octokit.Tests/Clients/OauthClientTests.cs index b2bf4228ac..a6f5187024 100644 --- a/Octokit.Tests/Clients/OauthClientTests.cs +++ b/Octokit.Tests/Clients/OauthClientTests.cs @@ -65,7 +65,7 @@ public class TheCreateAccessTokenMethod [Fact] public async Task PostsWithCorrectBodyAndContentType() { - var responseToken = new OauthToken(null, null, null); + var responseToken = new OauthToken(null, null, null, null, null, null); var response = Substitute.For<IApiResponse<OauthToken>>(); response.Body.Returns(responseToken); var connection = Substitute.For<IConnection>(); @@ -99,7 +99,7 @@ public async Task PostsWithCorrectBodyAndContentType() [Fact] public async Task PostsWithCorrectBodyAndContentTypeForGHE() { - var responseToken = new OauthToken(null, null, null); + var responseToken = new OauthToken(null, null, null, null, null, null); var response = Substitute.For<IApiResponse<OauthToken>>(); response.Body.Returns(responseToken); var connection = Substitute.For<IConnection>(); @@ -130,6 +130,68 @@ public async Task PostsWithCorrectBodyAndContentTypeForGHE() await calledBody.ReadAsStringAsync()); } + [Fact] + public async Task InitiateDeviceFlowPostsWithCorrectBodyAndContentType() + { + var responseToken = new OauthDeviceFlowResponse("devicecode", "usercode", "uri", 10, 5); + var response = Substitute.For<IApiResponse<OauthDeviceFlowResponse>>(); + response.Body.Returns(responseToken); + var connection = Substitute.For<IConnection>(); + connection.BaseAddress.Returns(new Uri("https://api.github.com/")); + Uri calledUri = null; + FormUrlEncodedContent calledBody = null; + Uri calledHostAddress = null; + connection.Post<OauthDeviceFlowResponse>( + Arg.Do<Uri>(uri => calledUri = uri), + Arg.Do<object>(body => calledBody = body as FormUrlEncodedContent), + "application/json", + null, + Arg.Do<Uri>(uri => calledHostAddress = uri)) + .Returns(_ => Task.FromResult(response)); + var client = new OauthClient(connection); + + var token = await client.InitiateDeviceFlow(new OauthDeviceFlowRequest("clientid")); + + Assert.Same(responseToken, token); + Assert.Equal("login/device/code", calledUri.ToString()); + Assert.NotNull(calledBody); + Assert.Equal("https://github.com/", calledHostAddress.ToString()); + Assert.Equal( + "client_id=clientid", + await calledBody.ReadAsStringAsync()); + } + + [Fact] + public async Task CreateAccessTokenForDeviceFlowPostsWithCorrectBodyAndContentType() + { + var responseToken = new OauthToken(null, null, null, null, null, null); + var response = Substitute.For<IApiResponse<OauthToken>>(); + response.Body.Returns(responseToken); + var connection = Substitute.For<IConnection>(); + connection.BaseAddress.Returns(new Uri("https://api.github.com/")); + Uri calledUri = null; + FormUrlEncodedContent calledBody = null; + Uri calledHostAddress = null; + connection.Post<OauthToken>( + Arg.Do<Uri>(uri => calledUri = uri), + Arg.Do<object>(body => calledBody = body as FormUrlEncodedContent), + "application/json", + null, + Arg.Do<Uri>(uri => calledHostAddress = uri)) + .Returns(_ => Task.FromResult(response)); + var client = new OauthClient(connection); + + var token = await client.CreateAccessTokenForDeviceFlow("clientid", new OauthDeviceFlowResponse("devicecode", "usercode", "uri", 10, 5)); + + Assert.Same(responseToken, token); + Assert.Equal("login/oauth/access_token", calledUri.ToString()); + Assert.NotNull(calledBody); + Assert.Equal("https://github.com/", calledHostAddress.ToString()); + Assert.Equal( + "client_id=clientid&device_code=devicecode&grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code", + await calledBody.ReadAsStringAsync()); + } + [Fact] public async Task DeserializesOAuthScopeFormat() { diff --git a/Octokit/Clients/IOAuthClient.cs b/Octokit/Clients/IOAuthClient.cs index b0bde0191a..2d8af15299 100644 --- a/Octokit/Clients/IOAuthClient.cs +++ b/Octokit/Clients/IOAuthClient.cs @@ -28,5 +28,27 @@ public interface IOauthClient /// <param name="request"></param> /// <returns></returns> Task<OauthToken> CreateAccessToken(OauthTokenRequest request); + + /// <summary> + /// Makes a request to initiate the device flow authentication. + /// </summary> + /// <remarks> + /// Returns a user verification code and verification URL that the you will use to prompt the user to authenticate. + /// This request also returns a device verification code that you must use to receive an access token to check the status of user authentication. + /// </remarks> + /// <param name="request"></param> + /// <returns></returns> + Task<OauthDeviceFlowResponse> InitiateDeviceFlow(OauthDeviceFlowRequest request); + + /// <summary> + /// Makes a request to get an access token using the response from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/>. + /// </summary> + /// <remarks> + /// Will poll the access token endpoint, until the device and user codes expire or the user has successfully authorized the app with a valid user code. + /// </remarks> + /// <param name="clientId">The client Id you received from GitHub when you registered the application.</param> + /// <param name="deviceFlowResponse">The response you received from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/></param> + /// <returns></returns> + Task<OauthToken> CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse); } } diff --git a/Octokit/Clients/OAuthClient.cs b/Octokit/Clients/OAuthClient.cs index 655fe00be9..75b477f988 100644 --- a/Octokit/Clients/OAuthClient.cs +++ b/Octokit/Clients/OAuthClient.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Net.Http; using System.Threading.Tasks; @@ -69,5 +70,75 @@ public async Task<OauthToken> CreateAccessToken(OauthTokenRequest request) var response = await connection.Post<OauthToken>(endPoint, body, "application/json", null, hostAddress).ConfigureAwait(false); return response.Body; } + + /// <summary> + /// Makes a request to initiate the device flow authentication. + /// </summary> + /// <remarks> + /// Returns a user verification code and verification URL that the you will use to prompt the user to authenticate. + /// This request also returns a device verification code that you must use to receive an access token to check the status of user authentication. + /// </remarks> + /// <param name="request"></param> + /// <returns></returns> + [ManualRoute("POST", "/login/device/code")] + public async Task<OauthDeviceFlowResponse> InitiateDeviceFlow(OauthDeviceFlowRequest request) + { + Ensure.ArgumentNotNull(request, nameof(request)); + + var endPoint = ApiUrls.OauthDeviceCode(); + + var body = new FormUrlEncodedContent(request.ToParametersDictionary()); + + var response = await connection.Post<OauthDeviceFlowResponse>(endPoint, body, "application/json", null, hostAddress).ConfigureAwait(false); + return response.Body; + } + + /// <summary> + /// Makes a request to get an access token using the response from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/>. + /// </summary> + /// <remarks> + /// Will poll the access token endpoint, until the device and user codes expire or the user has successfully authorized the app with a valid user code. + /// </remarks> + /// <param name="clientId">The client Id you received from GitHub when you registered the application.</param> + /// <param name="deviceFlowResponse">The response you received from <see cref="InitiateDeviceFlow(OauthDeviceFlowRequest)"/></param> + /// <returns></returns> + [ManualRoute("POST", "/login/oauth/access_token")] + public async Task<OauthToken> CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse) + { + Ensure.ArgumentNotNullOrEmptyString(clientId, nameof(clientId)); + Ensure.ArgumentNotNull(deviceFlowResponse, nameof(deviceFlowResponse)); + + var endPoint = ApiUrls.OauthAccessToken(); + + int pollingDelay = deviceFlowResponse.Interval; + + while (true) + { + var request = new OauthTokenRequestForDeviceFlow(clientId, deviceFlowResponse.DeviceCode); + var body = new FormUrlEncodedContent(request.ToParametersDictionary()); + var response = await connection.Post<OauthToken>(endPoint, body, "application/json", null, hostAddress).ConfigureAwait(false); + + if (response.Body.Error != null) + { + switch (response.Body.Error) + { + case "authorization_pending": + break; + case "slow_down": + pollingDelay += 5; + break; + case "expired_token": + default: + throw new ApiException(string.Format(CultureInfo.InvariantCulture, "{0}: {1}\n{2}", response.Body.Error, response.Body.ErrorDescription, response.Body.ErrorUri), null); + } + + await Task.Delay(TimeSpan.FromSeconds(pollingDelay)); + } + else + { + return response.Body; + } + } + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 74f0ff3f9c..48b5660ac5 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2350,6 +2350,15 @@ public static Uri OauthAuthorize() return "login/oauth/authorize".FormatUri(); } + /// <summary> + /// Creates the relative <see cref="Uri"/> for initiating the OAuth device Flow + /// </summary> + /// <returns></returns> + public static Uri OauthDeviceCode() + { + return "login/device/code".FormatUri(); + } + /// <summary> /// Creates the relative <see cref="Uri"/> to request an OAuth access token. /// </summary> diff --git a/Octokit/Models/Request/OauthDeviceFlowRequest.cs b/Octokit/Models/Request/OauthDeviceFlowRequest.cs new file mode 100644 index 0000000000..5e3ba24cbb --- /dev/null +++ b/Octokit/Models/Request/OauthDeviceFlowRequest.cs @@ -0,0 +1,54 @@ +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Globalization; +using Octokit.Internal; + +namespace Octokit +{ + /// <summary> + /// Used to create an Oauth device flow initiation request. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OauthDeviceFlowRequest + : RequestParameters + { + /// <summary> + /// Creates an instance of the OAuth login request with the required parameter. + /// </summary> + /// <param name="clientId">The client Id you received from GitHub when you registered the application.</param> + public OauthDeviceFlowRequest(string clientId) + { + Ensure.ArgumentNotNullOrEmptyString(clientId, nameof(clientId)); + + ClientId = clientId; + Scopes = new Collection<string>(); + } + + /// <summary> + /// The client Id you received from GitHub when you registered the application. + /// </summary> + [Parameter(Key = "client_id")] + public string ClientId { get; private set; } + + /// <summary> + /// A set of scopes to request. If not provided, scope defaults to an empty list of scopes for users that don’t + /// have a valid token for the app. For users who do already have a valid token for the app, the user won't be + /// shown the OAuth authorization page with the list of scopes. Instead, this step of the flow will + /// automatically complete with the same scopes that were used last time the user completed the flow. + /// </summary> + /// <remarks> + /// See the <see href="https://developer.github.com/v3/oauth/#scopes">scopes documentation</see> for more + /// information about scopes. + /// </remarks> + [Parameter(Key = "scope")] + public Collection<string> Scopes { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "ClientId: {0}, Scopes: {1}", ClientId, Scopes); + } + } + } +} diff --git a/Octokit/Models/Request/OauthTokenRequestForDeviceFlow.cs b/Octokit/Models/Request/OauthTokenRequestForDeviceFlow.cs new file mode 100644 index 0000000000..b53e1406ac --- /dev/null +++ b/Octokit/Models/Request/OauthTokenRequestForDeviceFlow.cs @@ -0,0 +1,55 @@ +using System.Diagnostics; +using System.Globalization; +using Octokit.Internal; + +namespace Octokit +{ + /// <summary> + /// Used to create an Oauth login request for the device flow. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + internal class OauthTokenRequestForDeviceFlow : RequestParameters + { + /// <summary> + /// Creates an instance of the OAuth login request with the required parameter. + /// </summary> + /// <param name="clientId">The client Id you received from GitHub when you registered the application.</param> + /// <param name="deviceCode">The device code you received from the device flow initiation call.</param> + public OauthTokenRequestForDeviceFlow(string clientId, string deviceCode) + { + Ensure.ArgumentNotNullOrEmptyString(clientId, nameof(clientId)); + Ensure.ArgumentNotNullOrEmptyString(deviceCode, nameof(deviceCode)); + + ClientId = clientId; + DeviceCode = deviceCode; + } + + /// <summary> + /// The client Id you received from GitHub when you registered the application. + /// </summary> + [Parameter(Key = "client_id")] + public string ClientId { get; private set; } + + /// <summary> + /// The device code you received from the device flow initiation call. + /// </summary> + [Parameter(Key = "device_code")] + public string DeviceCode { get; private set; } + + /// <summary> + /// The authorization grant type. + /// </summary> + [Parameter(Key = "grant_type")] + public string GrantType => "urn:ietf:params:oauth:grant-type:device_code"; + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "ClientId: {0}, DeviceCode: {1}", + ClientId, + DeviceCode); + } + } + } +} diff --git a/Octokit/Models/Response/OauthDeviceFlowResponse.cs b/Octokit/Models/Response/OauthDeviceFlowResponse.cs new file mode 100644 index 0000000000..2f3ab0ad94 --- /dev/null +++ b/Octokit/Models/Response/OauthDeviceFlowResponse.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OauthDeviceFlowResponse + { + public OauthDeviceFlowResponse() { } + + public OauthDeviceFlowResponse(string deviceCode, string userCode, string verificationUri, int expiresIn, int interval) + { + DeviceCode = deviceCode; + UserCode = userCode; + VerificationUri = verificationUri; + ExpiresIn = expiresIn; + Interval = interval; + } + + /// <summary> + /// The device verification code is 40 characters and used to verify the device. + /// </summary> + public string DeviceCode { get; private set; } + + /// <summary> + /// The user verification code is displayed on the device so the user can enter the code in a browser. This code is 8 characters with a hyphen in the middle. + /// </summary> + public string UserCode { get; private set; } + + /// <summary> + /// The verification URL where users need to enter the UserCode: https://github.com/login/device. + /// </summary> + public string VerificationUri { get; private set; } + + /// <summary> + /// The number of seconds before the DeviceCode and UserCode expire. The default is 900 seconds or 15 minutes. + /// </summary> + public int ExpiresIn { get; private set; } + + /// <summary> + /// The minimum number of seconds that must pass before you can make a new access token request (POST https://github.com/login/oauth/access_token) to complete the device authorization. + /// For example, if the interval is 5, then you cannot make a new request until 5 seconds pass. If you make more than one request over 5 seconds, then you will hit the rate limit + /// and receive a slow_down error. + /// </summary> + public int Interval { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "DeviceCode: {0}, UserCode: {1}, VerificationUri: {2}, ExpiresIn: {3}, Interval: {4}", + DeviceCode, + UserCode, + VerificationUri, + ExpiresIn, + Interval); + } + } + } +} diff --git a/Octokit/Models/Response/OauthToken.cs b/Octokit/Models/Response/OauthToken.cs index e61f2b1ea2..b7ecd50b88 100644 --- a/Octokit/Models/Response/OauthToken.cs +++ b/Octokit/Models/Response/OauthToken.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using Octokit.Internal; namespace Octokit { @@ -9,36 +10,57 @@ public class OauthToken { public OauthToken() { } - public OauthToken(string tokenType, string accessToken, IReadOnlyList<string> scope) + public OauthToken(string tokenType, string accessToken, IReadOnlyList<string> scope, string error, string errorDescription, string errorUri) { - TokenType = tokenType; - AccessToken = accessToken; - Scope = scope; + this.TokenType = tokenType; + this.AccessToken = accessToken; + this.Scope = scope; + this.Error = error; + this.ErrorDescription = errorDescription; + this.ErrorUri = errorUri; } /// <summary> /// The type of OAuth token /// </summary> - public string TokenType { get; protected set; } + public string TokenType { get; private set; } /// <summary> /// The secret OAuth access token. Use this to authenticate Octokit.net's client. /// </summary> - public string AccessToken { get; protected set; } + public string AccessToken { get; private set; } /// <summary> /// The list of scopes the token includes. /// </summary> - public IReadOnlyList<string> Scope { get; protected set; } + public IReadOnlyList<string> Scope { get; private set; } + + /// <summary> + /// Gets or sets the error code or the response. + /// </summary> + [Parameter(Key = "error")] + public string Error { get; private set; } + + /// <summary> + /// Gets or sets the error description. + /// </summary> + [Parameter(Key = "error_description")] + public string ErrorDescription { get; private set; } + + /// <summary> + /// Gets or sets the error uri. + /// </summary> + [Parameter(Key = "error_uri")] + public string ErrorUri { get; private set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "TokenType: {0}, AccessToken: {1}, Scopes: {2}", - TokenType, - AccessToken, - Scope); + this.TokenType, + this.AccessToken, + this.Scope); } } } From c4e6fcdbccc9a34e1b5c84e948edc34f2d9990d5 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Wed, 27 Apr 2022 14:49:19 -0500 Subject: [PATCH 042/209] Updates the repo docs with the current release workflow (#2438) * updates the repo docs with the current release workflow --- DEPLOYMENT.md | 66 ++- ReleaseNotes.md | 997 ------------------------------------------- docs/contributing.md | 20 +- mkdocs.yml | 2 +- 4 files changed, 72 insertions(+), 1013 deletions(-) delete mode 100644 ReleaseNotes.md diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index bc84029763..1de4dc0525 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -1,19 +1,59 @@ ## Deploying a new release -When we're ready to deploy a new release, we need to do the following steps: +### Requirements + +Creating a new release and deploying the package to nuget are administrative tasks and require that you have/do the following: +1. Admin access to the [GitHub](https://www.nuget.org/profiles/GitHub) NuGet organization +2. Admin rights to the [octokit.net](https://github.com/octokit/octokit.net) repository +3. For any PRs that should be noted in the release notes, each pull request must have a comment formatted like `release_notes: description` where description represents the details of the change. + +### Prepare the changeset & publish to nuget.org 1. Create a branch named `release`. -2. Update [`ReleaseNotes.md`](ReleaseNotes.md). Note that the format is -important as we parse the version out and use that for the NuGet packages. -3. Push the branch to GitHub and create a pull request. This will kick off the -MyGet build of the NuGet package with this new version. - If you're impatient, you can run `.\build CreatePackages` and get the packages locally. -4. Test! -5. When you're satisfied with this release, push the package -[from MyGet](https://www.myget.org/feed/Packages/octokit) to NuGet. -6. Create a tag `git tag v#.#.#`. For example, to create a tag for 1.0.0 +2. Push the branch to GitHub and create a pull request. This will kick off the CI builds to verify the changes. +3. Test! +4. [Generate](https://github.com/shiftkey/octokit.releasenotes) the release notes. `Octokit.ReleaseNotes generate v0.50.0 [BASE] [HEAD]` + Any PRs that should be noted in the release notes, each pull request must have a comment formatted like `release_notes: description` where description represents the details of the change. Make sure for the commit range any changeset in a PR that should be represented has a comment on the PR prefixed with `release_notes:` and corresponding label (details below) +5. When you're satisfied with this release, create a tag `git tag v#.#.#`. For example, to create a tag for 1.0.0 `git tag v1.0.0` -7. Push the tag to the server. `git push --tags` -8. Accept the pull request. +6. Push the tag to the server. `git push --tags` +7. When the tag is successfully pushed, the [publish workflow](https://github.com/octokit/octokit.net/blob/main/.github/workflows/publish.yml) will run and build and push the package to nuget +8. Verify that the package has been uploaded to [nuget.org](https://www.nuget.org/packages/Octokit/) +8. Accept the pull request 9. Create a [new release](https://github.com/octokit/octokit.net/releases/new) -using the tag you just created and pasting in the release notes you just wrote up +using the tag you just created and pasting in the release notes you just generated + +--- + +### Details on the release notes generator + +Release notes [generator](https://github.com/shiftkey/octokit.releasenotes): this is used to pull details using the GitHub API to generate the release notes. + +The generator helps in that it produces release notes that are consistently formatted based on information directly from the change scope (from the previous release to the current tip i.e. the `release` branch). + +The nuances are mostly around how it gets and parses release notes from the PRs found in the changeset. The following are the comment prefixes that the generator currently supports: + +* `release_notes` - Having this in the comment with a corresponding "category" label on the PR will put the given note under the "Release Notes" section of the output in the group for the given label +* `advisories` - Having this in the comment will put the given note into the "Advisories and Breaking Changes" section of the output + +In addition to formatted comment parsing, the generator also looks at the following labels to generate categories with in the release notes. + +* `category: bug` - This will add the comment in the PR prefixed with `release_notes` into the `Fixes` group +* `category: docs-and-samples` - This will add the comment in the PR prefixed with `release_notes` into the `Documentation Updates` group +* `category: feature` - This will add the comment in the PR prefixed with `release_notes` into the `Features/Enhancements` group +* `category: housekeeping` - This will add the comment in the PR prefixed with `release_notes` into the `Housekeeping` group + +When these labels are added to a given PR the generator will produce and categorize comment in the release notes formatted like: + +`Comment content` - `PR Id and link` via `Contributor` +ex. "Cleans up some mentions of `master` branch in codebase - [#2306](https://github.com/octokit/octokit.net/pull/2306) via [@shiftkey](https://github.com/shiftkey)" + +---- +### Troubleshooting + +When running the release notes generator on a mac if dotnet has not been added to the PATH or there is not alias defined in your dotfiles you'll need to execute the command as follows: + +`dotnet run generate [BASE] [HEAD]` +(where `[BASE]` is the last release label (i.e. v0.50.0) and `[HEAD]` represents the `release` branch tip that was generated above) + +The tool looks for a environment variable named `OCTOKIT_OAUTHTOKEN`. This token requires a minimal scope to execute and pull the data from the repository via API. Keep in mind that if a token is not provided then you will most likely run into rate limit errors because the requests are being made anonymously. diff --git a/ReleaseNotes.md b/ReleaseNotes.md deleted file mode 100644 index fbdb2f26b6..0000000000 --- a/ReleaseNotes.md +++ /dev/null @@ -1,997 +0,0 @@ -### New in 0.32.0 (released 09/09/2018) - -## Advisories and Breaking Changes - -- Due to upstream breaking changes in the CheckRuns API, using check runs against github.com will require using the new/renamed fields on `CheckRunAnnotation` response and `NewCheckRunAnnotation` request models. However the old fields are maintained in octokit.net (marked as deprecated) to continue supporting GitHub Enterprise 2.14, which will not receive these changes. Users of GHE 2.14 should use the old fields, whilst users of github.com should update to use the new fields - -## Release Notes - -### Milestone: GitHub Apps - -**Features/Enhancements** - -- Adjust GitHub App Installation Access Token route in line with [announced API changes](https://developer.github.com/changes/2018-08-16-renaming-and-deprecation-of-github-app-installation-access-token-route/) - [#1860](https://github.com/octokit/octokit.net/pull/1860) via [@ryangribble](https://github.com/ryangribble) -- Implement additional endpoints for GitHub Apps to find installations for a given organization, repository or user - [#1854](https://github.com/octokit/octokit.net/pull/1854) via [@StanleyGoldman](https://github.com/StanleyGoldman), [@ryangribble](https://github.com/ryangribble) -- Implement GitHub Apps Installation API to allow listing all repositories a GitHub App Installation or GitHub App authenticated user has access to - [#1854](https://github.com/octokit/octokit.net/pull/1854) via [@StanleyGoldman](https://github.com/StanleyGoldman), [@ryangribble](https://github.com/ryangribble) -- Implement new/changed fields on `CheckRunAnnotation` response and `NewCheckRunAnnotation` request models - replace `Filename` with `Path`, `WarningLevel` with `AnnotationLevel` and add `StartColumn` and `EndColumn` - [#1857](https://github.com/octokit/octokit.net/pull/1857) via [@ryangribble](https://github.com/ryangribble) -- Add new method `CheckSuitesClient.Rerequest()` and mark the old `CheckSuitesClient.Request()` method as deprecated (this will no longer function on github.com but will continue to be supported on GitHub Enterprise 2.14) - [#1857](https://github.com/octokit/octokit.net/pull/1857) via [@ryangribble](https://github.com/ryangribble) - -**Fixes** - -- Adjust `StartedAt` and `Status` fields of `NewCheckRun` and `CheckRunUpdate` requests, to allow `null` values, avoiding resetting these to default values when not specified - [#1852](https://github.com/octokit/octokit.net/pull/1852) via [@Cyberboss](https://github.com/Cyberboss), [@ryangribble](https://github.com/ryangribble) - -**Documentation Updates** - -- Fixed code samples in GitHub Apps sample docs to use the correct sub client property name - [#1853](https://github.com/octokit/octokit.net/pull/1853) via [@d-a-s](https://github.com/d-a-s) - - -### Milestone: None - -**Fixes** - -- `IssueLabelsClient.RemoveFromIssue()` no longer fails with a HTTP 400 "Bad Request" error from the GitHub Api - [#1868](https://github.com/octokit/octokit.net/pull/1868) via [@ryangribble](https://github.com/ryangribble) - - -### New in 0.31.0 (released 21/07/2018) - -## Advisories and Breaking Changes - -- None - -## Release Notes - -### Milestone: GitHub Apps - -**Features/Enhancements** - -- Implemented Check Suites component of [New Checks Api (Public Beta)](https://developer.github.com/changes/2018-05-07-new-checks-api-public-beta/) - [#1846](https://github.com/octokit/octokit.net/pull/1846) via [@ryangribble](https://github.com/ryangribble), [@Cyberboss](https://github.com/Cyberboss) -- Implemented Check Runs component of [New Checks Api (Public Beta)](https://developer.github.com/changes/2018-05-07-new-checks-api-public-beta/) - [#1847](https://github.com/octokit/octokit.net/pull/1847) via [@ryangribble](https://github.com/ryangribble), [@Cyberboss](https://github.com/Cyberboss) - - -### Milestone: None - -**Features/Enhancements** - -- Add new `EventInfoState` values (`MarkedAsDuplicate`, `UnmarkedAsDuplicate` and `CommentDeleted`) - [#1818](https://github.com/octokit/octokit.net/pull/1818) via [@mirsaeedi](https://github.com/mirsaeedi) -- Add GraphQL NodeId property to all affected response models - [#1806](https://github.com/octokit/octokit.net/pull/1806) via [@ryangribble](https://github.com/ryangribble) -- Implemented [New API parameters for Project Card archiving (Preview)](https://developer.github.com/changes/2018-06-27-project-card-archiving/) including `ProjectCard.Archived`, `ProjectCardUpdate.Archived` and new `ProjectCardRequest` request - [#1842](https://github.com/octokit/octokit.net/pull/1842) via [@ryangribble](https://github.com/ryangribble) -- Implement support for [Archiving repositories](https://developer.github.com/changes/2017-11-08-archiving-repositories/) including adding `Archived` property to `Repository` response model, adding the ability to archive a repository via `UpdateRepository.Archived` request, and filtering repo/issues searches with `SearchRepositoriesRequest.Archived` and `SearchIssuesRequest.Archived` - [#1845](https://github.com/octokit/octokit.net/pull/1845) via [@jguevara](https://github.com/jguevara), [@ryangribble](https://github.com/ryangribble) - -**Fixes** - -- Fix exception in `RepositoriesClient.GetAllLanguages()` when no languages exist - [#1831](https://github.com/octokit/octokit.net/pull/1831) via [@ryangribble](https://github.com/ryangribble) - -**Housekeeping** - -- Remove nuget dependency on `SourceLink.Create.GitHub` package - [#1822](https://github.com/octokit/octokit.net/pull/1822) via [@ryangribble](https://github.com/ryangribble) - -**Documentation Updates** - -- Clarify the rate limit `Reset` field is in UTC - [#1819](https://github.com/octokit/octokit.net/pull/1819) via [@mirsaeedi](https://github.com/mirsaeedi) -- Revise GitHub Apps walkthrough documentation to provide more clarity - [#1824](https://github.com/octokit/octokit.net/pull/1824) via [@ryangribble](https://github.com/ryangribble) - - -### New in 0.30.0 (released 17/06/2018) - -## Advisories and Breaking Changes - -- Note that the `IssuesLabelsClient.RemoveFromIssue()` methods which previously had no return value, will now return an `IReadonlyList<Label>`. This change is source compatible but not binary compatible. -- The following `[Obsolete]` items have been removed from octokit, please use the indicated replacements: - -Client Methods -- `OranizationsClient.GetAll()` => `GetAllForUser()` -- `PullRequestsClient.Comment` => `ReviewComment` -- `RepositoryBranchesClient.GetRequiredStatusChecksContexts()` => `GetAllRequiredStatusChecksContexts()` -- `RepositoryBranchesClient.GetProtectedBranchTeamRestrictions()` => `GetAllProtectedBranchTeamRestrictions()` -- `RepositoryBranchesClient.GetProtectedBranchUserRestrictions()` => `GetAllProtectedBranchUserRestrictions()` -- `RepositoryTrafficClient.GetReferrers()` => `GetAllReferrers()` -- `RepositoryTrafficClient.GetPaths()` => `GetAllPaths()` -- `TeamsClient.GetMembership()` => `GetMembershipDetails()` -- `TeamsClient.AddMembership()` => `AddOrEditMembership()` -- `TeamsClient.AddMembership()` => `AddOrEditMembership()` - -Request Models -- Remove unwanted `ctor`'s from `BranchProtectionUpdateSettings` and `UpdateTeam` -- `NewIssue` `Assignee` => `Assignees` -- `IssueUpdate` `Assignee` => `Assignees` - -Response Models -- `TeamMembership` => `TeamMembershipDetails` - -## Release Notes - -### Milestone: GitHub Apps - -**Features/Enhancements** - -- Add initial support for GitHub Apps, see [the documentation](http://octokitnet.readthedocs.io/en/latest/github-apps/) for further information - [#1738](https://github.com/octokit/octokit.net/pull/1738) via [@itaibh](https://github.com/itaibh), [@adriangodong](https://github.com/adriangodong), [@ryangribble](https://github.com/ryangribble) - - -### Milestone: None - -**Features/Enhancements** - -- Added `PreviousFileName` field to `PullRequestFile` response - [#1770](https://github.com/octokit/octokit.net/pull/1770) via [@Kaneraz](https://github.com/Kaneraz) -- Support `PullRequestReviewEvent` payloads using new response model `PullRequestReviewEventPayload` - [#1767](https://github.com/octokit/octokit.net/pull/1767) via [@Cyberboss](https://github.com/Cyberboss) -- Add the ability to search issues by milestones, using `SearchIssuesRequest.Milestone` - [#1788](https://github.com/octokit/octokit.net/pull/1788) via [@mkArtak](https://github.com/mkArtak) -- Add an overload to `IReleasesClient.Get()` that allows retrieving a `Release` by the associated tag - [#1793](https://github.com/octokit/octokit.net/pull/1793) via [@tasadar2](https://github.com/tasadar2), [@ryangribble](https://github.com/ryangribble) -- Add `MaintainerCanModify` field to `PullRequest` response and `NewPullRequest` and `UpdatePullRequest` requests - [#1771](https://github.com/octokit/octokit.net/pull/1771) via [@Cyberboss](https://github.com/Cyberboss), [@ryangribble](https://github.com/ryangribble) -- Enabled additional methods for preview "Nested Teams" support: - - `IRepositoriesClient.GetAllTeams()` - - `IRepositoryBranchesClient.GetAllProtectedBranchTeamRestrictions()` - - `IRepositoryBranchesClient.UpdateProtectedBranchTeamRestrictions()` - - `IRepositoryBranchesClient.AddProtectedBranchTeamRestrictions()` - - `IRepositoryBranchesClient.DeleteProtectedBranchTeamRestrictions()` - [#1795](https://github.com/octokit/octokit.net/pull/1795) via [@MikhailTymchukDX](https://github.com/MikhailTymchukDX), [@ryangribble](https://github.com/ryangribble) -- Implement [Pre Receive Environments API (Preview)](https://developer.github.com/enterprise/2.13/v3/enterprise/pre_receive_environments/) for GitHub Enterprise - [#1796](https://github.com/octokit/octokit.net/pull/1796) via [@tasadar2](https://github.com/tasadar2), [@ryangribble](https://github.com/ryangribble) -- Implement support for [Label API Improvements](https://developer.github.com/changes/2018-02-22-label-description-search-preview/), including additional fields (`Description` and `Default`), emoji support and searching for labels (`SearchClient.SearchLabels()`) - [#1802](https://github.com/octokit/octokit.net/pull/1802) via [@jozefizso](https://github.com/jozefizso), [@ryangribble](https://github.com/ryangribble) - -**Housekeeping** - -- Correct missing/incorrect XmlDoc entries for parameters on some methods - [#1779](https://github.com/octokit/octokit.net/pull/1779) via [@ryangribble](https://github.com/ryangribble) -- Parameter names in validation exception messages are now derived from the parameters themselves, rather than a literal string that was hopefully kept up to date - [#1781](https://github.com/octokit/octokit.net/pull/1781) via [@itaibh](https://github.com/itaibh) -- Update Octokit build tooling to use .NET SDK 2.x (note that this is only an SDK tooling update - `Octokit` and `Octokit.Reactive` libraries are still targeting `netstandard1.1`) - [#1784](https://github.com/octokit/octokit.net/pull/1784) via [@ryangribble](https://github.com/ryangribble) -- Removed a number of `[Obsolete]` methods, members and constructors inline with our standard deprecation schedule - [#1780](https://github.com/octokit/octokit.net/pull/1780) via [@ryangribble](https://github.com/ryangribble) -- Ensure all response models have appropriate `ctor`'s to allow mocking, and enforce with a convention test - [#1798](https://github.com/octokit/octokit.net/pull/1798) via [@tasadar2](https://github.com/tasadar2), [@ryangribble](https://github.com/ryangribble) - -**Documentation Updates** - -- Tidy up code formatting in docs/samples - [#1791](https://github.com/octokit/octokit.net/pull/1791) via [@txdv](https://github.com/txdv) -- Clarify the usage of `reference` parameter in `IReferencesClient` methods - [#1778](https://github.com/octokit/octokit.net/pull/1778) via [@Cyberboss](https://github.com/Cyberboss), [@ryangribble](https://github.com/ryangribble) -- Improved the "Upload Release Asset" doc sample - [#1805](https://github.com/octokit/octokit.net/pull/1805) via [@mungojam](https://github.com/mungojam) -- Fixed error in "Create Release" doc sample - [#1804](https://github.com/octokit/octokit.net/pull/1804) via [@mungojam](https://github.com/mungojam) - - -### New in 0.29.0 (released 19/02/2018) - -## Advisories and Breaking Changes - -- On February 22, 2018 19:00 UTC, GitHub will [disable permanently the use of weak cryptogrpahic standards](https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/). Applications targeting .NET Framework 4.5.x will be affected, as that framework does not enable the now required protocol (TLS1.2) by default. This octokit.net release will automatically enable this protocol, when the `GitHubClient` is constructed. Note that applications targeting .NET Framework 4.6+ or .NET Core should already have TLS1.2 enabled by default, and this release does nothing with enabled protocols on those platforms. -- Affected clients that are unable to update octokit.net, can include their own [code change](https://github.com/octokit/octokit.net/blob/41b4059c110a60aee86a912dda2987fecc5a3fcb/Octokit/Http/HttpClientAdapter.cs#L31) to enable TLS1.2 as an alternative to updating to this release. - -## Release Notes - -### Milestone: Missing Pagination Support - -**Features/Enhancements** - -- Add pagination support to `ReferencesClient` - [#1694](https://github.com/octokit/octokit.net/pull/1694) via [@gdziadkiewicz](https://github.com/gdziadkiewicz) -- Add pagination support to `RepositoryInvitationsClient` - [#1692](https://github.com/octokit/octokit.net/pull/1692) via [@gdziadkiewicz](https://github.com/gdziadkiewicz) - - -### Milestone: None - -**Features/Enhancements** - -- Add `InReplyToId` property to `PullRequestReviewComment` response model, to indicate when a comment is in reply to another comment - [#1715](https://github.com/octokit/octokit.net/pull/1715) via [@thedillonb](https://github.com/thedillonb) -- Ensure the `netstandard1.1` targeted package is compatible with AWS Lambda `netcoreapp1.0` environment, by explicitly specifying the `NetStandard.Library` meta-package version - [#1713](https://github.com/octokit/octokit.net/pull/1713) via [@ryangribble](https://github.com/ryangribble) -- Add `UpdatedAt` property to `Milestone` response model, to indicate when it was last updated - [#1722](https://github.com/octokit/octokit.net/pull/1722) via [@shaggygi](https://github.com/shaggygi), [@ryangribble](https://github.com/ryangribble) -- Support `StatusEvent` payloads, using new response model `StatusEventPayload` - [#1732](https://github.com/octokit/octokit.net/pull/1732) via [@itaibh](https://github.com/itaibh) -- Octokit now handles `DateTime` and `DateTimeOffset` response fields whose API response is in an unexpected Unix epoch time format - [#1735](https://github.com/octokit/octokit.net/pull/1735) via [@itaibh](https://github.com/itaibh) -- Add `PullRequestReviewId ` property to `PullRequestReviewComment` response model, to indicate which `PullRequestReview` the comment is related to - [#1739](https://github.com/octokit/octokit.net/pull/1739) via [@mirsaeedi](https://github.com/mirsaeedi) -- Implement support for Repository Licenses, including adding `License` property to `Repository` response model, adding `SpxId` field to `LicenseMetadata` response model and a new `IRepositoriesClient.GetLicenseContents()` call - [#1630](https://github.com/octokit/octokit.net/pull/1630) via [@jozefizso](https://github.com/jozefizso), [@M-Zuber](https://github.com/M-Zuber), [@ryangribble](https://github.com/ryangribble) -- Add `MergeableState` property to `PullRequest` response model, to indicate additional information about why a pull request can't be merged - [#1764](https://github.com/octokit/octokit.net/pull/1764) via [@ryangribble](https://github.com/ryangribble) -- Add `Visibility` property to `EmailAddress` response model, to indicate whether a primary email address is `Public` or `Private` - [#1757](https://github.com/octokit/octokit.net/pull/1757) via [@asapferg](https://github.com/asapferg), [@ryangribble](https://github.com/ryangribble) - -**Fixes** - -- `OAuthClient` now handles GitHub Enterprise instances correctly in `CreateAccessToken()` and `GetGitHubLoginUrl()` methods - [#1726](https://github.com/octokit/octokit.net/pull/1726) via [@ryangribble](https://github.com/ryangribble) -- Using the same `GitHubClient` instance from multiple threads in parallel will no longer throw occasional exceptions, after making the `GitHubSerializerStrategy` internals thread-safe - [#1748](https://github.com/octokit/octokit.net/pull/1748) via [@daveaglick](https://github.com/daveaglick) -- Remove deserializer enum cache miss by correcting the case of `AccountType` parameter values - [#1759](https://github.com/octokit/octokit.net/pull/1759) via [@ryangribble](https://github.com/ryangribble) -- Add TLS1.2 to enabled security protocols (.NET Framework 4.5 only) to avoid SSL connectivity errors when [GitHub deprecates weak algorithms](https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/) on February 22 - [#1758](https://github.com/octokit/octokit.net/pull/1758) via [@ryangribble](https://github.com/ryangribble) -- Deserializer now handles nullable `StringEnum<T>` members - [#1760](https://github.com/octokit/octokit.net/pull/1760) via [@ryangribble](https://github.com/ryangribble) - -**Documentation Updates** - -- Updated Rate Limits documentation and samples - [#1742](https://github.com/octokit/octokit.net/pull/1742) via [@mirsaeedi](https://github.com/mirsaeedi) -- Update supported platforms in README.md to include `.NET Standard 1.1` - [#1744](https://github.com/octokit/octokit.net/pull/1744) via [@ShalokShalom](https://github.com/ShalokShalom), [@ryangribble](https://github.com/ryangribble) -- Clarified `ProductHeaderValue` usage to align with GitHub API Docs - [#1751](https://github.com/octokit/octokit.net/pull/1751) via [@IAmHughes](https://github.com/IAmHughes), [@ryangribble](https://github.com/ryangribble) - -### New in 0.28.0 (released 6/11/2017) - -## Advisories and Breaking Changes - -- This release has been pushed out in response to `CommitStatus.Id` on GitHub exceeding `Int32.MaxValue`. We've made this field a `long` now... sorry about that! - -## Release Notes - -**Features/Enhancements** - -- You can now use `IGitHubClient.SetRequestTimeout(TimeSpan timeout)` to set a custom timeout, particularly useful for lengthy operations such as uploading release assets. - [#1693](https://github.com/octokit/octokit.net/pull/1693) via [@pmiossec](https://github.com/pmiossec), [@ryangribble](https://github.com/ryangribble) - -**Fixes** - -- Update `CommitStatus.Id` field from `int` to `long` to prevent overflow exceptions - [#1703](https://github.com/octokit/octokit.net/pull/1703) via [@kzu](https://github.com/kzu) - -**Housekeeping** - -- Correct rendering of `HttpClient` documentation page - [#1699](https://github.com/octokit/octokit.net/pull/1699) via [@scovetta](https://github.com/scovetta) - - -### New in 0.27.0 (released 7/10/2017) - -## Advisories and Breaking Changes - -- `NewTeam.Permission` has been changed to a nullable type `Permission?` and will no longer be sent unless explicitly set - -## Release Notes - -**Features/Enhancements** - -- Implement additional fields in `Team` response and `NewTeam` and `UpdateTeam` requests, for `Privacy`, `Maintainers` and `Description` where they were missing - [#1669](https://github.com/octokit/octokit.net/pull/1669) via [@ryangribble](https://github.com/ryangribble) -- Implement `Organization` filter in `ISearchClient.SearchCode()` - [#1672](https://github.com/octokit/octokit.net/pull/1672) via [@sepharg](https://github.com/sepharg), [@ryangribble](https://github.com/ryangribble) -- Implement team membership enhancements for role (Maintainer or Member) and state (Active or Pending) including new methods `TeamsClient.AddOrEditMembership()` and `TeamsClient.GetMembershipDetails()` and updating `TeamsClient.GetAllMembers()` to allow filtering by role. - [#1670](https://github.com/octokit/octokit.net/pull/1670) via [@ryangribble](https://github.com/ryangribble) -- Implement [Nested Teams API (Preview)](https://developer.github.com/changes/2017-08-30-preview-nested-teams/) - [#1682](https://github.com/octokit/octokit.net/pull/1682) via [@ryangribble](https://github.com/ryangribble) - -**Fixes** - -- Assembly versioning, NuGet package metadata and inter-package version dependencies should now be correct, after automating them via the build process - [#1660](https://github.com/octokit/octokit.net/pull/1660) via [@ryangribble](https://github.com/ryangribble), [@mderriey](https://github.com/mderriey) -- Octokit can now run in environments where `PlatformNotSupported` exception was encountered when initializing the API connection (eg AWS Lambda) - [#1660](https://github.com/octokit/octokit.net/pull/1660) via [@ryangribble](https://github.com/ryangribble), [@mderriey](https://github.com/mderriey) -- Intellisense should once again be available for Octokit libraries - sorry about that! - [#1674](https://github.com/octokit/octokit.net/pull/1674) via [@mderriey](https://github.com/mderriey) -- `ISearchClient.SearchRepo()` now uses the correct values for the `Forks` search qualifiers (`Include` or `Only`) - [#1680](https://github.com/octokit/octokit.net/pull/1680) via [@ryangribble](https://github.com/ryangribble) - -**Housekeeping** - -- Add convention tests to enforce API Pagination support and naming conventions - [#1659](https://github.com/octokit/octokit.net/pull/1659) via [@ryangribble](https://github.com/ryangribble) -- BranchProtection response class `EnforceAdmins` now provides a standard `ctor` allowing it to be mocked if required - [#1679](https://github.com/octokit/octokit.net/pull/1679) via [@ryangribble](https://github.com/ryangribble) - - -### New in 0.26.0 (released 31/8/2017) - -## Advisories and Breaking Changes - -- This release contains the necessary Octokit changes to specify the `required_pull_request_reviews` field on Branch Protection updates, which becomes mandatory when the Protected Branches API [graduates from preview mode](https://developer.github.com/changes/2017-06-16-loki-preview-ending-soon/) on the 1st September - -## Release Notes - -**Features/Enhancements** - -- Implement `RequiredPullRequestReviews` support in `IRepositoryBranchesClient.UpdateBranchProtection` and additional granular methods to `GetReviewEnforcement`, `UpdateReviewEnforcement` and `RemoveReviewEnforcement` via [@M-Zuber](https://github.com/M-Zuber), [@ryangribble](https://github.com/ryangribble) - -### New in 0.25.0 (released 23/8/2017) - -## Advisories and Breaking Changes - -- Octokit.net has been ported to dotnetcore :tada: providing libraries targetting `netstandard1.1` and `net45` frameworks - -- `Enum` fields in Octokit response classes are now wrapped in an `StringEnum<TEnum>` helper class, to provide more robustness in dealing with unknown API values for these fields. Whilst the changes are backwards compatible, please consult the guidance on [working with Enums](https://github.com/octokit/octokit.net/blob/main/docs/working-with-enums.md) for more information - -- `IncludeAdmins` field is no longer present in `BranchProtectionRequiredStatusChecks` and `BranchProtectionRequiredStatusChecksUpdate` classes, instead use the new `EnforceAdmins` field on `BranchProtectionSettingsUpdate` or the [new explicit methods](https://github.com/octokit/octokit.net/blob/main/Octokit/Clients/IRepositoryBranchesClient.cs#L304-L365) for configuring Admin Enforcement on protected branches. This was an [upstream API breaking change](https://developer.github.com/changes/2017-05-02-adoption-of-admin-enforced/) so we couldn't follow our normal deprecation schedule - -## Release Notes - -### Milestone: CAKE Builds - -**Features/Enhancements** - -- Add a build task to validate LINQPad samples - [#1551](https://github.com/octokit/octokit.net/pull/1551) via [@mderriey](https://github.com/mderriey) -- Add a code formatting task to CAKE - [#1550](https://github.com/octokit/octokit.net/pull/1550) via [@mderriey](https://github.com/mderriey) -- Add GitVersion configuration file - [#1555](https://github.com/octokit/octokit.net/pull/1555) via [@mderriey](https://github.com/mderriey) - - -### Milestone: dotnetcore Support - -**Features/Enhancements** - -- Port to .NET Core - [#1503](https://github.com/octokit/octokit.net/pull/1503) via [@mderriey](https://github.com/mderriey), [@ryangribble](https://github.com/ryangribble) -- Remove unneeded files for .NET Core - [#1549](https://github.com/octokit/octokit.net/pull/1549) via [@mderriey](https://github.com/mderriey) -- Migrate dotnetcore to vs2017 tooling - [#1567](https://github.com/octokit/octokit.net/pull/1567) via [@ryangribble](https://github.com/ryangribble), [@mderriey](https://github.com/mderriey) -- Provide [SourceLink](https://github.com/ctaggart/SourceLink) capability for Octokit and Octokit.Reactive assemblies - [#1574](https://github.com/octokit/octokit.net/pull/1574) via [@ryangribble](https://github.com/ryangribble), [@mderriey](https://github.com/mderriey) -- Deliver the dotnetcore port and CAKE build framework changes - [#1581](https://github.com/octokit/octokit.net/pull/1581) via [@ryangribble](https://github.com/ryangribble), [@mderriey](https://github.com/mderriey) - -**Fixes** - -- Fix broken JSON deserialization in .NET 4.5 after VS2017 project update - [#1647](https://github.com/octokit/octokit.net/pull/1647) via [@mderriey](https://github.com/mderriey) - - -### Milestone: None - -**Features/Enhancements** - -- Add support for the newly resurrected `PullRequest.MergeCommitSha` property - [#1562](https://github.com/octokit/octokit.net/pull/1562) via [@alexperovich](https://github.com/alexperovich) -- Enhance `RepositoryBranchesClient` to support Admin Enforcement changes - [#1598](https://github.com/octokit/octokit.net/pull/1598) via [@M-Zuber](https://github.com/M-Zuber) -- Implement [Pull Request Review Requests API (Preview)](https://developer.github.com/v3/pulls/review_requests/) - [#1588](https://github.com/octokit/octokit.net/pull/1588) via [@gdziadkiewicz](https://github.com/gdziadkiewicz), [@ryangribble](https://github.com/ryangribble) -- Provide a robust way to handle unknown enum values returned by GitHub API, to prevent deserialization errors until the enum values can be added to octokit - [#1595](https://github.com/octokit/octokit.net/pull/1595) via [@khellang](https://github.com/khellang), [@ryangribble](https://github.com/ryangribble) -- Implement [Projects API (Preview)](https://developer.github.com/v3/projects/) - [#1480](https://github.com/octokit/octokit.net/pull/1480) via [@maddin2016](https://github.com/maddin2016), [@ryangribble](https://github.com/ryangribble) -- Implement `ReviewPermission()` functionality for `OrganizationMembersClient` (Preview API) - [#1633](https://github.com/octokit/octokit.net/pull/1633) via [@alfhenrik](https://github.com/alfhenrik) -- Implement [Organization OutsideCollaborators API (Preview)](https://developer.github.com/v3/orgs/outside_collaborators/) - [#1639](https://github.com/octokit/octokit.net/pull/1639) via [@alfhenrik](https://github.com/alfhenrik), [@ryangribble](https://github.com/ryangribble) -- Implement pagination support for `OrganizationOutsideCollaboratorsClient.GetAll()` method - [#1650](https://github.com/octokit/octokit.net/pull/1650) via [@ryangribble](https://github.com/ryangribble) -- Implement `GetAllPendingInvitations()` functionality for `OrganizationMembersClient` and `TeamsClient` (Preview API) - [#1640](https://github.com/octokit/octokit.net/pull/1640) via [@alfhenrik](https://github.com/alfhenrik), [@ryangribble](https://github.com/ryangribble) -- Implement [Pull Request Reviews API](https://developer.github.com/v3/pulls/reviews/) - [#1648](https://github.com/octokit/octokit.net/pull/1648) via [@hartra344](https://github.com/hartra344), [@ryangribble](https://github.com/ryangribble) - -**Fixes** - -- Fix `RepositoryTrafficClient` to handle upstream API change in timestamps from Unix epoch time to ISO8601 - [#1560](https://github.com/octokit/octokit.net/pull/1560) via [@mderriey](https://github.com/mderriey), [@ryangribble](https://github.com/ryangribble) -- Fix more `IssueTimelineClient` deserialization exceptions by adding more new `EventInfoState` values - [#1563](https://github.com/octokit/octokit.net/pull/1563) via [@ryangribble](https://github.com/ryangribble) -- Fix `NotificationsClient.MarkAsRead()` exception by specifying a payload body in the `PUT` request - [#1579](https://github.com/octokit/octokit.net/pull/1579) via [@shiftkey](https://github.com/shiftkey), [@ryangribble](https://github.com/ryangribble) -- Fix `connection.GetLastApiInfo()` was returning `null` in some situations - [#1580](https://github.com/octokit/octokit.net/pull/1580) via [@ryangribble](https://github.com/ryangribble) -- Fix even more `IssueTimelineClient` deserialization exceptions by adding even more new `EventInfoState` values (this is getting old!) - [#1591](https://github.com/octokit/octokit.net/pull/1591) via [@lynnfaraday](https://github.com/lynnfaraday), [@ryangribble](https://github.com/ryangribble) -- `NewRepositoryWebHook.ToRequest()` no longer discards existing fields if they are set - [#1623](https://github.com/octokit/octokit.net/pull/1623) via [@ctolkien](https://github.com/ctolkien) -- Fix pagination on API calls that use `Uri` parameters (typically for requests that include some form of filtering) - [#1649](https://github.com/octokit/octokit.net/pull/1649) via [@ryangribble](https://github.com/ryangribble) -- Fixed `RepositoryCommitsClient.GetSha1()` to correctly obtain the sha1 of the specified commit, after the API went from preview to official - [#1654](https://github.com/octokit/octokit.net/pull/1654) via [@ryangribble](https://github.com/ryangribble) - -**Housekeeping** - -- Remove obsolete constructor of `RepositoryUpdate` request class - [#1569](https://github.com/octokit/octokit.net/pull/1569) via [@eriawan](https://github.com/eriawan) -- Remove unused Rx-Main dependency from LINQPad samples - [#1593](https://github.com/octokit/octokit.net/pull/1593) via [@NickCraver](https://github.com/NickCraver) -- Change response models 'Url' properties from `Uri` to `string` - [#1585](https://github.com/octokit/octokit.net/pull/1585) via [@mderriey](https://github.com/mderriey) -- Remove obsolete branch protection methods/classes - [#1620](https://github.com/octokit/octokit.net/pull/1620) via [@ryangribble](https://github.com/ryangribble) -- Remove methods and members that were marked `[Obsolete]` in 0.23 or earlier - [#1622](https://github.com/octokit/octokit.net/pull/1622) via [@ryangribble](https://github.com/ryangribble) - -**Documentation Updates** - -- Fix `Issue` documentation samples (`GetForRepository()` should be `GetForRepository()`) - [#1602](https://github.com/octokit/octokit.net/pull/1602) via [@tnaoto](https://github.com/tnaoto) -- Fix `Release` documentation samples (`ReleaseUpdate` should be `NewRelease`) - [#1611](https://github.com/octokit/octokit.net/pull/1611) via [@watsonlu](https://github.com/watsonlu) - -### New in 0.24.0 (released 17/1/2017) - -**Features/Enhancements** - - - Add `GetAll` method to `OrganizationsClient` - [#1469](https://github.com/octokit/octokit.net/pull/1469) via [malamour-work](https://github.com/malamour-work) - - Add missing fields to `Repository` class - `HasPages`, `SubscribersCount`, `Size` - [#1473](https://github.com/octokit/octokit.net/pull/1473) via [ryangribble](https://github.com/ryangribble) - - Allow base64 content for create/update file - [#1488](https://github.com/octokit/octokit.net/pull/1488) via [laedit](https://github.com/laedit) - - Add `HtmlUrl` field to `Milestone` class - [#1489](https://github.com/octokit/octokit.net/pull/1489) via [StanleyGoldman](https://github.com/StanleyGoldman) - - Add support for passing sort options to `IssueCommentsClient.GetAllForRepository()` - [#1501](https://github.com/octokit/octokit.net/pull/1501) via [pjc0247](https://github.com/pjc0247) - - Rename `PullRequest.Comment` to `PullRequest.ReviewComment` for better accuracy - [#1520](https://github.com/octokit/octokit.net/pull/1520) via [bmeverett](https://github.com/bmeverett) - - Introduce `AbuseException` - [#1528](https://github.com/octokit/octokit.net/pull/1528) via [SeanKilleen](https://github.com/SeanKilleen) - - Add `Id` field to `PullRequest` class - [#1537](https://github.com/octokit/octokit.net/pull/1537) via [YunLi1988](https://github.com/YunLi1988) - - Unparseable `ApiErrors` should now fall back to better default error messages - [#1540](https://github.com/octokit/octokit.net/pull/1540) via [SeanKilleen](https://github.com/SeanKilleen) - -**Fixes** - - - Fix errors in `ObservableEventsClient` caused by incorrect return types - [#1490](https://github.com/octokit/octokit.net/pull/1490) via [StanleyGoldman](https://github.com/StanleyGoldman) - - Add missing `SecurityCritical` attribute on `GetObjectData()` overrides - [#1493](https://github.com/octokit/octokit.net/pull/1493) via [M-Zuber](https://github.com/M-Zuber) - - Fix exceptions in Events API by adding missing event types to `EventInfo` enumeration - [#1536](https://github.com/octokit/octokit.net/pull/1536) via [lynnfaraday](https://github.com/lynnfaraday) - - Add new AccountType "Bot" to prevent deserialization errors - [#1541](https://github.com/octokit/octokit.net/pull/1541) via [ryangribble](https://github.com/ryangribble) - -**Documentation Updates** - - - Clarify `ApiInfo` rate limiting usage in docs - [#1524](https://github.com/octokit/octokit.net/pull/1524) via [SeanKilleen](https://github.com/SeanKilleen) - - Clarify label coloring usage in docs - [#1530](https://github.com/octokit/octokit.net/pull/1530) via [SeanKilleen](https://github.com/SeanKilleen) - -**Breaking Changes** - - - Creating and Editing Issues (and PullRequests) using `NewIssue` and `IssueUpdate` requests -should now use the `Assignees` collection rather than the now deprecated 'Assignee` field. -Both fields can't be specified on the same request, so any code still using `Assignee` will -need to explicitly set `Assignees` to `null` to avoid Api validation errors. - - - `OrganizationsClient.GetAll(string user)` has been marked obsolete in favour of -`OrganizationsClient.GetAllForUser(string user)` - - - `PullRequest.Comment` has been marked obsolete in favour of `PullRequest.ReviewComment` - -- Several `EventsClient` methods previously returned the incorrect `Activity` response class. -This has been corrected to `IssueEvent` which although is now correct could break calling -code that was written assuming this previous incorrect return type. - -### New in 0.23.0 (released 07/10/2016) - -**Features** - - - Added support to test whether a URL points to a GitHub Enterprise instance - #1404 via @haacked - - Added granular methods for Protected Branches preview API - #1443 via @maddin2016 - - Repository Traffic preview API support - #1457 via @maddin2016 - - Preview API for merge/squash/rebase in repository settings - #1477 via @ryangribble - - Added support for performing a rebase and merge through the API- #1479 via @ryangribble - -**Fixes** - - - Repository identifiers now use `long` instead of `int` - #1445 via @shana, #1485 via @ryangribble - - Searching for C# through the GitHub API now uses the correct alias - #1463 via @dampir - - Resolved deadlocking scenario in async/await usage - #1486 via @zzzprojects - -**Other** - - - LINQPad samples are now verified at build time - #1456 via @mderriey - - More obsolete APIs removed - #1458 via @ryangribble - - .NET Core support has been started - #1462 via @mderriey - -**Breaking Changes** - -Repository identifiers returned from the GitHub API will exceed `Int32.MaxValue` in -around 12 months, based on current growth. We've decided to update everywhere we -require (or return) a repository identifier from `int` to `long` so that these will -continue to work in the future, and the implicit conversion from `int` to `long` -means the impact should be manageable now. - -`MergePullRequest.Squash` has been marked as obsolete in favour of the `MergeMethod` -property - use `PullRequestMergeMethod.Squash` or `PullRequestMergeMethod.Rebase` if -you want to change the merge behaviour when merging a pull request. - -### New in 0.22.0 (released 2016/09/01) - -**Features** - - - Timeline preview API support - #1435 via @alfhenrik - - Initial groundwork for Branches API - #1437 via @ryangribble - - Base branch can now be updated when updating a pull request - #1450 via @ryangribble - - Enhancements to Protected Branches preview API - #1441 via @ryangribble - -**Fixes** - - - Redirect timeout when repository renamed - #1411 via @maddin2016 - -**Breaking Changes** - -The new Branches client added in #1437 means that existing methods on -I(Observable)RepositoryClient are now marked as obsolete. Please update your -usages to the new endpoints as these will be removed in a future release: - - - `client.Repository.GetBranch()` => `client.Repository.Branch.Get()` - - `client.Repository.GetAllBranches()` => `client.Repository.Branch.GetAll()` - - `client.Repository.EditBranch()` => `client.Repository.Branch.Edit()` - -There is also a change in how branch protection works with the API, due to -upstream changes. The existing methods have been marked as obsolete, but for -the sake of brevity here are the details about what you should be doing today. - -The process for inspecting branch protection is now two steps: - - - first, check the branch returned by `client.Repository.Branch.Get()` or - `client.Repository.Branch.GetAll()` has it's `Protected` property set to `true`. - - - then, a call to `client.Repository.Branch.GetBranchProtection()` will return - the details about the protection settings for the given branch. If no protection - is set for this branch, you will received a `HTTP 404` response. - -### New in 0.21.1 (released 2016/07/29) - -**Features** - -Due to a programming error in the tool to generate these release notes, additional -features were not properly documented for the previous release: - - - Reactions preview API support for issues, issue comments, commit comments and PR comments - #1335, #1341, #1405 via @maddin2016, @alfhenrik - - Repository Invitation preview API support - #1410 via @maddin2016 - - Added new fields for signature verification to Git Data Commit API - #1398 via @Sarmad93 - -No additional code changes have been made to this release. - -### New in 0.21.0 (released 2016/07/29) - -**Features** - -This release adds support across Octokit.net for providing the repository Id -rather than a name/owner pair. The repository Id does not change when transferring -ownership of a repository, and is more robust for API callers. This work -was lead by @dampir as part of Google Summer of Code 2016. - - - Added new fields for Deployment and DeploymentStatus preview API - #1365 via @ErikSchierboom - - Added new fields for signature verification to Git Data Tag API - #1420 via @Sarmad93 - - Added new fields for GitHub Pages preview API - #1421 via @dampir - -**Fixes** - - - Fix serialization of enum value attributes - #1402 via @maddin2016 - - Fix searching for repositories with underscore in name - #1418 via @dsplaisted, @shiftkey - -**Other** - - - Clarified obsolete warnings for Protected Branch preview API - #1428 via @ryangribble - - Remove Obsolete items - #1422 via @ryangribble - -**Breaking Changes** - -After a long grace period, #1422 has removed these obsoleted members. These features -exist in other parts of the API surface: - - - `I(Observable)GitHubClient.Release` - - `I(Observable)GitHubClient.Notification` - - `I(Observable)GitHubClient.GitDatabase` - - `I(Observable)GitHubClient.SshKey` - - `I(Observable)GitHubClient.Repository.RepositoryComments` - - `I(Observable)GitHubClient.Repository.CommitStatus` - - `I(Observable)GitHubClient.Repository.RepoCollaborators` - - `I(Observable)GitHubClient.Repository.Commits` - -This method is no longer supported through the API and has been removed from Octokit.net.: - - - `I(Observable)GitHubClient.Authorization.RevokeAllApplicationAuthentications()` - -### New in 0.20.0 (released 2016/06/15) - -**Features** - -The big focus for this release is pagination support. This lets the caller -control how much data to retrieve for `GetAll*` endpoints throughout Octokit. -This was a team effort to apply this across the entire codebase, with -contributions from @dampir, @devkhan, @prayankmathur, @SamTheDev and @shiftkey. - -For more information about how to use pagination in your projects refer to the -documentation: http://octokitnet.readthedocs.io/en/latest/extensibility/#pagination - - - Add Migrations preview API - #1141 via @devkhan - - Add Issue Lock/Unlock functionality - #1185 via @prayankmathur - - Added Commit Reference SHA-1 API - #1195 via @ryangribble - - Add additional parameters to `SearchIssuesRequest` - #1228 via @ryangribble - - Add `Importer` property to Meta endpoint - #1235 via @ryangribble - - Raise HTTP 451 exception when repository has DMCA notice - #1239 via @devkhan - - Add Merge and Squash preview API - #1245 via @Sarmad93 - - Add additional methods to `IEventsClient` - #1288 via @drasticactions - - Add Organization Permissions preview API - #1342 via @ryangribble - - Add GPG Keys preview API - #1343 via @alfhenrik - -**Fixes** - - - Renamed `IUserKeysClient.GetAll()` to `IUserKeysClient.GetAllForCurrent()` - #1139 via @M-Zuber - - Add `ItemStateFilter` enum to differentiate between search and list endpoints - #1140 via @prayankmathur - - `RepositoriesClient.GetAllPublic()` fails for Enterprise instanes due to URI structure - #1204 via @ryangribble - - `ConfigureAwait(false)` usages added, eliminating deadlocks - #1248 via @shiftkey - - Renamed `CompareResult.MergedBaseCommit` to fix serialization issue - #1265 via @kivancmuslu - - Activity Feed now returns issues and repository events - #1288 via @drasticactions - - Add `Repository` property to `Issue` response - #1292 via @M-Zuber - - `SearchCodeRequest` now supports searching without specifying a term - #1338 via @dsplaisted - - Add required Permission parameter to team management APIs - #1347 via @ryangribble - - Add `ClosedBy` property to `Issue` - #1353 via @maddin2016 - -**Other** - - - Deleting now-obsolete code - #1224 via @M-Zuber - - Centralize and cleanup the `Uri`s created in Octokit - #1287, #1290 via @dampir - - Updated documentation links - #1289 via @radu-matei, #1250 via @SamTheDev - -**Breaking Changes** - - - `IUserKeysClient.GetAll()` was named incorrectly when it was originally implemented - and only works for the current user's keys. Update all usages to `GetAllForCurrent()`. - - - `CompareResult.MergedBaseCommit` was never deserialized correctly, and has - been marked as obsolete. You should use `CompareResult.MergeBaseCommit` - instead (note the lack of a `d`). - - - `IEventsClient.GetAllForRepository` was incorrectly retrieving issue - events before this release. Use the new `IEventsClient.GetAllIssuesForRepository` - method if you still require issues, or continue to use `IEventsClient.GetAllForRepository` - if you require all repository events. - - - `IUsersClient` has a property named `Keys` which has been renamed in the - GitHub API documentation - Octokit has added the name `GitSshKey` to - reflect this change, and `Keys` will be removed in a later release. - -### New in 0.19.0 (released 2016/03/11) - -**Features** - - - Add `GetLatest` endpoint for Releases API - #975 via @chenjiaming93 - - Add Enterprise License and Organization APIs - #1073 via @ryangribble - - Add Locked property to `PullRequest` - #1089 via @M-Zuber - - Add Enterprise Search Indexing API - #1095 via @ryangribble - - Add support for `Visibility` and `Affiliation` to repository search - #1096, #1132 via @Sarmad93, @AlexP11223 - - Add Enterprise LDAP API - #1099 via @ryangribble - - Add `CreateBranch` extension methods to IReferencesClient - #1103 via @M-Zuber - - Additional Enterprise methods on User Administration Client - #1108 via @ryangribble - - Complete `UserKeysClient` API - #1112 via @ryangribble - - `RepositoryContentsClient` create, update and delete actions now specify branch - #1093 via @M-Zuber - -**Fixes** - - - `StatisticsClient` should not clobber /api/v3/ in path - #1085 via @shiftkey - - Fix JSON deserialization of string containing hyphens to List<string> property - #1094 via @ryangribble - - Incorrect reference passed to `RepositoryContentsClient.GetArchive` - #1113 via @michael-kokorin - -**Other** - - - Add failing integration test for Issue Search API - #1083 via @hahmed - - Add integration tests for `IReleasesClient.GetLatest` - #1090 via @M-Zuber - - Remove extraneous Bcl .targets reference - #1100 via @shana - - Add proper syntax highlighting to exploring-pull-requests.md - #1117 via @tiesmaster - - Fix issue with optional parameters in .\script\configure-integration-tests - #1118 via @Anubhav10 - - Update Issue creation sample code - #1131 via @AlexP11223 - - `IJsonSerializer` not used inside `Connection` - #1133 via @devkhan - -**Breaking Changes** - -`ISshKeysClient` has a number of methods which at the time should have been -implemented in `IUserKeysClient` - these methods are marked as obsolete and will -be removed in a future release: - - - `ISshKeysClient.Get(int id)` - - `ISshKeysClient.GetAll(string user)` - - `ISshKeysClient.GetAllForCurrent()` - - `ISshKeysClient.Create(SshKeyUpdate key)` - - `ISshKeysClient.Update(int id, SshKeyUpdate key)` - - `ISshKeysClient.Delete(int id)` - -### New in 0.18.0 (released 2016/02/03) - -* New: support for User Administration API (GitHub Enterprise) - #1068 via @paladique -* New: support for Admin Stats API (GitHub Enterprise) - - #1049 via @ryangribble -* New: support for Repository Pages API - #1061 via @M-Zuber -* New: get stargazer creation timestamps - #1060 via @daveaglick -* New: support for Protected Branches API - #996 via @ryangribble -* New: support for creating Personal Access Tokens - #990 via @alfhenrik -* Fixed: `Milestone` property added to `PullRequest` response - #1075 via @Eilon -* Fixed: Add member role filter to `OrganizationMembersClient.GetAll()` - #1072 via @ryangribble -* Fixed: `Repository.Content.GetAllContents` now support the root of the repository - #1064 via @naveensrinivasan, @shiftkey -* Fixed: added `Id` and `Locked` to `Issue`, added `CommitUrl` to `IssueEvent` - #1039 via @gabrielweyer -* Fixed: additional fields on `Release` and `ReleaseAsset` - #1009 via @gabrielweyer -* Fixed: `ApiException` now includes JSON payload when `.ToString()`- #974 via @asizikov - -**Breaking Changes:** - -As part of reaching 1.0 we went through to audit the current implementation -and identify areas that didn't align with our conventions. For this release, -we're marking the endpoints as `[Obsolete]` and indicating the new location. -These will be cleaned up in the next release: - - - `IGitHubClient.Notifications` -> `IGitHubClient.Activity.Notifications` - #1019 via @M-Zuber - - `IGitHubClient.Repository.CommitStatus` -> `IGitHubClient.Repository.Status` - #1043 via @RobPethick - - `IGitHubClient.Repository.Commits` -> `IGitHubClient.Repository.Commit` - #1057 via @M-Zuber - - `IGitHubClient.Repository.RepoCollaborators` -> `IGitHubClient.Repository.Collaborator` - #1040 via @M-Zuber - - `IGitHubClient.Repository.RepositoryComments` -> `IGitHubClient.Repository.Comment` - #1044 via @M-Zuber - - `IGitHubClient.Release` -> `IGitHubClient.Repository.Release` - #1058 via @RobPethick - - `IGitHubClient.GitDatabase` -> `IGitHubClient.Git` - #1048 via @RobPethick - -Other breaking changes: - - - a public `ApiExtensions.Get<T>` extension method was causing a bunch of - tests to be written in a confusing way. This has been ported to an interface - method on `IApiConnection` but hopefully you're not referencing this method - externally - see #1063 for more information. - - - `IRepositoryContentsClient.GetArchiveLink` is no longer correct, as the HTTP - behaviour in Octokit was updated to follow redirects received from the server. - See #986 for the last bits of cleanup. - - - `IRepositoryContentsClient.GetAllContents(string owner, string name, string path, string reference)` - has been renamed to `GetAllContentsByRef(string owner, string name, string path, string reference)` - to prevent overlap with methods on `IRepositoryContentsClient` which do not - specify a path - and thus look at the root of the repository. - - - `IssueEventPayload` has two fields which are never populated from the API - - `Assignee` and `Label` - these are now removed. You should use - `Issue.Assignee` and `Issue.Labels` instead. See #1039 for more details. - - - `PullRequest.MergeCommitSha` is marked as obsolete by the GitHub API - we - are cleaning up the behaviour for determining whether a PR has been - merged in #997 - see the PR for more information. - - - `IAuthorizationsClient.RevokeAllApplicationAuthentications` is no longer - available through the GitHub API - this will be removed in the next - release. - -**Shout outs** - -A lot of extra work went into this release, and I wanted to thank those people -who helped out - without their efforts we wouldn't be at this point: - - - @naveensrinivasan - for helping set up our Travis CI builds to test this on - Mono - see #995 for the details - - @hahmed - for contributing a bunch of documentation around the Octokit search - APIs - see #955, #954 and #951 - - @JakesCode - for clarifying some documentation after he reported an issue - #1054 - - @ryangribble - for helping get our GitHub Enterprise testing off the ground - #987 - - @naveensrinivasan - for catching and addressing an issue with our LINQPad snippets - #987 - -### New in 0.17.0 (released 2015/12/07) - -* New: `NewRepositoryWebHook` helper class useful for creating web hooks - #917 via @alfhenrik -* New: Overloads to the `GetArchive` method of `RepositoryContentsClient` that accept a timeout - #918 via @willsb -* Improved: Added `EventsUrl` to `Issue` - #901 via @alfhenrik -* Improved: Added `Committer` and `Author` to the `GitHubCommit` object - #903 via @willsb -* Improved: Made `EncodedContent` property of `RepositoryContent` public - #861 via @naveensrinivasan -* Improved: Added ability to create deploy keys that are read only and can only be used to read repository contents and not write to them - #915 via @haacked -* Improved: Added `Content` property to `NewTreeItem` to allow specifying content for a tree - #915 via @haacked -* Improved: Added `Description` property to `NewTeam` to allow specifying a description for a team - #915 via @haacked -* Improved: Added `Description` property to `OrganizationUpdate` to allow specifying a description for an organization - #915 via @haacked -* Improved: Added `Before` property to `NotificationsRequest` to find notifications updated before a specific time - #915 via @haacked -* Improved: Renamed `SignatureResponse` to `Committer` and replaced `CommitEntity` with `Committer` - #916 via @haacked -* Improved: Added URLs with more information to the `PrivateRepositoryQuotaExceededException` - #929 via @elbaloo -* Improved: The `Merge` method of `PullRequestsClient` now throws more specific exceptions when pull request is not mergeable - #976 via @elbaloo and @shiftkey -* Fixed: Bug that prevented specifying a commit message for pull request merges - #915 via @haacked -* Fixed: Added `System` to required framework assemblies for the `net45` NuGet package - #919 via @adamralph -* Fixed: Change the `HasIssues` property of `NewRepository` to be a nullable boolean because it's optional - #942 via @alfhenrik -* Fixed: Bug that caused downloading release assets to fail because it didn't handle the `application/octet-stream` content type properly - #943 via @naveensrinivasan -* Fixed: JSON serialization bug with unicode characters - #972 via @naveensrinivasan - -**Breaking Changes:** - - `NewDeployment` constructor requires a ref as this is required for the API. It no longer has a default constructor. - - `NewDeploymentStatus` constructor requires a `DeploymentState` as this is required for the API. It no longer has a default constructor. - - The `Name` property of `NewTeam` is now read only. It is specified via the constructor. - - Renamed `SignatureResponse` to `Committer` and removes `CommitEntity`, replacing it with `Committer`. - - Changed the type of `HasIssues` property of `NewRepository` to be nullable. - -### New in 0.16.0 (released 2015/09/17) - -* New: Implemented `GetMetadata` method of `IMiscellaneousClient` to retrieve information from the Meta endpoint -#892 via @haacked -* Improved: Add missing `ClosedAt` property to `Milestone` response - #890 via @geek0r -* Fixed: `NullReferenceException` when retrieving contributors for an empty repository - #897 via @adamralph -* Fixed: Bug that prevented release uploads and will unblock the entire F# ecosystem - #895 via @naveensrinivasan - -### New in 0.15.0 (released 2015/09/11) -* New: `IRepositoryContentsClient.GetAllContents` now has an overload to support specifying a reference - #730 via @goalie7960 -* New: Support for retrieving rate limit information from `IMiscellaneousClient` - #848 via @Red-Folder -* New: Use `GitHubClient.GetLastApiInfo()` to get API information for previous request - #855 via @Red-Folder, @khellang -* New: `PreviousFileName` returned to show renamed files in commit - #871 via @CorinaCiocanea -* Improved: `CommentUrl` returned on `Issue` response - #884 via @naveensrinivasan -* Improved: Issue and Code Search now accepts multiple repositories - #835 via @shiftkey -* Improved: Search now accepts a range of dates - #857 via @ChrisMissal -* Improved: Documentation on `Issue` response - #876 via @Eilon -* Improved: Code Search now accepts `FileName` parameter - #864 via @fffej -* Fixed: `GetQueuedContent` should return empty response for `204 No Content`, instead of throwing - #862 via @haacked -* Fixed: `TeamClient.AddMembership` sends correct parameter to server - #856 via @davidalpert -* Obsolete: `Authorization` endpoint which does not require fingerprint - #878 via @niik - -**Breaking Changes:** - - #835 has changed the `Repos` property for `SearchIssuesRequest` and `SearchCodeRequest` - are now of type `RepositoryCollection` so that multiple repositories can be searched. - - The workarounds removed in #878 were added initially to support transitioning, but now - we enforce the use of a fingerprint. See https://developer.github.com/v3/oauth_authorizations/ - for more details. - - -### New in 0.14.0 (released 2015/07/21) -* New: Repository redirects are supported natively - #808 via @darrelmiller, @shiftkey -* Fixed: Support for searching repositories without a search term - #828 via @alexandrugyori - -### New in 0.13.0 (released 2015/06/17) -* Fixed: Added some missing Organization Teams methods - #795 via @phantomtypist, @shiftkey - -### New in 0.12.0 (released 2015/05/19) -* New: Added support for repository hooks and forks - #776 via @kristianhald, @johnduhart and @AndyCross -* Fixed: Merging a PR should permit specifying a SHA - #805 via @alfhenrik - -### New in 0.11.0 (released 2015/05/10) -* New: Added overload to `IRepositoryClient.GetAllPublic` specifying a `since` parameter - #774 via @alfhenrik -* New: Added `IGistsClient.GetAllCommits` and `IGistsClient.GetAllForks` implementations - #542 via @haagenson, #794 via @shiftkey -* New: Added `IRepositoryContentsClient.GetArchiveLink` for getting archived code - #765 via @alfhenrik -* Fixed: `PullRequestFile` properties were not serialized correctly - #789 via @thedillonb -* Fixed: Allow to download zip-attachments - #792 via @csware - -### New in 0.10.0 (released 2015/04/22) -* Fixed: renamed methods to follow `GetAll` convention - #771 via @alfhenrik -* Fixed: helper functions and cleanup to make using Authorization API easier to consume - #786 via @haacked - -**Breaking Changes:** - - As part of #771 there were many method which were returning collections - but the method name made it unclear. You might think that it wasn't much, but - you'd be wrong. So if you have a method that no longer compile, - it is likely that you need to set the prefix to `GetAll` to re-disocver that API. - - `CommitComment.Position` is now a nullable `int` to prevent serialization issues. - -### New in 0.9.0 (released 2015/04/04) -* New: added `PullRequest.Files` APIs - #752 via @alfhenrik -* Fixed: `PullRequestRequest` now supports `SortDirection` and `SortProperty` - #752 via @alfhenrik -* Fixed: `Repository.Create` now enforces a repository name - #763 via @haacked -* Fixed: corrected naming conventions for endpoints which return a list of results - #766 via @alfhenrik -* Deprecated: `Repository.GetReadme` and `Repository.GetReadmeHtml` - #759 via @khellang - -**Breaking Changes:** - - `NewRepository` constructor requires a `name` parameter - - `IRepositoriesClient.GetReadme` -> `IRepositoriesClient.Content.GetReadme` - - `IRepositoriesClient.GetReadmeHtml` -> `IRepositoriesClient.Content.GetReadmeHtml` - - `IFollowersClient.GetFollowingForCurrent` -> `IFollowersClient.GetAllFollowingForCurrent` - - `IFollowersClient.GetFollowing` -> `IFollowersClient.GetAllFollowing` - -### New in 0.8.0 (released 2015/03/20) -* New: added `MiscellaneousClient.GetGitIgnoreTemplates` and `MiscellaneousClient.GetGitIgnoreTemplates` APIs - #753 via @haacked -* New: added `MiscellaneousClient.GetLicenses` and `MiscellaneousClient.GetLicense` preview APIs - #754 via @haacked -* New: enhancements to `AuthorizationClient`- #731 via @alfhenrik -* Fixed: handled `unsubscribe` type for Issue events - #751 via @darrencamp -* Fixes: ensure response models define readonly interfaces - #755 via @khellang - -### New in 0.7.3 (released 2015/03/06) -* New: added `Repository.GetAllPublic` for searching public repositories - #691 via @rms81 -* New: added filters to `Repository.GetAllForCurrent()` - #742 via @shiftkey -* Fixed: deserializing `EventInfoType` value with underscore now works - #727 via @janovesk -* Deprecated: `Repository.SubscriberCount` has no data - #739 via @basildk -* Deprecated: `Repository.Organization` has no data - #726 via @alfhenrik - -### New in 0.7.2 (released 2015/03/01) -* Fixed: unshipped Orgs Permissions preview API changes due to excessive paging in some situations. - -### New in 0.7.1 (released 2015/02/26) -* New: `SearchCodeRequest` has overloads for owner and repository name - #705 via @kfrancis -* New - support for preview Authorization API changes - #647 via @shiftkey -* New - `Account.Type` to identify user or organization account - #714 via @shiftkey -* Fixed: `EventTypeInfo` did not parse `head_ref_deleted` and `head_ref_restored` - #711 via @janovesk -* Fixed: `IssueUpdate.Labels` did not support "no change" updates - #718 via @shiftkey -* Fixed: `ReleaseUploadAsset` does not require protected setters - #720 via @shiftkey -* Deprecated: `Repository.WatchedCount` has no data - #701 via @DaveWM - -### New in 0.7.0 (Released 2015/02/24) -* New: Response models now use read-only properties - #658, #662 via @haacked, #663 via @khellang, #679 via @Zoltu -* New: Added `Truncated` property to `TreeResponse` - #674 via @Zoltu -* New: Added `GetRecursive` method to `ITreesClient` - #673 via @Zoltu -* New: Added `Merging` client to `Repository` API: - #603 via @tabro -* New: API internals are now read-only - #662 via @haacked -* Fixed: Commit Status API now supports combined status- #618 via @khellang -* Fixed: Changed `IGistCommentsClient` identifiers to `string` instead of `int` - #681 via @thedillonb -* Fixed: Improved error message when repository creation fails - #667 via @gabrielweyer -* Fixed: Team membership API was incorrect - #695 via @aneville - -**Breaking Changes** -- Response models are all read only. It is recommended that you subclass the - model class if you need to contructor responses (e.g. for testing) -- `IResponse` is now a `readonly` interface. -- `ApiResponse<T>` accepts the strongly typed body as an argument. -- `IResponse<T>` changed to `IApiResponse<T>`. - -### New in 0.6.2 (Released 2015/01/06) -* New: Added `Assignee` and `Label` to `EventInfo` and `IssueEvent` repsonses - #644 via @thedillonb -* New: Added `BrowserDownloadUrl` to `ReleaseAsset` response - #648 via @erangeljr -* New: Added `Stats` to `GitHubCommit` and `Patch` to `GitHubCommitFile` - #646 via @thedillonb -* New: Support for retrieving and manipulating repository contents using `GitClient.Repository.Content` - #649 via @haacked and @khellang -* Fixed: updated enum values returned from `EventInfo.Event` - #644 via @thedillonb -* Fixed: serialization issue with `Head` and `Base` in pull request - #606 via @mge -* Fixed: `SignatureResponse.Date` is now a `DateTimeOffset` - #646 via @thedillonb - -**Breaking Changes:** - - `EventInfo.InfoState` is now `EventInfo.Event` - - `IssueEvent.InfoState` is now `IssueEvent.Event` - - `SignatureResponse.Date` has changed from `Date` to `DateTimeOffset` - -### New in 0.6.1 (Released 2014/12/23) -* New: `IOrganizationMembersClient.GetAll` now has enum to filter 2FA - #626 via @gbaychev -* Fixed: `User.GravatarId` and `Author.GravatarId` are marked as obsolete - #622 via @gbaychev -* Fixed: Use `DateTimeOffset.MinValue` as default parameter for `NotificationRequest.Since` - #641 via @thedillonb - -### New in 0.6.0 (Released 2014/12/15) -* Fixed: Typo in guard clause for `ApiInfo` - #588 via @karlbohlmark -* Fixed: Documentation typos in `NewRepository` - #590 via @karlbohlmark -* Fixed: `Files` array now included when fetching a commit - #608 via @kzu -* Fixed: `GetAllContributors` return `Contributions` count - #614 via @SimonCropp - -### New in 0.5.3 (Released 2014/12/05) -* New: Uploading release assets now supports an optional timeout value - #587 via @shiftkey - -### New in 0.5.2 (Released 2014/10/13) -* New: Method to add repository to team - #546 via @kevfromireland -* Fixed: PATCH parameters for releases, issues and pull requests are now nullable - #561 via @thedillonb - -**Breaking Changes:** - - - `PullRequestUpdate` removed unused fields: `Number`, `State`, `Base`, and `Head` - - `ReleaseClient.Create` now accepts a `NewRelease` parameter (was `ReleaseUpdate`) - - `ReleaseUpdate` no longer requires a `TagName` in the constructor (see `NewRelease`) - - `ReleaseUpdate` now has nullable `Draft` and `Prerelease` properties - only - set these if you want to apply changes to the API - - `IssueUpdate.State` is now a nullable `ItemState` - - `MilestoneUpdate.Number` is now removed - - `MilestoneUpdate.State` is now a nullable `ItemState` - -### New in 0.5.1 (Released 2014/10/08) -* New: added XML docs to NuGet package for Maximum Intellisense - #586 via @shiftkey - -### New in 0.5.0 (Released 2014/10/07) -* New: added more methods for users and orgs - #553 via @andrerod -* New: added support for Universal Apps - #575 via @hippiehunter -* New: added missing fields to `Repository` - #560 via @thedillonb -* New: upgraded Octokit.Reactive to Rx 2.2.5 - #564 via @haacked -* Fixed: added `ItemState.All` enum value so issue filtering can be bypassed - #550 via @MitjaBezensek -* Fixed: remove trailing slash in `ApiUrl` that causes /team/{id}/repos to fail - #555 via @matt-gibbs -* Fixed: `PullRequest.Mergeable` was misspelt, causing serialization issue - #576 via @jrowies -* Fixed: serialization issue when parsing `OAuthToken.Scope` list - @shiftkey - -**Breaking Change:** `Readme.GetHtmlContent()` would return a 404, due to `Readme.HtmlUrl` not accepting custom Accepts header. This method now uses `Readme.Url` internally, which will return a slightly different DOM. - -### New in 0.4.1 (Released 2014/07/22) -* New: Added a public method for turning pages of requests into a flat observable - #544 via @haacked - -### New in 0.4.0 (Released 2014/07/14) -* New: added Commit.CommentCount property - #494 via @gabrielweyer -* New: added initial support for User Keys - #525 via @shiftkey -* New: support for listing commits on a repository - #529 via @haagenson -* New: support for Pull Request Comments - #531 via @gabrielweyer -* Fixed: unassign milestone from issue - #526 via @shiftkey -* Fixed: organization deserialization bug - #522 via @shiftkey -* Fixed: Repository.MasterBranch -> Repository.DefaultBranch - #523 via @shiftkey -* Improved: refinements to Releases API - #519 via @shiftkey -* Improved: can delete registered emails for the authenticated user - #524 via @shiftkey - -### New in 0.3.5 (Released 2014/06/30) -* Fix issue search filtering bug - #481 via @shiftkey -* Fix methods to edit a release - #507 via @distantcam -* Fix methods to edit a release assset - #514 via @haacked - -### New in 0.3.4 (Released 2014/05/01) -* Improvements to "repository exists" exception result - #473 via @shiftkey -* Encoding query parameters impacts search clients - #467 via @shiftkey - -### New in 0.3.3 (Released 2014/04/22) -* Add methods to retrieve a team's members and to check if a user is a member of a team - #449 via @kzu -* Add OAuth web flow methods - #462 via @haacked - -### New in 0.3.2 (Released 2014/04/16) -* Allow passing a parameter to the Patch method - #440 via @nigel-sampson -* Remove the redundant Team suffix from ITeamsClient - #451 via @kzu -* Remove Immutable Collections dependency to support .NET 4 builds - #453 via @paulcbetts -* Add method to retrieve raw bytes from a request - #457 via @haacked -* Fix readonly deserialization bug in NetCore45 and related projects - #455 via @nigel-sampson - -### New in 0.3.1 (Released 2014/03/31) -* Add support for comparing two commits - #428 via @shiftkey -* Fix regression in throwing proper 2FA exception - #437 via @Haacked - -### New in 0.3.0 (Released 2014/03/19) -* Add Portable Class Library support for Octokit package - #401 via @trsneed -* Filter repository issues by users - #427 via @shiftkey - -### New in 0.2.2 (Released 2014/03/06) -* Task-based and Observable-based APIs are now consistent - #361 #376 #378 via @shiftkey and @ammeep -* "_links" JSON field serialization convention fix - #387 via @haacked -* Added Feeds client - #386 via @sgwill -* Added support for creating Gists - #391 via @Therzok and @rgmills -* Make readonly collections truly readonly - #394 #399 via @Haacked -* Internalize ProductHeaderValue - #406 via @trsneed -* HttpClient.Send without cancellation token - #410 via @ammeep -* Implement Repository Comments API - #413 via @Haacked @wfroese -* Corrected Search response to match API - #412 #417 #419 #420 via @shiftkey - -### New in 0.2.1 (Released 2014/02/19) -* Reverted the dependency on Reactive Extensions 2.2.2 which introduced breaking changes - -### New in 0.2.0 (Released 2014/02/19) -* Fixed an issue where some new observable clients were not accessible - #376 via @shiftkey - -### New in 0.1.9 (Released 2014/02/19) -* New client for searching users - #289 via @hahmed -* New client for the statistics API - #296 via @ammeep -* New client for managing deployments and deployment status - #298 via @pmacn -* Added methods to repositories client for getting metadata such as contributors, languages, tags, etc. - #319 via @pmacn -* Added GetAll and Add methods to the user emails client - #323 via @pmacn -* New client for managing user followers - #343 via @alfhenrik -* Add more methods for managing releases - #344 via @alfhenrik -* New client for the activity watching API - #350 via @nigel-sampson -* ObservableStarredClient can now be accessed via a property - #351 via @nigel-sampson -* Emoji api now has Emoji type rather than dictionary - #354 via @haacked -* New client for the Pull Requests API - #360 via @jpsullivan and @shiftkey -* Now throws RepositoryExistsException when repository already exists - #377 via @haacked -* Now throws PrivateRepositoryQuotaExceededException when private repository quota would be exceeded by a new repository - #379 via @haacked - -### New in 0.1.8 (Released 2014/01/22) -* Added IRepositoryClient.GetAllBranches - #270 via @goalie7960 -* Install-Package should add reference to System.Net.Http - #286 via @alfhenrik -* Return a more helpful error if invalid refs path provided - #288 via @alfhenrik -* Refactor SearchIssuesRequest to match the API - #290 via @alfhenrik -* Deprecate custom Releases Accept header - #291 via @shiftkey -* Fix date format used in DateRange - #293 via @alfhenrik -* Add base class for search requests - #301 via @hahmed -* Deprecate IGitHubClient.Blob - #305 via @shiftkey -* Improving Proxy Server support - #306 via @shiftkey -* Add integration tests for IRepositoryClient.GetAllBranches - #309 via @lbargaoanu -* Refactor SearchCodeRequest to match the API - #311 from @alfhenrik -* Implemented Delete for IssueCommentsClient - #315 from @pmacn -* Implemented missing methods for IssueLabels - #316 from @pmacn - -### New in 0.1.7 (Released 2013/12/27) -* New client for repository search - #226 and @273 via @hahmed -* Bugfix for creating/updating issue comments - #262 via @tpeczek -* Bugfix for retrieving events - #264 via @shiftkey - -### New in 0.1.6 (Released 2013/12/18) -* New client for managing Gists - #225 via @SimonCropp -* New client for managing Git references - #238 via @khellang -* Added missing Observable versions for Git objects client - #251 by @khellang -* New client for Gist comments - #252 by @khellang -* Lots of documentation - #253 by @pmacn -* New client for managing issue labels - #256 by @andrerod - -### New in 0.1.5 (Released 2013/11/19) -* New client for starring repositories -* New client for retrieving commits -* New client for managing an organization's teams and members -* New client for managing blobs -* New client for retrieving and creating trees -* New client for managing collaborators of a repository - -### New in 0.1.4 (Released 2013/11/6) -* New client for retrieving activity events -* Fixed bug where concealing an org's member actually shows the member - -### New in 0.1.3 (Released 2013/11/5) -* New Xamarin Component store versions of Octokit.net -* New clients for managing assignees, milestones, and tags -* New clients for managing issues, issue events, and issue comments -* New client for managing organization members -* Fixed bug in applying query parameters that could cause paging to continually request the same page - -### New in 0.1.2 (Released 2013/10/31) -* New default constructors in Octokit.Reactive -* New IObservableAssigneesClient in Octokit.Reactive - -### New in 0.1.1 (Released 2013/10/30) -* Fixed problems with Microsoft.Threading.Tasks - -### New in 0.1.0 (Released 2013/10/30) -* Initial release diff --git a/docs/contributing.md b/docs/contributing.md index 074317502c..c6a8f80b0a 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -3,7 +3,7 @@ so you can edit changes and view them immediately. ## Windows -You need these things: +You'll need to install the following: - this repo - `git clone https://github.com/octokit/octokit.net.git` - Python - install it from Chocolatey: `cinst python` @@ -20,7 +20,7 @@ to `http://localhost:8000/` ## OS X -You need these things: +You'll need to install the following: - this repo - `git clone https://github.com/octokit/octokit.net.git` - Python - if you don't have it already, get it from homebrew: `brew install python3` @@ -28,3 +28,19 @@ You need these things: Once you've got all that, run `mkdocs serve` from the root of your repository and then point your browser to `http://localhost:8000/` + +## Codespaces + +Note: By default `Python 3.x` and `pip` should already be installed on your [codespace](https://github.com/features/codespaces) instance when it spins up. + +You'll need to install the following: + + - mkdocs - install it with pip: `pip install mkdocs` + + +## Troubleshooting + +In some instances you (depending on how python and pip were installed) you'll need to use the python module flag `-m` to install mkdocs. +Using this flag ensures that you are using the instance of pip that is connected to the active instance of Python. + +ex. `python -m pip install mkdocs` diff --git a/mkdocs.yml b/mkdocs.yml index 5fdb655b7b..9f838a8517 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -12,7 +12,7 @@ theme: readthedocs #theme_dir: ./theme/mkdocs/ #theme_center_lead: false -pages: +nav: - 'Home' : 'index.md' - 'Getting Started' : getting-started.md From 02b08cb63992189e8025388fd4dd246107714a51 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Tue, 10 May 2022 15:39:40 +0300 Subject: [PATCH 043/209] bump to dotnet 6 --- Octokit.Reactive/Octokit.Reactive.csproj | 2 +- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- Octokit/Octokit.csproj | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 240d790153..0cceaf7de0 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -6,7 +6,7 @@ <Authors>GitHub</Authors> <Version>0.0.0-dev</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> - <TargetFramework>net5.0</TargetFramework> + <TargetFramework>net6.0</TargetFramework> <AssemblyName>Octokit.Reactive</AssemblyName> <PackageId>Octokit.Reactive</PackageId> <DebugType>embedded</DebugType> diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 1adcc2d3d5..0cb59c7629 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -4,7 +4,7 @@ <Description>Convention-based tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Conventions</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks> + <TargetFramework>net6.0</TargetFramework> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Conventions</AssemblyName> <PackageId>Octokit.Tests.Conventions</PackageId> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 32c46d0e35..3874bf1f0c 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -4,7 +4,7 @@ <Description>Integration tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Integration</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks> + <TargetFramework>net6.0</TargetFramework> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Integration</AssemblyName> <PackageId>Octokit.Tests.Integration</PackageId> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index a39c193f21..a47c6b9aff 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -4,7 +4,7 @@ <Description>Tests for Octokit</Description> <AssemblyTitle>Octokit.Tests</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks> + <TargetFramework>net6.0</TargetFramework> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests</AssemblyName> <PackageId>Octokit.Tests</PackageId> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 8c30f01b39..3225ff0ae9 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -16,11 +16,11 @@ <PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageTags>GitHub API Octokit linqpad-samples dotnetcore</PackageTags> <Copyright>Copyright GitHub 2017</Copyright> - <TargetFramework>net5.0</TargetFramework> + <TargetFramework>net6.0</TargetFramework> <LangVersion>9</LangVersion> </PropertyGroup> - <PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' "> + <PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' "> <DefineConstants>$(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;HAS_SERVICEPOINTMANAGERS</DefineConstants> </PropertyGroup> From 8e800f29c6a018994652c362454d0d8b0d6a6a47 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Tue, 10 May 2022 10:53:37 -0500 Subject: [PATCH 044/209] creates the config file for stalebot to help us clean up old/inactive issues (#2441) --- .github/stale.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000000..ef516e2c82 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,40 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale (approx. 9 months) +daysUntilStale: 270 + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +# Set to false to disable. If disabled, issues still need to be closed manually but will remain marked as stale. +daysUntilClose: 7 + +# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) +onlyLabels: [] + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - pinned + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: false + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: false + +# Label to use when marking as stale +staleLabel: stale + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + Hey Friends, this issue has been automatically marked as `stale` because it has not had + recent activity. It will be closed if no further activity occurs. Please add the + `pinned` label if you feel that this issue needs to remain open/active. + Thank you for your contributions and help in keeping things tidy! + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Limit to only `issues` or `pulls` +only: issues From 486c83a23e33a5f58849ced40ea5c2dd77d7c202 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Tue, 10 May 2022 16:36:37 -0500 Subject: [PATCH 045/209] adds stale bot functionallity via action and removes the stalebot config (#2442) --- .github/stale.yml | 40 ------------------------------------- .github/workflows/stale.yml | 27 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 40 deletions(-) delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index ef516e2c82..0000000000 --- a/.github/stale.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Configuration for probot-stale - https://github.com/probot/stale - -# Number of days of inactivity before an Issue or Pull Request becomes stale (approx. 9 months) -daysUntilStale: 270 - -# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. -# Set to false to disable. If disabled, issues still need to be closed manually but will remain marked as stale. -daysUntilClose: 7 - -# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) -onlyLabels: [] - -# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable -exemptLabels: - - pinned - -# Set to true to ignore issues in a project (defaults to false) -exemptProjects: false - -# Set to true to ignore issues in a milestone (defaults to false) -exemptMilestones: false - -# Set to true to ignore issues with an assignee (defaults to false) -exemptAssignees: false - -# Label to use when marking as stale -staleLabel: stale - -# Comment to post when marking as stale. Set to `false` to disable -markComment: > - Hey Friends, this issue has been automatically marked as `stale` because it has not had - recent activity. It will be closed if no further activity occurs. Please add the - `pinned` label if you feel that this issue needs to remain open/active. - Thank you for your contributions and help in keeping things tidy! - -# Limit the number of actions per hour, from 1-30. Default is 30 -limitPerRun: 30 - -# Limit to only `issues` or `pulls` -only: issues diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000000..a6c3615e83 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,27 @@ + +name: 'Close stale issues and PRs' +on: + workflow_dispatch: + schedule: + - cron: '30 1 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v4 + with: + stale-issue-message: > + '👋 Hey Friends, this issue has been automatically marked as `stale` because it has no recent activity. + It will be closed if no further activity occurs. + Please add the `pinned` label if you feel that this issue needs to remain open/active. + Thank you for your contributions and help in keeping things tidy!' + stale-pr-message: > + '👋 Hey Friends, this pull request has been automatically marked as `stale` because it has no recent activity. + It will be closed if no further activity occurs. + Please add the `pinned` label if you feel that this issue needs to remain open/active. + Thank you for your contributions and help in keeping things tidy!' + days-before-stale: 270 + days-before-close: 7 + exempt-issue-labels: 'pinned, work-in-progress' + exempt-pr-labels: 'pinned, work-in-progress' From 74a2c7b97d8372cf6dcc23b703b0c5ad255ca6e9 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Tue, 10 May 2022 16:43:21 -0500 Subject: [PATCH 046/209] Cleans up unnecessary ticks --- .github/workflows/stale.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index a6c3615e83..20f04ff758 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -12,15 +12,15 @@ jobs: - uses: actions/stale@v4 with: stale-issue-message: > - '👋 Hey Friends, this issue has been automatically marked as `stale` because it has no recent activity. + 👋 Hey Friends, this issue has been automatically marked as `stale` because it has no recent activity. It will be closed if no further activity occurs. Please add the `pinned` label if you feel that this issue needs to remain open/active. - Thank you for your contributions and help in keeping things tidy!' + Thank you for your contributions and help in keeping things tidy! stale-pr-message: > - '👋 Hey Friends, this pull request has been automatically marked as `stale` because it has no recent activity. + 👋 Hey Friends, this pull request has been automatically marked as `stale` because it has no recent activity. It will be closed if no further activity occurs. Please add the `pinned` label if you feel that this issue needs to remain open/active. - Thank you for your contributions and help in keeping things tidy!' + Thank you for your contributions and help in keeping things tidy! days-before-stale: 270 days-before-close: 7 exempt-issue-labels: 'pinned, work-in-progress' From d10be6fd237bc1fcd3210157a77487820d629b37 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Wed, 11 May 2022 11:51:12 +0300 Subject: [PATCH 047/209] Added SecretScanningAlert to InstallationPermissions --- Octokit.Tests/Models/InstallationTest.cs | 70 +++++++++++++++++++ .../Response/InstallationPermissions.cs | 8 ++- Octokit/Octokit.csproj | 2 +- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 Octokit.Tests/Models/InstallationTest.cs diff --git a/Octokit.Tests/Models/InstallationTest.cs b/Octokit.Tests/Models/InstallationTest.cs new file mode 100644 index 0000000000..5d47740086 --- /dev/null +++ b/Octokit.Tests/Models/InstallationTest.cs @@ -0,0 +1,70 @@ +using System.Linq; +using Octokit.Internal; +using Xunit; + +namespace Octokit.Tests.Models; + +public class InstallationTest +{ + [Fact] + public void CanBeDeserialized() + { + const string json = @"{ + ""id"": 1, + ""account"": { + ""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 + }, + ""access_tokens_url"": ""https://api.github.com/installations/1/access_tokens"", + ""repositories_url"": ""https://api.github.com/installation/repositories"", + ""html_url"": ""https://github.com/organizations/github/settings/installations/1"", + ""app_id"": 1, + ""target_id"": 1, + ""target_type"": ""Organization"", + ""permissions"": { + ""checks"": ""write"", + ""metadata"": ""read"", + ""contents"": ""read"", + ""secret_scanning_alert"": ""write"" + }, + ""events"": [ + ""push"", + ""pull_request"" + ], + ""single_file_name"": ""config.yaml"", + ""has_multiple_single_files"": true, + ""single_file_paths"": [ + ""config.yml"", + "".github/issue_TEMPLATE.md"" + ], + ""repository_selection"": ""all"", + ""created_at"": ""2017-07-08T16:18:44-04:00"", + ""updated_at"": ""2017-07-08T16:18:44-04:00"", + ""app_slug"": ""github-actions"", + ""suspended_at"": null, + ""suspended_by"": null +}"; + var serializer = new SimpleJsonSerializer(); + + var installation = serializer.Deserialize<Installation>(json); + + Assert.Equal(1, installation.Id); + Assert.Equal(InstallationPermissionLevel.Write, installation.Permissions.SecretScanningAlert); + } +} diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index 1b01d031fc..c4342af96f 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -9,7 +9,7 @@ public class InstallationPermissions { public InstallationPermissions() { } - public InstallationPermissions(InstallationPermissionLevel? metadata, InstallationPermissionLevel? administration, InstallationPermissionLevel? statuses, InstallationPermissionLevel? deployments, InstallationPermissionLevel? issues, InstallationPermissionLevel? pages, InstallationPermissionLevel? pullRequests, InstallationPermissionLevel? contents, InstallationPermissionLevel? singleFile, InstallationPermissionLevel? repositoryProjects, InstallationPermissionLevel? members, InstallationPermissionLevel? organizationProjects, InstallationPermissionLevel? teamDiscussions, InstallationPermissionLevel? checks) + public InstallationPermissions(InstallationPermissionLevel? metadata, InstallationPermissionLevel? administration, InstallationPermissionLevel? statuses, InstallationPermissionLevel? deployments, InstallationPermissionLevel? issues, InstallationPermissionLevel? pages, InstallationPermissionLevel? pullRequests, InstallationPermissionLevel? contents, InstallationPermissionLevel? secretScanningAlert, InstallationPermissionLevel? singleFile, InstallationPermissionLevel? repositoryProjects, InstallationPermissionLevel? members, InstallationPermissionLevel? organizationProjects, InstallationPermissionLevel? teamDiscussions, InstallationPermissionLevel? checks) { Metadata = metadata; Administration = administration; @@ -19,6 +19,7 @@ public InstallationPermissions(InstallationPermissionLevel? metadata, Installati Pages = pages; PullRequests = pullRequests; Contents = contents; + SecretScanningAlert = secretScanningAlert; SingleFile = singleFile; RepositoryProjects = repositoryProjects; Members = members; @@ -76,6 +77,11 @@ public InstallationPermissions(InstallationPermissionLevel? metadata, Installati public StringEnum<InstallationPermissionLevel>? Contents { get; protected set; } /// <summary> + /// Secret scanning alert + /// View and manage secret scanning alerts. + /// </summary> + public StringEnum<InstallationPermissionLevel>? SecretScanningAlert { get; protected set; }/// <summary> + /// Single file /// Manage just a single file. /// </summary> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 3225ff0ae9..729eda7a3c 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.2</Version> + <Version>1.0.3</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From c9a7533f2cbe866ecb137bd596f5d16be5b27f0e Mon Sep 17 00:00:00 2001 From: Tim Rogers <timrogers@github.com> Date: Fri, 13 May 2022 10:03:24 +0100 Subject: [PATCH 048/209] Configure the project for GitHub Codespaces (#2443) * Add configuration for Codespaces This adds a simple Codespaces configuration, `.devcontainer/devcontainer.json`, to the project. It uses v3.1 of the .NET Core SDK from Docker Hub, installs Python 3 and `mkdocs` to support building the docs and includes useful VS Code extensions for working on the project. * Add VS Code tasks for running tests and building the docs This improves the Visual Studio Code tasks definitions (`.vscode/ tasks.json`), adding pre-defined tasks for running unit and convention tests and building the docs. Codespaces magic means that, when you build the docs, the port will automatically be opened so you can view the docs in real time at `localhost:4000`. --- .devcontainer/Dockerfile | 4 ++ .devcontainer/devcontainer.json | 19 ++++++++ .devcontainer/setup.sh | 3 ++ .vscode/tasks.json | 85 ++++++++++++++++++++++++++++++++- 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/setup.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..e0709ba7bd --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +FROM mcr.microsoft.com/dotnet/sdk:3.1 +WORKDIR /home/ +COPY . . +RUN bash ./setup.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..56c5b1f4bf --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "Octokit.NET", + "extensions": [ + "formulahendry.dotnet-test-explorer", + "eamodio.gitlens", + "fernandoescolar.vscode-solution-explorer", + "ms-dotnettools.csharp", + "redhat.vscode-yaml", + ], + "dockerFile": "Dockerfile", + "containerEnv": { + // Enable detection of running in a container + "DOTNET_RUNNING_IN_CONTAINER": "true", + // Enable correct mode for dotnet watch (only mode supported in a container) + "DOTNET_USE_POLLING_FILE_WATCHER": "true", + // Skip extraction of XML docs - generally not useful within an image/container - helps perfomance + "NUGET_XMLDOC_MODE": "true" + } +} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 0000000000..1c7b62142b --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,3 @@ +apt-get update +apt-get install -y python3 python3-pip +pip3 install mkdocs diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 609f11f165..b732378ca3 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,7 +2,7 @@ "version": "2.0.0", "tasks": [ { - "label": "build", + "label": "Build", "command": "dotnet", "type": "shell", "args": [ @@ -28,6 +28,89 @@ "reveal": "silent" }, "problemMatcher": "$msCompile" + }, + { + "label": "Run docs server", + "command": "mkdocs", + "type": "shell", + "args": ["serve"], + "presentation": { + "reveal": "silent", + "revealProblems": "onProblem" + } + } + ] +} +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build", + "command": "dotnet", + "type": "shell", + "args": [ + "build", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "Unit Tests", + "command": "./build.sh", + "type": "shell", + "args": [ + "--target=UnitTests" + ], + "group": { + "kind": "test" + }, + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "Convention Tests", + "command": "./build.sh", + "type": "shell", + "args": [ + "--target=ConventionTests" + ], + "group": { + "kind": "test" + }, + "presentation": { + "reveal": "always" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "Format", + "command": "dotnet", + "type": "shell", + "args": ["format"], + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + }, + { + "label": "Docs", + "command": "mkdocs", + "type": "shell", + "args": ["serve"], + "presentation": { + "reveal": "silent", + "revealProblems": "onProblem" + } } ] } From 218f89f136b074caad0bbe1f609feda66ff195f8 Mon Sep 17 00:00:00 2001 From: Tim Rogers <me@timrogers.co.uk> Date: Thu, 19 May 2022 09:41:39 +0100 Subject: [PATCH 049/209] Fix the Visual Studio Code tasks configuration file (#2448) This fixes the Visual Studio Code tasks configuration file (`.vscode/tasks.json`), which somehow got corrupted, meaning that it was no longer valid and didn't work. --- .vscode/tasks.json | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b732378ca3..eb8edc4f29 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,46 +1,3 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Build", - "command": "dotnet", - "type": "shell", - "args": [ - "build", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "presentation": { - "reveal": "silent" - }, - "problemMatcher": "$msCompile" - }, - { - "label": "Format", - "command": "dotnet", - "type": "shell", - "args": ["format"], - "presentation": { - "reveal": "silent" - }, - "problemMatcher": "$msCompile" - }, - { - "label": "Run docs server", - "command": "mkdocs", - "type": "shell", - "args": ["serve"], - "presentation": { - "reveal": "silent", - "revealProblems": "onProblem" - } - } - ] -} { "version": "2.0.0", "tasks": [ From bbddb9d72348c4a411e1be395d444578487f20d7 Mon Sep 17 00:00:00 2001 From: Tim Rogers <me@timrogers.co.uk> Date: Thu, 19 May 2022 09:42:57 +0100 Subject: [PATCH 050/209] Explicitly configure identation settings for VSCode (#2450) This adds explicit configuration to `.vscode/settings.json` so we use two spaces for indentation, rather than relying on the user's own settings or automatic detection. --- .vscode/settings.json | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 91f78ee477..c51385840c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,14 @@ { - "files.exclude": { - "**/bin": true, - "**/obj": true, - "**/packaging": true, - "**/coverage-results": true - }, - "files.trimTrailingWhitespace": true, - "files.trimFinalNewlines": true, - "files.insertFinalNewline": true + "files.exclude": { + "**/bin": true, + "**/obj": true, + "**/packaging": true, + "**/coverage-results": true + }, + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "files.insertFinalNewline": true, + "editor.detectIndentation": false, + "editor.tabSize": 2, + "editor.insertSpaces": true } From 727029c5d2b3e019a88f1e7a87239f48d2333ce5 Mon Sep 17 00:00:00 2001 From: Tim Rogers <me@timrogers.co.uk> Date: Thu, 19 May 2022 09:48:53 +0100 Subject: [PATCH 051/209] Use the official Codespaces template configuration, rather than something homegrown (#2449) * Test commit Hello! * Correct indentation in `.devcontainer` * Change devcontainer name to `Octokit.net` --- .devcontainer/Dockerfile | 22 +++++++++-- .devcontainer/devcontainer.json | 69 ++++++++++++++++++++++++++------- .devcontainer/setup.sh | 3 -- 3 files changed, 74 insertions(+), 20 deletions(-) delete mode 100644 .devcontainer/setup.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e0709ba7bd..0deea1cae7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,18 @@ -FROM mcr.microsoft.com/dotnet/sdk:3.1 -WORKDIR /home/ -COPY . . -RUN bash ./setup.sh +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/dotnet/.devcontainer/base.Dockerfile + +# [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal +ARG VARIANT="6.0-bullseye-slim" +FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] Uncomment this section to install additional OS packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends python3-pip + +RUN pip3 install mkdocs + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 56c5b1f4bf..d05fa8554e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,19 +1,62 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/dotnet { - "name": "Octokit.NET", + "name": "Octokit.net", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0 + // Append -bullseye or -focal to pin to an OS version. + "VARIANT": "3.1", + // Options + "NODE_VERSION": "none" + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": {}, + + // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "formulahendry.dotnet-test-explorer", + "ms-dotnettools.csharp", + "formulahendry.dotnet-test-explorer", "eamodio.gitlens", "fernandoescolar.vscode-solution-explorer", - "ms-dotnettools.csharp", - "redhat.vscode-yaml", + "redhat.vscode-yaml" ], - "dockerFile": "Dockerfile", - "containerEnv": { - // Enable detection of running in a container - "DOTNET_RUNNING_IN_CONTAINER": "true", - // Enable correct mode for dotnet watch (only mode supported in a container) - "DOTNET_USE_POLLING_FILE_WATCHER": "true", - // Skip extraction of XML docs - generally not useful within an image/container - helps perfomance - "NUGET_XMLDOC_MODE": "true" + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [5000, 5001], + + // [Optional] To reuse of your local HTTPS dev cert: + // + // 1. Export it locally using this command: + // * Windows PowerShell: + // dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere" + // * macOS/Linux terminal: + // dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere" + // + // 2. Uncomment these 'remoteEnv' lines: + // "remoteEnv": { + // "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere", + // "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx", + // }, + // + // 3. Do one of the following depending on your scenario: + // * When using GitHub Codespaces and/or Remote - Containers: + // 1. Start the container + // 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer + // 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https" + // + // * If only using Remote - Containers with a local container, uncomment this line instead: + // "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "dotnet restore", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode", + "features": { + "python": "latest" + } } -} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh deleted file mode 100644 index 1c7b62142b..0000000000 --- a/.devcontainer/setup.sh +++ /dev/null @@ -1,3 +0,0 @@ -apt-get update -apt-get install -y python3 python3-pip -pip3 install mkdocs From bd2bd2efff27439ec03488f8419f5974924259ed Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Wed, 25 May 2022 16:13:10 +0300 Subject: [PATCH 052/209] Add number of seats deserialization for organization plan responses --- Octokit.Tests/Models/OrganizationTests.cs | 2 ++ Octokit/Models/Response/Plan.cs | 14 +++++++++++++- Octokit/Octokit.csproj | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Models/OrganizationTests.cs b/Octokit.Tests/Models/OrganizationTests.cs index dbe53b4e9d..b17bbdeedc 100644 --- a/Octokit.Tests/Models/OrganizationTests.cs +++ b/Octokit.Tests/Models/OrganizationTests.cs @@ -53,6 +53,8 @@ public void CanBeDeserializedWithNullPrivateGistsDiskUsageAndCollaborators() Assert.Equal("octocat", org.Login); Assert.Equal(1234, org.Id); + Assert.Equal(45, org.Plan.Seats); + Assert.Equal(45, org.Plan.FilledSeats); } } diff --git a/Octokit/Models/Response/Plan.cs b/Octokit/Models/Response/Plan.cs index f5de2a8b3b..3995980e20 100644 --- a/Octokit/Models/Response/Plan.cs +++ b/Octokit/Models/Response/Plan.cs @@ -9,7 +9,9 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class Plan { - public Plan() { } + public Plan() + { + } public Plan(long collaborators, string name, long privateRepos, long space, string billingEmail) { @@ -48,6 +50,16 @@ public Plan(long collaborators, string name, long privateRepos, long space, stri /// </summary> public string BillingEmail { get; protected set; } + /// <summary> + /// The number of seats in the organization + /// </summary> + public long Seats { get; protected set; } + + /// <summary> + /// The number of filled seats in the organization + /// </summary> + public long FilledSeats { get; protected set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Name: {0}, Space: {1}, Private Repos: {2}, Collaborators: {3}", Name, Space, PrivateRepos, Collaborators); } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 729eda7a3c..a9248a55d9 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.3</Version> + <Version>1.0.4</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 316c343d67754160c774bf07b8fcd77083f0a5f2 Mon Sep 17 00:00:00 2001 From: Aditi Takle <69855282+adtakle@users.noreply.github.com> Date: Thu, 26 May 2022 14:49:12 -0700 Subject: [PATCH 053/209] Add Draft to MergeableState enum (#2381) --- Octokit/Models/Response/PullRequest.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/PullRequest.cs b/Octokit/Models/Response/PullRequest.cs index ff90a59a2b..9ca99408ad 100644 --- a/Octokit/Models/Response/PullRequest.cs +++ b/Octokit/Models/Response/PullRequest.cs @@ -302,6 +302,12 @@ public enum MergeableState /// No conflicts, everything good. Merging is allowed. /// </summary> [Parameter(Value = "clean")] - Clean + Clean, + + /// <summary> + /// Not ready for review. Merging is blocked. + /// </summary> + [Parameter(Value = "draft")] + Draft } } From a5afcc229fea93644004fcbd434a5cc2e8865a21 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Fri, 27 May 2022 13:57:14 -0500 Subject: [PATCH 054/209] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..3db6f6ad88 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,72 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '29 4 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 From 30cd6d34acf55ae92c7ec426dc3b6b8505bc4390 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Wed, 1 Jun 2022 15:47:13 +0300 Subject: [PATCH 055/209] Added installation deletion endpoint --- Octokit/Clients/GitHubAppsClient.cs | 10 ++++++++++ Octokit/Clients/IGitHubAppsClient.cs | 7 +++++++ Octokit/Octokit.csproj | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Octokit/Clients/GitHubAppsClient.cs b/Octokit/Clients/GitHubAppsClient.cs index 7a0f08c875..ac1e1120c6 100644 --- a/Octokit/Clients/GitHubAppsClient.cs +++ b/Octokit/Clients/GitHubAppsClient.cs @@ -203,5 +203,15 @@ public Task<Installation> GetUserInstallationForCurrent(string user) return ApiConnection.Get<Installation>(ApiUrls.UserInstallation(user), null, AcceptHeaders.GitHubAppsPreview); } + + /// <summary> + /// Uninstalls a GitHub App on a user, organization, or business account (requires GitHubApp auth). + /// </summary> + /// <remarks>https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app</remarks> + /// <param name="installationId">The Id of the GitHub App Installation</param> + public Task DeleteInstallationForCurrent(long installationId) + { + return ApiConnection.Delete(ApiUrls.Installation(installationId)); + } } } diff --git a/Octokit/Clients/IGitHubAppsClient.cs b/Octokit/Clients/IGitHubAppsClient.cs index 4906a4fe9f..0bea372979 100644 --- a/Octokit/Clients/IGitHubAppsClient.cs +++ b/Octokit/Clients/IGitHubAppsClient.cs @@ -112,5 +112,12 @@ public interface IGitHubAppsClient /// <remarks>https://developer.github.com/v3/apps/#find-user-installation</remarks> /// <param name="user">The name of the user</param> Task<Installation> GetUserInstallationForCurrent(string user); + + /// <summary> + /// Uninstalls a GitHub App on a user, organization, or business account (requires GitHubApp auth). + /// </summary> + /// <remarks>https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app</remarks> + /// <param name="installationId">The Id of the GitHub App Installation</param> + Task DeleteInstallationForCurrent(long installationId); } } \ No newline at end of file diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a9248a55d9..c070cfc6a3 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.4</Version> + <Version>1.0.5</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From bfdcb18f38121547a2f3fb5b056742f05010c82a Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Fri, 10 Jun 2022 10:35:06 -0500 Subject: [PATCH 056/209] Dev container rework to support OmniSharp changes (#2456) * given the c# extension no longer is packaged with mono this is an attempt to get code nav and intellsense back in order for vscode --- .devcontainer/Dockerfile | 19 ++++------ .devcontainer/devcontainer.json | 61 ++++++++++----------------------- 2 files changed, 26 insertions(+), 54 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0deea1cae7..dbe59ba1ed 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,18 +1,13 @@ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/dotnet/.devcontainer/base.Dockerfile # [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal -ARG VARIANT="6.0-bullseye-slim" -FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} +ARG VARIANT="6.0-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/dotnet -# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 -ARG NODE_VERSION="none" -RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi - -# [Optional] Uncomment this section to install additional OS packages. -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends python3-pip +# "install" the dotnet 3.1 & 5.0 runtime for tests +COPY --from=mcr.microsoft.com/dotnet/sdk:3.1 /usr/share/dotnet/shared /usr/share/dotnet/shared +COPY --from=mcr.microsoft.com/dotnet/sdk:5.0 /usr/share/dotnet/shared /usr/share/dotnet/shared +# # Add mkdocs for doc generation +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends python3-pip RUN pip3 install mkdocs - -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d05fa8554e..2e8d25a1b7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,56 +7,33 @@ "args": { // Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0 // Append -bullseye or -focal to pin to an OS version. - "VARIANT": "3.1", - // Options - "NODE_VERSION": "none" + "VARIANT": "latest" } }, - // Set *default* container specific settings.json values on container create. - "settings": {}, - + "settings": { + "omnisharp.path": "latest", + "omnisharp.defaultLaunchSolution": "Octokit.sln", + "omnisharp.disableMSBuildDiagnosticWarning": false, + "omnisharp.useModernNet": true, + "omnisharp.enableAsyncCompletion": true, + "omnisharp.enableEditorConfigSupport": true, + "omnisharp.enableImportCompletion": true, + "omnisharp.enableRoslynAnalyzers": true, + "omnisharp.organizeImportsOnFormat": true + }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-dotnettools.csharp", - "formulahendry.dotnet-test-explorer", "eamodio.gitlens", "fernandoescolar.vscode-solution-explorer", "redhat.vscode-yaml" ], - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [5000, 5001], - - // [Optional] To reuse of your local HTTPS dev cert: - // - // 1. Export it locally using this command: - // * Windows PowerShell: - // dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere" - // * macOS/Linux terminal: - // dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere" - // - // 2. Uncomment these 'remoteEnv' lines: - // "remoteEnv": { - // "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere", - // "ASPNETCORE_Kestrel__Certificates__Default__Path": "/home/vscode/.aspnet/https/aspnetapp.pfx", - // }, - // - // 3. Do one of the following depending on your scenario: - // * When using GitHub Codespaces and/or Remote - Containers: - // 1. Start the container - // 2. Drag ~/.aspnet/https/aspnetapp.pfx into the root of the file explorer - // 3. Open a terminal in VS Code and run "mkdir -p /home/vscode/.aspnet/https && mv aspnetapp.pfx /home/vscode/.aspnet/https" - // - // * If only using Remote - Containers with a local container, uncomment this line instead: - // "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ], - - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "dotnet restore", - - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - // "remoteUser": "vscode", - "features": { - "python": "latest" - } + // This is needed so that the C# extension can resolve to the correct SDK version + "remoteEnv": { + "PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:PATH}", + "DOTNET_MULTILEVEL_LOOKUP": "0", + "TARGET": "net7.0", + "DOTNET_WATCH_SUPPRESS_LAUNCH_BROWSER": "true" } +} From 1f7362acfa275d47424fada23ed62459c2d5f51b Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Thu, 16 Jun 2022 13:14:32 -0500 Subject: [PATCH 057/209] Create SECURITY.md --- SECURITY.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..ec0098f04e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,12 @@ +# Security Policy + +Thanks for helping make GitHub Open Source Software safe for everyone. + +GitHub takes the security of our software products and services seriously, including all of the open source code repositories managed through our GitHub organizations, such as [Octokit](https://github.com/octokit). + +Even though [open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope) and therefore not eligible for bounty rewards, we want to make sure that your finding gets passed along to the maintainers of this project for remediation. + + +## Reporting a Vulnerability + +Since this source is part of [Octokit](https://github.com/octokit) (a GitHub organization) we ask that you follow the guildlines [here](https://github.com/github/.github/blob/master/SECURITY.md#reporting-security-issues) to report anything that you might've found. From 30c0ad59aea4c5616d11825ee14bd04747fe79ee Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Thu, 16 Jun 2022 15:03:38 -0500 Subject: [PATCH 058/209] Update SECURITY.md --- SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index ec0098f04e..0605b07dbd 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -9,4 +9,4 @@ Even though [open source repositories are outside of the scope of our bug bounty ## Reporting a Vulnerability -Since this source is part of [Octokit](https://github.com/octokit) (a GitHub organization) we ask that you follow the guildlines [here](https://github.com/github/.github/blob/master/SECURITY.md#reporting-security-issues) to report anything that you might've found. +Since this source is part of [Octokit](https://github.com/octokit) (a GitHub organization) we ask that you follow the guidelines [here](https://github.com/github/.github/blob/master/SECURITY.md#reporting-security-issues) to report anything that you might've found. From 7144e29275b4cf5f033bb9c26e3bdb833ddf75e4 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Fri, 17 Jun 2022 14:47:49 -0500 Subject: [PATCH 059/209] Uses https instead of http so that the badges will load (#2461) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3232bc2cd2..21b439b034 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ [![Build status](https://ci.appveyor.com/api/projects/status/cego2g42yw26th26/branch/main?svg=true)](https://ci.appveyor.com/project/github-windows/octokit-net/branch/main) [![codecov](https://codecov.io/gh/octokit/octokit.net/branch/main/graph/badge.svg)](https://codecov.io/gh/octokit/octokit.net) [![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![NuGet](http://img.shields.io/nuget/v/Octokit.svg)](https://www.nuget.org/packages/Octokit) -[![NuGet](http://img.shields.io/nuget/v/Octokit.Reactive.svg)](https://www.nuget.org/packages/Octokit.Reactive) +[![NuGet](https://img.shields.io/nuget/v/Octokit.svg)](https://www.nuget.org/packages/Octokit) +[![NuGet](https://img.shields.io/nuget/v/Octokit.Reactive.svg)](https://www.nuget.org/packages/Octokit.Reactive) ![logo](octokit-dotnet_2.png) From 659ce5f4f7c7ff8c7a57b7c0e819922a917dc1bb Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Thu, 30 Jun 2022 08:33:46 -0500 Subject: [PATCH 060/209] Adds mono-complete to the dev container (#2468) adds mono to docker - this is a test/env dependency --- .devcontainer/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index dbe59ba1ed..2e0527ea2c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -11,3 +11,5 @@ COPY --from=mcr.microsoft.com/dotnet/sdk:5.0 /usr/share/dotnet/shared /usr/share # # Add mkdocs for doc generation RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends python3-pip RUN pip3 install mkdocs + +RUN apt-get install -y mono-complete From f317f9dadc223375303b7c66f1e5b14fe4397297 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Thu, 30 Jun 2022 21:20:45 +0100 Subject: [PATCH 061/209] Support for IsTemplate and Create Template from Repository (#2331) --- .../Clients/IObservableRepositoriesClient.cs | 9 +++ .../Clients/ObservableRepositoriesClient.cs | 18 +++++ .../Clients/RepositoriesClientTests.cs | 45 ++++++++++++ .../Helpers/GithubClientExtensions.cs | 7 ++ .../Clients/RepositoriesClientTests.cs | 70 ++++++++++++++----- Octokit/Clients/IRepositoriesClient.cs | 10 +++ Octokit/Clients/RepositoriesClient.cs | 38 ++++++++-- Octokit/Helpers/AcceptHeaders.cs | 2 + Octokit/Helpers/ApiUrls.cs | 9 +++ Octokit/Models/Request/NewRepository.cs | 5 ++ .../Request/NewRepositoryFromTemplate.cs | 46 ++++++++++++ 11 files changed, 237 insertions(+), 22 deletions(-) create mode 100644 Octokit/Models/Request/NewRepositoryFromTemplate.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index ff3c79ff43..d9da62cbc0 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -23,6 +23,15 @@ public interface IObservableRepositoriesClient /// <returns>An <see cref="IObservable{Repository}"/> instance for the created repository</returns> IObservable<Repository> Create(string organizationLogin, NewRepository newRepository); + /// <summary> + /// Creates a new repository using a repository template. + /// </summary> + /// <param name="templateOwner">The owner of the template</param> + /// <param name="templateRepo">The name of the template</param> + /// <param name="newRepository">A <see cref="NewRepositoryFromTemplate"/> instance describing the new repository to create from a template</param> + /// <returns>An <see cref="IObservable{Repository}"/> instance for the created repository</returns> + IObservable<Repository> Generate(string templateOwner, string templateRepo, NewRepositoryFromTemplate newRepository); + /// <summary> /// Deletes a repository for the specified owner and name. /// </summary> diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 6b835c29e1..9fbb2157b1 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -72,6 +72,24 @@ public IObservable<Repository> Create(string organizationLogin, NewRepository ne return _client.Create(organizationLogin, newRepository).ToObservable(); } + /// <summary> + /// Creates a new repository from a template + /// </summary> + /// <param name="templateOwner">The organization or person who will owns the template</param> + /// <param name="templateRepo">The name of template repository to work from</param> + /// <param name="newRepository">A <see cref="NewRepositoryFromTemplate"/> instance describing the new repository to create from a template</param> + /// <returns></returns> + public IObservable<Repository> Generate(string templateOwner, string templateRepo, NewRepositoryFromTemplate newRepository) + { + Ensure.ArgumentNotNull(templateOwner, nameof(templateOwner)); + Ensure.ArgumentNotNull(templateRepo, nameof(templateRepo)); + Ensure.ArgumentNotNull(newRepository, nameof(newRepository)); + if (string.IsNullOrEmpty(newRepository.Name)) + throw new ArgumentException("The new repository's name must not be null."); + + return _client.Generate(templateOwner, templateRepo, newRepository).ToObservable(); + } + /// <summary> /// Deletes a repository for the specified owner and name. /// </summary> diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 432deb99c3..cd1fffea94 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -219,6 +219,51 @@ public async Task CreatesARepositoryWithALicenseTemplate() } } + [IntegrationTest] + public async Task CreatesARepositoryAsTemplate() + { + var github = Helper.GetAuthenticatedClient(); + var repoName = Helper.MakeNameWithTimestamp("repo-as-template"); + + var newRepository = new NewRepository(repoName) + { + IsTemplate = true + }; + + using (var context = await github.CreateRepositoryContext(newRepository)) + { + var createdRepository = context.Repository; + + var repository = await github.Repository.Get(Helper.UserName, repoName); + + Assert.True(repository.IsTemplate); + } + } + + [IntegrationTest] + public async Task CreatesARepositoryFromTemplate() + { + var github = Helper.GetAuthenticatedClient(); + var repoTemplateName = Helper.MakeNameWithTimestamp("repo-template"); + var repoFromTemplateName = Helper.MakeNameWithTimestamp("repo-from-template"); + var owner = github.User.Current().Result.Login; + + var newTemplate = new NewRepository(repoTemplateName) + { + IsTemplate = true + }; + + var newRepo = new NewRepositoryFromTemplate(repoFromTemplateName); + + using (var templateContext = await github.CreateRepositoryContext(newTemplate)) + using (var context = await github.Generate(owner, repoFromTemplateName, newRepo)) + { + var repository = await github.Repository.Get(Helper.UserName, repoFromTemplateName); + + Assert.Equal(repoFromTemplateName, repository.Name); + } + } + [IntegrationTest] public async Task CreatesARepositoryWithDeleteBranchOnMergeEnabled() { diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs index 329b6360ea..3c6b0f3fa9 100644 --- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs @@ -26,6 +26,13 @@ internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitH return new RepositoryContext(client.Connection, repo); } + internal static async Task<RepositoryContext> Generate(this IGitHubClient client, string owner, string repoName, NewRepositoryFromTemplate newRepository) + { + var repo = await client.Repository.Generate(owner, repoName, newRepository); + + return new RepositoryContext(client.Connection, repo); + } + internal static async Task<TeamContext> CreateTeamContext(this IGitHubClient client, string organization, NewTeam newTeam) { newTeam.Privacy = TeamPrivacy.Closed; diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index c518b7152c..00b3b520bf 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -42,7 +42,7 @@ public void UsesTheUserReposUrl() connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Any<NewRepository>(), - "application/vnd.github.nebula-preview+json"); + "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); } [Fact] @@ -54,7 +54,7 @@ public void TheNewRepositoryDescription() client.Create(newRepository); - connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json"); + connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); } [Fact] @@ -70,7 +70,7 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentU var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); connection.Connection.Credentials.Returns(credentials); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -97,7 +97,7 @@ public async Task ThrowsExceptionWhenPrivateRepositoryQuotaExceeded() var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); connection.Connection.Credentials.Returns(credentials); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -130,7 +130,7 @@ public async Task UsesTheOrganizationsReposUrl() connection.Received().Post<Repository>( Arg.Is<Uri>(u => u.ToString() == "orgs/theLogin/repos"), Args.NewRepository, - "application/vnd.github.nebula-preview+json"); + "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); } [Fact] @@ -142,7 +142,7 @@ public async Task TheNewRepositoryDescription() await client.Create("aLogin", newRepository); - connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json"); + connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); } [Fact] @@ -156,7 +156,7 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForSpecifie + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -181,7 +181,7 @@ public async Task ThrowsValidationException() + @"""http://developer.github.com/v3/repos/#create"",""errors"":[]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -202,7 +202,7 @@ public async Task ThrowsRepositoryExistsExceptionForEnterpriseInstance() + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(new Uri("https://example.com")); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json") + connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -214,6 +214,44 @@ public async Task ThrowsRepositoryExistsExceptionForEnterpriseInstance() } } + public class TheGenerateMethod + { + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Generate(null, null, null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Generate("asd", null, null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Generate("asd", "asd", null)); + } + + [Fact] + public void UsesTheUserReposUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoriesClient(connection); + + client.Generate("asd", "asd", new NewRepositoryFromTemplate("aName")); + + connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/asd/asd/generate"), + Arg.Any<NewRepositoryFromTemplate>(), + "application/vnd.github.baptiste-preview+json"); + } + + [Fact] + public void TheNewRepositoryDescription() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoriesClient(connection); + var newRepository = new NewRepositoryFromTemplate("aName"); + + client.Generate("anOwner", "aRepo", newRepository); + + connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.baptiste-preview+json"); + } + } + public class TheTransferMethod { [Fact] @@ -490,7 +528,7 @@ public async Task RequestsTheCorrectUrlAndReturnsRepositories() connection.Received() .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), null, - "application/vnd.github.nebula-preview+json", + "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json", Args.ApiOptions); } @@ -644,7 +682,7 @@ public async Task RequestsTheCorrectUrl() await client.GetAllForOrg("orgname"); connection.Received() - .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgname/repos"), null, "application/vnd.github.nebula-preview+json", Args.ApiOptions); + .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgname/repos"), null, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json", Args.ApiOptions); } [Fact] @@ -1078,7 +1116,7 @@ public void PatchesCorrectUrl() connection.Received() .Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo"), Arg.Any<RepositoryUpdate>(), - "application/vnd.github.nebula-preview+json"); + "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); } [Fact] @@ -1332,7 +1370,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithEmptyTopics() await _client.ReplaceAllTopics("owner", "name", _emptyTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null,"application/vnd.github.mercy-preview+json"); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null, "application/vnd.github.mercy-preview+json"); } [Fact] @@ -1341,7 +1379,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithListOfTopics() await _client.ReplaceAllTopics("owner", "name", _listOfTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics,null, "application/vnd.github.mercy-preview+json"); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics, null, "application/vnd.github.mercy-preview+json"); } [Fact] @@ -1356,10 +1394,10 @@ public async Task RequestsTheCorrectUrlForRepoIdWithEmptyTopics() [Fact] public async Task RequestsTheCorrectUrlForRepoIdWithListOfTopics() { - await _client.ReplaceAllTopics(1234,_listOfTopics); + await _client.ReplaceAllTopics(1234, _listOfTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics,null, "application/vnd.github.mercy-preview+json"); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics, null, "application/vnd.github.mercy-preview+json"); } } } diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index dd291cfd1e..976766f96c 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -77,6 +77,16 @@ public interface IRepositoriesClient /// <returns>A <see cref="Repository"/> instance for the created repository</returns> Task<Repository> Create(string organizationLogin, NewRepository newRepository); + /// <summary> + /// Creates a new repository from a template + /// </summary> + /// <param name="templateOwner">The organization or person who will owns the template</param> + /// <param name="templateRepo">The name of template repository to work from</param> + /// <param name="newRepository"></param> + /// <returns></returns> + Task<Repository> Generate(string templateOwner, string templateRepo, NewRepositoryFromTemplate newRepository); + + /// <summary> /// Deletes the specified repository. /// </summary> diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 256b24fbd9..5a279837c0 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -70,6 +70,7 @@ public Task<Repository> Create(NewRepository newRepository) /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/> instance for the created repository</returns> [Preview("nebula")] + [Preview("baptiste")] [ManualRoute("POST", "/orgs/{org}/repos")] public Task<Repository> Create(string organizationLogin, NewRepository newRepository) { @@ -81,11 +82,31 @@ public Task<Repository> Create(string organizationLogin, NewRepository newReposi return Create(ApiUrls.OrganizationRepositories(organizationLogin), organizationLogin, newRepository); } + /// <summary> + /// Creates a new repository from a template + /// </summary> + /// <param name="templateOwner">The organization or person who will owns the template</param> + /// <param name="templateRepo">The name of template repository to work from</param> + /// <param name="newRepository"></param> + /// <returns></returns> + [Preview("baptiste")] + [ManualRoute("POST", "/repos/{owner}/{repo}/generate")] + public Task<Repository> Generate(string templateOwner, string templateRepo, NewRepositoryFromTemplate newRepository) + { + Ensure.ArgumentNotNull(templateOwner, nameof(templateOwner)); + Ensure.ArgumentNotNull(templateRepo, nameof(templateRepo)); + Ensure.ArgumentNotNull(newRepository, nameof(newRepository)); + if (string.IsNullOrEmpty(newRepository.Name)) + throw new ArgumentException("The new repository's name must not be null."); + + return ApiConnection.Post<Repository>(ApiUrls.Repositories(templateOwner, templateRepo), newRepository, AcceptHeaders.TemplatePreview); + } + async Task<Repository> Create(Uri url, string organizationLogin, NewRepository newRepository) { try { - return await ApiConnection.Post<Repository>(url, newRepository, AcceptHeaders.VisibilityPreview).ConfigureAwait(false); + return await ApiConnection.Post<Repository>(url, newRepository, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview)).ConfigureAwait(false); } catch (ApiValidationException e) { @@ -216,6 +237,7 @@ public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositor /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> [Preview("nebula")] + [Preview("baptiste")] [ManualRoute("PATCH", "/repos/{owner}/{repo}")] public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) { @@ -224,7 +246,7 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) Ensure.ArgumentNotNull(update, nameof(update)); Ensure.ArgumentNotNull(update.Name, nameof(update.Name)); - return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.VisibilityPreview); + return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview)); } /// <summary> @@ -326,6 +348,7 @@ public Task<IReadOnlyList<Repository>> GetAllPublic(PublicRepositoryRequest requ /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> [Preview("nebula")] + [Preview("baptiste")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent() { @@ -343,12 +366,13 @@ public Task<IReadOnlyList<Repository>> GetAllForCurrent() /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> [Preview("nebula")] + [Preview("baptiste")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), null, AcceptHeaders.VisibilityPreview, options); + return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), null, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview), options); } /// <summary> @@ -440,6 +464,7 @@ public Task<IReadOnlyList<Repository>> GetAllForUser(string login, ApiOptions op /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> [Preview("nebula")] + [Preview("baptiste")] [ManualRoute("GET", "/orgs/{org}/repos")] public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization) { @@ -459,13 +484,14 @@ public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization) /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> [Preview("nebula")] + [Preview("baptiste")] [ManualRoute("GET", "/orgs/{org}/repos")] public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization), null, AcceptHeaders.VisibilityPreview, options); + return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization), null, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview), options); } /// <summary> @@ -745,7 +771,7 @@ public async Task<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions o { Ensure.ArgumentNotNull(options, nameof(options)); var endpoint = ApiUrls.RepositoryTopics(repositoryId); - var data = await ApiConnection.Get<RepositoryTopics>(endpoint,null,AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + var data = await ApiConnection.Get<RepositoryTopics>(endpoint, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); return data ?? new RepositoryTopics(); } @@ -824,7 +850,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(string owner, string name, Ensure.ArgumentNotNull(topics, nameof(topics)); var endpoint = ApiUrls.RepositoryTopics(owner, name); - var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics,null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); return data ?? new RepositoryTopics(); } diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 09826011e3..a2723a8e27 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -54,6 +54,8 @@ public static class AcceptHeaders public const string VisibilityPreview = "application/vnd.github.nebula-preview+json"; + public const string TemplatePreview = "application/vnd.github.baptiste-preview+json"; + /// <summary> /// Combines multiple preview headers. GitHub API supports Accept header with multiple /// values separated by comma. diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 48b5660ac5..1637866a51 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -58,6 +58,15 @@ public static Uri Repositories(string login) return "users/{0}/repos".FormatUri(login); } + /// <summary> + /// Returns the <see cref="Uri"/> that create a repository using a template. + /// </summary> + /// <returns></returns> + public static Uri Repositories(string owner, string repo) + { + return "repos/{0}/{1}/generate".FormatUri(owner, repo); + } + /// <summary> /// Returns the <see cref="Uri"/> that returns all of the repositories for the specified organization in /// response to a GET request. A POST to this URL creates a new repository for the organization. diff --git a/Octokit/Models/Request/NewRepository.cs b/Octokit/Models/Request/NewRepository.cs index 3942d53ed6..aa5152e618 100644 --- a/Octokit/Models/Request/NewRepository.cs +++ b/Octokit/Models/Request/NewRepository.cs @@ -47,6 +47,11 @@ public NewRepository(string name) /// </summary> public bool? HasWiki { get; set; } + /// <summary> + /// Either true to make this repo available as a template repository or false to prevent it. Default: false. + /// </summary> + public bool? IsTemplate { get; set; } + /// <summary> /// Optional. Gets or sets the new repository's optional website. /// </summary> diff --git a/Octokit/Models/Request/NewRepositoryFromTemplate.cs b/Octokit/Models/Request/NewRepositoryFromTemplate.cs new file mode 100644 index 0000000000..5385ef3cf0 --- /dev/null +++ b/Octokit/Models/Request/NewRepositoryFromTemplate.cs @@ -0,0 +1,46 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Describes a new repository to create via the <see cref="IRepositoriesClient.Generate"/> method. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class NewRepositoryFromTemplate + { + /// <summary> + /// Creates an object that describes the repository to create on GitHub. + /// </summary> + /// <param name="name">The name of the repository. This is the only required parameter.</param> + public NewRepositoryFromTemplate(string name) + { + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + Name = name; + } + + /// <summary> + /// Optional. The organization or person who will own the new repository. + /// To create a new repository in an organization, the authenticated user must be a member of the specified organization. + /// </summary> + public string Owner { get; set; } + + /// <summary> + /// Required. The name of the new repository. + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Optional. A short description of the new repository. + /// </summary> + public string Description { get; set; } + + /// <summary> + /// Optional. Either true to create a new private repository or false to create a new public one. Default: false + /// </summary> + public bool Private { get; set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Name: {0} Description: {1}", Name, Description); + } +} From 23a91a492e22d4d363091b96b2fb79b1d18050f7 Mon Sep 17 00:00:00 2001 From: Lee Boynton <lee@lboynton.com> Date: Wed, 6 Jul 2022 17:29:21 +0100 Subject: [PATCH 062/209] Add method to check if repo vulnerability alerts are enabled (#2453) --- .../Clients/IObservableRepositoriesClient.cs | 11 ++++ .../Clients/ObservableRepositoriesClient.cs | 17 ++++++ .../Clients/RepositoriesClientTests.cs | 11 ++++ .../Clients/RepositoriesClientTests.cs | 52 +++++++++++++++++++ .../ObservableRepositoriesClientTests.cs | 25 +++++++++ Octokit/Clients/IRepositoriesClient.cs | 11 ++++ Octokit/Clients/RepositoriesClient.cs | 26 ++++++++++ Octokit/Helpers/ApiUrls.cs | 11 ++++ 8 files changed, 164 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index d9da62cbc0..dd5c78bc85 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -72,6 +72,17 @@ public interface IObservableRepositoriesClient /// <returns>A <see cref="Repository"/></returns> IObservable<Repository> Transfer(long repositoryId, RepositoryTransfer repositoryTransfer); + /// <summary> + /// Checks if vulnerability alerts are enabled for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The current owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>A <c>bool</c> indicating if alerts are turned on or not.</returns> + IObservable<bool> AreVulnerabilityAlertsEnabled(string owner, string name); + /// <summary> /// Retrieves the <see cref="Repository"/> for the specified owner and name. /// </summary> diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 9fbb2157b1..80f68d1009 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -151,6 +151,23 @@ public IObservable<Repository> Transfer(long repositoryId, RepositoryTransfer re return _client.Transfer(repositoryId, repositoryTransfer).ToObservable(); } + /// <summary> + /// Checks if vulnerability alerts are enabled for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The current owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>A <c>bool</c> indicating if alerts are turned on or not.</returns> + public IObservable<bool> AreVulnerabilityAlertsEnabled(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.AreVulnerabilityAlertsEnabled(owner, name).ToObservable(); + } + /// <summary> /// Retrieves the <see cref="Repository"/> for the specified owner and name. /// </summary> diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index cd1fffea94..cd0c7eb64e 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -2055,4 +2055,15 @@ public async Task TransfersFromUserToOrgWithTeamsById() } } } + + public class TheAreVulnerabilityAlertsEnabledMethod + { + [IntegrationTest] + public async Task AreVulnerabilityAlertsEnabledReturnsTrue() + { + var github = Helper.GetAuthenticatedClient(); + var enabled = await github.Repository.AreVulnerabilityAlertsEnabled("owner", "name"); + Assert.True(enabled); + } + } } diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 00b3b520bf..9d95cd1cee 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -3,8 +3,11 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; +using Octokit.Internal; using Xunit; +using static Octokit.Internal.TestSetup; + namespace Octokit.Tests.Clients { /// <summary> @@ -395,6 +398,55 @@ public async Task SendsPreviewHeaderById() } } + public class TheAreVulnerabilityAlertsEnabledMethod + { + [Theory] + [InlineData(HttpStatusCode.NoContent, true)] + [InlineData(HttpStatusCode.NotFound, false)] + public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected) + { + var response = CreateResponse(status); + var responseTask = Task.FromResult<IApiResponse<object>>(new ApiResponse<object>(response)); + var connection = Substitute.For<IConnection>(); + connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/vulnerability-alerts"), + null, null).Returns(responseTask); + var apiConnection = Substitute.For<IApiConnection>(); + apiConnection.Connection.Returns(connection); + var client = new RepositoriesClient(apiConnection); + + var result = await client.AreVulnerabilityAlertsEnabled("owner", "name"); + + Assert.Equal(expected, result); + } + + [Fact] + public async Task ThrowsExceptionForInvalidStatusCode() + { + var response = CreateResponse(HttpStatusCode.Conflict); + var responseTask = Task.FromResult<IApiResponse<object>>(new ApiResponse<object>(response)); + var connection = Substitute.For<IConnection>(); + connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/vulnerability-alerts"), + null, null).Returns(responseTask); + var apiConnection = Substitute.For<IApiConnection>(); + apiConnection.Connection.Returns(connection); + var client = new RepositoriesClient(apiConnection); + + await Assert.ThrowsAsync<ApiException>(() => client.AreVulnerabilityAlertsEnabled("owner", "name")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoriesClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AreVulnerabilityAlertsEnabled(null, "name")); + await Assert.ThrowsAsync<ArgumentException>(() => client.AreVulnerabilityAlertsEnabled("", "name")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AreVulnerabilityAlertsEnabled( "owner", null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.AreVulnerabilityAlertsEnabled("owner", "")); + } + } + public class TheDeleteMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index ca4ffb13eb..8bac0894d9 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Net; using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; @@ -89,6 +90,30 @@ public void CallsIntoClientById() } } + public class TheIsFollowingMethod + { + [Fact] + public void CallsIntoClient() + { + var githubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositoriesClient(githubClient); + + client.AreVulnerabilityAlertsEnabled("owner", "name"); + githubClient.Repository.Received().AreVulnerabilityAlertsEnabled("owner", "name"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositoriesClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AreVulnerabilityAlertsEnabled(null, "name").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.AreVulnerabilityAlertsEnabled("", "name").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AreVulnerabilityAlertsEnabled("owner", null).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.AreVulnerabilityAlertsEnabled("owner", "").ToTask()); + } + } + public class TheDeleteMethod { [Fact] diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 976766f96c..773b76353c 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -133,6 +133,17 @@ public interface IRepositoriesClient /// <returns>A <see cref="Repository"/></returns> Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositoryTransfer); + /// <summary> + /// Checks if vulnerability alerts are enabled for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The current owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>A <c>bool</c> indicating if alerts are turned on or not.</returns> + Task<bool> AreVulnerabilityAlertsEnabled(string owner, string name); + /// <summary> /// Gets the specified repository. /// </summary> diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 5a279837c0..612de5d15e 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -229,6 +229,32 @@ public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositor return ApiConnection.Post<Repository>(ApiUrls.RepositoryTransfer(repositoryId), repositoryTransfer); } + /// <summary> + /// Checks if vulnerability alerts are enabled for the specified repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The current owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>A <c>bool</c> indicating if alerts are turned on or not.</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/vulnerability-alerts")] + public async Task<bool> AreVulnerabilityAlertsEnabled(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + try + { + var response = await Connection.Get<object>(ApiUrls.RepositoryVulnerabilityAlerts(owner, name), null, null).ConfigureAwait(false); + return response.HttpResponse.IsTrue(); + } + catch (NotFoundException) + { + return false; + } + } + /// <summary> /// Updates the specified repository with the values given in <paramref name="update"/> /// </summary> diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 1637866a51..92616ad1e2 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2255,6 +2255,17 @@ public static Uri RepositoryDeployKeys(string owner, string name) return "repos/{0}/{1}/keys".FormatUri(owner, name); } + /// <summary> + /// Returns the <see cref="Uri"/> for checking vulnerability alerts for a repository. + /// </summary> + /// <param name="owner"></param> + /// <param name="name"></param> + /// <returns></returns> + public static Uri RepositoryVulnerabilityAlerts(string owner, string name) + { + return "repos/{0}/{1}/vulnerability-alerts".FormatUri(owner, name); + } + /// <summary> /// Returns the <see cref="System.Uri"/> for the Deployments API for the given repository. /// </summary> From 6f78c521bce2e8b2a6168bda07e40f609bbe5d27 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 09:02:57 -0500 Subject: [PATCH 063/209] [deps] Microsoft.NET.Test.Sdk from 16.11.0 to 17.2.0 (#2445) --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 9677af5ae3..f612037e9f 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 739074bca8..3b45c0f191 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -36,7 +36,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 514a5c79c6..efc323f0b2 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -36,7 +36,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> From b023602347a57238b634853568111f3584faf0ce Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Mon, 11 Jul 2022 15:03:31 +0100 Subject: [PATCH 064/209] [FEAT] Adding in handling for secondary rate limit exceptions (#2473) --- Octokit.Tests/Http/ConnectionTests.cs | 24 ++++++- .../SecondaryRateLimitExceededException.cs | 67 +++++++++++++++++++ Octokit/Http/Connection.cs | 5 ++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 Octokit/Exceptions/SecondaryRateLimitExceededException.cs diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index c38aee0759..0dc817c246 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -180,7 +180,7 @@ public async Task ThrowsApiValidationExceptionFor422Response() } [Fact] - public async Task ThrowsRateLimitExceededExceptionForForbidderResponse() + public async Task ThrowsRateLimitExceededExceptionForForbiddenResponse() { var httpClient = Substitute.For<IHttpClient>(); var response = CreateResponse( @@ -202,6 +202,28 @@ public async Task ThrowsRateLimitExceededExceptionForForbidderResponse() exception.Message); } + [Fact] + public async Task ThrowsSecondaryRateLimitExceededExceptionForForbiddenResponse() + { + var httpClient = Substitute.For<IHttpClient>(); + var response = CreateResponse( + HttpStatusCode.Forbidden, + "{\"message\":\"You have exceeded a secondary rate limit. Please wait a few minutes before you try again.\"}"); + + httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response)); + var connection = new Connection(new ProductHeaderValue("OctokitTests"), + _exampleUri, + Substitute.For<ICredentialStore>(), + httpClient, + Substitute.For<IJsonSerializer>()); + + var exception = await Assert.ThrowsAsync<SecondaryRateLimitExceededException>( + () => connection.GetResponse<string>(new Uri("endpoint", UriKind.Relative))); + + Assert.Equal("You have exceeded a secondary rate limit. Please wait a few minutes before you try again.", + exception.Message); + } + [Fact] public async Task ThrowsLoginAttemptsExceededExceptionForForbiddenResponse() { diff --git a/Octokit/Exceptions/SecondaryRateLimitExceededException.cs b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs new file mode 100644 index 0000000000..48d264a751 --- /dev/null +++ b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs @@ -0,0 +1,67 @@ +using System; +using System.Diagnostics.CodeAnalysis; +#if !NO_SERIALIZABLE +using System.Runtime.Serialization; +#endif + +namespace Octokit +{ + /// <summary> + /// Exception thrown when Secondary GitHub API Rate limits are exceeded. + /// </summary> + /// <summary> + /// <para> + /// This occurs when GitHub perceives misuse of the API. You may get this if + /// you are polling heavily, creating content rapidly or making concurrent requests. + /// </para> + /// <para>See https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits for more details.</para> + /// </summary> +#if !NO_SERIALIZABLE + [Serializable] +#endif + [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", + Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] + public class SecondaryRateLimitExceededException : ForbiddenException + { + /// <summary> + /// Constructs an instance of the <see cref="Octokit.SecondaryRateLimitExceededException"/> class. + /// </summary> + /// <param name="response">The HTTP payload from the server</param> + public SecondaryRateLimitExceededException(IResponse response) : this(response, null) + { + } + + /// <summary> + /// Constructs an instance of the <see cref="Octokit.SecondaryRateLimitExceededException"/> class. + /// </summary> + /// <param name="response">The HTTP payload from the server</param> + /// <param name="innerException">The inner exception</param> + public SecondaryRateLimitExceededException(IResponse response, Exception innerException) : base(response, innerException) + { + Ensure.ArgumentNotNull(response, nameof(response)); + } + + public override string Message + { + get { return ApiErrorMessageSafe ?? "Secondary API Rate Limit exceeded"; } + } + +#if !NO_SERIALIZABLE + /// <summary> + /// Constructs an instance of <see cref="Octokit.SecondaryRateLimitExceededException"/>. + /// </summary> + /// <param name="info"> + /// The <see cref="SerializationInfo"/> that holds the + /// serialized object data about the exception being thrown. + /// </param> + /// <param name="context"> + /// The <see cref="StreamingContext"/> that contains + /// contextual information about the source or destination. + /// </param> + protected SecondaryRateLimitExceededException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } +#endif + } +} diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 81759fdc2a..46bb710f12 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -724,6 +724,11 @@ static Exception GetExceptionForForbidden(IResponse response) return new RateLimitExceededException(response); } + if (body.Contains("secondary rate limit")) + { + return new SecondaryRateLimitExceededException(response); + } + if (body.Contains("number of login attempts exceeded")) { return new LoginAttemptsExceededException(response); From 3d6cdc459fe000be8c959044a98b8a3d70de1fa6 Mon Sep 17 00:00:00 2001 From: Tim Rogers <me@timrogers.co.uk> Date: Mon, 11 Jul 2022 15:04:44 +0100 Subject: [PATCH 065/209] [MAINT] Tweak `User-Agent` to refer to `Octokit.net`, not just `Octokit` (#2447) --- Octokit.Tests/Http/ConnectionTests.cs | 3 ++- Octokit/Http/Connection.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index 0dc817c246..ced0736d57 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -771,6 +771,7 @@ public void CreatesConnectionWithBaseAddress() Assert.Equal(new Uri("https://github.com/"), connection.BaseAddress); Assert.StartsWith("OctokitTests (", connection.UserAgent); + Assert.Contains("Octokit.net", connection.UserAgent); } } diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 46bb710f12..4f30d5c0ed 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -768,7 +768,7 @@ internal static TwoFactorType ParseTwoFactorType(IResponse restResponse) static string FormatUserAgent(ProductHeaderValue productInformation) { - return string.Format(CultureInfo.InvariantCulture, "{0} ({1}; {2}; Octokit {3})", + return string.Format(CultureInfo.InvariantCulture, "{0} ({1}; {2}; Octokit.net {3})", productInformation, GetPlatformInformation(), GetCultureInformation(), From 1a98d8f0d8e1757e4ac89359e53646a30f08e4a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 09:08:15 -0500 Subject: [PATCH 066/209] [DEPS] Bump NSubstitute from 4.2.2 to 4.3.0 (#2402) --- Octokit.Tests/Octokit.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index efc323f0b2..0a2513010b 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -28,7 +28,7 @@ <ItemGroup> <ProjectReference Include="..\Octokit\Octokit.csproj" /> <ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj" /> - <PackageReference Include="NSubstitute" Version="4.2.2" /> + <PackageReference Include="NSubstitute" Version="4.3.0" /> </ItemGroup> <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' "> From 73b7a7a18ce33862ca48892982d69d952d755df4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 09:10:15 -0500 Subject: [PATCH 067/209] [DEPS] Bump Microsoft.SourceLink.GitHub from 1.0.0 to 1.1.1 (#2372) --- Octokit.Reactive/Octokit.Reactive.csproj | 2 +- Octokit/Octokit.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index aeb9b429da..6bcbbfae72 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -42,7 +42,7 @@ <ItemGroup> <PackageReference Include="System.Reactive" Version="4.4.1" /> - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/> + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index ee3e1bffeb..ace89edc6b 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -44,7 +44,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" /> + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> </ItemGroup> </Project> From f92f0b8194d7105cf08ca8f11eea6f25b9f642e7 Mon Sep 17 00:00:00 2001 From: Jan Verhaeghe <jan@hwfaq.be> Date: Mon, 11 Jul 2022 16:12:20 +0200 Subject: [PATCH 068/209] [FEAT] add Triage/Maintain permission (#2467) --- ...nseModelSetterlessAutoPropertyException.cs | 22 ++++++++++++++ Octokit.Tests.Conventions/ModelTests.cs | 29 ++++++++++++++++++- .../Models/Response/RepositoryPermissions.cs | 27 +++++++++++++---- 3 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 Octokit.Tests.Conventions/Exception/ResponseModelSetterlessAutoPropertyException.cs diff --git a/Octokit.Tests.Conventions/Exception/ResponseModelSetterlessAutoPropertyException.cs b/Octokit.Tests.Conventions/Exception/ResponseModelSetterlessAutoPropertyException.cs new file mode 100644 index 0000000000..4fe22e43d4 --- /dev/null +++ b/Octokit.Tests.Conventions/Exception/ResponseModelSetterlessAutoPropertyException.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace Octokit.Tests.Conventions +{ + public class ResponseModelSetterlessAutoPropertyException : Exception + { + public ResponseModelSetterlessAutoPropertyException(Type modelType, IEnumerable<PropertyInfo> setterlessProperties) + : base(CreateMessage(modelType, setterlessProperties)) + { } + + static string CreateMessage(Type modelType, IEnumerable<PropertyInfo> setterlessProperties) + { + return string.Format("Model type '{0}' contains the following setterless properties: {1}{2}", + modelType.FullName, + Environment.NewLine, + string.Join(Environment.NewLine, setterlessProperties.Select(x => x.Name))); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/ModelTests.cs b/Octokit.Tests.Conventions/ModelTests.cs index e6b19e9dfd..6b7c66c90d 100644 --- a/Octokit.Tests.Conventions/ModelTests.cs +++ b/Octokit.Tests.Conventions/ModelTests.cs @@ -90,7 +90,7 @@ public void AllResponseModelsHavePublicCtorWithAllProperties(Type modelType) [Theory] [MemberData(nameof(ResponseModelTypes))] - public void ResponseModelsHaveGetterOnlyProperties(Type modelType) + public void ResponseModelsHaveNoPublicSettableProperties(Type modelType) { var mutableProperties = new List<PropertyInfo>(); @@ -112,6 +112,33 @@ public void ResponseModelsHaveGetterOnlyProperties(Type modelType) } } + [Theory] + [MemberData(nameof(ResponseModelTypes))] + public void ResponseModelsHaveNoSetterlessAutoPropertiesForReflection(Type modelType) + { + var setterlessAutoProperties = new List<PropertyInfo>(); + + foreach (var property in modelType.GetProperties()) + { + var propertyHasNoSetter = property.GetSetMethod(true) is null; + if (IsAutoProperty(property) && propertyHasNoSetter) + { + setterlessAutoProperties.Add(property); + } + } + + if (setterlessAutoProperties.Any()) + { + throw new ResponseModelSetterlessAutoPropertyException(modelType, setterlessAutoProperties); + } + } + + private bool IsAutoProperty(PropertyInfo prop) + { + return prop.DeclaringType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance) + .Any(f => f.Name.Contains("<" + prop.Name + ">")); + } + [Theory] [MemberData(nameof(ResponseModelTypes))] public void ResponseModelsHaveReadOnlyCollections(Type modelType) diff --git a/Octokit/Models/Response/RepositoryPermissions.cs b/Octokit/Models/Response/RepositoryPermissions.cs index 41c1ec810f..6e43cbd21e 100644 --- a/Octokit/Models/Response/RepositoryPermissions.cs +++ b/Octokit/Models/Response/RepositoryPermissions.cs @@ -1,5 +1,5 @@ using System.Diagnostics; -using System.Globalization; +using System; namespace Octokit { @@ -8,31 +8,46 @@ public class RepositoryPermissions { public RepositoryPermissions() { } - public RepositoryPermissions(bool admin, bool push, bool pull) + public RepositoryPermissions(bool admin, bool maintain, bool push, bool triage, bool pull) { Admin = admin; + Maintain = maintain; Push = push; + Triage = triage; Pull = pull; } /// <summary> /// Whether the current user has administrative permissions /// </summary> - public bool Admin { get; protected set; } + public bool Admin { get; private set;} + + /// <summary> + /// Whether the current user has maintain permissions + /// </summary> + public bool Maintain { get; private set;} /// <summary> /// Whether the current user has push permissions /// </summary> - public bool Push { get; protected set; } + public bool Push { get; private set;} + + /// <summary> + /// Whether the current user has triage permissions + /// </summary> + public bool Triage { get; private set;} /// <summary> /// Whether the current user has pull permissions /// </summary> - public bool Pull { get; protected set; } + public bool Pull { get; private set;} internal string DebuggerDisplay { - get { return string.Format(CultureInfo.InvariantCulture, "Admin: {0}, Push: {1}, Pull: {2}", Admin, Push, Pull); } + get + { + return FormattableString.Invariant($"Admin: {Admin}, Maintain: {Maintain}, Push: {Push}, Triage: {Triage}, Pull: {Pull}"); + } } } } From 21790652015f17cd0ff96b283fe993865e32ea43 Mon Sep 17 00:00:00 2001 From: Stefan-J-Hanke <54064208+Stefan-J-Hanke@users.noreply.github.com> Date: Mon, 11 Jul 2022 16:23:08 +0200 Subject: [PATCH 069/209] [DOCS] Corrects links into github documentation (#2378) --- docs/getting-started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 308de9e93d..ae99a35ca4 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -6,11 +6,11 @@ The easiest way to get started with Octokit is to use a plain `GitHubClient`: var client = new GitHubClient(new ProductHeaderValue("my-cool-app")); ``` -This will let you access unauthenticated GitHub APIs, but you will be subject to rate limiting (you can read more about this [here](https://developer.github.com/v3/#rate-limiting)). +This will let you access unauthenticated GitHub APIs, but you will be subject to rate limiting (you can read more about this [here](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting)). But why do you need this `ProductHeaderValue` value? -The API will reject you if you don't provide a `User-Agent` header (more details [here](https://developer.github.com/v3/#user-agent-required)). This is also to identify applications that are accessing the API and enable GitHub to contact the application author if there are problems. So pick a name that stands out! +The API will reject you if you don't provide a `User-Agent` header (more details [here](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required)). This is also to identify applications that are accessing the API and enable GitHub to contact the application author if there are problems. So pick a name that stands out! ### Authenticated Access From 8e6bcd1e496d64243ee64e3e7ff4de5fe01fa731 Mon Sep 17 00:00:00 2001 From: tasadar2 <4000239+tasadar2@users.noreply.github.com> Date: Mon, 11 Jul 2022 10:59:24 -0400 Subject: [PATCH 070/209] [FEAT] Added enterprise pre-receive hooks client (#2375) --- .../Enterprise/IObservableEnterpriseClient.cs | 8 + ...servableEnterprisePreReceiveHooksClient.cs | 77 ++++ .../Enterprise/ObservableEnterpriseClient.cs | 9 + ...servableEnterprisePreReceiveHooksClient.cs | 114 ++++++ .../EnterprisePreReceiveHooksClientTests.cs | 357 +++++++++++++++++ Octokit.Tests.Integration/EnterpriseHelper.cs | 14 + ...bleEnterprisePreReceiveHooksClientTests.cs | 359 ++++++++++++++++++ .../EnterprisePreReceiveHooksClientTests.cs | 158 ++++++++ ...bleEnterprisePreReceiveHooksClientTests.cs | 159 ++++++++ .../Clients/Enterprise/EnterpriseClient.cs | 9 + .../EnterprisePreReceiveHooksClient.cs | 118 ++++++ .../Clients/Enterprise/IEnterpriseClient.cs | 8 + .../IEnterprisePreReceiveHooksClient.cs | 77 ++++ Octokit/Helpers/ApiUrls.cs | 18 + .../Request/Enterprise/NewPreReceiveHook.cs | 98 +++++ .../PreReceiveEnvironmentReference.cs | 22 ++ .../Request/Enterprise/RepositoryReference.cs | 22 ++ .../Enterprise/UpdatePreReceiveHook.cs | 47 +++ .../Response/Enterprise/PreReceiveHook.cs | 85 +++++ .../Enterprise/PreReceiveHookEnforcement.cs | 28 ++ 20 files changed, 1787 insertions(+) create mode 100644 Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs create mode 100644 Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs create mode 100644 Octokit.Tests.Integration/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs create mode 100644 Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs create mode 100644 Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs create mode 100644 Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs create mode 100644 Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs create mode 100644 Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs create mode 100644 Octokit/Models/Request/Enterprise/NewPreReceiveHook.cs create mode 100644 Octokit/Models/Request/Enterprise/PreReceiveEnvironmentReference.cs create mode 100644 Octokit/Models/Request/Enterprise/RepositoryReference.cs create mode 100644 Octokit/Models/Request/Enterprise/UpdatePreReceiveHook.cs create mode 100644 Octokit/Models/Response/Enterprise/PreReceiveHook.cs create mode 100644 Octokit/Models/Response/Enterprise/PreReceiveHookEnforcement.cs diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs index f3aa7fdcc3..ed7cf6467e 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs @@ -63,5 +63,13 @@ public interface IObservableEnterpriseClient /// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/">Enterprise Pre-receive Environments API documentation</a> for more information. ///</remarks> IObservableEnterprisePreReceiveEnvironmentsClient PreReceiveEnvironment { get; } + + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + IObservableEnterprisePreReceiveHooksClient PreReceiveHook { get; } } } diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs new file mode 100644 index 0000000000..1cd389481f --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs @@ -0,0 +1,77 @@ +using System; +using System.Reactive; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + public interface IObservableEnterprisePreReceiveHooksClient + { + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<PreReceiveHook> GetAll(); + + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <param name="options">Options for changing the API response</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<PreReceiveHook> GetAll(ApiOptions options); + + /// <summary> + /// Gets a single <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<PreReceiveHook> Get(long hookId); + + /// <summary> + /// Creates a new <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook); + + /// <summary> + /// Edits an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook updatePreReceiveHook); + + /// <summary> + /// Deletes an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<Unit> Delete(long hookId); + } +} diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs index e9d01ae29e..44ddd5f528 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs @@ -19,6 +19,7 @@ public ObservableEnterpriseClient(IGitHubClient client) Organization = new ObservableEnterpriseOrganizationClient(client); SearchIndexing = new ObservableEnterpriseSearchIndexingClient(client); PreReceiveEnvironment = new ObservableEnterprisePreReceiveEnvironmentsClient(client); + PreReceiveHook = new ObservableEnterprisePreReceiveHooksClient(client); } /// <summary> @@ -76,5 +77,13 @@ public ObservableEnterpriseClient(IGitHubClient client) /// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/">Enterprise Pre-receive Environments API documentation</a> for more information. ///</remarks> public IObservableEnterprisePreReceiveEnvironmentsClient PreReceiveEnvironment { get; private set; } + + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + public IObservableEnterprisePreReceiveHooksClient PreReceiveHook { get; private set; } } } diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs new file mode 100644 index 0000000000..7320aaa067 --- /dev/null +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs @@ -0,0 +1,114 @@ +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + public class ObservableEnterprisePreReceiveHooksClient : IObservableEnterprisePreReceiveHooksClient + { + readonly IEnterprisePreReceiveHooksClient _client; + readonly IConnection _connection; + + public ObservableEnterprisePreReceiveHooksClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Enterprise.PreReceiveHook; + _connection = client.Connection; + } + + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<PreReceiveHook> GetAll() + { + return GetAll(ApiOptions.None); + } + + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <param name="options">Options for changing the API response</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<PreReceiveHook> GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<PreReceiveHook>(ApiUrls.AdminPreReceiveHooks(), null, AcceptHeaders.StableVersionJson, options); + } + + /// <summary> + /// Gets a single <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<PreReceiveHook> Get(long hookId) + { + return _client.Get(hookId).ToObservable(); + } + + /// <summary> + /// Creates a new <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook) + { + Ensure.ArgumentNotNull(newPreReceiveHook, nameof(newPreReceiveHook)); + + return _client.Create(newPreReceiveHook).ToObservable(); + } + + /// <summary> + /// Edits an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook updatePreReceiveHook) + { + Ensure.ArgumentNotNull(updatePreReceiveHook, nameof(updatePreReceiveHook)); + + return _client.Edit(hookId, updatePreReceiveHook).ToObservable(); + } + + /// <summary> + /// Deletes an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<Unit> Delete(long hookId) + { + return _client.Delete(hookId).ToObservable(); + } + } +} diff --git a/Octokit.Tests.Integration/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs b/Octokit.Tests.Integration/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs new file mode 100644 index 0000000000..4f4583779f --- /dev/null +++ b/Octokit.Tests.Integration/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs @@ -0,0 +1,357 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Octokit; +using Octokit.Tests.Integration; +using Xunit; + +public class EnterprisePreReceiveHooksClientTests +{ + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new EnterprisePreReceiveHooksClient(null)); + } + } + + public class TheGetAllMethod : IDisposable + { + private readonly IGitHubClient _githubEnterprise; + private readonly IEnterprisePreReceiveHooksClient _preReceiveHooksClient; + private readonly List<PreReceiveHook> _preReceiveHooks; + + public TheGetAllMethod() + { + _githubEnterprise = EnterpriseHelper.GetAuthenticatedClient(); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + + _preReceiveHooks = new List<PreReceiveHook>(); + for (var count = 0; count < 3; count++) + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + _preReceiveHooks.Add(_preReceiveHooksClient.Create(newPreReceiveHook).Result); + } + } + + [GitHubEnterpriseTest] + public async Task ReturnsPreReceiveHooks() + { + var preReceiveHooks = await _preReceiveHooksClient.GetAll(); + + Assert.NotEmpty(preReceiveHooks); + } + + [GitHubEnterpriseTest] + public async Task ReturnsCorrectCountOfPreReceiveHooksWithoutStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var preReceiveHooks = await _preReceiveHooksClient.GetAll(options); + + Assert.Equal(1, preReceiveHooks.Count); + } + + [GitHubEnterpriseTest] + public async Task ReturnsCorrectCountOfPreReceiveHooksWithStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var preReceiveHooks = await _preReceiveHooksClient.GetAll(options); + + Assert.Equal(1, preReceiveHooks.Count); + } + + [GitHubEnterpriseTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstPage = await _preReceiveHooksClient.GetAll(startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _preReceiveHooksClient.GetAll(skipStartOptions); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + } + + public void Dispose() + { + foreach (var preReceiveHook in _preReceiveHooks) + { + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + } + + public class TheGetMethod : IDisposable + { + private readonly IGitHubClient _githubEnterprise; + private readonly IEnterprisePreReceiveHooksClient _preReceiveHooksClient; + private readonly NewPreReceiveHook _expectedPreReceiveHook; + private readonly PreReceiveHook _preReceiveHook; + + public TheGetMethod() + { + _githubEnterprise = EnterpriseHelper.GetAuthenticatedClient(); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + + _expectedPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1) + { + AllowDownstreamConfiguration = true, + Enforcement = PreReceiveHookEnforcement.Testing, + }; + _preReceiveHook = _preReceiveHooksClient.Create(_expectedPreReceiveHook).Result; + } + + [GitHubEnterpriseTest] + public async Task ReturnsName() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.Name, preReceiveHook.Name); + } + + [GitHubEnterpriseTest] + public async Task ReturnsScript() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.Script, preReceiveHook.Script); + } + + [GitHubEnterpriseTest] + public async Task ReturnsRepository() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.NotNull(preReceiveHook.ScriptRepository); + Assert.Equal(_expectedPreReceiveHook.ScriptRepository.FullName, preReceiveHook.ScriptRepository.FullName); + } + + [GitHubEnterpriseTest] + public async Task ReturnsEnvironment() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.NotNull(preReceiveHook.Environment); + Assert.Equal(_expectedPreReceiveHook.Environment.Id, preReceiveHook.Environment.Id); + } + + [GitHubEnterpriseTest] + public async Task ReturnsAllowDownstreamConfiguration() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.AllowDownstreamConfiguration, preReceiveHook.AllowDownstreamConfiguration); + } + + [GitHubEnterpriseTest] + public async Task ReturnsEnforcement() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.Enforcement.Value, preReceiveHook.Enforcement); + } + + [GitHubEnterpriseTest] + public async Task NoHookExists() + { + await Assert.ThrowsAsync<NotFoundException>(() => _preReceiveHooksClient.Get(-1)); + } + + public void Dispose() + { + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, _preReceiveHook); + } + } + + public class TheCreateMethod + { + private readonly IGitHubClient _githubEnterprise; + private readonly IEnterprisePreReceiveHooksClient _preReceiveHooksClient; + + public TheCreateMethod() + { + _githubEnterprise = EnterpriseHelper.GetAuthenticatedClient(); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + } + + [GitHubEnterpriseTest] + public async Task CanCreatePreReceiveHook() + { + PreReceiveHook preReceiveHook = null; + try + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + Assert.NotNull(preReceiveHook); + Assert.Equal(newPreReceiveHook.Name, preReceiveHook.Name); + Assert.Equal(newPreReceiveHook.Script, preReceiveHook.Script); + Assert.Equal(newPreReceiveHook.ScriptRepository.FullName, preReceiveHook.ScriptRepository.FullName); + Assert.Equal(newPreReceiveHook.Environment.Id, preReceiveHook.Environment.Id); + } + finally + { + //Cleanup + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWhenRepoDoesNotExist() + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "doesntExist/repo", Helper.MakeNameWithTimestamp("script"), 1); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWhenEnvironmentDoesNotExist() + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), -1); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWithSameName() + { + PreReceiveHook preReceiveHook = null; + try + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + newPreReceiveHook.Script = Helper.MakeNameWithTimestamp("script"); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + finally + { + //Cleanup + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWithSameScript() + { + PreReceiveHook preReceiveHook = null; + try + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + newPreReceiveHook.Name = Helper.MakeNameWithTimestamp("hook"); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + finally + { + //Cleanup + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + } + + public class TheEditMethod : IDisposable + { + private readonly IGitHubClient _githubEnterprise; + private readonly IEnterprisePreReceiveHooksClient _preReceiveHooksClient; + private readonly PreReceiveHook _preReceiveHook; + + public TheEditMethod() + { + _githubEnterprise = EnterpriseHelper.GetAuthenticatedClient(); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + _preReceiveHook = _preReceiveHooksClient.Create(newPreReceiveHook).Result; + } + + [GitHubEnterpriseTest] + public async Task CanChangeName() + { + var updatePreReceiveHook = new UpdatePreReceiveHook + { + Name = Helper.MakeNameWithTimestamp("hook") + }; + + var updatedPreReceiveHook = await _preReceiveHooksClient.Edit(_preReceiveHook.Id, updatePreReceiveHook); + + Assert.Equal(_preReceiveHook.Id, updatedPreReceiveHook.Id); + Assert.Equal(updatePreReceiveHook.Name, updatedPreReceiveHook.Name); + } + + [GitHubEnterpriseTest] + public async Task CanChangeScript() + { + var updatePreReceiveHook = new UpdatePreReceiveHook + { + Script = Helper.MakeNameWithTimestamp("script") + }; + + var updatedPreReceiveHook = await _preReceiveHooksClient.Edit(_preReceiveHook.Id, updatePreReceiveHook); + + Assert.Equal(_preReceiveHook.Id, updatedPreReceiveHook.Id); + Assert.Equal(updatePreReceiveHook.Script, updatedPreReceiveHook.Script); + } + + public void Dispose() + { + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, _preReceiveHook); + } + } + + public class TheDeleteMethod + { + private readonly IEnterprisePreReceiveHooksClient _preReceiveHooksClient; + + public TheDeleteMethod() + { + var githubEnterprise = EnterpriseHelper.GetAuthenticatedClient(); + _preReceiveHooksClient = githubEnterprise.Enterprise.PreReceiveHook; + } + + [GitHubEnterpriseTest] + public async Task CanDelete() + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + var preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + await _preReceiveHooksClient.Delete(preReceiveHook.Id); + + await Assert.ThrowsAsync<NotFoundException>(async () => await _preReceiveHooksClient.Get(preReceiveHook.Id)); + } + + [GitHubEnterpriseTest] + public async Task CannotDeleteWhenHookDoesNotExist() + { + await Assert.ThrowsAsync<NotFoundException>(async () => await _preReceiveHooksClient.Delete(-1)); + } + } +} diff --git a/Octokit.Tests.Integration/EnterpriseHelper.cs b/Octokit.Tests.Integration/EnterpriseHelper.cs index bd9f5cde1e..3d123730a4 100644 --- a/Octokit.Tests.Integration/EnterpriseHelper.cs +++ b/Octokit.Tests.Integration/EnterpriseHelper.cs @@ -161,6 +161,20 @@ public static void DeletePreReceiveEnvironment(IConnection connection, PreReceiv } } + public static void DeletePreReceiveHook(IConnection connection, PreReceiveHook preReceiveHook) + { + if (preReceiveHook != null) + { + try + { + var client = new GitHubClient(connection); + client.Enterprise.PreReceiveHook.Delete(preReceiveHook.Id).Wait(TimeSpan.FromSeconds(15)); + } + catch + { } + } + } + public static void SetMaintenanceMode(IConnection connection, bool enabled) { try diff --git a/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs new file mode 100644 index 0000000000..2ec9b074a8 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs @@ -0,0 +1,359 @@ +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit; +using Octokit.Reactive; +using Octokit.Tests.Integration; +using Xunit; + +public class ObservableEnterprisePreReceiveHooksClientTests +{ + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new EnterprisePreReceiveHooksClient(null)); + } + } + + public class TheGetAllMethod : IDisposable + { + private readonly IObservableGitHubClient _githubEnterprise; + private readonly IObservableEnterprisePreReceiveHooksClient _preReceiveHooksClient; + private readonly List<PreReceiveHook> _preReceiveHooks; + + public TheGetAllMethod() + { + _githubEnterprise = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient()); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + + _preReceiveHooks = new List<PreReceiveHook>(); + for (var count = 0; count < 3; count++) + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + _preReceiveHooks.Add(_preReceiveHooksClient.Create(newPreReceiveHook).Wait()); + } + } + + [GitHubEnterpriseTest] + public async Task ReturnsPreReceiveHooks() + { + var preReceiveHooks = await _preReceiveHooksClient.GetAll().ToList(); + + Assert.NotEmpty(preReceiveHooks); + } + + [GitHubEnterpriseTest] + public async Task ReturnsCorrectCountOfPreReceiveHooksWithoutStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var preReceiveHooks = await _preReceiveHooksClient.GetAll(options).ToList(); + + Assert.Equal(1, preReceiveHooks.Count); + } + + [GitHubEnterpriseTest] + public async Task ReturnsCorrectCountOfPreReceiveHooksWithStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var preReceiveHooks = await _preReceiveHooksClient.GetAll(options).ToList(); + + Assert.Equal(1, preReceiveHooks.Count); + } + + [GitHubEnterpriseTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstPage = await _preReceiveHooksClient.GetAll(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _preReceiveHooksClient.GetAll(skipStartOptions).ToList(); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + } + + public void Dispose() + { + foreach (var preReceiveHook in _preReceiveHooks) + { + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + } + + public class TheGetMethod : IDisposable + { + private readonly IObservableGitHubClient _githubEnterprise; + private readonly IObservableEnterprisePreReceiveHooksClient _preReceiveHooksClient; + private readonly NewPreReceiveHook _expectedPreReceiveHook; + private readonly PreReceiveHook _preReceiveHook; + + public TheGetMethod() + { + _githubEnterprise = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient()); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + + _expectedPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1) + { + AllowDownstreamConfiguration = true, + Enforcement = PreReceiveHookEnforcement.Testing, + }; + _preReceiveHook = _preReceiveHooksClient.Create(_expectedPreReceiveHook).Wait(); + } + + [GitHubEnterpriseTest] + public async Task ReturnsName() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.Name, preReceiveHook.Name); + } + + [GitHubEnterpriseTest] + public async Task ReturnsScript() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.Script, preReceiveHook.Script); + } + + [GitHubEnterpriseTest] + public async Task ReturnsRepository() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.NotNull(preReceiveHook.ScriptRepository); + Assert.Equal(_expectedPreReceiveHook.ScriptRepository.FullName, preReceiveHook.ScriptRepository.FullName); + } + + [GitHubEnterpriseTest] + public async Task ReturnsEnvironment() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.NotNull(preReceiveHook.Environment); + Assert.Equal(_expectedPreReceiveHook.Environment.Id, preReceiveHook.Environment.Id); + } + + [GitHubEnterpriseTest] + public async Task ReturnsAllowDownstreamConfiguration() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.AllowDownstreamConfiguration, preReceiveHook.AllowDownstreamConfiguration); + } + + [GitHubEnterpriseTest] + public async Task ReturnsEnforcement() + { + var preReceiveHook = await _preReceiveHooksClient.Get(_preReceiveHook.Id); + + Assert.NotNull(preReceiveHook); + Assert.Equal(_expectedPreReceiveHook.Enforcement.Value, preReceiveHook.Enforcement); + } + + [GitHubEnterpriseTest] + public async Task NoHookExists() + { + await Assert.ThrowsAsync<NotFoundException>(async () => await _preReceiveHooksClient.Get(-1)); + } + + public void Dispose() + { + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, _preReceiveHook); + } + } + + public class TheCreateMethod + { + private readonly IObservableGitHubClient _githubEnterprise; + private readonly IObservableEnterprisePreReceiveHooksClient _preReceiveHooksClient; + + public TheCreateMethod() + { + _githubEnterprise = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient()); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + } + + [GitHubEnterpriseTest] + public async Task CanCreatePreReceiveHook() + { + PreReceiveHook preReceiveHook = null; + try + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + Assert.NotNull(preReceiveHook); + Assert.Equal(newPreReceiveHook.Name, preReceiveHook.Name); + Assert.Equal(newPreReceiveHook.Script, preReceiveHook.Script); + Assert.Equal(newPreReceiveHook.ScriptRepository.FullName, preReceiveHook.ScriptRepository.FullName); + Assert.Equal(newPreReceiveHook.Environment.Id, preReceiveHook.Environment.Id); + } + finally + { + //Cleanup + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWhenRepoDoesNotExist() + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "doesntExist/repo", Helper.MakeNameWithTimestamp("script"), 1); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWhenEnvironmentDoesNotExist() + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), -1); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWithSameName() + { + PreReceiveHook preReceiveHook = null; + try + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + newPreReceiveHook.Script = Helper.MakeNameWithTimestamp("script"); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + finally + { + //Cleanup + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + + [GitHubEnterpriseTest] + public async Task CannotCreateWithSameScript() + { + PreReceiveHook preReceiveHook = null; + try + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + newPreReceiveHook.Name = Helper.MakeNameWithTimestamp("hook"); + await Assert.ThrowsAsync<ApiValidationException>(async () => await _preReceiveHooksClient.Create(newPreReceiveHook)); + } + finally + { + //Cleanup + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, preReceiveHook); + } + } + } + + public class TheEditMethod : IDisposable + { + private readonly IObservableGitHubClient _githubEnterprise; + private readonly IObservableEnterprisePreReceiveHooksClient _preReceiveHooksClient; + private readonly PreReceiveHook _preReceiveHook; + + public TheEditMethod() + { + _githubEnterprise = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient()); + _preReceiveHooksClient = _githubEnterprise.Enterprise.PreReceiveHook; + + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + _preReceiveHook = _preReceiveHooksClient.Create(newPreReceiveHook).Wait(); + } + + [GitHubEnterpriseTest] + public async Task CanChangeName() + { + var updatePreReceiveHook = new UpdatePreReceiveHook + { + Name = Helper.MakeNameWithTimestamp("hook") + }; + + var updatedPreReceiveHook = await _preReceiveHooksClient.Edit(_preReceiveHook.Id, updatePreReceiveHook); + + Assert.Equal(_preReceiveHook.Id, updatedPreReceiveHook.Id); + Assert.Equal(updatePreReceiveHook.Name, updatedPreReceiveHook.Name); + } + + [GitHubEnterpriseTest] + public async Task CanChangeScript() + { + var updatePreReceiveHook = new UpdatePreReceiveHook + { + Script = Helper.MakeNameWithTimestamp("script") + }; + + var updatedPreReceiveHook = await _preReceiveHooksClient.Edit(_preReceiveHook.Id, updatePreReceiveHook); + + Assert.Equal(_preReceiveHook.Id, updatedPreReceiveHook.Id); + Assert.Equal(updatePreReceiveHook.Script, updatedPreReceiveHook.Script); + } + + public void Dispose() + { + EnterpriseHelper.DeletePreReceiveHook(_githubEnterprise.Connection, _preReceiveHook); + } + } + + public class TheDeleteMethod + { + private readonly IObservableEnterprisePreReceiveHooksClient _preReceiveHooksClient; + + public TheDeleteMethod() + { + var githubEnterprise = new ObservableGitHubClient(EnterpriseHelper.GetAuthenticatedClient()); + _preReceiveHooksClient = githubEnterprise.Enterprise.PreReceiveHook; + } + + [GitHubEnterpriseTest] + public async Task CanDelete() + { + var newPreReceiveHook = new NewPreReceiveHook(Helper.MakeNameWithTimestamp("hook"), "octokit/octokit.net", Helper.MakeNameWithTimestamp("script"), 1); + var preReceiveHook = await _preReceiveHooksClient.Create(newPreReceiveHook); + + await _preReceiveHooksClient.Delete(preReceiveHook.Id); + + await Assert.ThrowsAsync<NotFoundException>(async () => await _preReceiveHooksClient.Get(preReceiveHook.Id)); + } + + [GitHubEnterpriseTest] + public async Task CannotDeleteWhenHookDoesNotExist() + { + await Assert.ThrowsAsync<NotFoundException>(async () => await _preReceiveHooksClient.Delete(-1)); + } + } +} diff --git a/Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs new file mode 100644 index 0000000000..fac4f0804f --- /dev/null +++ b/Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveHooksClientTests.cs @@ -0,0 +1,158 @@ +using System; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class EnterprisePreReceiveHooksClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new EnterprisePreReceiveHooksClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new EnterprisePreReceiveHooksClient(connection); + + await client.GetAll(); + + connection.Received().GetAll<PreReceiveHook>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-hooks"), + null, + "application/vnd.github.v3+json", + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For<IApiConnection>(); + var client = new EnterprisePreReceiveHooksClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + await client.GetAll(options); + + connection.Received().GetAll<PreReceiveHook>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-hooks"), + null, + "application/vnd.github.v3+json", + options); + } + } + + public class TheGetMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new EnterprisePreReceiveHooksClient(connection); + + await client.Get(1); + + connection.Received().Get<PreReceiveHook>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-hooks/1"), + null, + "application/vnd.github.v3+json"); + } + } + + public class TheCreateMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new EnterprisePreReceiveHooksClient(connection); + var data = new NewPreReceiveHook("name", "repo", "script", 1); + + await client.Create(data); + + connection.Received().Post<PreReceiveHook>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-hooks"), + data, + "application/vnd.github.v3+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new EnterprisePreReceiveHooksClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null)); + + Assert.Throws<ArgumentNullException>(() => new NewPreReceiveHook(null, "repo", "script", 1)); + Assert.Throws<ArgumentException>(() => new NewPreReceiveHook("", "repo", "script", 1)); + Assert.Throws<ArgumentNullException>(() => new NewPreReceiveHook("name", null, "script", 1)); + Assert.Throws<ArgumentException>(() => new NewPreReceiveHook("name", "", "script", 1)); + Assert.Throws<ArgumentNullException>(() => new NewPreReceiveHook("name", "repo", null, 1)); + Assert.Throws<ArgumentException>(() => new NewPreReceiveHook("name", "repo", "", 1)); + } + } + + public class TheEditMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new EnterprisePreReceiveHooksClient(connection); + var data = new UpdatePreReceiveHook + { + Name = "name", + ScriptRepository = new RepositoryReference + { + FullName = "repo" + }, + Script = "script", + Environment = new PreReceiveEnvironmentReference + { + Id = 1 + } + }; + + await client.Edit(1, data); + + connection.Received().Patch<PreReceiveHook>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-hooks/1"), + data, + "application/vnd.github.v3+json"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new EnterprisePreReceiveHooksClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(1, null)); + } + } + + public class TheDeleteMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new EnterprisePreReceiveHooksClient(connection); + + await client.Delete(1); + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-hooks/1"), + Arg.Any<object>(), + "application/vnd.github.v3+json"); + } + } + } +} diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs new file mode 100644 index 0000000000..6158826762 --- /dev/null +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveHooksClientTests.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableEnterprisePreReceiveHooksClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableEnterprisePreReceiveHooksClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableEnterprisePreReceiveHooksClient(gitHubClient); + + client.GetAll(); + + gitHubClient.Connection.Received(1).Get<List<PreReceiveHook>>( + new Uri("admin/pre-receive-hooks", UriKind.Relative), + Args.EmptyDictionary, + "application/vnd.github.v3+json"); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableEnterprisePreReceiveHooksClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + client.GetAll(options); + + gitHubClient.Connection.Received(1).Get<List<PreReceiveHook>>( + new Uri("admin/pre-receive-hooks", UriKind.Relative), + Arg.Is<IDictionary<string, string>>(d => d.Count == 2), + "application/vnd.github.v3+json"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableEnterprisePreReceiveHooksClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetAll(null)); + } + } + + public class TheGetMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableEnterprisePreReceiveHooksClient(gitHubClient); + + client.Get(1); + + gitHubClient.Enterprise.PreReceiveHook.Received(1).Get(1); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableEnterprisePreReceiveHooksClient(gitHubClient); + var data = new NewPreReceiveHook("name", "repo", "script", 1); + + client.Create(data); + + gitHubClient.Enterprise.PreReceiveHook.Received(1).Create(data); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableEnterprisePreReceiveHooksClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.Create(null)); + + Assert.Throws<ArgumentNullException>(() => new NewPreReceiveHook(null, "repo", "script", 1)); + Assert.Throws<ArgumentException>(() => new NewPreReceiveHook("", "repo", "script", 1)); + Assert.Throws<ArgumentNullException>(() => new NewPreReceiveHook("name", null, "script", 1)); + Assert.Throws<ArgumentException>(() => new NewPreReceiveHook("name", "", "script", 1)); + Assert.Throws<ArgumentNullException>(() => new NewPreReceiveHook("name", "repo", null, 1)); + Assert.Throws<ArgumentException>(() => new NewPreReceiveHook("name", "repo", "", 1)); + } + } + + public class TheEditMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var releasesClient = new ObservableEnterprisePreReceiveHooksClient(gitHubClient); + var data = new UpdatePreReceiveHook + { + Name = "name", + ScriptRepository = new RepositoryReference + { + FullName = "repo" + }, + Script = "script", + Environment = new PreReceiveEnvironmentReference + { + Id = 1 + } + }; + + releasesClient.Edit(1, data); + + gitHubClient.Enterprise.PreReceiveHook.Received(1).Edit(1, data); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableEnterprisePreReceiveHooksClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.Edit(1, null)); + } + } + + public class TheDeleteMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableEnterprisePreReceiveHooksClient(gitHubClient); + + client.Delete(1); + + gitHubClient.Enterprise.PreReceiveHook.Received(1).Delete(1); + } + } + } +} diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs index d3d37fd42f..adfdaf1af3 100644 --- a/Octokit/Clients/Enterprise/EnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -21,6 +21,7 @@ public EnterpriseClient(IApiConnection apiConnection) : base(apiConnection) Organization = new EnterpriseOrganizationClient(apiConnection); SearchIndexing = new EnterpriseSearchIndexingClient(apiConnection); PreReceiveEnvironment = new EnterprisePreReceiveEnvironmentsClient(apiConnection); + PreReceiveHook = new EnterprisePreReceiveHooksClient(apiConnection); } /// <summary> @@ -78,5 +79,13 @@ public EnterpriseClient(IApiConnection apiConnection) : base(apiConnection) /// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/">Enterprise Pre-receive Environments API documentation</a> for more information. ///</remarks> public IEnterprisePreReceiveEnvironmentsClient PreReceiveEnvironment { get; private set; } + + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + public IEnterprisePreReceiveHooksClient PreReceiveHook { get; private set; } } } diff --git a/Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs b/Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs new file mode 100644 index 0000000000..6bde1e1952 --- /dev/null +++ b/Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs @@ -0,0 +1,118 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + public class EnterprisePreReceiveHooksClient : ApiClient, IEnterprisePreReceiveHooksClient + { + /// <summary> + /// Initializes a new instance of <see cref="EnterprisePreReceiveHooksClient"/>. + /// </summary> + /// <param name="apiConnection">An API connection</param> + public EnterprisePreReceiveHooksClient(IApiConnection apiConnection) + : base(apiConnection) + { } + + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("GET", "/admin/pre-receive-hooks")] + public Task<IReadOnlyList<PreReceiveHook>> GetAll() + { + return GetAll(ApiOptions.None); + } + + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <param name="options">Options for changing the API response</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("GET", "/admin/pre-receive-hooks")] + public Task<IReadOnlyList<PreReceiveHook>> GetAll(ApiOptions options) + { + var endpoint = ApiUrls.AdminPreReceiveHooks(); + return ApiConnection.GetAll<PreReceiveHook>(endpoint, null, AcceptHeaders.StableVersionJson, options); + } + + /// <summary> + /// Gets a single <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("GET", "/admin/pre-receive-hooks/{pre_receive_hook_id}")] + public Task<PreReceiveHook> Get(long hookId) + { + var endpoint = ApiUrls.AdminPreReceiveHooks(hookId); + return ApiConnection.Get<PreReceiveHook>(endpoint, null, AcceptHeaders.StableVersionJson); + } + + /// <summary> + /// Creates a new <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("POST", "/admin/pre-receive-hooks")] + public Task<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook) + { + Ensure.ArgumentNotNull(newPreReceiveHook, nameof(newPreReceiveHook)); + + var endpoint = ApiUrls.AdminPreReceiveHooks(); + return ApiConnection.Post<PreReceiveHook>(endpoint, newPreReceiveHook, AcceptHeaders.StableVersionJson); + } + + /// <summary> + /// Edits an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("PATCH", "/admin/pre-receive-hooks/{pre_receive_hook_id}")] + public Task<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook updatePreReceiveHook) + { + Ensure.ArgumentNotNull(updatePreReceiveHook, nameof(updatePreReceiveHook)); + + var endpoint = ApiUrls.AdminPreReceiveHooks(hookId); + return ApiConnection.Patch<PreReceiveHook>(endpoint, updatePreReceiveHook, AcceptHeaders.StableVersionJson); + } + + /// <summary> + /// Deletes an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("DELETE", "/admin/pre-receive-hooks/{pre_receive_hook_id}")] + public Task Delete(long hookId) + { + var endpoint = ApiUrls.AdminPreReceiveHooks(hookId); + return ApiConnection.Delete(endpoint, new object(), AcceptHeaders.StableVersionJson); + } + } +} diff --git a/Octokit/Clients/Enterprise/IEnterpriseClient.cs b/Octokit/Clients/Enterprise/IEnterpriseClient.cs index 8a7841d5e0..30b1502d69 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseClient.cs @@ -63,5 +63,13 @@ public interface IEnterpriseClient /// See the <a href="https://developer.github.com/v3/enterprise-admin/pre_receive_environments/">Enterprise Pre-receive Environments API documentation</a> for more information. ///</remarks> IEnterprisePreReceiveEnvironmentsClient PreReceiveEnvironment { get; } + + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server@3.3/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + IEnterprisePreReceiveHooksClient PreReceiveHook { get; } } } diff --git a/Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs b/Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs new file mode 100644 index 0000000000..eb1e0e09a2 --- /dev/null +++ b/Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Enterprise Pre-receive Hooks API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + ///</remarks> + public interface IEnterprisePreReceiveHooksClient + { + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<IReadOnlyList<PreReceiveHook>> GetAll(); + + /// <summary> + /// Gets all <see cref="PreReceiveHook"/>s. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// </remarks> + /// <param name="options">Options for changing the API response</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<IReadOnlyList<PreReceiveHook>> GetAll(ApiOptions options); + + /// <summary> + /// Gets a single <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<PreReceiveHook> Get(long hookId); + + /// <summary> + /// Creates a new <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook); + + /// <summary> + /// Edits an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook updatePreReceiveHook); + + /// <summary> + /// Deletes an existing <see cref="PreReceiveHook"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// </remarks> + /// <param name="hookId">The id of the pre-receive hook</param> + /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task Delete(long hookId); + } +} \ No newline at end of file diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 92616ad1e2..5544d18a59 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2724,6 +2724,24 @@ public static Uri AdminPreReceiveEnvironmentDownloadStatus(long environmentId) return "admin/pre-receive-environments/{0}/downloads/latest".FormatUri(environmentId); } + /// <summary> + /// Creates the <see cref="Uri"/> for pre-receive hooks. + /// </summary> + /// <returns></returns> + public static Uri AdminPreReceiveHooks() + { + return "admin/pre-receive-hooks".FormatUri(); + } + + /// <summary> + /// Creates the <see cref="Uri"/> for pre-receive hooks. + /// </summary> + /// <returns></returns> + public static Uri AdminPreReceiveHooks(long hookId) + { + return "admin/pre-receive-hooks/{0}".FormatUri(hookId); + } + /// <summary> /// Creates the relative <see cref="Uri"/> for altering administration status of a user. /// </summary> diff --git a/Octokit/Models/Request/Enterprise/NewPreReceiveHook.cs b/Octokit/Models/Request/Enterprise/NewPreReceiveHook.cs new file mode 100644 index 0000000000..2a5a4c442c --- /dev/null +++ b/Octokit/Models/Request/Enterprise/NewPreReceiveHook.cs @@ -0,0 +1,98 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Describes a new pre-receive hook. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class NewPreReceiveHook + { + /// <summary> + /// Initializes a new instance of the <see cref="NewPreReceiveHook"/> class. + /// </summary> + /// <param name="name">The name of the hook.</param> + /// <param name="script">The script that the hook runs.</param> + /// <param name="scriptRepository">The repository where the script is kept.</param> + /// <param name="environment">The pre-receive environment where the script is executed.</param> + public NewPreReceiveHook(string name, Repository scriptRepository, string script, PreReceiveEnvironment environment) + { + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(scriptRepository, nameof(scriptRepository)); + Ensure.ArgumentNotNullOrEmptyString(script, nameof(script)); + Ensure.ArgumentNotNull(environment, nameof(environment)); + + Name = name; + ScriptRepository = new RepositoryReference + { + FullName = scriptRepository.FullName + }; + Script = script; + Environment = new PreReceiveEnvironmentReference + { + Id = environment.Id + }; + } + + /// <summary> + /// Initializes a new instance of the <see cref="NewPreReceiveHook"/> class. + /// </summary> + /// <param name="name">The name of the hook.</param> + /// <param name="script">The script that the hook runs.</param> + /// <param name="scriptRepositoryFullName">The <see cref="Repository.FullName"/> of a repository where the script is kept.</param> + /// <param name="environmentId">The <see cref="PreReceiveEnvironment.Id"/> of a pre-receive environment where the script is executed.</param> + public NewPreReceiveHook(string name, string scriptRepositoryFullName, string script, long environmentId) + { + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(script, nameof(script)); + Ensure.ArgumentNotNullOrEmptyString(scriptRepositoryFullName, nameof(scriptRepositoryFullName)); + + Name = name; + ScriptRepository = new RepositoryReference + { + FullName = scriptRepositoryFullName + }; + Script = script; + Environment = new PreReceiveEnvironmentReference + { + Id = environmentId + }; + } + + /// <summary> + /// The name of the hook. + /// </summary> + public string Name { get; set; } + + /// <summary> + /// The script that the hook runs. + /// </summary> + public string Script { get; set; } + + /// <summary> + /// The script that the hook runs. + /// </summary> + public RepositoryReference ScriptRepository { get; set; } + + /// <summary> + /// The script that the hook runs. + /// </summary> + public PreReceiveEnvironmentReference Environment { get; set; } + + /// <summary> + /// The state of enforcement for this hook. default: <see cref="PreReceiveHookEnforcement.Disabled"/> + /// </summary> + public PreReceiveHookEnforcement? Enforcement { get; set; } + + /// <summary> + /// Whether enforcement can be overridden at the org or repo level. default: false. + /// </summary> + public bool? AllowDownstreamConfiguration { get; set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} Repo: {1} Script: {2}", Name, ScriptRepository.FullName, Script); } + } + } +} diff --git a/Octokit/Models/Request/Enterprise/PreReceiveEnvironmentReference.cs b/Octokit/Models/Request/Enterprise/PreReceiveEnvironmentReference.cs new file mode 100644 index 0000000000..be55542df7 --- /dev/null +++ b/Octokit/Models/Request/Enterprise/PreReceiveEnvironmentReference.cs @@ -0,0 +1,22 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// A reference to a pre-receive environment. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PreReceiveEnvironmentReference + { + /// <summary> + /// The identifier for the pre-receive environment. + /// </summary> + public long Id { get; set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Id: {0}", Id); } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/Enterprise/RepositoryReference.cs b/Octokit/Models/Request/Enterprise/RepositoryReference.cs new file mode 100644 index 0000000000..65490a7f69 --- /dev/null +++ b/Octokit/Models/Request/Enterprise/RepositoryReference.cs @@ -0,0 +1,22 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// A Reference to a repository. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositoryReference + { + /// <summary> + /// The full name for the repository. + /// </summary> + public string FullName { get; set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "FullName: {0}", FullName); } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Request/Enterprise/UpdatePreReceiveHook.cs b/Octokit/Models/Request/Enterprise/UpdatePreReceiveHook.cs new file mode 100644 index 0000000000..69321558ee --- /dev/null +++ b/Octokit/Models/Request/Enterprise/UpdatePreReceiveHook.cs @@ -0,0 +1,47 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Describes a new pre-receive hook. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class UpdatePreReceiveHook + { + /// <summary> + /// The name of the hook. + /// </summary> + public string Name { get; set; } + + /// <summary> + /// The script that the hook runs. + /// </summary> + public string Script { get; set; } + + /// <summary> + /// The script that the hook runs. + /// </summary> + public RepositoryReference ScriptRepository { get; set; } + + /// <summary> + /// The script that the hook runs. + /// </summary> + public PreReceiveEnvironmentReference Environment { get; set; } + + /// <summary> + /// The state of enforcement for this hook. Defaults is <see cref="PreReceiveHookEnforcement.Disabled"/> + /// </summary> + public PreReceiveHookEnforcement? Enforcement { get; set; } + + /// <summary> + /// Whether enforcement can be overridden at the org or repo level. Default is false. + /// </summary> + public bool? AllowDownstreamConfiguration { get; set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} Script: {1}", Name, Script); } + } + } +} diff --git a/Octokit/Models/Response/Enterprise/PreReceiveHook.cs b/Octokit/Models/Response/Enterprise/PreReceiveHook.cs new file mode 100644 index 0000000000..af9d5c7c51 --- /dev/null +++ b/Octokit/Models/Response/Enterprise/PreReceiveHook.cs @@ -0,0 +1,85 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Describes a pre-receive hook. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PreReceiveHook + { + public PreReceiveHook() + { } + + public PreReceiveHook(int id, string name, StringEnum<PreReceiveHookEnforcement> enforcement, string script, Repository scriptRepository, PreReceiveEnvironment environment, bool allowDownstreamConfiguration) + { + Id = id; + Name = name; + Enforcement = enforcement; + Script = script; + ScriptRepository = scriptRepository; + Environment = environment; + AllowDownstreamConfiguration = allowDownstreamConfiguration; + } + + /// <summary> + /// The identifier for the pre-receive hook. + /// </summary> + public int Id { get; protected set; } + + /// <summary> + /// The name of the hook. + /// </summary> + public string Name { get; protected set; } + + /// <summary> + /// The state of enforcement for this hook. + /// </summary> + public StringEnum<PreReceiveHookEnforcement> Enforcement { get; protected set; } + + /// <summary> + /// The script that the hook runs. + /// </summary> + public string Script { get; protected set; } + + /// <summary> + /// The GitHub repository where the script is kept. + /// </summary> + public Repository ScriptRepository { get; protected set; } + + /// <summary> + /// The pre-receive environment where the script is executed. + /// </summary> + public PreReceiveEnvironment Environment { get; protected set; } + + /// <summary> + /// Whether enforcement can be overridden at the org or repo level. + /// </summary> + public bool AllowDownstreamConfiguration { get; protected set; } + + public UpdatePreReceiveHook ToUpdate() + { + return new UpdatePreReceiveHook + { + Name = Name, + Enforcement = Enforcement.Value, + Script = Script, + ScriptRepository = new RepositoryReference + { + FullName = ScriptRepository.FullName + }, + Environment = new PreReceiveEnvironmentReference + { + Id = Environment.Id + }, + AllowDownstreamConfiguration = AllowDownstreamConfiguration + }; + } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} Name: {1} Script: {2}", Id, Name, Script); } + } + } +} diff --git a/Octokit/Models/Response/Enterprise/PreReceiveHookEnforcement.cs b/Octokit/Models/Response/Enterprise/PreReceiveHookEnforcement.cs new file mode 100644 index 0000000000..0734bd1a9f --- /dev/null +++ b/Octokit/Models/Response/Enterprise/PreReceiveHookEnforcement.cs @@ -0,0 +1,28 @@ +using Octokit.Internal; + +namespace Octokit +{ + /// <summary> + /// The state of enforcement for a hook. + /// </summary> + public enum PreReceiveHookEnforcement + { + /// <summary> + /// Indicates the pre-receive hook will not run. + /// </summary> + [Parameter(Value = "disabled")] + Disabled, + + /// <summary> + /// Indicates it will run and reject any pushes that result in a non-zero status. + /// </summary> + [Parameter(Value = "enabled")] + Enabled, + + /// <summary> + /// Means the script will run but will not cause any pushes to be rejected. + /// </summary> + [Parameter(Value = "testing")] + Testing + } +} \ No newline at end of file From f6e541d616f884d0458883c8a70c716b9c69133f Mon Sep 17 00:00:00 2001 From: samvdd-247 <79514502+samvdd-247@users.noreply.github.com> Date: Mon, 11 Jul 2022 18:00:00 +0200 Subject: [PATCH 071/209] [FEAT] Update permissions based on GitHub documentation (#2424) --- Octokit/Models/Request/Permission.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Request/Permission.cs index 0f5ea6c8aa..8e5eca5c3f 100644 --- a/Octokit/Models/Request/Permission.cs +++ b/Octokit/Models/Request/Permission.cs @@ -14,7 +14,19 @@ public enum Permission /// </summary> [Parameter(Value = "admin")] Admin, - + + /// <summary> + /// team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations. + /// </summary> + [Parameter(Value = "maintain")] + Maintain, + + /// <summary> + /// team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations. + /// </summary> + [Parameter(Value = "triage")] + Triage, + /// <summary> /// team members can pull and push, but not administer these repositories /// </summary> @@ -27,4 +39,4 @@ public enum Permission [Parameter(Value = "pull")] Pull } -} \ No newline at end of file +} From 7ab6dc3cec4fe80cfe10e210d6b7ac5b5583d66f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 12:39:52 -0500 Subject: [PATCH 072/209] [deps] Bump NSubstitute from 4.3.0 to 4.4.0 (#2475) --- Octokit.Tests/Octokit.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 0a2513010b..b287644f48 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -28,7 +28,7 @@ <ItemGroup> <ProjectReference Include="..\Octokit\Octokit.csproj" /> <ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj" /> - <PackageReference Include="NSubstitute" Version="4.3.0" /> + <PackageReference Include="NSubstitute" Version="4.4.0" /> </ItemGroup> <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' "> From 312904022d48e593af9f0e261f90fd9aa4078be0 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Wed, 13 Jul 2022 18:42:07 +0100 Subject: [PATCH 073/209] [feat] Add AutoMerge and add MergeOptions to NewRepository object (#2476) --- .../Clients/RepositoriesClientTests.cs | 99 ++++++++++++++++++- Octokit/Models/Request/NewRepository.cs | 20 ++++ Octokit/Models/Request/RepositoryUpdate.cs | 6 ++ Octokit/Models/Response/Repository.cs | 5 +- 4 files changed, 127 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index cd0c7eb64e..161c21a085 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -36,6 +36,10 @@ public async Task CreatesANewPublicRepository() Assert.Null(repository.Homepage); Assert.NotNull(repository.DefaultBranch); Assert.Null(repository.License); + Assert.False(repository.AllowAutoMerge); + Assert.True(repository.AllowMergeCommit); + Assert.True(repository.AllowRebaseMerge); + Assert.True(repository.AllowSquashMerge); } } @@ -62,6 +66,89 @@ public async Task CreatesANewPrivateRepository() } } + [IntegrationTest] + public async Task CreatesARepositoryWithAllowAutoMergeSet() + { + var github = Helper.GetAuthenticatedClient(); + + var repoName = Helper.MakeNameWithTimestamp("repo-auto-merge"); + + var newRepository = new NewRepository(repoName) { AllowAutoMerge = true }; + + using (var context = await github.CreateRepositoryContext(newRepository)) + { + var createdRepository = context.Repository; + + // Default is false if unset, so check for true to ensure change + Assert.True(createdRepository.AllowAutoMerge); + var repository = await github.Repository.Get(Helper.UserName, repoName); + Assert.True(repository.AllowAutoMerge); + + } + } + + [IntegrationTest] + public async Task CreatesARepositoryWithAllowMergeCommitSet() + { + var github = Helper.GetAuthenticatedClient(); + + var repoName = Helper.MakeNameWithTimestamp("repo-merge-commit"); + + var newRepository = new NewRepository(repoName) { AllowMergeCommit = false }; + + using (var context = await github.CreateRepositoryContext(newRepository)) + { + var createdRepository = context.Repository; + + // Default is true if unset, so check for false to ensure change + Assert.False(createdRepository.AllowMergeCommit); + var repository = await github.Repository.Get(Helper.UserName, repoName); + Assert.False(repository.AllowMergeCommit); + } + } + + [IntegrationTest] + public async Task CreatesARepositoryWithAllowRebaseMergeSet() + { + var github = Helper.GetAuthenticatedClient(); + + var repoName = Helper.MakeNameWithTimestamp("repo-rebase-merge"); + + var newRepository = new NewRepository(repoName) { AllowRebaseMerge = false }; + + using (var context = await github.CreateRepositoryContext(newRepository)) + { + var createdRepository = context.Repository; + + // Default is true if unset, so check for false to ensure change + Assert.False(createdRepository.AllowRebaseMerge); + var repository = await github.Repository.Get(Helper.UserName, repoName); + Assert.False(repository.AllowRebaseMerge); + + } + } + + [IntegrationTest] + public async Task CreatesARepositoryWithAllowSquashMergeSet() + { + var github = Helper.GetAuthenticatedClient(); + + var repoName = Helper.MakeNameWithTimestamp("repo-squash-merge"); + + var newRepository = new NewRepository(repoName) { AllowSquashMerge = false }; + + using (var context = await github.CreateRepositoryContext(newRepository)) + { + var createdRepository = context.Repository; + + // Default is true if unset, so check for false to ensure change + Assert.False(createdRepository.AllowSquashMerge); + var repository = await github.Repository.Get(Helper.UserName, repoName); + Assert.False(repository.AllowSquashMerge); + + } + } + [IntegrationTest] public async Task CreatesARepositoryWithoutDownloads() { @@ -632,18 +719,21 @@ public async Task UpdatesMergeMethod() { AllowMergeCommit = false, AllowSquashMerge = false, - AllowRebaseMerge = true + AllowRebaseMerge = true, // this is the default, but the value is tested in UpdatesMergeMethodWithRepositoryId test + AllowAutoMerge = true }; var editedRepository = await github.Repository.Edit(context.RepositoryOwner, context.RepositoryName, updateRepository); Assert.False(editedRepository.AllowMergeCommit); Assert.False(editedRepository.AllowSquashMerge); Assert.True(editedRepository.AllowRebaseMerge); + Assert.True(editedRepository.AllowAutoMerge); var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); Assert.False(repository.AllowMergeCommit); Assert.False(repository.AllowSquashMerge); Assert.True(repository.AllowRebaseMerge); + Assert.True(repository.AllowAutoMerge); } } @@ -658,18 +748,21 @@ public async Task UpdatesMergeMethodWithRepositoryId() { AllowMergeCommit = true, AllowSquashMerge = true, - AllowRebaseMerge = false + AllowRebaseMerge = false, + AllowAutoMerge = true }; var editedRepository = await github.Repository.Edit(context.RepositoryId, updateRepository); Assert.True(editedRepository.AllowMergeCommit); Assert.True(editedRepository.AllowSquashMerge); Assert.False(editedRepository.AllowRebaseMerge); + Assert.True(editedRepository.AllowAutoMerge); var repository = await github.Repository.Get(context.RepositoryId); Assert.True(repository.AllowMergeCommit); Assert.True(repository.AllowSquashMerge); Assert.False(repository.AllowRebaseMerge); + Assert.True(editedRepository.AllowAutoMerge); } } @@ -861,6 +954,7 @@ public async Task ReturnsRepositoryMergeOptions() Assert.NotNull(repository.AllowRebaseMerge); Assert.NotNull(repository.AllowSquashMerge); Assert.NotNull(repository.AllowMergeCommit); + Assert.NotNull(repository.AllowAutoMerge); } } @@ -876,6 +970,7 @@ public async Task ReturnsRepositoryMergeOptionsWithRepositoryId() Assert.NotNull(repository.AllowRebaseMerge); Assert.NotNull(repository.AllowSquashMerge); Assert.NotNull(repository.AllowMergeCommit); + Assert.NotNull(repository.AllowAutoMerge); } } diff --git a/Octokit/Models/Request/NewRepository.cs b/Octokit/Models/Request/NewRepository.cs index aa5152e618..5b8a9feca7 100644 --- a/Octokit/Models/Request/NewRepository.cs +++ b/Octokit/Models/Request/NewRepository.cs @@ -95,6 +95,26 @@ public NewRepository(string name) /// </summary> public RepositoryVisibility? Visibility { get; set; } + /// <summary> + /// Optional. Gets or sets whether the new repository allows rebase merges. + /// </summary> + public bool? AllowRebaseMerge { get; set; } + + /// <summary> + /// Optional. Gets or sets whether the new repository allows squash merges. + /// </summary> + public bool? AllowSquashMerge { get; set; } + + /// <summary> + /// Optional. Gets or sets whether the new repository allows merge commits. + /// </summary> + public bool? AllowMergeCommit { get; set; } + + /// <summary> + /// Optional. Gets or sets whether the new repository allows auto merge. + /// </summary> + public bool? AllowAutoMerge { get; set; } + internal string DebuggerDisplay { get diff --git a/Octokit/Models/Request/RepositoryUpdate.cs b/Octokit/Models/Request/RepositoryUpdate.cs index 8801787950..4a876f05d3 100644 --- a/Octokit/Models/Request/RepositoryUpdate.cs +++ b/Octokit/Models/Request/RepositoryUpdate.cs @@ -77,6 +77,7 @@ public RepositoryUpdate(string name) /// Optional. Allows the "Create a merge commit" merge method to be used. /// </summary> public bool? AllowMergeCommit { get; set; } + public bool? DeleteBranchOnMerge { get; set; } @@ -90,6 +91,11 @@ public RepositoryUpdate(string name) /// </summary> public RepositoryVisibility? Visibility { get; set; } + /// <summary> + /// Options. Allows the "Auto Merge" method to be used. + /// </summary> + public bool? AllowAutoMerge { get; set; } + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 504d98b330..9a078ece9c 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -17,7 +17,7 @@ public Repository(long id) Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable<string> topics) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable<string> topics, bool? allowAutoMerge) { Url = url; HtmlUrl = htmlUrl; @@ -62,6 +62,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st Topics = topics.ToList(); DeleteBranchOnMerge = deleteBranchOnMerge; Visibility = visibility; + AllowAutoMerge = allowAutoMerge; } public string Url { get; protected set; } @@ -154,6 +155,8 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public RepositoryVisibility? Visibility { get; protected set; } + public bool? AllowAutoMerge { get; protected set; } + internal string DebuggerDisplay { get From 0e469a9e3b5bcea57fb13d6a1a52bad640147cd9 Mon Sep 17 00:00:00 2001 From: Matt <mryanmurphy@gmail.com> Date: Wed, 13 Jul 2022 13:49:57 -0400 Subject: [PATCH 074/209] [feat] Deployment task is arbitrary string value (#2413) --- Octokit.Tests/Models/DeploymentTests.cs | 6 ++++-- Octokit/Models/Request/NewDeployment.cs | 25 ++----------------------- Octokit/Models/Response/Deployment.cs | 8 +++++++- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/Octokit.Tests/Models/DeploymentTests.cs b/Octokit.Tests/Models/DeploymentTests.cs index dab6b66842..b1630152de 100644 --- a/Octokit.Tests/Models/DeploymentTests.cs +++ b/Octokit.Tests/Models/DeploymentTests.cs @@ -17,7 +17,7 @@ public void CanSerialize() }; var deserialized = new SimpleJsonSerializer().Serialize(deployment); - Assert.Equal(@"{""ref"":""ref"",""task"":""deploy"",""payload"":{""environment"":""production""}}", deserialized); + Assert.Equal(@"{""ref"":""ref"",""payload"":{""environment"":""production""}}", deserialized); } [Fact] @@ -50,7 +50,8 @@ public void CanDeserialize() ""created_at"": ""2012-07-20T01:19:13Z"", ""updated_at"": ""2012-07-20T01:19:13Z"", ""description"": ""Deploy request from hubot"", - ""statuses_url"": ""https://api.github.com/repos/octocat/example/deployments/1/statuses"" + ""statuses_url"": ""https://api.github.com/repos/octocat/example/deployments/1/statuses"", + ""task"": ""deploy"" }"; var actual = new SimpleJsonSerializer().Deserialize<Deployment>(json); @@ -63,6 +64,7 @@ public void CanDeserialize() Assert.Equal(DateTimeOffset.Parse("2012-07-20T01:19:13Z"), actual.UpdatedAt); Assert.Equal("Deploy request from hubot", actual.Description); Assert.Equal("https://api.github.com/repos/octocat/example/deployments/1/statuses", actual.StatusesUrl); + Assert.Equal("deploy", actual.Task); } } } diff --git a/Octokit/Models/Request/NewDeployment.cs b/Octokit/Models/Request/NewDeployment.cs index 7fdf30d4ba..eea8086959 100644 --- a/Octokit/Models/Request/NewDeployment.cs +++ b/Octokit/Models/Request/NewDeployment.cs @@ -33,12 +33,9 @@ public NewDeployment(string @ref) /// <summary> /// Gets or sets the optional task used to specify a task to execute, e.g. deploy or deploy:migrations. - /// Default: deploy + /// Default if not specified: deploy /// </summary> - /// <value> - /// The task. - /// </value> - public DeployTask Task { get; set; } + public string Task { get; set; } /// <summary> /// Merges the default branch into the requested deployment branch if true; @@ -95,22 +92,4 @@ internal string DebuggerDisplay } } } - - /// <summary> - /// The types of deployments tasks that are available. - /// </summary> - public enum DeployTask - { - /// <summary> - /// Deploy everything (default) - /// </summary> - [Parameter(Value = "deploy")] - Deploy, - - /// <summary> - /// Deploy migrations only. - /// </summary> - [Parameter(Value = "deploy:migrations")] - DeployMigrations - } } diff --git a/Octokit/Models/Response/Deployment.cs b/Octokit/Models/Response/Deployment.cs index 4d4e5be667..ba3016a295 100644 --- a/Octokit/Models/Response/Deployment.cs +++ b/Octokit/Models/Response/Deployment.cs @@ -13,7 +13,7 @@ public class Deployment { public Deployment() { } - public Deployment(int id, string nodeId, string sha, string url, User creator, IReadOnlyDictionary<string, string> payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment) + public Deployment(int id, string nodeId, string sha, string url, User creator, IReadOnlyDictionary<string, string> payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment, string task) { Id = id; NodeId = nodeId; @@ -27,6 +27,7 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I StatusesUrl = statusesUrl; TransientEnvironment = transientEnvironment; ProductionEnvironment = productionEnvironment; + Task = task; } /// <summary> @@ -89,6 +90,11 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I /// </summary> public bool ProductionEnvironment { get; protected set; } + /// <summary> + /// Specifies a task to execute (e.g., deploy or deploy:migrations) + /// </summary> + public string Task { get; protected set; } + internal string DebuggerDisplay { get From 7384b467723cbce7c63e0069ee1a2fa9195f65d0 Mon Sep 17 00:00:00 2001 From: Daniel <46620773+Whitestripe7773@users.noreply.github.com> Date: Wed, 13 Jul 2022 19:52:05 +0200 Subject: [PATCH 075/209] [feat] Adds the slug field to the GitHubApp response object --- Octokit/Models/Response/GitHubApp.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Response/GitHubApp.cs b/Octokit/Models/Response/GitHubApp.cs index b96efa82db..182dd3b309 100644 --- a/Octokit/Models/Response/GitHubApp.cs +++ b/Octokit/Models/Response/GitHubApp.cs @@ -12,9 +12,10 @@ public class GitHubApp { public GitHubApp() { } - public GitHubApp(long id, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt) + public GitHubApp(long id, string slug, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt) { Id = id; + Slug = slug; Name = name; Owner = owner; Description = description; @@ -29,6 +30,11 @@ public GitHubApp(long id, string name, User owner, string description, string ex /// </summary> public long Id { get; protected set; } + /// <summary> + /// The url-friendly version of the repository name. + /// </summary> + public string Slug { get; protected set; } + /// <summary> /// The Name of the GitHub App. /// </summary> From 3f3466c764290f36d0212a12652c3e9174b07e39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 13:31:01 -0500 Subject: [PATCH 076/209] [deps] Bump Cake.Frosting from 1.1.0 to 2.2.0 in /build (#2437) --- build/Build.csproj | 2 +- build/Tasks/Build.cs | 4 ++-- build/Tasks/ConventionTests.cs | 4 ++-- build/Tasks/Default.cs | 4 ++-- build/Tasks/IntegrationTests.cs | 4 ++-- build/Tasks/Package.cs | 6 +++--- build/Tasks/Restore.cs | 4 ++-- build/Tasks/TestSourceLink.cs | 4 ++-- build/Tasks/UnitTests.cs | 4 ++-- build/Tasks/ValidateLINQPadSamples.cs | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/build/Build.csproj b/build/Build.csproj index d30897b482..97efd74a08 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -8,7 +8,7 @@ <ItemGroup> <PackageReference Include="Cake.Coverlet" Version="2.5.4" /> - <PackageReference Include="Cake.Frosting" Version="1.1.0" /> + <PackageReference Include="Cake.Frosting" Version="2.2.0" /> </ItemGroup> </Project> diff --git a/build/Tasks/Build.cs b/build/Tasks/Build.cs index 67c76bf6b4..353c9e10b1 100644 --- a/build/Tasks/Build.cs +++ b/build/Tasks/Build.cs @@ -3,8 +3,8 @@ using Cake.Core; using Cake.Frosting; -[Dependency(typeof(Restore))] -[Dependency(typeof(FormatCode))] +[IsDependentOn(typeof(Restore))] +[IsDependentOn(typeof(FormatCode))] public class Build : FrostingTask<Context> { public override void Run(Context context) diff --git a/build/Tasks/ConventionTests.cs b/build/Tasks/ConventionTests.cs index e1c93d97dc..d79c7c84e9 100644 --- a/build/Tasks/ConventionTests.cs +++ b/build/Tasks/ConventionTests.cs @@ -3,7 +3,7 @@ using Cake.Common.Tools.DotNetCore; using Cake.Frosting; -[Dependency(typeof(Build))] +[IsDependentOn(typeof(Build))] public sealed class ConventionTests : FrostingTask<Context> { public override void Run(Context context) @@ -14,4 +14,4 @@ public override void Run(Context context) context.DotNetCoreTest(project.Path.FullPath, context.GetTestSettings()); } } -} \ No newline at end of file +} diff --git a/build/Tasks/Default.cs b/build/Tasks/Default.cs index cca762bf58..e69c10e224 100644 --- a/build/Tasks/Default.cs +++ b/build/Tasks/Default.cs @@ -1,6 +1,6 @@ using Cake.Frosting; -[Dependency(typeof(TestSourceLink))] +[IsDependentOn(typeof(TestSourceLink))] public sealed class Default : FrostingTask<Context> { -} \ No newline at end of file +} diff --git a/build/Tasks/IntegrationTests.cs b/build/Tasks/IntegrationTests.cs index 615deb937f..9acafeaef7 100644 --- a/build/Tasks/IntegrationTests.cs +++ b/build/Tasks/IntegrationTests.cs @@ -4,7 +4,7 @@ using Cake.Common.Tools.DotNetCore.Test; using Cake.Frosting; -[Dependency(typeof(Build))] +[IsDependentOn(typeof(Build))] public sealed class IntegrationTests : FrostingTask<Context> { public override void Run(Context context) @@ -29,4 +29,4 @@ public override bool ShouldRun(Context context) return areEnvironmentVariablesSet; } -} \ No newline at end of file +} diff --git a/build/Tasks/Package.cs b/build/Tasks/Package.cs index a2988a4b4d..bbaddd9223 100644 --- a/build/Tasks/Package.cs +++ b/build/Tasks/Package.cs @@ -4,9 +4,9 @@ using Cake.Core; using Cake.Frosting; -[Dependency(typeof(UnitTests))] -[Dependency(typeof(ConventionTests))] -[Dependency(typeof(ValidateLINQPadSamples))] +[IsDependentOn(typeof(UnitTests))] +[IsDependentOn(typeof(ConventionTests))] +[IsDependentOn(typeof(ValidateLINQPadSamples))] public sealed class Package : FrostingTask<Context> { public override void Run(Context context) diff --git a/build/Tasks/Restore.cs b/build/Tasks/Restore.cs index e7cdb7850a..e84cf90bca 100644 --- a/build/Tasks/Restore.cs +++ b/build/Tasks/Restore.cs @@ -3,7 +3,7 @@ using Cake.Core; using Cake.Frosting; -[Dependency(typeof(Clean))] +[IsDependentOn(typeof(Clean))] public sealed class Restore : FrostingTask<Context> { public override void Run(Context context) @@ -14,4 +14,4 @@ public override void Run(Context context) .Append("/p:Version={0}", context.Version.GetSemanticVersion()) }); } -} \ No newline at end of file +} diff --git a/build/Tasks/TestSourceLink.cs b/build/Tasks/TestSourceLink.cs index 34e2f57a54..003c617be5 100644 --- a/build/Tasks/TestSourceLink.cs +++ b/build/Tasks/TestSourceLink.cs @@ -6,7 +6,7 @@ using Cake.Core.IO; using Cake.Frosting; -[Dependency(typeof(Package))] +[IsDependentOn(typeof(Package))] public class TestSourceLink : FrostingTask<Context> { public override void Run(Context context) @@ -33,4 +33,4 @@ public override bool ShouldRun(Context context) { return context.LinkSources; } -} \ No newline at end of file +} diff --git a/build/Tasks/UnitTests.cs b/build/Tasks/UnitTests.cs index 42584c642a..620cd3838f 100644 --- a/build/Tasks/UnitTests.cs +++ b/build/Tasks/UnitTests.cs @@ -3,7 +3,7 @@ using Cake.Common.Tools.DotNetCore; using Cake.Frosting; -[Dependency(typeof(Build))] +[IsDependentOn(typeof(Build))] public sealed class UnitTests : FrostingTask<Context> { public override void Run(Context context) @@ -14,4 +14,4 @@ public override void Run(Context context) context.DotNetCoreTest(project.Path.FullPath, context.GetTestSettings()); } } -} \ No newline at end of file +} diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index b196c6d7d5..1bfaf1b758 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -8,7 +8,7 @@ using Cake.Core.IO; using Cake.Frosting; -[Dependency(typeof(Build))] +[IsDependentOn(typeof(Build))] public sealed class ValidateLINQPadSamples : FrostingTask<Context> { public override void Run(Context context) @@ -109,4 +109,4 @@ private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, return tempFilePath; } -} \ No newline at end of file +} From aca587b104f08cbf80e3c8f7ac0d71f3e94e429a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 14:14:04 -0500 Subject: [PATCH 077/209] [deps] Bump xunit.runner.visualstudio from 2.4.3 to 2.4.5 (#2440) --- .../Octokit.Tests.Conventions.csproj | 6 +++--- .../Octokit.Tests.Integration.csproj | 8 ++++---- Octokit.Tests/Octokit.Tests.csproj | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index f612037e9f..3ecc8effd1 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -4,7 +4,7 @@ <Description>Convention-based tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Conventions</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks> + <TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Conventions</AssemblyName> <PackageId>Octokit.Tests.Conventions</PackageId> @@ -35,10 +35,10 @@ <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="xunit" Version="2.4.1" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> + <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> - <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> + <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 3b45c0f191..02e69f70ba 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -4,7 +4,7 @@ <Description>Integration tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Integration</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks> + <TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Integration</AssemblyName> <PackageId>Octokit.Tests.Integration</PackageId> @@ -22,7 +22,7 @@ <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' "> <DefineConstants>$(DefineConstants);GITHUBJWT_HELPER_AVAILABLE</DefineConstants> </PropertyGroup> - + <ItemGroup> <Compile Include="..\Octokit.Tests\Helpers\AssertEx.cs" /> <EmbeddedResource Include="fixtures\hello-world.txt;fixtures\hello-world.zip" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" /> @@ -39,7 +39,7 @@ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.1" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> + <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> <ItemGroup> @@ -50,7 +50,7 @@ <PackageReference Include="GitHubJwt" Version="0.0.5" /> </ItemGroup> - <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> + <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> </ItemGroup> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index b287644f48..08e3d1a926 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -4,7 +4,7 @@ <Description>Tests for Octokit</Description> <AssemblyTitle>Octokit.Tests</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net46</TargetFrameworks> + <TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests</AssemblyName> <PackageId>Octokit.Tests</PackageId> @@ -39,10 +39,10 @@ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.1" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> + <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> - <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> + <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> <Reference Include="System" /> <Reference Include="Microsoft.CSharp" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> From bfbc2ebbe18c7ef8736ecec6f205cd242d6a8f1a Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Thu, 14 Jul 2022 17:01:22 +0100 Subject: [PATCH 078/209] feat: Adding squash title to NewRepository (#2482) --- Octokit/Models/Request/NewRepository.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Octokit/Models/Request/NewRepository.cs b/Octokit/Models/Request/NewRepository.cs index 5b8a9feca7..79efa0729e 100644 --- a/Octokit/Models/Request/NewRepository.cs +++ b/Octokit/Models/Request/NewRepository.cs @@ -42,6 +42,11 @@ public NewRepository(string name) /// </summary> public bool? HasIssues { get; set; } + /// <summary> + /// Optional. Gets or sets whether to enable projects for the new repository. The default is true. + /// </summary> + public bool? HasProjects { get; set; } + /// <summary> /// Optional. Gets or sets whether to enable the wiki for the new repository. The default is true. /// </summary> @@ -115,6 +120,11 @@ public NewRepository(string name) /// </summary> public bool? AllowAutoMerge { get; set; } + /// <summary> + /// Optional. Gets or sets whether the squash pr title is used as default when using Squash Merge. Default is false. Cannot currently be tested as it isn't returned in the GET method. + /// </summary> + public bool? UseSquashPrTitleAsDefault { get; set; } + internal string DebuggerDisplay { get From fb68c67ff498f7d15b379c4d53070f5376a5d15c Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Thu, 14 Jul 2022 17:04:13 +0100 Subject: [PATCH 079/209] feat: Adding DetailsUrl to CheckRun (#2479) --- Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs | 6 ++++-- .../Reactive/ObservableCheckRunsClientTests.cs | 6 ++++-- Octokit/Models/Response/CheckRun.cs | 8 +++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs index f51c7eb5d1..07ba5f93cf 100644 --- a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs @@ -332,7 +332,7 @@ public async Task GetsCheckRun() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -349,6 +349,7 @@ public async Task GetsCheckRun() Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha); Assert.Equal("name", checkRun.Name); Assert.Equal(CheckStatus.InProgress, checkRun.Status); + Assert.Equal(created.DetailsUrl, checkRun.DetailsUrl); } } @@ -358,7 +359,7 @@ public async Task GetsCheckRunWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -375,6 +376,7 @@ public async Task GetsCheckRunWithRepositoryId() Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha); Assert.Equal("name", checkRun.Name); Assert.Equal(CheckStatus.InProgress, checkRun.Status); + Assert.Equal(created.DetailsUrl, checkRun.DetailsUrl); } } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs index aa178b568e..c7b95c492e 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs @@ -333,7 +333,7 @@ public async Task GetsCheckRun() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -350,6 +350,7 @@ public async Task GetsCheckRun() Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha); Assert.Equal("name", checkRun.Name); Assert.Equal(CheckStatus.InProgress, checkRun.Status); + Assert.Equal(created.DetailsUrl, checkRun.DetailsUrl); } } @@ -359,7 +360,7 @@ public async Task GetsCheckRunWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -376,6 +377,7 @@ public async Task GetsCheckRunWithRepositoryId() Assert.Equal(featureBranch.Object.Sha, checkRun.HeadSha); Assert.Equal("name", checkRun.Name); Assert.Equal(CheckStatus.InProgress, checkRun.Status); + Assert.Equal(created.DetailsUrl, checkRun.DetailsUrl); } } } diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index d2a58f1442..3482a5bcea 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -12,13 +12,14 @@ public CheckRun() { } - public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, CheckStatus status, CheckConclusion? conclusion, DateTimeOffset startedAt, DateTimeOffset? completedAt, CheckRunOutputResponse output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList<PullRequest> pullRequests) + public CheckRun(long id, string headSha, string externalId, string url, string htmlUrl, string detailsUrl, CheckStatus status, CheckConclusion? conclusion, DateTimeOffset startedAt, DateTimeOffset? completedAt, CheckRunOutputResponse output, string name, CheckSuite checkSuite, GitHubApp app, IReadOnlyList<PullRequest> pullRequests) { Id = id; HeadSha = headSha; ExternalId = externalId; Url = url; HtmlUrl = htmlUrl; + DetailsUrl = detailsUrl; Status = status; Conclusion = conclusion; StartedAt = startedAt; @@ -55,6 +56,11 @@ public CheckRun(long id, string headSha, string externalId, string url, string h /// </summary> public string HtmlUrl { get; protected set; } + /// <summary> + /// The URL of the integrator's site that has the full details of the check. + /// </summary> + public string DetailsUrl { get; protected set; } + /// <summary> /// The check run status /// </summary> From d15517dff3001dcd845347aac84a422cd6a86b40 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Thu, 14 Jul 2022 17:10:15 +0100 Subject: [PATCH 080/209] maint: Adding App slug tests (#2477) --- Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs | 2 ++ .../Reactive/ObservableGitHubAppsClientTests.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs b/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs index e66f78e4c7..d935d23abc 100644 --- a/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs @@ -23,6 +23,7 @@ public async Task GetsApp() var result = await _github.GitHubApps.Get(Helper.GitHubAppSlug); Assert.Equal(Helper.GitHubAppId, result.Id); + Assert.Equal(Helper.GitHubAppSlug, result.Slug); Assert.False(string.IsNullOrEmpty(result.Name)); Assert.NotNull(result.Owner); } @@ -44,6 +45,7 @@ public async Task GetsCurrentApp() var result = await _github.GitHubApps.GetCurrent(); Assert.Equal(Helper.GitHubAppId, result.Id); + Assert.Equal(Helper.GitHubAppSlug, result.Slug); Assert.False(string.IsNullOrEmpty(result.Name)); Assert.NotNull(result.Owner); } diff --git a/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs index f853783578..59e6e402cd 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs @@ -25,6 +25,7 @@ public async Task GetsApp() var result = await _github.GitHubApps.Get(Helper.GitHubAppSlug); Assert.Equal(Helper.GitHubAppId, result.Id); + Assert.Equal(Helper.GitHubAppSlug, result.Slug); Assert.False(string.IsNullOrEmpty(result.Name)); Assert.NotNull(result.Owner); } @@ -46,6 +47,7 @@ public async Task GetsCurrentApp() var result = await _github.GitHubApps.GetCurrent(); Assert.Equal(Helper.GitHubAppId, result.Id); + Assert.Equal(Helper.GitHubAppSlug, result.Slug); Assert.False(string.IsNullOrEmpty(result.Name)); Assert.NotNull(result.Owner); } From ab1331a5a2ddb973c46862f09e9d993264a8055d Mon Sep 17 00:00:00 2001 From: Martin Costello <martin@martincostello.com> Date: Thu, 14 Jul 2022 17:15:48 +0100 Subject: [PATCH 081/209] docs: Fixes GitHubApp response object code docs typo (#2478) --- Octokit/Models/Response/GitHubApp.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/GitHubApp.cs b/Octokit/Models/Response/GitHubApp.cs index 182dd3b309..1f233e05a2 100644 --- a/Octokit/Models/Response/GitHubApp.cs +++ b/Octokit/Models/Response/GitHubApp.cs @@ -31,7 +31,7 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti public long Id { get; protected set; } /// <summary> - /// The url-friendly version of the repository name. + /// The url-friendly version of the GitHub App name. /// </summary> public string Slug { get; protected set; } @@ -56,7 +56,7 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti public string ExternalUrl { get; protected set; } /// <summary> - /// The URL to view the GitHub App on GitHub + /// The URL to view the GitHub App on GitHub. /// </summary> public string HtmlUrl { get; protected set; } From d32c9a432c1b88acc1dd8692edb2487a4d7912ea Mon Sep 17 00:00:00 2001 From: Tim Rogers <me@timrogers.co.uk> Date: Fri, 15 Jul 2022 20:32:39 +0100 Subject: [PATCH 082/209] docs: Update organizations-related `GetAllForUser` method docs to make it clear that only public memberships are returned (#2487) --- Octokit/Clients/IOrganizationsClient.cs | 16 ++++++++++++---- Octokit/Clients/OrganizationsClient.cs | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Octokit/Clients/IOrganizationsClient.cs b/Octokit/Clients/IOrganizationsClient.cs index faaf082f3d..63f7c5758c 100644 --- a/Octokit/Clients/IOrganizationsClient.cs +++ b/Octokit/Clients/IOrganizationsClient.cs @@ -65,19 +65,27 @@ public interface IOrganizationsClient Task<IReadOnlyList<Organization>> GetAllForCurrent(ApiOptions options); /// <summary> - /// Returns all <see cref="Organization" />s for the specified user. + /// Returns <see cref="Organization" />s which the specified user is a member of, + /// where the user hasn't marked their membership as private. /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - /// <returns>A list of the specified user's <see cref="Organization"/>s.</returns> + /// <returns> + /// A list of the <see cref="Organization"/>s which the specified user is a member + /// of, where they haven't marked their membership as private + /// </returns> Task<IReadOnlyList<Organization>> GetAllForUser(string user); /// <summary> - /// Returns all <see cref="Organization" />s for the specified user. + /// Returns <see cref="Organization" />s which the specified user is a member of, + /// where the user hasn't marked their membership as private. /// </summary> /// <param name="user">The login of the user</param> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - /// <returns>A list of the specified user's <see cref="Organization"/>s.</returns> + /// <returns> + /// A list of the <see cref="Organization"/>s which the specified user is a member + /// of, where they haven't marked their membership as private + /// </returns> Task<IReadOnlyList<Organization>> GetAllForUser(string user, ApiOptions options); /// <summary> diff --git a/Octokit/Clients/OrganizationsClient.cs b/Octokit/Clients/OrganizationsClient.cs index 5d13ca1895..42a89cd13b 100644 --- a/Octokit/Clients/OrganizationsClient.cs +++ b/Octokit/Clients/OrganizationsClient.cs @@ -85,11 +85,15 @@ public Task<IReadOnlyList<Organization>> GetAllForCurrent(ApiOptions options) } /// <summary> - /// Returns all <see cref="Organization" />s for the specified user. + /// Returns <see cref="Organization" />s which the specified user is a member of, + /// where the user hasn't marked their membership as private. /// </summary> /// <param name="user">The login of the user</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - /// <returns>A list of the specified user's <see cref="Organization"/>s.</returns> + /// <returns> + /// A list of the <see cref="Organization"/>s which the specified user is a member + /// of, where they haven't marked their membership as private + /// </returns> [ManualRoute("GET", "/users/{username}/orgs")] public Task<IReadOnlyList<Organization>> GetAllForUser(string user) { @@ -99,12 +103,16 @@ public Task<IReadOnlyList<Organization>> GetAllForUser(string user) } /// <summary> - /// Returns all <see cref="Organization" />s for the specified user. + /// Returns <see cref="Organization" />s which the specified user is a member of, + /// where the user hasn't marked their membership as private. /// </summary> /// <param name="user">The login of the user</param> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - /// <returns>A list of the specified user's <see cref="Organization"/>s.</returns> + /// <returns> + /// A list of the <see cref="Organization"/>s which the specified user is a member + /// of, where they haven't marked their membership as private + /// </returns> [ManualRoute("GET", "/users/{username}/orgs")] public Task<IReadOnlyList<Organization>> GetAllForUser(string user, ApiOptions options) { From 55e2072be34620d00d467a91c5ab1f3eae28693f Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 15 Jul 2022 20:42:19 +0100 Subject: [PATCH 083/209] feat: Updates the EventInfoState enum to align with the GitHub REST API(#2484) Update the EventInfoState enum to be in order (not quite alphabetical) and in line with current github documentation --- Octokit/Models/Response/EventInfo.cs | 275 ++++++++++++++++----------- 1 file changed, 166 insertions(+), 109 deletions(-) diff --git a/Octokit/Models/Response/EventInfo.cs b/Octokit/Models/Response/EventInfo.cs index ddde182459..16ebc58148 100644 --- a/Octokit/Models/Response/EventInfo.cs +++ b/Octokit/Models/Response/EventInfo.cs @@ -81,73 +81,81 @@ internal string DebuggerDisplay public enum EventInfoState { /// <summary> - /// The issue was closed by the actor. When the commit_id is present, it identifies the commit that - /// closed the issue using “closes / fixes #NN” syntax. + /// The issue was added to a project board. /// </summary> - [Parameter(Value = "closed")] - Closed, + [Parameter(Value = "added_to_project")] + AddedToProject, /// <summary> - /// The issue was reopened by the actor. + /// The issue was assigned to the actor. /// </summary> - [Parameter(Value = "reopened")] - Reopened, + [Parameter(Value = "assigned")] + Assigned, /// <summary> - /// The actor subscribed to receive notifications for an issue. + /// GitHub unsuccessfully attempted to automatically change the base branch of the pull request. /// </summary> - [Parameter(Value = "subscribed")] - Subscribed, + [Parameter(Value = "automatic_base_change_failed")] + AutomaticBaseChangeFailed, /// <summary> - /// The issue was merged by the actor. The commit_id attribute is the SHA1 of the HEAD commit that was merged. + /// GitHub successfully attempted to automatically change the base branch of the pull request. /// </summary> - [Parameter(Value = "merged")] - Merged, + [Parameter(Value = "automatic_base_change_succeeded")] + AutomaticBaseChangeSucceeded, /// <summary> - /// The issue was referenced from a commit message. The commit_id attribute is the commit SHA1 of where - /// that happened. + /// The base reference branch of the pull request changed. /// </summary> - [Parameter(Value = "referenced")] - Referenced, + [Parameter(Value = "base_ref_changed")] + BaseRefChanged, /// <summary> - /// The actor was @mentioned in an issue body. + /// The issue was closed by the actor. When the commit_id is present, it identifies the commit that + /// closed the issue using “closes / fixes #NN” syntax. /// </summary> - [Parameter(Value = "mentioned")] - Mentioned, + [Parameter(Value = "closed")] + Closed, /// <summary> - /// The issue was assigned to the actor. + /// A comment was added to the issue. /// </summary> - [Parameter(Value = "assigned")] - Assigned, + [Parameter(Value = "commented")] + Commented, /// <summary> - /// The issue was unassigned to the actor. + /// A commit was added to the pull request's HEAD branch. + /// Only provided for pull requests. /// </summary> - [Parameter(Value = "unassigned")] - Unassigned, + [Parameter(Value = "committed")] + Committed, /// <summary> - /// A label was added to the issue. + /// An issue was connected. /// </summary> - [Parameter(Value = "labeled")] - Labeled, + [Parameter(Value = "connected")] + Connected, /// <summary> - /// A label was removed from the issue. + /// The pull request was converted to draft mode. /// </summary> - [Parameter(Value = "unlabeled")] - Unlabeled, + [Parameter(Value = "convert_to_draft")] + ConvertToDraft, /// <summary> - /// The issue was added to a milestone. + /// The issue was created by converting a note in a project board to an issue. /// </summary> - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Milestoned")] - [Parameter(Value = "milestoned")] - Milestoned, + [Parameter(Value = "converted_note_to_issue")] + ConvertedNoteToIssue, + + /// <summary> + /// The issue was referenced from another issue. + /// The source attribute contains the id, actor, and + /// url of the reference's source. + /// </summary> + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Crossreferenced")] + [Parameter(Value = "cross-referenced")] + Crossreferenced, /// <summary> /// The issue was removed from a milestone. @@ -157,22 +165,22 @@ public enum EventInfoState Demilestoned, /// <summary> - /// The issue title was changed. + /// The pull request was deployed. /// </summary> - [Parameter(Value = "renamed")] - Renamed, + [Parameter(Value = "deployed")] + Deployed, /// <summary> - /// The issue was locked by the actor. + /// The pull request deployment environment was changed. /// </summary> - [Parameter(Value = "locked")] - Locked, + [Parameter(Value = "deployment_environment_changed")] + DeploymentEnvironmentChanged, /// <summary> - /// The issue was unlocked by the actor. + /// The issue or pull request was unlinked from another issue or pull request. /// </summary> - [Parameter(Value = "unlocked")] - Unlocked, + [Parameter(Value = "disconnected")] + Disconnected, /// <summary> /// The pull request’s branch was deleted. @@ -193,34 +201,41 @@ public enum EventInfoState HeadRefForcePushed, /// <summary> - /// The pull request is ready for review + /// A label was added to the issue. /// </summary> - [Parameter(Value = "ready_for_review")] - ReadyForReview, + [Parameter(Value = "labeled")] + Labeled, /// <summary> - /// The actor dismissed a review from the pull request. + /// The issue was locked by the actor. /// </summary> - [Parameter(Value = "review_dismissed")] - ReviewDismissed, + [Parameter(Value = "locked")] + Locked, /// <summary> - /// The actor requested review from the subject on this pull request. + /// The actor was @mentioned in an issue body. /// </summary> - [Parameter(Value = "review_requested")] - ReviewRequested, + [Parameter(Value = "mentioned")] + Mentioned, /// <summary> - /// The actor removed the review request for the subject on this pull request. + /// A user with write permissions marked an issue as a duplicate of another issue or a pull request as a duplicate of another pull request. /// </summary> - [Parameter(Value = "review_request_removed")] - ReviewRequestRemoved, + [Parameter(Value = "marked_as_duplicate")] + MarkedAsDuplicate, /// <summary> - /// The issue was added to a project board. + /// The issue was merged by the actor. The commit_id attribute is the SHA1 of the HEAD commit that was merged. /// </summary> - [Parameter(Value = "added_to_project")] - AddedToProject, + [Parameter(Value = "merged")] + Merged, + + /// <summary> + /// The issue was added to a milestone. + /// </summary> + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Milestoned")] + [Parameter(Value = "milestoned")] + Milestoned, /// <summary> /// The issue was moved between columns in a project board. @@ -229,50 +244,59 @@ public enum EventInfoState MovedColumnsInProject, /// <summary> - /// The issue was removed from a project board. + /// An issue was pinned. /// </summary> - [Parameter(Value = "removed_from_project")] - RemovedFromProject, + [Parameter(Value = "pinned")] + Pinned, /// <summary> - /// The issue was created by converting a note in a project board to an issue. + /// The pull request is ready for review /// </summary> - [Parameter(Value = "converted_note_to_issue")] - ConvertedNoteToIssue, + [Parameter(Value = "ready_for_review")] + ReadyForReview, /// <summary> - /// The actor unsubscribed from notifications for an issue. + /// The issue was referenced from a commit message. The commit_id attribute is the commit SHA1 of where + /// that happened. /// </summary> - [Parameter(Value = "unsubscribed")] - Unsubscribed, + [Parameter(Value = "referenced")] + Referenced, /// <summary> - /// A comment was added to the issue. + /// The issue was removed from a project board. /// </summary> - [Parameter(Value = "commented")] - Commented, + [Parameter(Value = "removed_from_project")] + RemovedFromProject, /// <summary> - /// A commit was added to the pull request's HEAD branch. - /// Only provided for pull requests. + /// The issue title was changed. /// </summary> - [Parameter(Value = "committed")] - Committed, + [Parameter(Value = "renamed")] + Renamed, /// <summary> - /// Base branch of the pull request was changed. + /// The issue was reopened by the actor. /// </summary> - [Parameter(Value = "base_ref_changed")] - BaseRefChanged, + [Parameter(Value = "reopened")] + Reopened, /// <summary> - /// The issue was referenced from another issue. - /// The source attribute contains the id, actor, and - /// url of the reference's source. + /// The actor dismissed a review from the pull request. /// </summary> - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Crossreferenced")] - [Parameter(Value = "cross-referenced")] - Crossreferenced, + [Parameter(Value = "review_dismissed")] + ReviewDismissed, + + /// <summary> + /// The actor requested review from the subject on this pull request. + /// </summary> + [Parameter(Value = "review_requested")] + ReviewRequested, + + /// <summary> + /// The actor removed the review request for the subject on this pull request. + /// </summary> + [Parameter(Value = "review_request_removed")] + ReviewRequestRemoved, /// <summary> /// The issue was reviewed. @@ -281,57 +305,90 @@ public enum EventInfoState Reviewed, /// <summary> - /// A line comment was made. + /// The actor subscribed to receive notifications for an issue. /// </summary> - [Parameter(Value = "line-commented")] - LineCommented, + [Parameter(Value = "subscribed")] + Subscribed, + + /// <summary> + /// An issue was transferred. + /// </summary> + [Parameter(Value = "transferred")] + Transferred, /// <summary> - /// A commit comment was made. + /// The issue was unassigned to the actor. /// </summary> - [Parameter(Value = "commit-commented")] - CommitCommented, + [Parameter(Value = "unassigned")] + Unassigned, + + /// <summary> + /// A label was removed from the issue. + /// </summary> + [Parameter(Value = "unlabeled")] + Unlabeled, /// <summary> - /// A user with write permissions marked an issue as a duplicate of another issue or a pull request as a duplicate of another pull request. + /// The issue was unlocked by the actor. /// </summary> - [Parameter(Value = "marked_as_duplicate")] - MarkedAsDuplicate, + [Parameter(Value = "unlocked")] + Unlocked, /// <summary> /// An issue that a user had previously marked as a duplicate of another issue is no longer considered a duplicate. /// </summary> [Parameter(Value = "unmarked_as_duplicate")] UnmarkedAsDuplicate, + + /// <summary> + /// An issue was unpinned. + /// </summary> + [Parameter(Value = "unpinned")] + Unpinned, /// <summary> - /// An issue comment was deleted. + /// The actor unsubscribed from notifications for an issue. /// </summary> - [Parameter(Value = "comment_deleted")] - CommentDeleted, + [Parameter(Value = "unsubscribed")] + Unsubscribed, /// <summary> - /// An issue was transferred. + /// An organization owner blocked a user from the organization. /// </summary> - [Parameter(Value = "transferred")] - Transferred, + [Parameter(Value = "user_blocked")] + UserBlocked, + + + + + + + + + /// <summary> - /// An issue was connected. + /// A line comment was made. /// </summary> - [Parameter(Value = "connected")] - Connected, + [Parameter(Value = "line-commented")] + LineCommented, /// <summary> - /// An issue was pinned. + /// A commit comment was made. /// </summary> - [Parameter(Value = "pinned")] - Pinned, + [Parameter(Value = "commit-commented")] + CommitCommented, + + /// <summary> - /// An issue was unpinned. + /// An issue comment was deleted. /// </summary> - [Parameter(Value = "unpinned")] - Unpinned, + [Parameter(Value = "comment_deleted")] + CommentDeleted, + + + + } } From 5cf604b0a4bb0fa1d1150cea21936f1e699498a5 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 15 Jul 2022 20:46:56 +0100 Subject: [PATCH 084/209] feat: Adds missing properties to the branch protection response object (#2485) --- .../Clients/RepositoryBranchesClientTests.cs | 47 ++++++++--- .../OrganizationRepositoryWithTeamContext.cs | 7 +- ...ObservableRepositoryBranchesClientTests.cs | 61 +++++++++++--- .../Models/Request/BranchProtectionUpdate.cs | 64 +++++++++++++- Octokit/Models/Response/BranchProtection.cs | 83 +++++++++++++++++-- 5 files changed, 227 insertions(+), 35 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index b4bb14819c..6e2b747bf8 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -197,7 +197,6 @@ public class TheGetBranchProtectionMethod : IDisposable { IRepositoryBranchesClient _client; RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; public TheGetBranchProtectionMethod() { @@ -205,7 +204,6 @@ public TheGetBranchProtectionMethod() _client = github.Repository.Branch; _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; } [IntegrationTest] @@ -213,7 +211,7 @@ public async Task GetsBranchProtection() { var repoOwner = _userRepoContext.RepositoryOwner; var repoName = _userRepoContext.RepositoryName; - var protection = await _client.GetBranchProtection(repoOwner, repoName, "master"); + var protection = await _client.GetBranchProtection(repoOwner, repoName, "main"); Assert.True(protection.RequiredStatusChecks.Strict); Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); @@ -225,13 +223,18 @@ public async Task GetsBranchProtection() Assert.Null(protection.Restrictions); Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.False(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); } [IntegrationTest] public async Task GetsBranchProtectionWithRepositoryId() { var repoId = _userRepoContext.RepositoryId; - var protection = await _client.GetBranchProtection(repoId, "master"); + var protection = await _client.GetBranchProtection(repoId, "main"); Assert.True(protection.RequiredStatusChecks.Strict); Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); @@ -243,14 +246,39 @@ public async Task GetsBranchProtectionWithRepositoryId() Assert.Null(protection.Restrictions); Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.False(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); } - [IntegrationTest] + public void Dispose() + { + if (_userRepoContext != null) + _userRepoContext.Dispose(); + } + } + + public class TheGetBranchOrgProtectionMethod : IDisposable + { + IRepositoryBranchesClient _client; + OrganizationRepositoryWithTeamContext _orgRepoContext; + + public TheGetBranchOrgProtectionMethod() + { + var github = Helper.GetAuthenticatedClient(); + _client = github.Repository.Branch; + + _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + } + + [OrganizationTest] public async Task GetsBranchProtectionForOrgRepo() { var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var protection = await _client.GetBranchProtection(repoOwner, repoName, "master"); + var protection = await _client.GetBranchProtection(repoOwner, repoName, "main"); Assert.True(protection.RequiredStatusChecks.Strict); Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); @@ -266,11 +294,11 @@ public async Task GetsBranchProtectionForOrgRepo() Assert.True(protection.EnforceAdmins.Enabled); } - [IntegrationTest] + [OrganizationTest] public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() { var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var protection = await _client.GetBranchProtection(repoId, "master"); + var protection = await _client.GetBranchProtection(repoId, "main"); Assert.True(protection.RequiredStatusChecks.Strict); Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); @@ -288,9 +316,6 @@ public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() public void Dispose() { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - if (_orgRepoContext != null) _orgRepoContext.Dispose(); } diff --git a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs index 8c36d50389..c0e89ba72a 100644 --- a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs +++ b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs @@ -34,9 +34,14 @@ internal async static Task<RepositoryContext> CreateRepositoryWithProtectedBranc new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), new BranchProtectionRequiredReviewsUpdate(true, true, 3), null, + true, + true, + true, + true, + false, true); - await client.Repository.Branch.UpdateBranchProtection(contextUserRepo.RepositoryOwner, contextUserRepo.RepositoryName, "master", update); + await client.Repository.Branch.UpdateBranchProtection(contextUserRepo.RepositoryOwner, contextUserRepo.RepositoryName, "main", update); return contextUserRepo; } diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs index 8cbac07c59..2e49b7e39c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -121,7 +121,6 @@ public class TheUpdateBranchProtectionMethod : IDisposable { IObservableRepositoryBranchesClient _client; RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; public TheUpdateBranchProtectionMethod() { @@ -129,7 +128,6 @@ public TheUpdateBranchProtectionMethod() _client = new ObservableRepositoryBranchesClient(github); _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; } [IntegrationTest] @@ -142,7 +140,7 @@ public async Task UpdatesBranchProtection() new BranchProtectionRequiredReviewsUpdate(false, true, 2), false); - var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update); + var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "main", update); Assert.False(protection.RequiredStatusChecks.Strict); Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); @@ -166,7 +164,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId() new BranchProtectionRequiredReviewsUpdate(false, true, 2), false); - var protection = await _client.UpdateBranchProtection(repoId, "master", update); + var protection = await _client.UpdateBranchProtection(repoId, "main", update); Assert.False(protection.RequiredStatusChecks.Strict); Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); @@ -181,7 +179,27 @@ public async Task UpdatesBranchProtectionWithRepositoryId() Assert.False(protection.EnforceAdmins.Enabled); } - [IntegrationTest] + public void Dispose() + { + if (_userRepoContext != null) + _userRepoContext.Dispose(); + } + } + + public class TheUpdateOrgBranchProtectionMethod : IDisposable + { + IObservableRepositoryBranchesClient _client; + OrganizationRepositoryWithTeamContext _orgRepoContext; + + public TheUpdateOrgBranchProtectionMethod() + { + var github = Helper.GetAuthenticatedClient(); + _client = new ObservableRepositoryBranchesClient(github); + + _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + } + + [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepo() { var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; @@ -190,9 +208,14 @@ public async Task UpdatesBranchProtectionForOrgRepo() new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), new BranchProtectionPushRestrictionsUpdate(), - false); + false, + true, + true, + true, + true, + true); - var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update); + var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "main", update); Assert.False(protection.RequiredStatusChecks.Strict); Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); @@ -206,9 +229,14 @@ public async Task UpdatesBranchProtectionForOrgRepo() Assert.Empty(protection.Restrictions.Users); Assert.False(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.True(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); } - [IntegrationTest] + [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() { var repoId = _orgRepoContext.RepositoryContext.RepositoryId; @@ -216,9 +244,14 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), new BranchProtectionPushRestrictionsUpdate(), - false); + false, + true, + true, + true, + true, + true); - var protection = await _client.UpdateBranchProtection(repoId, "master", update); + var protection = await _client.UpdateBranchProtection(repoId, "main", update); Assert.False(protection.RequiredStatusChecks.Strict); Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); @@ -232,13 +265,15 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() Assert.Empty(protection.Restrictions.Users); Assert.False(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.True(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); } public void Dispose() { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - if (_orgRepoContext != null) _orgRepoContext.Dispose(); } diff --git a/Octokit/Models/Request/BranchProtectionUpdate.cs b/Octokit/Models/Request/BranchProtectionUpdate.cs index 227730c3da..1c2424cdf7 100644 --- a/Octokit/Models/Request/BranchProtectionUpdate.cs +++ b/Octokit/Models/Request/BranchProtectionUpdate.cs @@ -85,7 +85,10 @@ public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate /// <param name="requiredPullRequestReviews">Specifies if reviews are required to merge the pull request. Pass null to disable required reviews</param> /// <param name="restrictions">Specifies the requested push access restrictions (applies only to Organization owned repositories). Pass null to disable push access restrictions</param> /// <param name="enforceAdmins">Specifies whether the protections applied to this branch also apply to repository admins</param> - public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate requiredStatusChecks, BranchProtectionRequiredReviewsUpdate requiredPullRequestReviews, BranchProtectionPushRestrictionsUpdate restrictions, bool enforceAdmins) + public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate requiredStatusChecks, + BranchProtectionRequiredReviewsUpdate requiredPullRequestReviews, + BranchProtectionPushRestrictionsUpdate restrictions, + bool enforceAdmins) { RequiredStatusChecks = requiredStatusChecks; RequiredPullRequestReviews = requiredPullRequestReviews; @@ -93,6 +96,39 @@ public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate EnforceAdmins = enforceAdmins; } + /// <summary> + /// Create a BranchProtection update request + /// </summary> + /// <param name="requiredStatusChecks">Specifies the requested status check settings. Pass null to disable status checks</param> + /// <param name="requiredPullRequestReviews">Specifies if reviews are required to merge the pull request. Pass null to disable required reviews</param> + /// <param name="restrictions">Specifies the requested push access restrictions (applies only to Organization owned repositories). Pass null to disable push access restrictions</param> + /// <param name="enforceAdmins">Specifies whether the protections applied to this branch also apply to repository admins</param> + /// <param name="requiredLinearHistory">Enforces a linear commit Git history</param> + /// <param name="allowForcePushes">Permits force pushes to the protected branch</param> + /// <param name="allowDeletions">Allows deletion of the protected branch</param> + /// <param name="blockCreations">The restrictions branch protection settings will also block pushes which create new branches</param> + /// <param name="requiredConversationResolution">Requires all conversations on code to be resolved before a pull request can be merged</param> + public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate requiredStatusChecks, + BranchProtectionRequiredReviewsUpdate requiredPullRequestReviews, + BranchProtectionPushRestrictionsUpdate restrictions, + bool enforceAdmins, + bool requiredLinearHistory, + bool? allowForcePushes, + bool allowDeletions, + bool blockCreations, + bool requiredConversationResolution) + { + RequiredStatusChecks = requiredStatusChecks; + RequiredPullRequestReviews = requiredPullRequestReviews; + Restrictions = restrictions; + EnforceAdmins = enforceAdmins; + RequiredLinearHistory = requiredLinearHistory; + AllowForcePushes = allowForcePushes; + AllowDeletions = allowDeletions; + BlockCreations = blockCreations; + RequiredConversationResolution = requiredConversationResolution; + } + /// <summary> /// Status check settings for the protected branch /// </summary> @@ -116,6 +152,32 @@ public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate /// </summary> public bool EnforceAdmins { get; set; } + /// <summary> + /// Enforces a linear commit Git history. Default is false. + /// </summary> + public bool RequiredLinearHistory { get; set; } + + /// <summary> + /// Permits force pushes to the protected branch by anyone with write access to the repository. Default is false. + /// </summary> + public bool? AllowForcePushes { get; set; } + + /// <summary> + /// Allows deletion of the protected branch by anyone with write access to the repository. Default is false. + /// </summary> + public bool AllowDeletions { get; set; } + + /// <summary> + /// If set to true, the restrictions branch protection settings which limits who can push will also block pushes which create new branches, unless the push is initiated by a user, team, or app which has the ability to push. Default is false. + /// </summary> + public bool BlockCreations { get; set; } + + /// <summary> + /// Requires all conversations on code to be resolved before a pull request can be merged. Default is false. + /// </summary> + public bool RequiredConversationResolution { get; set; } + + internal string DebuggerDisplay { get diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index e73e864507..2c1703d164 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -9,41 +9,85 @@ namespace Octokit /// <summary> /// Protection details for a <see cref="Branch"/>. /// </summary> - /// <remarks> - /// Note: this is a PREVIEW api: https://developer.github.com/changes/2016-06-27-protected-branches-api-update/ - /// </remarks> [DebuggerDisplay("{DebuggerDisplay,nq}")] public class BranchProtectionSettings { public BranchProtectionSettings() { } - public BranchProtectionSettings(BranchProtectionRequiredStatusChecks requiredStatusChecks, BranchProtectionPushRestrictions restrictions, BranchProtectionRequiredReviews requiredPullRequestReviews, EnforceAdmins enforceAdmins) + public BranchProtectionSettings(BranchProtectionRequiredStatusChecks requiredStatusChecks, + BranchProtectionRequiredReviews requiredPullRequestReviews, + BranchProtectionPushRestrictions restrictions, + EnforceAdmins enforceAdmins, + BranchProtectionEnabledCommon requiredLinearHistory, + BranchProtectionEnabledCommon allowForcePushes, + BranchProtectionEnabledCommon allowDeletions, + BranchProtectionEnabledCommon blockCreations, + BranchProtectionEnabledCommon requiredConversationResolution, + BranchProtectionEnabledCommon requiredSignatures) { RequiredStatusChecks = requiredStatusChecks; - Restrictions = restrictions; RequiredPullRequestReviews = requiredPullRequestReviews; + Restrictions = restrictions; EnforceAdmins = enforceAdmins; + RequiredLinearHistory = requiredLinearHistory; + AllowForcePushes = allowForcePushes; + AllowDeletions = allowDeletions; + BlockCreations = blockCreations; + RequiredConversationResolution = requiredConversationResolution; + RequiredSignatures = requiredSignatures; } + + /// <summary> /// Status check settings for the protected branch /// </summary> - public BranchProtectionRequiredStatusChecks RequiredStatusChecks { get; protected set; } + public BranchProtectionRequiredStatusChecks RequiredStatusChecks { get; private set; } /// <summary> /// Required review settings for the protected branch /// </summary> - public BranchProtectionRequiredReviews RequiredPullRequestReviews { get; protected set; } + public BranchProtectionRequiredReviews RequiredPullRequestReviews { get; private set; } /// <summary> /// Push access restrictions for the protected branch /// </summary> - public BranchProtectionPushRestrictions Restrictions { get; protected set; } + public BranchProtectionPushRestrictions Restrictions { get; private set; } /// <summary> /// Specifies whether the protections applied to this branch also apply to repository admins /// </summary> - public EnforceAdmins EnforceAdmins { get; protected set; } + public EnforceAdmins EnforceAdmins { get; private set; } + + /// <summary> + /// Specifies whether a linear history is required + /// </summary> + public BranchProtectionEnabledCommon RequiredLinearHistory { get; private set; } + + /// <summary> + /// Specifies whether force pushes are allowed + /// </summary> + public BranchProtectionEnabledCommon AllowForcePushes { get; private set; } + + /// <summary> + /// Specifies whether deletions are allowed + /// </summary> + public BranchProtectionEnabledCommon AllowDeletions { get; private set; } + + /// <summary> + /// Specifies whether creations can be blocked + /// </summary> + public BranchProtectionEnabledCommon BlockCreations { get; private set; } + + /// <summary> + /// Specifies whether conversation resolution iss required + /// </summary> + public BranchProtectionEnabledCommon RequiredConversationResolution { get; private set; } + + /// <summary> + /// Specifies whether signatures are required + /// </summary> + public BranchProtectionEnabledCommon RequiredSignatures { get; private set; } internal string DebuggerDisplay { @@ -239,4 +283,25 @@ internal string DebuggerDisplay } } } + + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class BranchProtectionEnabledCommon + { + public BranchProtectionEnabledCommon() { } + + public BranchProtectionEnabledCommon(bool enabled) + { + Enabled = enabled; + } + + public bool Enabled { get; protected set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Enabled: {0}", Enabled); + } + } + } } From 13ba84b060ea1e025a7dcfa6c843289002cdab67 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 15 Jul 2022 20:50:35 +0100 Subject: [PATCH 085/209] fix: Trims trailing slashes from user passed paths that appear before query string parameters (#2486) --- .../Clients/RepositoryContentsClientTests.cs | 16 +++++++++++++++- Octokit/Helpers/ApiUrls.cs | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs index d2283388b0..099209d1b5 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs @@ -216,7 +216,21 @@ public async Task GetsDirectoryContent() var contents = await github .Repository .Content - .GetAllContentsByRef("octokit", "octokit.net", "Octokit", "master"); + .GetAllContentsByRef("octokit", "octokit.net", "Octokit", "main"); + + Assert.True(contents.Count > 2); + Assert.Equal(ContentType.Dir, contents.First().Type); + } + + [IntegrationTest] + public async Task GetsDirectoryContentWithTrailingSlash() + { + var github = Helper.GetAuthenticatedClient(); + + var contents = await github + .Repository + .Content + .GetAllContentsByRef("octokit", "octokit.net", "Octokit/", "main"); Assert.True(contents.Count > 2); Assert.Equal(ContentType.Dir, contents.First().Type); diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 5544d18a59..32955feb11 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1698,7 +1698,7 @@ public static Uri Tree(string owner, string name, string reference) /// <returns></returns> public static Uri TreeRecursive(string owner, string name, string reference) { - return "repos/{0}/{1}/git/trees/{2}?recursive=1".FormatUri(owner, name, reference); + return "repos/{0}/{1}/git/trees/{2}?recursive=1".FormatUri(owner, name, reference.TrimEnd('/')); } /// <summary> @@ -2445,7 +2445,7 @@ public static Uri RepositoryArchiveLink(string owner, string name, ArchiveFormat /// <returns>The <see cref="Uri"/> for getting the contents of the specified repository and path</returns> public static Uri RepositoryContent(string owner, string name, string path, string reference) { - return "repos/{0}/{1}/contents/{2}?ref={3}".FormatUri(owner, name, path == "/" ? "" : path, reference); + return "repos/{0}/{1}/contents/{2}?ref={3}".FormatUri(owner, name, path == "/" ? "" : path.TrimEnd('/'), reference); } /// <summary> @@ -3451,7 +3451,7 @@ public static Uri RepositoryContent(long repositoryId, string path) /// <returns>The <see cref="Uri"/> for getting the contents of the specified repository and path</returns> public static Uri RepositoryContent(long repositoryId, string path, string reference) { - return "repositories/{0}/contents/{1}?ref={2}".FormatUri(repositoryId, path, reference); + return "repositories/{0}/contents/{1}?ref={2}".FormatUri(repositoryId, path.TrimEnd('/'), reference); } /// <summary> @@ -3708,7 +3708,7 @@ public static Uri Tree(long repositoryId, string reference) /// <returns>The <see cref="Uri"/> for the specified tree.</returns> public static Uri TreeRecursive(long repositoryId, string reference) { - return "repositories/{0}/git/trees/{1}?recursive=1".FormatUri(repositoryId, reference); + return "repositories/{0}/git/trees/{1}?recursive=1".FormatUri(repositoryId, reference.TrimEnd('/')); } /// <summary> From 8b5a7fceaf79d9d9dba07e2f28a6ec8d42234b0a Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Wed, 20 Jul 2022 23:17:10 +0100 Subject: [PATCH 086/209] feat: Fixing master > main in integration tests (#2489) --- .../Clients/IObservableReferencesClient.cs | 12 +- .../IObservableRepositoryContentsClient.cs | 8 +- .../Clients/ObservableReferencesClient.cs | 20 +- .../ObservableRepositoryContentsClient.cs | 8 +- .../Clients/CheckRunsClientTests.cs | 24 +- .../Clients/CheckSuitesClientTests.cs | 16 +- .../Clients/MigrationsClientTests.cs | 6 +- ...nizationOutsideCollaboratorsClientTests.cs | 20 +- .../Clients/RepositoriesClientTests.cs | 10 +- .../Clients/RepositoryBranchesClientTests.cs | 2500 ++++++++--------- .../Clients/TeamsClientTests.cs | 6 +- Octokit.Tests.Integration/Helper.cs | 5 + .../Helpers/GithubClientExtensions.cs | 33 +- .../OrganizationRepositoryWithTeamContext.cs | 48 +- .../Helpers/OrganizationTestAttribute.cs | 2 +- .../Helpers/ReferenceExtensionsTests.cs | 2 +- .../Helpers/RepositoryContext.cs | 2 + ...nizationOutsideCollaboratorsClientTests.cs | 18 +- ...ObservableRepositoryBranchesClientTests.cs | 663 +++-- .../Reactive/ObservableTeamsClientTests.cs | 2 +- Octokit.Tests.Integration/SelfTests.cs | 10 + Octokit.Tests/Clients/EventsClientTests.cs | 10 +- .../Clients/RepositoryContentsClientTests.cs | 16 +- Octokit.Tests/Fixtures/release.json | 2 +- Octokit.Tests/Fixtures/releases.json | 18 +- Octokit.Tests/Fixtures/repositories.json | Bin 66996 -> 66992 bytes Octokit.Tests/Fixtures/repository.json | Bin 2610 -> 2606 bytes Octokit.Tests/GitHubConstants.cs | 7 + Octokit.Tests/Models/CheckRunEventTests.cs | 4 +- Octokit.Tests/Models/CheckSuiteEventTests.cs | 2 +- Octokit.Tests/Models/MigrationTests.cs | 2 +- .../Models/SearchRepositoryResultTests.cs | 4 +- ...ObservableRepositoryContentsClientTests.cs | 16 +- Octokit/Clients/IReferencesClient.cs | 44 +- Octokit/Clients/IRepositoryContentsClient.cs | 8 +- Octokit/Clients/ReferencesClient.cs | 32 +- Octokit/Clients/RepositoryContentsClient.cs | 8 +- Octokit/Helpers/ApiUrls.cs | 4 +- Octokit/Helpers/ReferenceExtensions.cs | 26 +- Octokit/Models/Request/CreateFileRequest.cs | 2 +- Octokit/Models/Request/NewReference.cs | 4 +- Octokit/Models/Request/NewRelease.cs | 2 +- Octokit/Models/Request/ReleaseUpdate.cs | 2 +- 43 files changed, 1772 insertions(+), 1856 deletions(-) create mode 100644 Octokit.Tests/GitHubConstants.cs diff --git a/Octokit.Reactive/Clients/IObservableReferencesClient.cs b/Octokit.Reactive/Clients/IObservableReferencesClient.cs index 323e1caa1e..7747528fd4 100644 --- a/Octokit.Reactive/Clients/IObservableReferencesClient.cs +++ b/Octokit.Reactive/Clients/IObservableReferencesClient.cs @@ -20,7 +20,7 @@ public interface IObservableReferencesClient /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] @@ -33,7 +33,7 @@ public interface IObservableReferencesClient /// http://developer.github.com/v3/git/refs/#get-a-reference /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] @@ -162,7 +162,7 @@ public interface IObservableReferencesClient /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <param name="referenceUpdate">The updated reference data</param> /// <returns></returns> IObservable<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate); @@ -174,7 +174,7 @@ public interface IObservableReferencesClient /// http://developer.github.com/v3/git/refs/#update-a-reference /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <param name="referenceUpdate">The updated reference data</param> /// <returns></returns> IObservable<Reference> Update(long repositoryId, string reference, ReferenceUpdate referenceUpdate); @@ -187,7 +187,7 @@ public interface IObservableReferencesClient /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> IObservable<Unit> Delete(string owner, string name, string reference); @@ -198,7 +198,7 @@ public interface IObservableReferencesClient /// http://developer.github.com/v3/git/refs/#delete-a-reference /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> IObservable<Unit> Delete(long repositoryId, string reference); } diff --git a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs index b55afc633c..9e5779761b 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs @@ -163,7 +163,7 @@ public interface IObservableRepositoryContentsClient /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> /// <param name="path">The content path</param> IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference, string path); @@ -187,7 +187,7 @@ public interface IObservableRepositoryContentsClient /// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> /// <param name="path">The content path</param> IObservable<RepositoryContent> GetAllContentsByRef(long repositoryId, string reference, string path); @@ -196,14 +196,14 @@ public interface IObservableRepositoryContentsClient /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference); /// <summary> /// Returns the contents of the home directory in a repository. /// </summary> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> IObservable<RepositoryContent> GetAllContentsByRef(long repositoryId, string reference); /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableReferencesClient.cs b/Octokit.Reactive/Clients/ObservableReferencesClient.cs index 21fcba501e..e666d5b644 100644 --- a/Octokit.Reactive/Clients/ObservableReferencesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReferencesClient.cs @@ -32,7 +32,7 @@ public ObservableReferencesClient(IGitHubClient client) /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> public IObservable<Reference> Get(string owner, string name, string reference) { @@ -50,7 +50,7 @@ public IObservable<Reference> Get(string owner, string name, string reference) /// http://developer.github.com/v3/git/refs/#get-a-reference /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> public IObservable<Reference> Get(long repositoryId, string reference) { @@ -148,9 +148,9 @@ public IObservable<Reference> GetAllForSubNamespace(string owner, string name, s /// <param name="options">Options for changing the API response</param> /// <remarks> /// The subNamespace parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> public IObservable<Reference> GetAllForSubNamespace(string owner, string name, string subNamespace, ApiOptions options) { @@ -192,9 +192,9 @@ public IObservable<Reference> GetAllForSubNamespace(long repositoryId, string su /// <param name="options">Options for changing the API response</param> /// <remarks> /// The subNamespace parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> public IObservable<Reference> GetAllForSubNamespace(long repositoryId, string subNamespace, ApiOptions options) { @@ -252,7 +252,7 @@ public IObservable<Reference> Create(long repositoryId, NewReference reference) /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <param name="referenceUpdate">The updated reference data</param> /// <returns></returns> public IObservable<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate) @@ -272,7 +272,7 @@ public IObservable<Reference> Update(string owner, string name, string reference /// http://developer.github.com/v3/git/refs/#update-a-reference /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <param name="referenceUpdate">The updated reference data</param> /// <returns></returns> public IObservable<Reference> Update(long repositoryId, string reference, ReferenceUpdate referenceUpdate) @@ -291,7 +291,7 @@ public IObservable<Reference> Update(long repositoryId, string reference, Refere /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> public IObservable<Unit> Delete(string owner, string name, string reference) { @@ -309,7 +309,7 @@ public IObservable<Unit> Delete(string owner, string name, string reference) /// http://developer.github.com/v3/git/refs/#delete-a-reference /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/master" or "tags/release-1"</param> + /// <param name="reference">The canonical name of the reference without the 'refs/' prefix. e.g. "heads/main" or "tags/release-1"</param> /// <returns></returns> public IObservable<Unit> Delete(long repositoryId, string reference) { diff --git a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs index a044e09096..777b380f00 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs @@ -281,7 +281,7 @@ public IObservable<RepositoryContent> GetAllContents(long repositoryId) /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> /// <param name="path">The content path</param> public IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference, string path) { @@ -325,7 +325,7 @@ public IObservable<byte[]> GetRawContentByRef(string owner, string name, string /// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> /// <param name="path">The content path</param> public IObservable<RepositoryContent> GetAllContentsByRef(long repositoryId, string reference, string path) { @@ -340,7 +340,7 @@ public IObservable<RepositoryContent> GetAllContentsByRef(long repositoryId, str /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> public IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -354,7 +354,7 @@ public IObservable<RepositoryContent> GetAllContentsByRef(string owner, string n /// Returns the contents of the home directory in a repository. /// </summary> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main )</param> public IObservable<RepositoryContent> GetAllContentsByRef(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); diff --git a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs index 07ba5f93cf..cd10169931 100644 --- a/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs @@ -27,7 +27,7 @@ public async Task CreatesCheckRun() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -49,7 +49,7 @@ public async Task CreatesCheckRunWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -85,7 +85,7 @@ public async Task UpdatesCheckRun() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -117,7 +117,7 @@ public async Task UpdatesCheckRunWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -163,7 +163,7 @@ public async Task GetsAllCheckRuns() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -198,7 +198,7 @@ public async Task GetsAllCheckRunsWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -247,7 +247,7 @@ public async Task GetsAllCheckRuns() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -283,7 +283,7 @@ public async Task GetsAllCheckRunsWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -332,7 +332,7 @@ public async Task GetsCheckRun() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -359,7 +359,7 @@ public async Task GetsCheckRunWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -400,7 +400,7 @@ public async Task GetsAllAnnotations() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -433,7 +433,7 @@ public async Task GetsAllAnnotationsWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch diff --git a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs index 52a97b03ab..03be9d99cf 100644 --- a/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CheckSuitesClientTests.cs @@ -26,7 +26,7 @@ public async Task GetsCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -44,7 +44,7 @@ public async Task GetsCheckSuiteWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -75,7 +75,7 @@ public async Task GetsAllCheckSuites() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); @@ -92,7 +92,7 @@ public async Task GetsAllCheckSuitesWithRepositoryId() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha); @@ -176,7 +176,7 @@ public async Task CreatesCheckSuite() await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -199,7 +199,7 @@ public async Task CreatesCheckSuiteWithRepositoryId() await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryId, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -232,7 +232,7 @@ public async Task RerequestsCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -248,7 +248,7 @@ public async Task RerequestsCheckSuiteWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id diff --git a/Octokit.Tests.Integration/Clients/MigrationsClientTests.cs b/Octokit.Tests.Integration/Clients/MigrationsClientTests.cs index 4d1e93b07a..8b868d2c00 100644 --- a/Octokit.Tests.Integration/Clients/MigrationsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MigrationsClientTests.cs @@ -28,17 +28,17 @@ public MigrationsClientTests() private async Task CreateTheWorld() { - _repos.Add(await _gitHub.CreateRepositoryContext(_orgName, new NewRepository(Helper.MakeNameWithTimestamp("migrationtest-repo1")) + _repos.Add(await _gitHub.CreateOrganizationRepositoryContext(_orgName, new NewRepository(Helper.MakeNameWithTimestamp("migrationtest-repo1")) { GitignoreTemplate = "VisualStudio", LicenseTemplate = "mit" })); - _repos.Add(await _gitHub.CreateRepositoryContext(_orgName, new NewRepository(Helper.MakeNameWithTimestamp("migrationtest-repo2")) + _repos.Add(await _gitHub.CreateOrganizationRepositoryContext(_orgName, new NewRepository(Helper.MakeNameWithTimestamp("migrationtest-repo2")) { GitignoreTemplate = "VisualStudio", LicenseTemplate = "mit" })); - _repos.Add(await _gitHub.CreateRepositoryContext(_orgName, new NewRepository(Helper.MakeNameWithTimestamp("migrationtest-repo3")) + _repos.Add(await _gitHub.CreateOrganizationRepositoryContext(_orgName, new NewRepository(Helper.MakeNameWithTimestamp("migrationtest-repo3")) { GitignoreTemplate = "VisualStudio", LicenseTemplate = "mit" diff --git a/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs index 57ffce1e88..ab4c548a7f 100644 --- a/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/OrganizationOutsideCollaboratorsClientTests.cs @@ -20,7 +20,7 @@ public TheGetAllMethod() public async Task ReturnsNoOutsideCollaborators() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { var outsideCollaborators = await _gitHub.Organization .OutsideCollaborator @@ -35,7 +35,7 @@ public async Task ReturnsNoOutsideCollaborators() public async Task ReturnsOutsideCollaborators() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); @@ -52,7 +52,7 @@ public async Task ReturnsOutsideCollaborators() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); @@ -75,7 +75,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -100,7 +100,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -118,7 +118,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOptions() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -142,7 +142,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOp public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStart() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -179,7 +179,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStar public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -198,7 +198,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilterAndApiOptions() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -234,7 +234,7 @@ public TheDeleteMethod() public async Task CanRemoveOutsideCollaborator() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 161c21a085..18b7578365 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -456,7 +456,7 @@ public async Task CreatesANewPublicRepository() var repoName = Helper.MakeNameWithTimestamp("public-org-repo"); - using (var context = await github.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { var createdRepository = context.Repository; @@ -484,7 +484,7 @@ public async Task ThrowsRepositoryExistsExceptionForExistingRepository() var repository = new NewRepository(repoName); - using (var context = await github.CreateRepositoryContext(Helper.Organization, repository)) + using (var context = await github.CreateOrganizationRepositoryContext(Helper.Organization, repository)) { var createdRepository = context.Repository; @@ -1604,7 +1604,7 @@ public TheReplaceAllTopicsMethod() { _theRepoOwner = Helper.Organization; _theRepository = Helper.MakeNameWithTimestamp("topics"); - _context = _github.CreateRepositoryContext(_theRepoOwner, new NewRepository(_theRepository)).Result; + _context = _github.CreateOrganizationRepositoryContext(_theRepoOwner, new NewRepository(_theRepository)).Result; var defaultTopicAssignmentResult = _github.Repository.ReplaceAllTopics(_context.RepositoryId, _defaultTopics).Result; } @@ -2035,7 +2035,7 @@ public async Task TransfersFromOrgToUser() var github = Helper.GetAuthenticatedClient(); var newRepo = new NewRepository(Helper.MakeNameWithTimestamp("transferred-repo")); var newOwner = Helper.UserName; - using (var context = await github.CreateRepositoryContext(Helper.Organization, newRepo)) + using (var context = await github.CreateOrganizationRepositoryContext(Helper.Organization, newRepo)) { var transfer = new RepositoryTransfer(newOwner); await github.Repository.Transfer(context.RepositoryOwner, context.RepositoryName, transfer); @@ -2051,7 +2051,7 @@ public async Task TransfersFromOrgToUserById() var github = Helper.GetAuthenticatedClient(); var newRepo = new NewRepository(Helper.MakeNameWithTimestamp("transferred-repo")); var newOwner = Helper.UserName; - using (var context = await github.CreateRepositoryContext(Helper.Organization, newRepo)) + using (var context = await github.CreateOrganizationRepositoryContext(Helper.Organization, newRepo)) { var transfer = new RepositoryTransfer(newOwner); await github.Repository.Transfer(context.RepositoryId, transfer); diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index 6e2b747bf8..9632171bf3 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -1,1689 +1,1507 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -using Octokit; -using Octokit.Tests.Integration; +using Octokit.Helpers; using Octokit.Tests.Integration.Helpers; using Xunit; -public class RepositoryBranchesClientTests +namespace Octokit.Tests.Integration.Clients { - public class TheGetAllMethod + public class RepositoryBranchesClientTests { - [IntegrationTest] - public async Task GetsAllBranches() + public class TheGetAllMethod : GitHubClientTestBase { - var github = Helper.GetAuthenticatedClient(); - - var branches = await github.Repository.Branch.GetAll("octokit", "octokit.net"); - - Assert.NotEmpty(branches); - } - - [IntegrationTest] - public async Task GetsAllBranchesWithRepositoryId() - { - var github = Helper.GetAuthenticatedClient(); - - var branches = await github.Repository.Branch.GetAll(7528679); - - Assert.NotEmpty(branches); - } - - [IntegrationTest] - public async Task ReturnsCorrectCountOfBranchesWithoutStart() - { - var github = Helper.GetAuthenticatedClient(); - - var options = new ApiOptions + [IntegrationTest] + public async Task GetsAllBranches() { - PageSize = 5, - PageCount = 1 - }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); - var branches = await github.Repository.Branch.GetAll("octokit", "octokit.net", options); + var branches = await _github.Repository.Branch.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName); - Assert.Equal(5, branches.Count); - } - - [IntegrationTest] - public async Task ReturnsCorrectCountOfBranchesWithoutStartWithRepositoryId() - { - var github = Helper.GetAuthenticatedClient(); + Assert.NotEmpty(branches); + } + } - var options = new ApiOptions + [IntegrationTest] + public async Task GetsAllBranchesWithRepositoryId() { - PageSize = 5, - PageCount = 1 - }; - - var branches = await github.Repository.Branch.GetAll(7528679, options); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); - Assert.Equal(5, branches.Count); - } + var branches = await _github.Repository.Branch.GetAll(repoContext.RepositoryId); - [IntegrationTest] - public async Task ReturnsCorrectCountOfBranchesWithStart() - { - var github = Helper.GetAuthenticatedClient(); + Assert.NotEmpty(branches); + } + } - var options = new ApiOptions + [IntegrationTest] + public async Task ReturnsCorrectCountOfBranchesWithoutStart() { - PageSize = 5, - PageCount = 1, - StartPage = 2 - }; - - var branches = await github.Repository.Branch.GetAll("octokit", "octokit.net", options); - - Assert.Equal(5, branches.Count); - } - - [IntegrationTest] - public async Task ReturnsCorrectCountOfBranchesWithStartWithRepositoryId() - { - var github = Helper.GetAuthenticatedClient(); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-4", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-5", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-6", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-7", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-8", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-9", repoContext.Repository.DefaultBranch); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var branches = await _github.Repository.Branch.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName, options); + + Assert.Equal(5, branches.Count); + } + } - var options = new ApiOptions + [IntegrationTest] + public async Task ReturnsCorrectCountOfBranchesWithoutStartWithRepositoryId() { - PageSize = 5, - PageCount = 1, - StartPage = 2 - }; - - var branches = await github.Repository.Branch.GetAll(7528679, options); - - Assert.Equal(5, branches.Count); - } - - [IntegrationTest] - public async Task GetsPagesOfBranches() - { - var github = Helper.GetAuthenticatedClient(); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-4", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-5", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-6", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-7", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-8", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-9", repoContext.Repository.DefaultBranch); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var branches = await _github.Repository.Branch.GetAll(repoContext.RepositoryId, options); + + Assert.Equal(5, branches.Count); + } + } - var firstPageOptions = new ApiOptions + [IntegrationTest] + public async Task ReturnsCorrectCountOfBranchesWithStart() { - PageSize = 5, - StartPage = 1, - PageCount = 1 - }; - - var firstPage = await github.Repository.Branch.GetAll("octokit", "octokit.net", firstPageOptions); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-4", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-5", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-6", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-7", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-8", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-9", repoContext.Repository.DefaultBranch); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var branches = await _github.Repository.Branch.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName, options); + + Assert.Equal(5, branches.Count); + } + } - var secondPageOptions = new ApiOptions + [IntegrationTest] + public async Task ReturnsCorrectCountOfBranchesWithStartWithRepositoryId() { - PageSize = 5, - StartPage = 2, - PageCount = 1 - }; - - var secondPage = await github.Repository.Branch.GetAll("octokit", "octokit.net", secondPageOptions); - - Assert.Equal(5, firstPage.Count); - Assert.Equal(5, secondPage.Count); - - Assert.NotEqual(firstPage[0].Name, secondPage[0].Name); - Assert.NotEqual(firstPage[1].Name, secondPage[1].Name); - Assert.NotEqual(firstPage[2].Name, secondPage[2].Name); - Assert.NotEqual(firstPage[3].Name, secondPage[3].Name); - Assert.NotEqual(firstPage[4].Name, secondPage[4].Name); - } - - [IntegrationTest] - public async Task GetsPagesOfBranchesWithRepositoryId() - { - var github = Helper.GetAuthenticatedClient(); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-4", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-5", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-6", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-7", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-8", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-9", repoContext.Repository.DefaultBranch); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var branches = await _github.Repository.Branch.GetAll(repoContext.RepositoryId, options); + + Assert.Equal(5, branches.Count); + } + } - var firstPageOptions = new ApiOptions + [IntegrationTest] + public async Task GetsPagesOfBranches() { - PageSize = 5, - StartPage = 1, - PageCount = 1 - }; - - var firstPage = await github.Repository.Branch.GetAll(7528679, firstPageOptions); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-4", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-5", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-6", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-7", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-8", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-9", repoContext.Repository.DefaultBranch); + + var firstPageOptions = new ApiOptions + { + PageSize = 5, + StartPage = 1, + PageCount = 1 + }; + + var firstPage = await _github.Repository.Branch.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName, firstPageOptions); + + var secondPageOptions = new ApiOptions + { + PageSize = 5, + StartPage = 2, + PageCount = 1 + }; + + var secondPage = await _github.Repository.Branch.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName, secondPageOptions); + + Assert.Equal(5, firstPage.Count); + Assert.Equal(5, secondPage.Count); + + Assert.NotEqual(firstPage[0].Name, secondPage[0].Name); + Assert.NotEqual(firstPage[1].Name, secondPage[1].Name); + Assert.NotEqual(firstPage[2].Name, secondPage[2].Name); + Assert.NotEqual(firstPage[3].Name, secondPage[3].Name); + Assert.NotEqual(firstPage[4].Name, secondPage[4].Name); + } + } - var secondPageOptions = new ApiOptions + [IntegrationTest] + public async Task GetsPagesOfBranchesWithRepositoryId() { - PageSize = 5, - StartPage = 2, - PageCount = 1 - }; - - var secondPage = await github.Repository.Branch.GetAll(7528679, secondPageOptions); - - Assert.Equal(5, firstPage.Count); - Assert.Equal(5, secondPage.Count); - - Assert.NotEqual(firstPage[0].Name, secondPage[0].Name); - Assert.NotEqual(firstPage[1].Name, secondPage[1].Name); - Assert.NotEqual(firstPage[2].Name, secondPage[2].Name); - Assert.NotEqual(firstPage[3].Name, secondPage[3].Name); - Assert.NotEqual(firstPage[4].Name, secondPage[4].Name); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-3", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-4", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-5", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-6", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-7", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-8", repoContext.Repository.DefaultBranch); + await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-9", repoContext.Repository.DefaultBranch); + + var firstPageOptions = new ApiOptions + { + PageSize = 5, + StartPage = 1, + PageCount = 1 + }; + + var firstPage = await _github.Repository.Branch.GetAll(repoContext.RepositoryId, firstPageOptions); + + var secondPageOptions = new ApiOptions + { + PageSize = 5, + StartPage = 2, + PageCount = 1 + }; + + var secondPage = await _github.Repository.Branch.GetAll(repoContext.RepositoryId, secondPageOptions); + + Assert.Equal(5, firstPage.Count); + Assert.Equal(5, secondPage.Count); + + Assert.NotEqual(firstPage[0].Name, secondPage[0].Name); + Assert.NotEqual(firstPage[1].Name, secondPage[1].Name); + Assert.NotEqual(firstPage[2].Name, secondPage[2].Name); + Assert.NotEqual(firstPage[3].Name, secondPage[3].Name); + Assert.NotEqual(firstPage[4].Name, secondPage[4].Name); + } + } } - } - public class TheGetMethod - { - [IntegrationTest] - public async Task GetsABranch() + public class TheGetMethod : GitHubClientTestBase { - var github = Helper.GetAuthenticatedClient(); + [IntegrationTest] + public async Task GetsABranch() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - var branch = await github.Repository.Branch.Get("octokit", "octokit.net", "master"); + var branch = await _github.Repository.Branch.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.NotNull(branch); - Assert.Equal("master", branch.Name); + Assert.NotNull(branch); + Assert.Equal(repoContext.RepositoryDefaultBranch, branch.Name); - Assert.True(branch.Protected); - } + Assert.True(branch.Protected); + } + } - [IntegrationTest] - public async Task GetsABranchWithRepositoryId() - { - var github = Helper.GetAuthenticatedClient(); + [IntegrationTest] + public async Task GetsABranchWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - var branch = await github.Repository.Branch.Get(7528679, "master"); + var branch = await _github.Repository.Branch.Get(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.NotNull(branch); - Assert.Equal("master", branch.Name); + Assert.NotNull(branch); + Assert.Equal(repoContext.RepositoryDefaultBranch, branch.Name); - Assert.True(branch.Protected); + Assert.True(branch.Protected); + } + } } - } - public class TheGetBranchProtectionMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - - public TheGetBranchProtectionMethod() + public class TheGetBranchProtectionMethod : GitHubClientTestBase { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - } + [IntegrationTest] + public async Task GetsBranchProtection() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - [IntegrationTest] - public async Task GetsBranchProtection() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var protection = await _client.GetBranchProtection(repoOwner, repoName, "main"); + var protection = await _github.Repository.Branch.GetBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Null(protection.Restrictions); + Assert.Null(protection.Restrictions); - Assert.True(protection.EnforceAdmins.Enabled); - Assert.True(protection.RequiredLinearHistory.Enabled); - Assert.True(protection.AllowForcePushes.Enabled); - Assert.True(protection.AllowDeletions.Enabled); - Assert.False(protection.BlockCreations.Enabled); - Assert.True(protection.RequiredConversationResolution.Enabled); - } + Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.False(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); + } + } - [IntegrationTest] - public async Task GetsBranchProtectionWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var protection = await _client.GetBranchProtection(repoId, "main"); + [IntegrationTest] + public async Task GetsBranchProtectionWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + var protection = await _github.Repository.Branch.GetBranchProtection(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.Null(protection.Restrictions); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.True(protection.EnforceAdmins.Enabled); - Assert.True(protection.RequiredLinearHistory.Enabled); - Assert.True(protection.AllowForcePushes.Enabled); - Assert.True(protection.AllowDeletions.Enabled); - Assert.False(protection.BlockCreations.Enabled); - Assert.True(protection.RequiredConversationResolution.Enabled); - } + Assert.Null(protection.Restrictions); - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - } - } - - public class TheGetBranchOrgProtectionMethod : IDisposable - { - IRepositoryBranchesClient _client; - OrganizationRepositoryWithTeamContext _orgRepoContext; + Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.False(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); + } + } - public TheGetBranchOrgProtectionMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + [OrganizationTest] + public async Task GetsBranchProtectionForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; - } + var protection = await _github.Repository.Branch.GetBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - [OrganizationTest] - public async Task GetsBranchProtectionForOrgRepo() - { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var protection = await _client.GetBranchProtection(repoOwner, repoName, "main"); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(1, protection.Restrictions.Teams.Count); + Assert.Equal(0, protection.Restrictions.Users.Count); - Assert.Equal(1, protection.Restrictions.Teams.Count); - Assert.Equal(0, protection.Restrictions.Users.Count); + Assert.True(protection.EnforceAdmins.Enabled); + } + } - Assert.True(protection.EnforceAdmins.Enabled); - } + [OrganizationTest] + public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - [OrganizationTest] - public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var protection = await _client.GetBranchProtection(repoId, "main"); + var protection = await _github.Repository.Branch.GetBranchProtection(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(1, protection.Restrictions.Teams.Count); - Assert.Equal(0, protection.Restrictions.Users.Count); + Assert.Equal(1, protection.Restrictions.Teams.Count); + Assert.Equal(0, protection.Restrictions.Users.Count); - Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.EnforceAdmins.Enabled); + } + } } - public void Dispose() + public class TheUpdateBranchProtectionMethod : GitHubClientTestBase { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + [IntegrationTest] + public async Task UpdatesBranchProtection() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public class TheUpdateBranchProtectionMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), + false); - public TheUpdateBranchProtectionMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + var protection = await _github.Repository.Branch.UpdateBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; - } + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - [IntegrationTest] - public async Task UpdatesBranchProtection() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true, 2), - false); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update); + Assert.Null(protection.Restrictions); - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); + Assert.False(protection.EnforceAdmins.Enabled); + } + } - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + [IntegrationTest] + public async Task UpdatesBranchProtectionWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - Assert.Null(protection.Restrictions); + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), + false); - Assert.False(protection.EnforceAdmins.Enabled); - } + var protection = await _github.Repository.Branch.UpdateBranchProtection(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); - [IntegrationTest] - public async Task UpdatesBranchProtectionWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true, 2), - false); + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - var protection = await _client.UpdateBranchProtection(repoId, "master", update); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); + Assert.Null(protection.Restrictions); - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + Assert.False(protection.EnforceAdmins.Enabled); + } + } - Assert.Null(protection.Restrictions); + [OrganizationTest] + public async Task UpdatesBranchProtectionForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - Assert.False(protection.EnforceAdmins.Enabled); - } + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), + new BranchProtectionPushRestrictionsUpdate(), + false); - [IntegrationTest] - public async Task UpdatesBranchProtectionForOrgRepo() - { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), - new BranchProtectionPushRestrictionsUpdate(), - false); + var protection = await _github.Repository.Branch.UpdateBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); - var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update); + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + Assert.Empty(protection.Restrictions.Teams); + Assert.Empty(protection.Restrictions.Users); - Assert.Empty(protection.Restrictions.Teams); - Assert.Empty(protection.Restrictions.Users); + Assert.False(protection.EnforceAdmins.Enabled); + } + } - Assert.False(protection.EnforceAdmins.Enabled); + [OrganizationTest] + public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), + new BranchProtectionPushRestrictionsUpdate(), + false); + + var protection = await _github.Repository.Branch.UpdateBranchProtection(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); + + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); + + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + + Assert.Empty(protection.Restrictions.Teams); + Assert.Empty(protection.Restrictions.Users); + + Assert.False(protection.EnforceAdmins.Enabled); + } + } } - [IntegrationTest] - public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() + public class TheDeleteBranchProtectionMethod : GitHubClientTestBase { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), - new BranchProtectionPushRestrictionsUpdate(), - false); - - var protection = await _client.UpdateBranchProtection(repoId, "master", update); - - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + [IntegrationTest] + public async Task DeletesBranchProtection() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - Assert.Empty(protection.Restrictions.Teams); - Assert.Empty(protection.Restrictions.Users); + var deleted = await _github.Repository.Branch.DeleteBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.False(protection.EnforceAdmins.Enabled); - } - - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); + Assert.True(deleted); + } + } - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + [IntegrationTest] + public async Task DeletesBranchProtectionWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public class TheDeleteBranchProtectionMethod - { - IGitHubClient _github; - IRepositoryBranchesClient _client; + var deleted = await _github.Repository.Branch.DeleteBranchProtection(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - public TheDeleteBranchProtectionMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - } + Assert.True(deleted); + } + } - [IntegrationTest] - public async Task DeletesBranchProtection() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task DeletesBranchProtectionForOrgRepo() { - var repoOwner = context.RepositoryOwner; - var repoName = context.RepositoryName; - var deleted = await _client.DeleteBranchProtection(repoOwner, repoName, "master"); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var deleted = await _github.Repository.Branch.DeleteBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.True(deleted); + Assert.True(deleted); + } } - } - [IntegrationTest] - public async Task DeletesBranchProtectionWithRepositoryId() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task DeletesBranchProtectionForOrgRepoWithRepositoryId() { - var repoId = context.RepositoryId; - var deleted = await _client.DeleteBranchProtection(repoId, "master"); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var deleted = await _github.Repository.Branch.DeleteBranchProtection(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.True(deleted); + Assert.True(deleted); + } } } - [IntegrationTest] - public async Task DeletesBranchProtectionForOrgRepo() + public class TheGetRequiredStatusChecksMethod : GitHubClientTestBase { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task GetsRequiredStatusChecks() { - var repoOwner = context.RepositoryContext.RepositoryOwner; - var repoName = context.RepositoryContext.RepositoryName; - var deleted = await _client.DeleteBranchProtection(repoOwner, repoName, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); + var requiredStatusChecks = await _github.Repository.Branch.GetRequiredStatusChecks(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); + + Assert.NotNull(requiredStatusChecks); + Assert.NotNull(requiredStatusChecks.Contexts); + Assert.True(requiredStatusChecks.Strict); + Assert.Equal(2, requiredStatusChecks.Contexts.Count); + } } - } - [IntegrationTest] - public async Task DeletesBranchProtectionForOrgRepoWithRepositoryId() - { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task GetsRequiredStatusChecksWithRepositoryId() { - var repoId = context.RepositoryContext.RepositoryId; - var deleted = await _client.DeleteBranchProtection(repoId, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); + var requiredStatusChecks = await _github.Repository.Branch.GetRequiredStatusChecks(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); + + Assert.NotNull(requiredStatusChecks); + Assert.NotNull(requiredStatusChecks.Contexts); + Assert.True(requiredStatusChecks.Strict); + Assert.Equal(2, requiredStatusChecks.Contexts.Count); + } } } - } - - public class TheGetRequiredStatusChecksMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - - public TheGetRequiredStatusChecksMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - } - - [IntegrationTest] - public async Task GetsRequiredStatusChecks() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var requiredStatusChecks = await _client.GetRequiredStatusChecks(repoOwner, repoName, "master"); - - Assert.NotNull(requiredStatusChecks); - Assert.NotNull(requiredStatusChecks.Contexts); - Assert.True(requiredStatusChecks.Strict); - Assert.Equal(2, requiredStatusChecks.Contexts.Count); - } - [IntegrationTest] - public async Task GetsRequiredStatusChecksWithRepositoryId() + public class TheUpdateRequiredStatusChecksMethod : GitHubClientTestBase { - var repoId = _userRepoContext.RepositoryId; - var requiredStatusChecks = await _client.GetRequiredStatusChecks(repoId, "master"); - - Assert.NotNull(requiredStatusChecks); - Assert.NotNull(requiredStatusChecks.Contexts); - Assert.True(requiredStatusChecks.Strict); - Assert.Equal(2, requiredStatusChecks.Contexts.Count); - } - - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - } - } - - public class TheUpdateRequiredStatusChecksMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - - public TheUpdateRequiredStatusChecksMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - } - - [IntegrationTest] - public async Task UpdateRequiredStatusChecks() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "new" }); - var requiredStatusChecks = await _client.UpdateRequiredStatusChecks(repoOwner, repoName, "master", update); - - Assert.NotNull(requiredStatusChecks); - Assert.NotNull(requiredStatusChecks.Contexts); - Assert.Contains("new", requiredStatusChecks.Contexts); - Assert.True(requiredStatusChecks.Strict); - Assert.Equal(1, requiredStatusChecks.Contexts.Count); - } - - [IntegrationTest] - public async Task UpdatesRequiredStatusChecksWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "new" }); - var requiredStatusChecks = await _client.UpdateRequiredStatusChecks(repoId, "master", update); - - Assert.NotNull(requiredStatusChecks); - Assert.NotNull(requiredStatusChecks.Contexts); - Assert.Contains("new", requiredStatusChecks.Contexts); - Assert.True(requiredStatusChecks.Strict); - Assert.Equal(1, requiredStatusChecks.Contexts.Count); - } - - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - } - } - - public class TheDeleteRequiredStatusChecksMethod - { - IGitHubClient _github; - IRepositoryBranchesClient _client; - - public TheDeleteRequiredStatusChecksMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - } - - [IntegrationTest] - public async Task DeletesRequiredStatusChecks() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task UpdateRequiredStatusChecks() { - var repoOwner = context.RepositoryOwner; - var repoName = context.RepositoryName; - var deleted = await _client.DeleteRequiredStatusChecks(repoOwner, repoName, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); + + var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "new" }); + var requiredStatusChecks = await _github.Repository.Branch.UpdateRequiredStatusChecks(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); + + Assert.NotNull(requiredStatusChecks); + Assert.NotNull(requiredStatusChecks.Contexts); + Assert.Contains("new", requiredStatusChecks.Contexts); + Assert.True(requiredStatusChecks.Strict); + Assert.Equal(1, requiredStatusChecks.Contexts.Count); + } } - } - [IntegrationTest] - public async Task DeletesRequiredStatusChecksWithRepositoryId() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task UpdatesRequiredStatusChecksWithRepositoryId() { - var repoId = context.RepositoryId; - var deleted = await _client.DeleteRequiredStatusChecks(repoId, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); + + var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "new" }); + var requiredStatusChecks = await _github.Repository.Branch.UpdateRequiredStatusChecks(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); + + Assert.NotNull(requiredStatusChecks); + Assert.NotNull(requiredStatusChecks.Contexts); + Assert.Contains("new", requiredStatusChecks.Contexts); + Assert.True(requiredStatusChecks.Strict); + Assert.Equal(1, requiredStatusChecks.Contexts.Count); + } } } - } - - public class TheGetAllRequiredStatusChecksContextsMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - - public TheGetAllRequiredStatusChecksContextsMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - } - [IntegrationTest] - public async Task GetsRequiredStatusChecksContexts() + public class TheDeleteRequiredStatusChecksMethod : GitHubClientTestBase { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var requiredStatusChecksContexts = await _client.GetAllRequiredStatusChecksContexts(repoOwner, repoName, "master"); - - Assert.NotNull(requiredStatusChecksContexts); - Assert.Equal(2, requiredStatusChecksContexts.Count); - } - - [IntegrationTest] - public async Task GetsRequiredStatusChecksContextsWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var requiredStatusChecksContexts = await _client.GetAllRequiredStatusChecksContexts(repoId, "master"); - - Assert.NotNull(requiredStatusChecksContexts); - Assert.Equal(2, requiredStatusChecksContexts.Count); - } - - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - } - } + [IntegrationTest] + public async Task DeletesRequiredStatusChecks() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public class TheUpdateRequiredStatusChecksContextsMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; + var deleted = await _github.Repository.Branch.DeleteRequiredStatusChecks(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - public TheUpdateRequiredStatusChecksContextsMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + Assert.True(deleted); + } + } - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - } + [IntegrationTest] + public async Task DeletesRequiredStatusChecksWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - [IntegrationTest] - public async Task UpdateRequiredStatusChecksContexts() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var update = new List<string>() { "build2" }; - var requiredStatusChecksContexts = await _client.UpdateRequiredStatusChecksContexts(repoOwner, repoName, "master", update); + var deleted = await _github.Repository.Branch.DeleteRequiredStatusChecks(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.Equal(1, requiredStatusChecksContexts.Count); + Assert.True(deleted); + } + } } - [IntegrationTest] - public async Task UpdatesRequiredStatusChecksContextsWithRepositoryId() + public class TheGetAllRequiredStatusChecksContextsMethod : GitHubClientTestBase { - var repoId = _userRepoContext.RepositoryId; - var update = new List<string>() { "build2" }; - var requiredStatusChecksContexts = await _client.UpdateRequiredStatusChecksContexts(repoId, "master", update); + [IntegrationTest] + public async Task GetsRequiredStatusChecksContexts() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - Assert.Equal(1, requiredStatusChecksContexts.Count); - } + var requiredStatusChecksContexts = await _github.Repository.Branch.GetAllRequiredStatusChecksContexts(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - } - } + Assert.NotNull(requiredStatusChecksContexts); + Assert.Equal(2, requiredStatusChecksContexts.Count); + } + } - public class TheAddRequiredStatusChecksContextsMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; + [IntegrationTest] + public async Task GetsRequiredStatusChecksContextsWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public TheAddRequiredStatusChecksContextsMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + var requiredStatusChecksContexts = await _github.Repository.Branch.GetAllRequiredStatusChecksContexts(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; + Assert.NotNull(requiredStatusChecksContexts); + Assert.Equal(2, requiredStatusChecksContexts.Count); + } + } } - [IntegrationTest] - public async Task AddsRequiredStatusChecksContexts() + public class TheUpdateRequiredStatusChecksContextsMethod : GitHubClientTestBase { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var update = new List<string>() { "build2", "deploy" }; - var requiredStatusChecksContexts = await _client.AddRequiredStatusChecksContexts(repoOwner, repoName, "master", update); - - Assert.NotNull(requiredStatusChecksContexts); - Assert.Equal(4, requiredStatusChecksContexts.Count); - } + [IntegrationTest] + public async Task UpdateRequiredStatusChecksContexts() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - [IntegrationTest] - public async Task AddsRequiredStatusChecksContextsWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var update = new List<string>() { "build2", "deploy" }; - var requiredStatusChecksContexts = await _client.AddRequiredStatusChecksContexts(repoId, "master", update); + var update = new List<string>() { "build2" }; + var requiredStatusChecksContexts = await _github.Repository.Branch.UpdateRequiredStatusChecksContexts(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); - Assert.NotNull(requiredStatusChecksContexts); - Assert.Equal(4, requiredStatusChecksContexts.Count); - } + Assert.Equal(1, requiredStatusChecksContexts.Count); + } + } - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - } - } + [IntegrationTest] + public async Task UpdatesRequiredStatusChecksContextsWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public class TheDeleteRequiredStatusChecksContextsMethod - { - IGitHubClient _github; - IRepositoryBranchesClient _client; + var update = new List<string>() { "build2" }; + var requiredStatusChecksContexts = await _github.Repository.Branch.UpdateRequiredStatusChecksContexts(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); - public TheDeleteRequiredStatusChecksContextsMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; + Assert.Equal(1, requiredStatusChecksContexts.Count); + } + } } - [IntegrationTest] - public async Task DeletesRequiredStatusChecksContexts() + public class TheAddRequiredStatusChecksContextsMethod : GitHubClientTestBase { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task AddsRequiredStatusChecksContexts() { - var repoOwner = context.RepositoryOwner; - var repoName = context.RepositoryName; - var contextsToRemove = new List<string>() { "build" }; - var deleted = await _client.DeleteRequiredStatusChecksContexts(repoOwner, repoName, "master", contextsToRemove); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); + + var update = new List<string>() { "build2", "deploy" }; + var requiredStatusChecksContexts = await _github.Repository.Branch.AddRequiredStatusChecksContexts(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); - Assert.NotNull(deleted); - Assert.Contains("test", deleted); + Assert.NotNull(requiredStatusChecksContexts); + Assert.Equal(4, requiredStatusChecksContexts.Count); + } } - } - [IntegrationTest] - public async Task DeletesRequiredStatusChecksContextsWithRepositoryId() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task AddsRequiredStatusChecksContextsWithRepositoryId() { - var repoId = context.RepositoryId; - var contextsToRemove = new List<string>() { "build" }; - var deleted = await _client.DeleteRequiredStatusChecksContexts(repoId, "master", contextsToRemove); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); + + var update = new List<string>() { "build2", "deploy" }; + var requiredStatusChecksContexts = await _github.Repository.Branch.AddRequiredStatusChecksContexts(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); - Assert.NotNull(deleted); - Assert.Contains("test", deleted); + Assert.NotNull(requiredStatusChecksContexts); + Assert.Equal(4, requiredStatusChecksContexts.Count); + } } } - } - public class TheGetReviewEnforcementMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; - - public TheGetReviewEnforcementMethod() + public class TheDeleteRequiredStatusChecksContextsMethod : GitHubClientTestBase { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; - } + [IntegrationTest] + public async Task DeletesRequiredStatusChecksContexts() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - [IntegrationTest] - public async Task GetsReviewEnforcement() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var requiredReviews = await _client.GetReviewEnforcement(repoOwner, repoName, "master"); + var contextsToRemove = new List<string>() { "build" }; + var deleted = await _github.Repository.Branch.DeleteRequiredStatusChecksContexts(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, contextsToRemove); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - } + Assert.NotNull(deleted); + Assert.Contains("test", deleted); + } + } - [IntegrationTest] - public async Task GetsReviewEnforcementWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var requiredReviews = await _client.GetReviewEnforcement(repoId, "master"); + [IntegrationTest] + public async Task DeletesRequiredStatusChecksContextsWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - } + var contextsToRemove = new List<string>() { "build" }; + var deleted = await _github.Repository.Branch.DeleteRequiredStatusChecksContexts(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, contextsToRemove); - [IntegrationTest] - public async Task GetsReviewEnforcementForOrgRepo() - { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var requiredReviews = await _client.GetReviewEnforcement(repoOwner, repoName, "master"); - - Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.NotNull(deleted); + Assert.Contains("test", deleted); + } + } } - [IntegrationTest] - public async Task GetsReviewEnforcementForOrgRepoWithRepositoryId() + public class TheGetReviewEnforcementMethod : GitHubClientTestBase { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var requiredReviews = await _client.GetReviewEnforcement(repoId, "master"); - - Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - } + [IntegrationTest] + public async Task GetsReviewEnforcement() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); + var requiredReviews = await _github.Repository.Branch.GetReviewEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } + } - public class TheUpdateReviewEnforcementMethod : IDisposable - { - IRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; + [IntegrationTest] + public async Task GetsReviewEnforcementWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public TheUpdateReviewEnforcementMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + var requiredReviews = await _github.Repository.Branch.GetReviewEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; - } + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } + } - [IntegrationTest] - public async Task UpdatesReviewEnforcement() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); + [OrganizationTest] + public async Task GetsReviewEnforcementForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); + var requiredReviews = await _github.Repository.Branch.GetReviewEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); - } + Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } + } - [IntegrationTest] - public async Task UpdatesReviewEnforcementWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); + [OrganizationTest] + public async Task GetsReviewEnforcementForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); + var requiredReviews = await _github.Repository.Branch.GetReviewEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } + } } - [IntegrationTest] - public async Task UpdatesReviewEnforcementForOrgRepo() + public class TheUpdateReviewEnforcementMethod : GitHubClientTestBase { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); - - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); - } + [IntegrationTest] + public async Task UpdatesReviewEnforcement() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - [IntegrationTest] - public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); - - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); - } + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); - [IntegrationTest] - public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() - { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); - - Assert.Empty(requiredReviews.DismissalRestrictions.Teams); - Assert.Empty(requiredReviews.DismissalRestrictions.Users); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); - } + var requiredReviews = await _github.Repository.Branch.UpdateReviewEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); - [IntegrationTest] - public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); - - Assert.Empty(requiredReviews.DismissalRestrictions.Teams); - Assert.Empty(requiredReviews.DismissalRestrictions.Users); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); - } + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } + } - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); + [IntegrationTest] + public async Task UpdatesReviewEnforcementWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); - public class TheRemoveReviewEnforcementMethod - { - IGitHubClient _github; - IRepositoryBranchesClient _client; + var requiredReviews = await _github.Repository.Branch.UpdateReviewEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); - public TheRemoveReviewEnforcementMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - } + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } + } - [IntegrationTest] - public async Task RemovesReviewEnforcement() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task UpdatesReviewEnforcementForOrgRepo() { - var repoOwner = context.RepositoryOwner; - var repoName = context.RepositoryName; - var deleted = await _client.RemoveReviewEnforcement(repoOwner, repoName, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), + false, + false, + 2); + + var requiredReviews = await _github.Repository.Branch.UpdateReviewEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); + + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } - } - [IntegrationTest] - public async Task RemovesReviewEnforcementWithRepositoryId() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() { - var repoId = context.RepositoryId; - var deleted = await _client.RemoveReviewEnforcement(repoId, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), + false, + false, + 2); + + var requiredReviews = await _github.Repository.Branch.UpdateReviewEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); + + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } - } - [IntegrationTest] - public async Task RemovesReviewEnforcementForOrgRepo() - { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() { - var repoOwner = context.RepositoryContext.RepositoryOwner; - var repoName = context.RepositoryContext.RepositoryName; - var deleted = await _client.RemoveReviewEnforcement(repoOwner, repoName, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), + false, + false, + 2); + + var requiredReviews = await _github.Repository.Branch.UpdateReviewEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); + + Assert.Empty(requiredReviews.DismissalRestrictions.Teams); + Assert.Empty(requiredReviews.DismissalRestrictions.Users); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } - } - [IntegrationTest] - public async Task RemovesReviewEnforcementForOrgRepoWithRepositoryId() - { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryId() { - var repoId = context.RepositoryContext.RepositoryId; - var deleted = await _client.RemoveReviewEnforcement(repoId, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), + false, + false, + 2); + + var requiredReviews = await _github.Repository.Branch.UpdateReviewEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, update); + + Assert.Empty(requiredReviews.DismissalRestrictions.Teams); + Assert.Empty(requiredReviews.DismissalRestrictions.Users); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } } - } - - public class TheGetAdminEnforcementMethod : IDisposable - { - private readonly IRepositoryBranchesClient _client; - private readonly RepositoryContext _userRepoContext; - public TheGetAdminEnforcementMethod() + public class TheRemoveReviewEnforcementMethod : GitHubClientTestBase { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + [IntegrationTest] + public async Task RemovesReviewEnforcement() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - } + var deleted = await _github.Repository.Branch.RemoveReviewEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - [IntegrationTest] - public async Task GetsAdminEnforcement() - { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var enforceAdmins = await _client.GetAdminEnforcement(repoOwner, repoName, "master"); + Assert.True(deleted); + } + } - Assert.NotNull(enforceAdmins); - Assert.True(enforceAdmins.Enabled); - } + [IntegrationTest] + public async Task RemovesReviewEnforcementWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - [IntegrationTest] - public async Task GetsAdminEnforcementWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; - var enforceAdmins = await _client.GetAdminEnforcement(repoId, "master"); + var deleted = await _github.Repository.Branch.RemoveReviewEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.NotNull(enforceAdmins); - Assert.True(enforceAdmins.Enabled); - } + Assert.True(deleted); + } + } - public void Dispose() - { - if (_userRepoContext != null) + [OrganizationTest] + public async Task RemovesReviewEnforcementForOrgRepo() { - _userRepoContext.Dispose(); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var deleted = await _github.Repository.Branch.RemoveReviewEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); + + Assert.True(deleted); + } } - } - } - public class TheAddAdminEnforcementMethod : IDisposable - { - private readonly IRepositoryBranchesClient _client; - private readonly RepositoryContext _userRepoContext; + [OrganizationTest] + public async Task RemovesReviewEnforcementForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - public TheAddAdminEnforcementMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + var deleted = await _github.Repository.Branch.RemoveReviewEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; + Assert.True(deleted); + } + } } - [IntegrationTest] - public async Task AddsAdminEnforcement() + public class TheGetAdminEnforcementMethod : GitHubClientTestBase { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; + [IntegrationTest] + public async Task GetsAdminEnforcement() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - await _client.RemoveAdminEnforcement(repoOwner, repoName, "master"); - var enforceAdmins = await _client.AddAdminEnforcement(repoOwner, repoName, "master"); + var enforceAdmins = await _github.Repository.Branch.GetAdminEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.NotNull(enforceAdmins); - Assert.True(enforceAdmins.Enabled); - } + Assert.NotNull(enforceAdmins); + Assert.True(enforceAdmins.Enabled); + } + } - [IntegrationTest] - public async Task AddsAdminEnforcementoWithRepositoryId() - { - var repoId = _userRepoContext.RepositoryId; + [IntegrationTest] + public async Task GetsAdminEnforcementWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - await _client.RemoveAdminEnforcement(repoId, "master"); - var enforceAdmins = await _client.AddAdminEnforcement(repoId, "master"); + var enforceAdmins = await _github.Repository.Branch.GetAdminEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.NotNull(enforceAdmins); - Assert.True(enforceAdmins.Enabled); + Assert.NotNull(enforceAdmins); + Assert.True(enforceAdmins.Enabled); + } + } } - public void Dispose() + public class TheAddAdminEnforcementMethod : GitHubClientTestBase { - if (_userRepoContext != null) + [IntegrationTest] + public async Task AddsAdminEnforcement() { - _userRepoContext.Dispose(); - } - } - } + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public class TheRemoveAdminEnforcementMethod - { - private readonly IRepositoryBranchesClient _client; - private readonly IGitHubClient _github; + await _github.Repository.Branch.RemoveAdminEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); + var enforceAdmins = await _github.Repository.Branch.AddAdminEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - public TheRemoveAdminEnforcementMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - } + Assert.NotNull(enforceAdmins); + Assert.True(enforceAdmins.Enabled); + } + } - [IntegrationTest] - public async Task RemovesAdminEnforcement() - { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task AddsAdminEnforcementoWithRepositoryId() { - var repoOwner = context.RepositoryOwner; - var repoName = context.RepositoryName; - var deleted = await _client.RemoveAdminEnforcement(repoOwner, repoName, "master"); - - Assert.True(deleted); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - var enforceAdmins = await _client.GetAdminEnforcement(repoOwner, repoName, "master"); + await _github.Repository.Branch.RemoveAdminEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); + var enforceAdmins = await _github.Repository.Branch.AddAdminEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.NotNull(enforceAdmins); - Assert.False(enforceAdmins.Enabled); + Assert.NotNull(enforceAdmins); + Assert.True(enforceAdmins.Enabled); + } } } - [IntegrationTest] - public async Task RemovesAdminEnforcementWithRepositoryId() + public class TheRemoveAdminEnforcementMethod : GitHubClientTestBase { - using (var context = await _github.CreateRepositoryWithProtectedBranch()) + [IntegrationTest] + public async Task RemovesAdminEnforcement() { - var repoId = context.RepositoryId; - var deleted = await _client.RemoveAdminEnforcement(repoId, "master"); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - Assert.True(deleted); + var deleted = await _github.Repository.Branch.RemoveAdminEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - var enforceAdmins = await _client.GetAdminEnforcement(repoId, "master"); + Assert.True(deleted); - Assert.NotNull(enforceAdmins); - Assert.False(enforceAdmins.Enabled); - } - } - } + var enforceAdmins = await _github.Repository.Branch.GetAdminEnforcement(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - public class TheGetProtectedBranchRestrictionsMethod : IDisposable - { - IRepositoryBranchesClient _client; - OrganizationRepositoryWithTeamContext _orgRepoContext; - - public TheGetProtectedBranchRestrictionsMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + Assert.NotNull(enforceAdmins); + Assert.False(enforceAdmins.Enabled); + } + } - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; - } + [IntegrationTest] + public async Task RemovesAdminEnforcementWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - [IntegrationTest] - public async Task GetsRequirProtectedBranchRestrictionsForOrgRepo() - { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var restrictions = await _client.GetProtectedBranchRestrictions(repoOwner, repoName, "master"); + var deleted = await _github.Repository.Branch.RemoveAdminEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.Equal(1, restrictions.Teams.Count); - Assert.Equal(0, restrictions.Users.Count); - } + Assert.True(deleted); - [IntegrationTest] - public async Task GetsProtectedBranchRestrictionsForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var restrictions = await _client.GetProtectedBranchRestrictions(repoId, "master"); + var enforceAdmins = await _github.Repository.Branch.GetAdminEnforcement(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.Equal(1, restrictions.Teams.Count); - Assert.Equal(0, restrictions.Users.Count); + Assert.NotNull(enforceAdmins); + Assert.False(enforceAdmins.Enabled); + } + } } - public void Dispose() + public class TheGetProtectedBranchRestrictionsMethod : GitHubClientTestBase { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + [OrganizationTest] + public async Task GetsRequirProtectedBranchRestrictionsForOrgRepo() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public class TheDeleteProtectedBranchRestrictionsMethod - { - IGitHubClient _github; - IRepositoryBranchesClient _client; + var restrictions = await _github.Repository.Branch.GetProtectedBranchRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - public TheDeleteProtectedBranchRestrictionsMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - } + Assert.Equal(1, restrictions.Teams.Count); + Assert.Equal(0, restrictions.Users.Count); + } + } - [IntegrationTest] - public async Task DeletesRProtectedBranchRestrictionsForOrgRepo() - { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task GetsProtectedBranchRestrictionsForOrgRepoWithRepositoryId() { - var repoOwner = context.RepositoryContext.RepositoryOwner; - var repoName = context.RepositoryContext.RepositoryName; - var deleted = await _client.DeleteProtectedBranchRestrictions(repoOwner, repoName, "master"); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); + + var restrictions = await _github.Repository.Branch.GetProtectedBranchRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - Assert.True(deleted); + Assert.Equal(1, restrictions.Teams.Count); + Assert.Equal(0, restrictions.Users.Count); + } } } - [IntegrationTest] - public async Task DeletesProtectedBranchRestrictionsForOrgRepoWithRepositoryId() + public class TheDeleteProtectedBranchRestrictionsMethod : GitHubClientTestBase { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task DeletesRProtectedBranchRestrictionsForOrgRepo() { - var repoId = context.RepositoryContext.RepositoryId; - var deleted = await _client.DeleteProtectedBranchRestrictions(repoId, "master"); + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - Assert.True(deleted); + var deleted = await _github.Repository.Branch.DeleteProtectedBranchRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); + + Assert.True(deleted); + } } - } - } - public class TheGetAllProtectedBranchTeamRestrictionsMethod : IDisposable - { - IRepositoryBranchesClient _client; - OrganizationRepositoryWithTeamContext _orgRepoContext; + [OrganizationTest] + public async Task DeletesProtectedBranchRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + await _github.ProtectDefaultBranch(repoContext); - public TheGetAllProtectedBranchTeamRestrictionsMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + var deleted = await _github.Repository.Branch.DeleteProtectedBranchRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + Assert.True(deleted); + } + } } - [IntegrationTest] - public async Task GetsProtectedBranchTeamRestrictionsForOrgRepo() + public class TheGetAllProtectedBranchTeamRestrictionsMethod : GitHubClientTestBase { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var restrictions = await _client.GetAllProtectedBranchTeamRestrictions(repoOwner, repoName, "master"); - - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); - } + [OrganizationTest] + public async Task GetsProtectedBranchTeamRestrictionsForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - [IntegrationTest] - public async Task GetsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var restrictions = await _client.GetAllProtectedBranchTeamRestrictions(repoId, "master"); + var restrictions = await _github.Repository.Branch.GetAllProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); - } + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); + } + } - public void Dispose() - { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + [OrganizationTest] + public async Task GetsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - public class TheUpdateProtectedBranchTeamRestrictionsMethod : IDisposable - { - IRepositoryBranchesClient _client; - OrganizationRepositoryWithTeamContext _orgRepoContext; - TeamContext _contextOrgTeam2; - IGitHubClient _github; + var restrictions = await _github.Repository.Branch.GetAllProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - public TheUpdateProtectedBranchTeamRestrictionsMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - - _contextOrgTeam2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result; - _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result; + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); + } + } } - [IntegrationTest] - public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepo() + public class TheUpdateProtectedBranchTeamRestrictionsMethod : GitHubClientTestBase { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; + [OrganizationTest] + public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - // Grant team push access to repo - await _github.Organization.Team.AddRepository( - _contextOrgTeam2.TeamId, - repoOwner, - repoName, - new RepositoryPermissionRequest(Permission.Push)); + var team2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result; - var newTeam = new BranchProtectionTeamCollection() { _contextOrgTeam2.TeamName }; - var restrictions = await _client.UpdateProtectedBranchTeamRestrictions(repoOwner, repoName, "master", newTeam); + // Grant team push access to repo + await _github.Organization.Team.AddRepository( + team2.TeamId, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + new RepositoryPermissionRequest(Permission.Push)); - Assert.NotNull(restrictions); - Assert.Equal(_contextOrgTeam2.TeamName, restrictions[0].Name); - } + var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; + var restrictions = await _github.Repository.Branch.UpdateProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newTeam); - [IntegrationTest] - public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - - // Grant team push access to repo - await _github.Organization.Team.AddRepository( - _contextOrgTeam2.TeamId, - repoOwner, - repoName, - new RepositoryPermissionRequest(Permission.Push)); - - var newTeam = new BranchProtectionTeamCollection() { _contextOrgTeam2.TeamName }; - var restrictions = await _client.UpdateProtectedBranchTeamRestrictions(repoId, "master", newTeam); - - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); - } + Assert.NotNull(restrictions); + Assert.Equal(team2.TeamName, restrictions[0].Name); + } + } - public void Dispose() - { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); + [OrganizationTest] + public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - if (_contextOrgTeam2 != null) - _contextOrgTeam2.Dispose(); - } - } + var team2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result; - public class TheAddProtectedBranchTeamRestrictionsMethod : IDisposable - { - IRepositoryBranchesClient _client; - OrganizationRepositoryWithTeamContext _orgRepoContext; - TeamContext _contextOrgTeam2; - IGitHubClient _github; + // Grant team push access to repo + await _github.Organization.Team.AddRepository( + team2.TeamId, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + new RepositoryPermissionRequest(Permission.Push)); - public TheAddProtectedBranchTeamRestrictionsMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; + var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; + var restrictions = await _github.Repository.Branch.UpdateProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newTeam); - _contextOrgTeam2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result; - _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result; + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); + } + } } - [IntegrationTest] - public async Task AddsProtectedBranchTeamRestrictionsForOrgRepo() + public class TheAddProtectedBranchTeamRestrictionsMethod : GitHubClientTestBase { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; + [OrganizationTest] + public async Task AddsProtectedBranchTeamRestrictionsForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - // Grant team push access to repo - await _github.Organization.Team.AddRepository( - _contextOrgTeam2.TeamId, - repoOwner, - repoName, - new RepositoryPermissionRequest(Permission.Push)); + var team2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result; - var newTeam = new BranchProtectionTeamCollection() { _contextOrgTeam2.TeamName }; - var restrictions = await _client.AddProtectedBranchTeamRestrictions(repoOwner, repoName, "master", newTeam); + // Grant team push access to repo + await _github.Organization.Team.AddRepository( + team2.TeamId, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + new RepositoryPermissionRequest(Permission.Push)); - Assert.NotNull(restrictions); - Assert.Equal(2, restrictions.Count); - } + var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; + var restrictions = await _github.Repository.Branch.AddProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newTeam); - [IntegrationTest] - public async Task AddsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - - // Grant team push access to repo - await _github.Organization.Team.AddRepository( - _contextOrgTeam2.TeamId, - repoOwner, - repoName, - new RepositoryPermissionRequest(Permission.Push)); - - var newTeam = new BranchProtectionTeamCollection() { _contextOrgTeam2.TeamName }; - var restrictions = await _client.AddProtectedBranchTeamRestrictions(repoId, "master", newTeam); - - Assert.NotNull(restrictions); - Assert.Equal(2, restrictions.Count); - } + Assert.NotNull(restrictions); + Assert.Equal(2, restrictions.Count); + } + } - public void Dispose() - { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); + [OrganizationTest] + public async Task AddsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - if (_contextOrgTeam2 != null) - _contextOrgTeam2.Dispose(); - } - } + var team2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result; - public class TheDeleteProtectedBranchTeamRestrictions - { - IGitHubClient _github; - IRepositoryBranchesClient _client; + // Grant team push access to repo + await _github.Organization.Team.AddRepository( + team2.TeamId, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + new RepositoryPermissionRequest(Permission.Push)); - public TheDeleteProtectedBranchTeamRestrictions() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - } + var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; + var restrictions = await _github.Repository.Branch.AddProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newTeam); - [IntegrationTest] - public async Task DeletesRProtectedBranchTeamRestrictionsForOrgRepo() - { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) - { - var repoOwner = context.RepositoryContext.RepositoryOwner; - var repoName = context.RepositoryContext.RepositoryName; - var teamToRemove = new BranchProtectionTeamCollection() { context.TeamContext.TeamName }; - var deleted = await _client.DeleteProtectedBranchTeamRestrictions(repoOwner, repoName, "master", teamToRemove); - - Assert.NotNull(deleted); - Assert.Equal(0, deleted.Count); + Assert.NotNull(restrictions); + Assert.Equal(2, restrictions.Count); + } } } - [IntegrationTest] - public async Task DeletesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() + public class TheDeleteProtectedBranchTeamRestrictions : GitHubClientTestBase { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task DeletesRProtectedBranchTeamRestrictionsForOrgRepo() { - var repoId = context.RepositoryContext.RepositoryId; - var teamToRemove = new BranchProtectionTeamCollection() { context.TeamContext.TeamName }; - var deleted = await _client.DeleteProtectedBranchTeamRestrictions(repoId, "master", teamToRemove); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + var team = await _github.ProtectDefaultBranchWithTeam(repoContext); - Assert.NotNull(deleted); - Assert.Equal(0, deleted.Count); + var teamToRemove = new BranchProtectionTeamCollection() { team.TeamName }; + var deleted = await _github.Repository.Branch.DeleteProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, teamToRemove); + + Assert.NotNull(deleted); + Assert.Equal(0, deleted.Count); + } } - } - } - public class TheGetAllProtectedBranchUserRestrictionsMethod : IDisposable - { - IRepositoryBranchesClient _client; - OrganizationRepositoryWithTeamContext _orgRepoContext; + [OrganizationTest] + public async Task DeletesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + var team = await _github.ProtectDefaultBranchWithTeam(repoContext); - public TheGetAllProtectedBranchUserRestrictionsMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = github.Repository.Branch; + var teamToRemove = new BranchProtectionTeamCollection() { team.TeamName }; + var deleted = await _github.Repository.Branch.DeleteProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, teamToRemove); - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + Assert.NotNull(deleted); + Assert.Equal(0, deleted.Count); + } + } } - [IntegrationTest] - public async Task GetsProtectedBranchUserRestrictionsForOrgRepo() + public class TheGetAllProtectedBranchUserRestrictionsMethod : GitHubClientTestBase { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var restrictions = await _client.GetAllProtectedBranchUserRestrictions(repoOwner, repoName, "master"); - - Assert.NotNull(restrictions); - Assert.Equal(0, restrictions.Count); - } + [OrganizationTest] + public async Task GetsProtectedBranchUserRestrictionsForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - [IntegrationTest] - public async Task GetsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var restrictions = await _client.GetAllProtectedBranchUserRestrictions(repoId, "master"); + var restrictions = await _github.Repository.Branch.GetAllProtectedBranchUserRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); - Assert.NotNull(restrictions); - Assert.Equal(0, restrictions.Count); - } + Assert.NotNull(restrictions); + Assert.Equal(0, restrictions.Count); + } + } - public void Dispose() - { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + [OrganizationTest] + public async Task GetsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - public class TheUpdateProtectedBranchUserRestrictionsMethod : IDisposable - { - IRepositoryBranchesClient _client; - IGitHubClient _github; - OrganizationRepositoryWithTeamContext _orgRepoContext; + var restrictions = await _github.Repository.Branch.GetAllProtectedBranchUserRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); - public TheUpdateProtectedBranchUserRestrictionsMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; - - _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result; + Assert.NotNull(restrictions); + Assert.Equal(0, restrictions.Count); + } + } } - [IntegrationTest] - public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepo() + public class TheUpdateProtectedBranchUserRestrictionsMethod : GitHubClientTestBase { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - - var restrictions = await _client.UpdateProtectedBranchUserRestrictions(repoOwner, repoName, "master", newUser); - - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); - } + [OrganizationTest] + public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - [IntegrationTest] - public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; + var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - var restrictions = await _client.UpdateProtectedBranchUserRestrictions(repoId, "master", newUser); + var restrictions = await _github.Repository.Branch.UpdateProtectedBranchUserRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newUser); - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); - } + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); + } + } - public void Dispose() - { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + [OrganizationTest] + public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - public class TheAddProtectedBranchUserRestrictionsMethod : IDisposable - { - IRepositoryBranchesClient _client; - IGitHubClient _github; - OrganizationRepositoryWithTeamContext _orgRepoContext; + var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - public TheAddProtectedBranchUserRestrictionsMethod() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; + var restrictions = await _github.Repository.Branch.UpdateProtectedBranchUserRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newUser); - _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result; + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); + } + } } - [IntegrationTest] - public async Task AddsProtectedBranchUserRestrictionsForOrgRepo() + public class TheAddProtectedBranchUserRestrictionsMethod : GitHubClientTestBase { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - - var restrictions = await _client.AddProtectedBranchUserRestrictions(repoOwner, repoName, "master", newUser); + [OrganizationTest] + public async Task AddsProtectedBranchUserRestrictionsForOrgRepo() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + var team = await _github.ProtectDefaultBranchWithTeam(repoContext); - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); - } + var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - [IntegrationTest] - public async Task AddsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() - { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; + var restrictions = await _github.Repository.Branch.AddProtectedBranchUserRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newUser); - var restrictions = await _client.AddProtectedBranchUserRestrictions(repoId, "master", newUser); + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); + } + } - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); - } + [OrganizationTest] + public async Task AddsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() + { + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); - public void Dispose() - { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); - } - } + var newUser = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - public class TheDeleteProtectedBranchUserRestrictions - { - IGitHubClient _github; - IRepositoryBranchesClient _client; + var restrictions = await _github.Repository.Branch.AddProtectedBranchUserRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newUser); - public TheDeleteProtectedBranchUserRestrictions() - { - _github = Helper.GetAuthenticatedClient(); - _client = _github.Repository.Branch; + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); + } + } } - [IntegrationTest] - public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo() + public class TheDeleteProtectedBranchUserRestrictions : GitHubClientTestBase { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo() { - var repoOwner = context.RepositoryContext.RepositoryOwner; - var repoName = context.RepositoryContext.RepositoryName; - var user = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - var restrictions = await _client.AddProtectedBranchUserRestrictions(repoOwner, repoName, "master", user); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var user = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; + var restrictions = await _github.Repository.Branch.AddProtectedBranchUserRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, user); - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); - var deleted = await _client.DeleteProtectedBranchUserRestrictions(repoOwner, repoName, "master", user); + var deleted = await _github.Repository.Branch.DeleteProtectedBranchUserRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, user); - Assert.NotNull(deleted); - Assert.Equal(0, deleted.Count); + Assert.NotNull(deleted); + Assert.Equal(0, deleted.Count); + } } - } - [IntegrationTest] - public async Task DeletesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() - { - using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + [OrganizationTest] + public async Task DeletesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - var repoId = context.RepositoryContext.RepositoryId; - var user = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; - var restrictions = await _client.AddProtectedBranchUserRestrictions(repoId, "master", user); + using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + { + await _github.ProtectDefaultBranchWithTeam(repoContext); + + var user = new BranchProtectionUserCollection() { _github.User.Current().Result.Login }; + var restrictions = await _github.Repository.Branch.AddProtectedBranchUserRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, user); - Assert.NotNull(restrictions); - Assert.Equal(1, restrictions.Count); + Assert.NotNull(restrictions); + Assert.Equal(1, restrictions.Count); - var deleted = await _client.DeleteProtectedBranchUserRestrictions(repoId, "master", user); + var deleted = await _github.Repository.Branch.DeleteProtectedBranchUserRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, user); - Assert.NotNull(deleted); - Assert.Equal(0, deleted.Count); + Assert.NotNull(deleted); + Assert.Equal(0, deleted.Count); + } } } } -} +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index ec6252c0e4..ac9260270c 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -18,7 +18,7 @@ public async Task CreatesTeam() var teamName = Helper.MakeNameWithTimestamp("new-team"); var teamDescription = Helper.MakeNameWithTimestamp("team description"); - using (var context = await github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("org-repo")))) + using (var context = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("org-repo")))) { var newTeam = new NewTeam(teamName) { @@ -295,7 +295,7 @@ public async Task GetsAllRepositories() { var github = Helper.GetAuthenticatedClient(); - using (var repositoryContext = await github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + using (var repositoryContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) { github.Organization.Team.AddRepository(_team.Id, Helper.Organization, repositoryContext.RepositoryName); @@ -320,7 +320,7 @@ public TheAddOrUpdateTeamRepositoryMethod() public async Task CanAddRepository() { using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) - using (var repoContext = await _github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) { var team = teamContext.Team; var repo = repoContext.Repository; diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index f005e0ffb9..455b8a7de2 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -113,8 +113,13 @@ static Helper() } public static string UserName { get; private set; } + public static string Organization { get; private set; } + public static bool HasNoOrganization => Organization == null; + + public static bool HasOrganization => Organization != null; + /// <summary> /// These credentials should be set to a test GitHub account using the powershell script configure-integration-tests.ps1 /// </summary> diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs index 3c6b0f3fa9..a30f4e624a 100644 --- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs @@ -4,17 +4,21 @@ namespace Octokit.Tests.Integration.Helpers { internal static class GithubClientExtensions { - internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string repositoryName) + /// <summary> + /// Creates a public repository with the timestamped name public-repo + /// </summary> + internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client) { - var repoName = Helper.MakeNameWithTimestamp(repositoryName); + var repoName = Helper.MakeNameWithTimestamp("public-repo"); var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); return new RepositoryContext(client.Connection, repo); } - internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository) + internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string repositoryName) { - var repo = await client.Repository.Create(organizationLogin, newRepository); + var repoName = Helper.MakeNameWithTimestamp(repositoryName); + var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); return new RepositoryContext(client.Connection, repo); } @@ -26,6 +30,27 @@ internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitH return new RepositoryContext(client.Connection, repo); } + /// <summary> + /// Creates an organisationrepository with the timestamped name organisation-repo + /// </summary> + internal static async Task<RepositoryContext> CreateOrganizationRepositoryContext(this IGitHubClient client) + { + var repoName = Helper.MakeNameWithTimestamp("organization-repo"); + var repo = await client.Repository.Create(Helper.Organization, new NewRepository(repoName) { AutoInit = true }); + + return new RepositoryContext(client.Connection, repo); + } + + /// <summary> + /// Creates an organization repository + /// </summary> + internal static async Task<RepositoryContext> CreateOrganizationRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository) + { + var repo = await client.Repository.Create(organizationLogin, newRepository); + + return new RepositoryContext(client.Connection, repo); + } + internal static async Task<RepositoryContext> Generate(this IGitHubClient client, string owner, string repoName, NewRepositoryFromTemplate newRepository) { var repo = await client.Repository.Generate(owner, repoName, newRepository); diff --git a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs index c0e89ba72a..df568cfef6 100644 --- a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs +++ b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs @@ -23,13 +23,30 @@ public void Dispose() internal static class RepositoryProtectedBranchHelperExtensions { + internal async static Task ProtectDefaultBranch(this IGitHubClient client, RepositoryContext repoContext) + { + // Protect default branch + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), + new BranchProtectionRequiredReviewsUpdate(true, true, 3), + null, + true, + true, + true, + true, + false, + true); + + await client.Repository.Branch.UpdateBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, update); + } + internal async static Task<RepositoryContext> CreateRepositoryWithProtectedBranch(this IGitHubClient client) { // Create user owned repo var userRepo = new NewRepository(Helper.MakeNameWithTimestamp("protected-repo")) { AutoInit = true }; var contextUserRepo = await client.CreateRepositoryContext(userRepo); - // Protect master branch + // Protect default branch var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), new BranchProtectionRequiredReviewsUpdate(true, true, 3), @@ -46,11 +63,34 @@ internal async static Task<RepositoryContext> CreateRepositoryWithProtectedBranc return contextUserRepo; } + internal async static Task<TeamContext> ProtectDefaultBranchWithTeam(this IGitHubClient client, RepositoryContext repoContext) + { + // Create team in org + var team = await client.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))); + + // Grant team push access to repo + await client.Organization.Team.AddRepository( + team.TeamId, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + new RepositoryPermissionRequest(Permission.Push)); + + // Protect default branch + var protection = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(new BranchProtectionTeamCollection { team.TeamName }), true, true, 3), + new BranchProtectionPushRestrictionsUpdate(new BranchProtectionTeamCollection { team.TeamName }), + true); + await client.Repository.Branch.UpdateBranchProtection(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, protection); + + return team; + } + internal async static Task<OrganizationRepositoryWithTeamContext> CreateOrganizationRepositoryWithProtectedBranch(this IGitHubClient client) { // Create organization owned repo var orgRepo = new NewRepository(Helper.MakeNameWithTimestamp("protected-org-repo")) { AutoInit = true }; - var contextOrgRepo = await client.CreateRepositoryContext(Helper.Organization, orgRepo); + var contextOrgRepo = await client.CreateOrganizationRepositoryContext(Helper.Organization, orgRepo); // Create team in org var contextOrgTeam = await client.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team"))); @@ -62,13 +102,13 @@ await client.Organization.Team.AddRepository( contextOrgRepo.RepositoryName, new RepositoryPermissionRequest(Permission.Push)); - // Protect master branch + // Protect default branch var protection = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }), true, true, 3), new BranchProtectionPushRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }), true); - await client.Repository.Branch.UpdateBranchProtection(contextOrgRepo.RepositoryOwner, contextOrgRepo.RepositoryName, "master", protection); + await client.Repository.Branch.UpdateBranchProtection(contextOrgRepo.RepositoryOwner, contextOrgRepo.RepositoryName, "main", protection); return new OrganizationRepositoryWithTeamContext { diff --git a/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs b/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs index 2d886f0783..817b2b7a61 100644 --- a/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs +++ b/Octokit.Tests.Integration/Helpers/OrganizationTestAttribute.cs @@ -17,7 +17,7 @@ public OrganizationTestDiscoverer(IMessageSink diagnosticMessageSink) public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { - if (Helper.Organization == null) + if (Helper.HasNoOrganization) { return Enumerable.Empty<IXunitTestCase>(); } diff --git a/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs b/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs index cba1997717..3a7f91133f 100644 --- a/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs +++ b/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs @@ -15,7 +15,7 @@ public async Task CreateABranch() using (var context = await client.CreateRepositoryContext("public-repo")) { - var branchFromMaster = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-1"); + var branchFromMaster = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-1", context.Repository.DefaultBranch); var branchFromPath = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-2", branchFromMaster); diff --git a/Octokit.Tests.Integration/Helpers/RepositoryContext.cs b/Octokit.Tests.Integration/Helpers/RepositoryContext.cs index 4d30f2b129..35f62931d2 100644 --- a/Octokit.Tests.Integration/Helpers/RepositoryContext.cs +++ b/Octokit.Tests.Integration/Helpers/RepositoryContext.cs @@ -16,12 +16,14 @@ internal RepositoryContext(IConnection connection, Repository repo) RepositoryId = repo.Id; RepositoryOwner = repo.Owner.Login; RepositoryName = repo.Name; + RepositoryDefaultBranch = repo.DefaultBranch; } private IConnection _connection; internal long RepositoryId { get; private set; } internal string RepositoryOwner { get; private set; } internal string RepositoryName { get; private set; } + internal string RepositoryDefaultBranch { get; private set; } internal Repository Repository { get; private set; } diff --git a/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs index ab8d40edbb..d3aca7128c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs @@ -34,7 +34,7 @@ public async Task ReturnsNoOutsideCollaborators() public async Task ReturnsOutsideCollaborators() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); @@ -50,7 +50,7 @@ public async Task ReturnsOutsideCollaborators() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); @@ -72,7 +72,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithoutStart() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -96,7 +96,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithStart() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -113,7 +113,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilter() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOptions() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -136,7 +136,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterAndApiOp public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStart() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -171,7 +171,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithAllFilterWithStar public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -189,7 +189,7 @@ public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilter() public async Task ReturnsCorrectCountOfOutsideCollaboratorsWithTwoFactorFilterAndApiOptions() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test2"); @@ -226,7 +226,7 @@ public TheDeleteMethod() public async Task CanRemoveOutsideCollaborator() { var repoName = Helper.MakeNameWithTimestamp("public-repo"); - using (var context = await _gitHub.CreateRepositoryContext(Helper.Organization, new NewRepository(repoName))) + using (var context = await _gitHub.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(repoName))) { await _gitHub.Repository.Collaborator.Add(context.RepositoryOwner, context.RepositoryName, _fixtureCollaborator); diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs index 2e49b7e39c..808a84217c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -1,281 +1,262 @@ -using System; -using System.Linq; -using System.Reactive.Linq; +using System.Reactive.Linq; using System.Threading.Tasks; using Octokit.Reactive; using Octokit.Tests.Integration.Helpers; using Xunit; -namespace Octokit.Tests.Integration +namespace Octokit.Tests.Integration.Reactive { public class ObservableRepositoryBranchesClientTests { - public class TheGetBranchProtectionMethod : IDisposable + public class TheGetBranchProtectionMethod { + IGitHubClient _github; IObservableRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; public TheGetBranchProtectionMethod() { - var github = Helper.GetAuthenticatedClient(); - _client = new ObservableRepositoryBranchesClient(github); - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + _github = Helper.GetAuthenticatedClient(); + _client = new ObservableRepositoryBranchesClient(_github); } [IntegrationTest] public async Task GetsBranchProtection() { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var protection = await _client.GetBranchProtection(repoOwner, repoName, "master"); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryOwner; + var repoName = context.RepositoryName; + var protection = await _client.GetBranchProtection(repoOwner, repoName, "main"); - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - Assert.Null(protection.Restrictions); + Assert.Null(protection.Restrictions); - Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.EnforceAdmins.Enabled); + } } [IntegrationTest] public async Task GetsBranchProtectionWithRepositoryId() { - var repoId = _userRepoContext.RepositoryId; - var protection = await _client.GetBranchProtection(repoId, "master"); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryId; + var protection = await _client.GetBranchProtection(repoId, "main"); - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - Assert.Null(protection.Restrictions); + Assert.Null(protection.Restrictions); - Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.EnforceAdmins.Enabled); + } } - [IntegrationTest] + [OrganizationTest] public async Task GetsBranchProtectionForOrgRepo() { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var protection = await _client.GetBranchProtection(repoOwner, repoName, "master"); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryContext.RepositoryOwner; + var repoName = context.RepositoryContext.RepositoryName; + var protection = await _client.GetBranchProtection(repoOwner, repoName, "main"); - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - Assert.Equal(1, protection.Restrictions.Teams.Count); - Assert.Equal(0, protection.Restrictions.Users.Count); + Assert.Equal(1, protection.Restrictions.Teams.Count); + Assert.Equal(0, protection.Restrictions.Users.Count); - Assert.True(protection.EnforceAdmins.Enabled); + Assert.True(protection.EnforceAdmins.Enabled); + } } - [IntegrationTest] + [OrganizationTest] public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var protection = await _client.GetBranchProtection(repoId, "master"); - - Assert.True(protection.RequiredStatusChecks.Strict); - Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryContext.RepositoryId; + var protection = await _client.GetBranchProtection(repoId, "main"); - Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); - Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + Assert.True(protection.RequiredStatusChecks.Strict); + Assert.Equal(2, protection.RequiredStatusChecks.Contexts.Count); - Assert.Equal(1, protection.Restrictions.Teams.Count); - Assert.Equal(0, protection.Restrictions.Users.Count); + Assert.Equal(1, protection.RequiredPullRequestReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); + Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - Assert.True(protection.EnforceAdmins.Enabled); - } + Assert.Equal(1, protection.Restrictions.Teams.Count); + Assert.Equal(0, protection.Restrictions.Users.Count); - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); + Assert.True(protection.EnforceAdmins.Enabled); + } } } - public class TheUpdateBranchProtectionMethod : IDisposable + public class TheUpdateBranchProtectionMethod { + IGitHubClient _github; IObservableRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; public TheUpdateBranchProtectionMethod() { - var github = Helper.GetAuthenticatedClient(); - _client = new ObservableRepositoryBranchesClient(github); - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; + _github = Helper.GetAuthenticatedClient(); + _client = new ObservableRepositoryBranchesClient(_github); } [IntegrationTest] public async Task UpdatesBranchProtection() { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true, 2), - false); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryOwner; + var repoName = context.RepositoryName; + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), + false); - var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "main", update); + var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "main", update); - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - Assert.Null(protection.Restrictions); + Assert.Null(protection.Restrictions); - Assert.False(protection.EnforceAdmins.Enabled); + Assert.False(protection.EnforceAdmins.Enabled); + } } [IntegrationTest] public async Task UpdatesBranchProtectionWithRepositoryId() { - var repoId = _userRepoContext.RepositoryId; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true, 2), - false); - - var protection = await _client.UpdateBranchProtection(repoId, "main", update); - - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryId; + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), + false); - Assert.Null(protection.Restrictions); + var protection = await _client.UpdateBranchProtection(repoId, "main", update); - Assert.False(protection.EnforceAdmins.Enabled); - } + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - } - } + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - public class TheUpdateOrgBranchProtectionMethod : IDisposable - { - IObservableRepositoryBranchesClient _client; - OrganizationRepositoryWithTeamContext _orgRepoContext; - - public TheUpdateOrgBranchProtectionMethod() - { - var github = Helper.GetAuthenticatedClient(); - _client = new ObservableRepositoryBranchesClient(github); + Assert.Null(protection.Restrictions); - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + Assert.False(protection.EnforceAdmins.Enabled); + } } [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepo() { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), - new BranchProtectionPushRestrictionsUpdate(), - false, - true, - true, - true, - true, - true); - - var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "main", update); - - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - - Assert.Empty(protection.Restrictions.Teams); - Assert.Empty(protection.Restrictions.Users); - - Assert.False(protection.EnforceAdmins.Enabled); - Assert.True(protection.RequiredLinearHistory.Enabled); - Assert.True(protection.AllowForcePushes.Enabled); - Assert.True(protection.AllowDeletions.Enabled); - Assert.True(protection.BlockCreations.Enabled); - Assert.True(protection.RequiredConversationResolution.Enabled); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryContext.RepositoryOwner; + var repoName = context.RepositoryContext.RepositoryName; + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), + new BranchProtectionPushRestrictionsUpdate(), + false, + true, + true, + true, + true, + true); + + var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "main", update); + + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); + + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + + Assert.Empty(protection.Restrictions.Teams); + Assert.Empty(protection.Restrictions.Users); + + Assert.False(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.True(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); + } } [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), - new BranchProtectionPushRestrictionsUpdate(), - false, - true, - true, - true, - true, - true); - - var protection = await _client.UpdateBranchProtection(repoId, "main", update); - - Assert.False(protection.RequiredStatusChecks.Strict); - Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); - - Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); - Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); - Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); - Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); - - Assert.Empty(protection.Restrictions.Teams); - Assert.Empty(protection.Restrictions.Users); - - Assert.False(protection.EnforceAdmins.Enabled); - Assert.True(protection.RequiredLinearHistory.Enabled); - Assert.True(protection.AllowForcePushes.Enabled); - Assert.True(protection.AllowDeletions.Enabled); - Assert.True(protection.BlockCreations.Enabled); - Assert.True(protection.RequiredConversationResolution.Enabled); - } - - public void Dispose() - { - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryContext.RepositoryId; + var update = new BranchProtectionSettingsUpdate( + new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), + new BranchProtectionPushRestrictionsUpdate(), + false, + true, + true, + true, + true, + true); + + var protection = await _client.UpdateBranchProtection(repoId, "main", update); + + Assert.False(protection.RequiredStatusChecks.Strict); + Assert.Equal(1, protection.RequiredStatusChecks.Contexts.Count); + + Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); + Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); + Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); + + Assert.Empty(protection.Restrictions.Teams); + Assert.Empty(protection.Restrictions.Users); + + Assert.False(protection.EnforceAdmins.Enabled); + Assert.True(protection.RequiredLinearHistory.Enabled); + Assert.True(protection.AllowForcePushes.Enabled); + Assert.True(protection.AllowDeletions.Enabled); + Assert.True(protection.BlockCreations.Enabled); + Assert.True(protection.RequiredConversationResolution.Enabled); + } } } @@ -297,7 +278,7 @@ public async Task DeletesBranchProtection() { var repoOwner = context.RepositoryOwner; var repoName = context.RepositoryName; - var deleted = await _client.DeleteBranchProtection(repoOwner, repoName, "master"); + var deleted = await _client.DeleteBranchProtection(repoOwner, repoName, "main"); Assert.True(deleted); } @@ -309,237 +290,241 @@ public async Task DeletesBranchProtectionWithRepositoryId() using (var context = await _github.CreateRepositoryWithProtectedBranch()) { var repoId = context.RepositoryId; - var deleted = await _client.DeleteBranchProtection(repoId, "master"); + var deleted = await _client.DeleteBranchProtection(repoId, "main"); Assert.True(deleted); } } - [IntegrationTest] + [OrganizationTest] public async Task DeletesBranchProtectionForOrgRepo() { using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) { var repoOwner = context.RepositoryContext.RepositoryOwner; var repoName = context.RepositoryContext.RepositoryName; - var deleted = await _client.DeleteBranchProtection(repoOwner, repoName, "master"); + var deleted = await _client.DeleteBranchProtection(repoOwner, repoName, "main"); Assert.True(deleted); } } - [IntegrationTest] + [OrganizationTest] public async Task DeletesBranchProtectionForOrgRepoWithRepositoryId() { using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) { var repoId = context.RepositoryContext.RepositoryId; - var deleted = await _client.DeleteBranchProtection(repoId, "master"); + var deleted = await _client.DeleteBranchProtection(repoId, "main"); Assert.True(deleted); } } } - public class TheGetReviewEnforcementMethod : IDisposable + public class TheGetReviewEnforcementMethod { + IGitHubClient _github; IObservableRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; public TheGetReviewEnforcementMethod() { - var github = Helper.GetAuthenticatedClient(); - _client = new ObservableRepositoryBranchesClient(github); - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + _github = Helper.GetAuthenticatedClient(); + _client = new ObservableRepositoryBranchesClient(_github); } [IntegrationTest] public async Task GetsReviewEnforcement() { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var requiredReviews = await _client.GetReviewEnforcement(repoOwner, repoName, "master"); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryOwner; + var repoName = context.RepositoryName; + var requiredReviews = await _client.GetReviewEnforcement(repoOwner, repoName, "main"); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } } [IntegrationTest] public async Task GetsReviewEnforcementWithRepositoryId() { - var repoId = _userRepoContext.RepositoryId; - var requiredReviews = await _client.GetReviewEnforcement(repoId, "master"); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryId; + var requiredReviews = await _client.GetReviewEnforcement(repoId, "main"); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } } - [IntegrationTest] + [OrganizationTest] public async Task GetsReviewEnforcementForOrgRepo() { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var requiredReviews = await _client.GetReviewEnforcement(repoOwner, repoName, "master"); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryContext.RepositoryOwner; + var repoName = context.RepositoryContext.RepositoryName; + var requiredReviews = await _client.GetReviewEnforcement(repoOwner, repoName, "main"); - Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } } - [IntegrationTest] + [OrganizationTest] public async Task GetsReviewEnforcementForOrgRepoWithRepositoryId() { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var requiredReviews = await _client.GetReviewEnforcement(repoId, "master"); - - Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); - Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); - Assert.True(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - } - - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryContext.RepositoryId; + var requiredReviews = await _client.GetReviewEnforcement(repoId, "main"); - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); + Assert.Equal(1, requiredReviews.DismissalRestrictions.Teams.Count); + Assert.Equal(0, requiredReviews.DismissalRestrictions.Users.Count); + Assert.True(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + } } } - public class TheUpdateReviewEnforcementMethod : IDisposable + public class TheUpdateReviewEnforcementMethod { + IGitHubClient _github; IObservableRepositoryBranchesClient _client; - RepositoryContext _userRepoContext; - OrganizationRepositoryWithTeamContext _orgRepoContext; public TheUpdateReviewEnforcementMethod() { - var github = Helper.GetAuthenticatedClient(); - _client = new ObservableRepositoryBranchesClient(github); - - _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result; - _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result; + _github = Helper.GetAuthenticatedClient(); + _client = new ObservableRepositoryBranchesClient(_github); } [IntegrationTest] public async Task UpdatesReviewEnforcement() { - var repoOwner = _userRepoContext.RepositoryOwner; - var repoName = _userRepoContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryOwner; + var repoName = context.RepositoryName; + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); - var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); + var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "main", update); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } [IntegrationTest] public async Task UpdatesReviewEnforcementWithRepositoryId() { - var repoId = _userRepoContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); + using (var context = await _github.CreateRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryId; + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); - var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); + var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "main", update); - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.True(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } - [IntegrationTest] + [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepo() { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); - - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryContext.RepositoryOwner; + var repoName = context.RepositoryContext.RepositoryName; + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), + false, + false, + 2); + + var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "main", update); + + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } - [IntegrationTest] + [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); - - Assert.Null(requiredReviews.DismissalRestrictions); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryContext.RepositoryId; + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), + false, + false, + 2); + + var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "main", update); + + Assert.Null(requiredReviews.DismissalRestrictions); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } - [IntegrationTest] + [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() { - var repoOwner = _orgRepoContext.RepositoryContext.RepositoryOwner; - var repoName = _orgRepoContext.RepositoryContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); - - Assert.Empty(requiredReviews.DismissalRestrictions.Teams); - Assert.Empty(requiredReviews.DismissalRestrictions.Users); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoOwner = context.RepositoryContext.RepositoryOwner; + var repoName = context.RepositoryContext.RepositoryName; + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), + false, + false, + 2); + + var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "main", update); + + Assert.Empty(requiredReviews.DismissalRestrictions.Teams); + Assert.Empty(requiredReviews.DismissalRestrictions.Users); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + } } - [IntegrationTest] + [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryId() { - var repoId = _orgRepoContext.RepositoryContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate( - new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), - false, - false, - 2); - - var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); - - Assert.Empty(requiredReviews.DismissalRestrictions.Teams); - Assert.Empty(requiredReviews.DismissalRestrictions.Users); - Assert.False(requiredReviews.DismissStaleReviews); - Assert.False(requiredReviews.RequireCodeOwnerReviews); - Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); - } - - public void Dispose() - { - if (_userRepoContext != null) - _userRepoContext.Dispose(); - - if (_orgRepoContext != null) - _orgRepoContext.Dispose(); + using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) + { + var repoId = context.RepositoryContext.RepositoryId; + var update = new BranchProtectionRequiredReviewsUpdate( + new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), + false, + false, + 2); + + var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "main", update); + + Assert.Empty(requiredReviews.DismissalRestrictions.Teams); + Assert.Empty(requiredReviews.DismissalRestrictions.Users); + Assert.False(requiredReviews.DismissStaleReviews); + Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); + } } } @@ -561,7 +546,7 @@ public async Task RemovesReviewEnforcement() { var repoOwner = context.RepositoryOwner; var repoName = context.RepositoryName; - var deleted = await _client.RemoveReviewEnforcement(repoOwner, repoName, "master"); + var deleted = await _client.RemoveReviewEnforcement(repoOwner, repoName, "main"); Assert.True(deleted); } @@ -573,32 +558,32 @@ public async Task RemovesReviewEnforcementWithRepositoryId() using (var context = await _github.CreateRepositoryWithProtectedBranch()) { var repoId = context.RepositoryId; - var deleted = await _client.RemoveReviewEnforcement(repoId, "master"); + var deleted = await _client.RemoveReviewEnforcement(repoId, "main"); Assert.True(deleted); } } - [IntegrationTest] + [OrganizationTest] public async Task RemovesReviewEnforcementForOrgRepo() { using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) { var repoOwner = context.RepositoryContext.RepositoryOwner; var repoName = context.RepositoryContext.RepositoryName; - var deleted = await _client.RemoveReviewEnforcement(repoOwner, repoName, "master"); + var deleted = await _client.RemoveReviewEnforcement(repoOwner, repoName, "main"); Assert.True(deleted); } } - [IntegrationTest] + [OrganizationTest] public async Task RemovesReviewEnforcementForOrgRepoWithRepositoryId() { using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch()) { var repoId = context.RepositoryContext.RepositoryId; - var deleted = await _client.RemoveReviewEnforcement(repoId, "master"); + var deleted = await _client.RemoveReviewEnforcement(repoId, "main"); Assert.True(deleted); } diff --git a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs index 0e8133659d..87431a8f56 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs @@ -254,7 +254,7 @@ public async Task GetsAllRepositories() var github = Helper.GetAuthenticatedClient(); var client = new ObservableTeamsClient(github); - using (var repositoryContext = await github.CreateRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + using (var repositoryContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) { client.AddRepository(_team.Id, Helper.Organization, repositoryContext.RepositoryName); diff --git a/Octokit.Tests.Integration/SelfTests.cs b/Octokit.Tests.Integration/SelfTests.cs index 418b512d32..23b286e976 100644 --- a/Octokit.Tests.Integration/SelfTests.cs +++ b/Octokit.Tests.Integration/SelfTests.cs @@ -15,4 +15,14 @@ public void NoTestsUseAsyncVoid() Assert.Equal("", errors); } } + + public class GitHubClientTestBase + { + protected readonly IGitHubClient _github; + + public GitHubClientTestBase() + { + _github = Helper.GetAuthenticatedClient(); + } + } } diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index d2bb2bfd4b..90b22719c4 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -637,7 +637,7 @@ public async Task DeserializesCreateEventCorrectly() { "payload", new { - @ref = "master", + @ref = GitHubConstants.DefaultBranchName, ref_type = "branch", } } @@ -648,7 +648,7 @@ public async Task DeserializesCreateEventCorrectly() Assert.Equal(1, activities.Count); var payload = activities.FirstOrDefault().Payload as CreateEventPayload; - Assert.Equal("master", payload.Ref); + Assert.Equal(GitHubConstants.DefaultBranchName, payload.Ref); Assert.Equal(RefType.Branch, payload.RefType); } @@ -661,7 +661,7 @@ public async Task DeserializesDeleteEventCorrectly() { "payload", new { - @ref = "master", + @ref = GitHubConstants.DefaultBranchName, ref_type = "branch", } } @@ -672,7 +672,7 @@ public async Task DeserializesDeleteEventCorrectly() Assert.Equal(1, activities.Count); var payload = activities.FirstOrDefault().Payload as DeleteEventPayload; - Assert.Equal("master", payload.Ref); + Assert.Equal(GitHubConstants.DefaultBranchName, payload.Ref); Assert.Equal(RefType.Branch, payload.RefType); } @@ -955,7 +955,7 @@ public async Task DeserializesStatusEventCorrectly() { new { - name = "master", + name = GitHubConstants.DefaultBranchName, commit = new { sha = "9049f1265b7d61be4a8904a9a27120d2064dab3b", diff --git a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs index 4f4ad4429f..1d6046aa83 100644 --- a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs @@ -261,9 +261,9 @@ public async Task ReturnsContentsByRef() connection.GetAll<RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList<RepositoryContent>)); var contentsClient = new RepositoryContentsClient(connection); - var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "readme.md", "master"); + var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "readme.md", GitHubConstants.DefaultBranchName); - connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/readme.md?ref=master")); + connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/readme.md?ref={GitHubConstants.DefaultBranchName}")); Assert.Equal(1, contents.Count); } @@ -276,9 +276,9 @@ public async Task ReturnsContentsByRefWithRepositoryId() connection.GetAll<RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList<RepositoryContent>)); var contentsClient = new RepositoryContentsClient(connection); - var contents = await contentsClient.GetAllContentsByRef(1, "readme.md", "master"); + var contents = await contentsClient.GetAllContentsByRef(1, "readme.md", GitHubConstants.DefaultBranchName); - connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/readme.md?ref=master")); + connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/readme.md?ref={GitHubConstants.DefaultBranchName}")); Assert.Equal(1, contents.Count); } @@ -291,9 +291,9 @@ public async Task ReturnsAllContentsByRef() connection.GetAll<RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList<RepositoryContent>)); var contentsClient = new RepositoryContentsClient(connection); - var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "master"); + var contents = await contentsClient.GetAllContentsByRef("fake", "repo", GitHubConstants.DefaultBranchName); - connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/?ref=master")); + connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/?ref={GitHubConstants.DefaultBranchName}")); Assert.Equal(1, contents.Count); } @@ -306,9 +306,9 @@ public async Task ReturnsAllContentsByRefWithRepositoryId() connection.GetAll<RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList<RepositoryContent>)); var contentsClient = new RepositoryContentsClient(connection); - var contents = await contentsClient.GetAllContentsByRef(1, "master"); + var contents = await contentsClient.GetAllContentsByRef(1, GitHubConstants.DefaultBranchName); - connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/?ref=master")); + connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/?ref={GitHubConstants.DefaultBranchName}")); Assert.Equal(1, contents.Count); } diff --git a/Octokit.Tests/Fixtures/release.json b/Octokit.Tests/Fixtures/release.json index 78847feddc..3d0a1a2b6d 100644 --- a/Octokit.Tests/Fixtures/release.json +++ b/Octokit.Tests/Fixtures/release.json @@ -4,7 +4,7 @@ "upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name}", "id": 1, "tag_name": "v1.0.0", - "target_commitish": "master", + "target_commitish": "main", "name": "v1.0.0", "body": "Description of the release", "draft": false, diff --git a/Octokit.Tests/Fixtures/releases.json b/Octokit.Tests/Fixtures/releases.json index 360220922e..07fbffc9fe 100644 --- a/Octokit.Tests/Fixtures/releases.json +++ b/Octokit.Tests/Fixtures/releases.json @@ -6,7 +6,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.18.0", "id": 16259, "tag_name": "v0.18.0", - "target_commitish": "master", + "target_commitish": "main", "name": "0.18.0", "body": "* Improve unshelve (#351)\r\n* Better support for running git-tfs in bare repositories (#353)\r\n* Use the saved author file for `rcheckin` (#366)\r\n* Add \"except\" to include an otherwise \"ignored\" file (#377)\r\n* Update libgit2sharp (#387)\r\n* Add a `--nofetch` option to the `branch` (#392) and `init-branch` (#379) commands\r\n* Reduce memory consumption during a fetch (#394)\r\n* Use only one workspace per fetch (rather than one workspace per changeset fetched) (#414)\r\n* Other fixes (#367, #376, #385, #389, #390, #397, #398, #400, #416)\r\n\r\n[Full diff](https://github.com/git-tfs/git-tfs/compare/v0.17.2...v0.18.0)", "draft": false, @@ -35,7 +35,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.12.1", "id": 10541, "tag_name": "v0.12.1", - "target_commitish": "master", + "target_commitish": "main", "name": "", "body": "- Fixed: 'TF14045: The identity MYDOMAIN\\John Doe is not a recognized identity' (#76, #81)\r\n- Fixed: exception on unshelve if some items was renamed (#77)\r\n- Fixed: rare problem when TFS' mixed mode assemblies cannot be loaded correctly (#93)\r\n- Some fixes for Unicode filenames and TFS usernames (#80)\r\n- git-tfs exit codes are now positive\r\n- git-tfs cleans up files if clone command resulted in exception (#94)\r\n- Restored VS2008 functionality (#99)", "draft": false, @@ -53,7 +53,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.14.0", "id": 10540, "tag_name": "v0.14.0", - "target_commitish": "master", + "target_commitish": "main", "name": "", "body": "- Fixed a bug in shelve (#133).\r\n- Fixed rename problem in checkintool (#148).\r\n- Fixed shelve -f (#157).\r\n- Fixed (or unfixed) case sensitivity (#159).\r\n- When a git subprocess exits with error, show the return/error code (#151).\r\n- Add support for VS11.", "draft": false, @@ -71,7 +71,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.15.0", "id": 10539, "tag_name": "v0.15.0", - "target_commitish": "master", + "target_commitish": "main", "name": "", "body": "- Use [libgit2sharp](https://github.com/libgit2/libgit2sharp).\r\n- Add default comment for shelves (#187)\r\n- Add support for files with international characters (#200)\r\n- Fix the mixed case problem (once and for all?) (#213)\r\n- Add support for authors file\r\n- Set up CI with [travis](http://travis-ci.org/git-tfs/git-tfs) and [teamcity](http://teamcity.codebetter.com/)", "draft": false, @@ -89,7 +89,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.17.2", "id": 277, "tag_name": "v0.17.2", - "target_commitish": "master", + "target_commitish": "main", "name": "0.17.2", "body": "* Use the git author as the TFS committer during `git tfs rcheckin` (#336) and `git tfs rcheckin --quick` (#357)\r\n* Improve temporary workspace handling (#328, #372)\r\n* Use libgit2sharp more and git-core less (#361)\r\n* Bug fix for bare repositories (#352)\r\n* Bug fix for crash during `git tfs clone` (#349)\r\n* Bug fix for VS2008 (#362)\r\n* Update libgit2sharp\r\n* Improved release process (#333, #340)\r\n\r\n[Full diff](https://github.com/git-tfs/git-tfs/compare/v0.17.1...v0.17.2)", "draft": false, @@ -118,7 +118,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.17.1", "id": 203, "tag_name": "v0.17.1", - "target_commitish": "master", + "target_commitish": "main", "name": "v0.17.1", "body": "- Fixed `git tfs clone` broken in some cases in 0.17 (#330)", "draft": false, @@ -147,7 +147,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.17.0", "id": 198, "tag_name": "v0.17.0", - "target_commitish": "master", + "target_commitish": "main", "name": "0.17.0", "body": "- [branch](commands/branch.md)\r\n- [labels](commands/labels.md) (#256)\r\n- git tfs pull --rebase (#254)\r\n- git tfs clone --with-branches (#255)\r\n- unicode support (#204)\r\n- Use a custom workspace (#266)\r\n- Clean workspaces directory (#269)\r\n- Add a note on the commit to keep trace of the workitems (#276)\r\n- Remove orphan folders (except in specific cases) (#323)", "draft": false, @@ -176,7 +176,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.16.0", "id": 171, "tag_name": "v0.16.0", - "target_commitish": "master", + "target_commitish": "main", "name": "0.16.0", "body": "- [init-branch](commands/init-branch.md)!! (#232)\r\n- Faster clone (#226) and quick-clone.\r\n- Add `git tfs info` (#219)\r\n- Better metadata processing during rcheckin: remove the flags (#237), ignore whitespace (#238), add `git-tfs-force:` reason (#219).\r\n- Always use CRLF in TFS checkin comments (#239)\r\n- Checkin notes (#245)\r\n- Use authors file more, and save it so you don't have to tell git-tfs about it every time you need it. (#252)", "draft": false, @@ -205,7 +205,7 @@ "html_url": "https://github.com/git-tfs/git-tfs/releases/v0.16.1", "id": 110, "tag_name": "v0.16.1", - "target_commitish": "master", + "target_commitish": "main", "name": "0.16.1", "body": "- Fixed `git tfs unshelve` (broken in 0.16.0) (#253).", "draft": false, diff --git a/Octokit.Tests/Fixtures/repositories.json b/Octokit.Tests/Fixtures/repositories.json index b6ffaa7c476ce0991f1a1108b1516fe2cad41809..986c5a3d387d15f6136a6ab4181f16c0d7afadd1 100644 GIT binary patch delta 22 ccmdne&9VWAZUiuAGUQDT6jt8M6u4;%0B2$dy8r+H delta 26 icmdnc&9bGNWy6gC_F{$-hE#^4$$`SkoBsuD+5!NIe+r=h diff --git a/Octokit.Tests/Fixtures/repository.json b/Octokit.Tests/Fixtures/repository.json index 44f352d78b6571944a9a96afff6192520fcbd558..44a88134290623187349f1c744825710ba0ef9dd 100644 GIT binary patch delta 16 XcmdlavQA{f8y4nFhP=(6S?pN>H$esQ delta 20 bcmZ1{vPopa8y5Crh7yKUhN8{yS?pN>P4NcU diff --git a/Octokit.Tests/GitHubConstants.cs b/Octokit.Tests/GitHubConstants.cs new file mode 100644 index 0000000000..cce109586d --- /dev/null +++ b/Octokit.Tests/GitHubConstants.cs @@ -0,0 +1,7 @@ +namespace Octokit.Tests +{ + public class GitHubConstants + { + public const string DefaultBranchName = "main"; + } +} diff --git a/Octokit.Tests/Models/CheckRunEventTests.cs b/Octokit.Tests/Models/CheckRunEventTests.cs index 360a72382a..c94f97ceaf 100644 --- a/Octokit.Tests/Models/CheckRunEventTests.cs +++ b/Octokit.Tests/Models/CheckRunEventTests.cs @@ -30,7 +30,7 @@ public void CanBeDeserialized() ""name"": ""randscape"", ""check_suite"": { ""id"": 5, - ""head_branch"": ""master"", + ""head_branch"": ""main"", ""head_sha"": ""d6fde92930d4715a2b49857d24b940956b26d2d3"", ""status"": ""completed"", ""conclusion"": ""neutral"", @@ -201,7 +201,7 @@ public void CanBeDeserialized() ""forks"": 0, ""open_issues"": 3, ""watchers"": 0, - ""default_branch"": ""master"" + ""default_branch"": ""main"" }, ""organization"": { ""login"": ""github"", diff --git a/Octokit.Tests/Models/CheckSuiteEventTests.cs b/Octokit.Tests/Models/CheckSuiteEventTests.cs index cccfa91454..45da12ea2e 100644 --- a/Octokit.Tests/Models/CheckSuiteEventTests.cs +++ b/Octokit.Tests/Models/CheckSuiteEventTests.cs @@ -8,7 +8,7 @@ public class CheckSuiteEventTests [Fact] public void CanBeDeserialized() { - const string json = "{\r\n \"action\": \"rerequested\",\r\n \"check_suite\": {\r\n \"id\": 276096,\r\n \"head_branch\": null,\r\n \"head_sha\": \"73955d02043135d48809add98052c2170522158f\",\r\n \"status\": \"queued\",\r\n \"conclusion\": null,\r\n \"url\": \"https://api.github.com/repos/tgstation/tgstation/check-suites/276096\",\r\n \"before\": null,\r\n \"after\": null,\r\n \"pull_requests\": [\r\n\r\n ],\r\n \"app\": {\r\n \"id\": 9880,\r\n \"owner\": {\r\n \"login\": \"Cyberboss\",\r\n \"id\": 8171642,\r\n \"avatar_url\": \"https://avatars3.githubusercontent.com/u/8171642?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/Cyberboss\",\r\n \"html_url\": \"https://github.com/Cyberboss\",\r\n \"followers_url\": \"https://api.github.com/users/Cyberboss/followers\",\r\n \"following_url\": \"https://api.github.com/users/Cyberboss/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/Cyberboss/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/Cyberboss/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/Cyberboss/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/Cyberboss/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/Cyberboss/repos\",\r\n \"events_url\": \"https://api.github.com/users/Cyberboss/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/Cyberboss/received_events\",\r\n \"type\": \"User\",\r\n \"site_admin\": false\r\n },\r\n \"name\": \"MapDiffBot\",\r\n \"description\": \"Creates diff images of BYOND .dmm maps\",\r\n \"external_url\": \"https://github.com/MapDiffBot/MapDiffBot\",\r\n \"html_url\": \"https://github.com/apps/mapdiffbot\",\r\n \"created_at\": 1520618356,\r\n \"updated_at\": 1521225691\r\n },\r\n \"created_at\": \"2018-05-11T05:42:21Z\",\r\n \"updated_at\": \"2018-05-11T13:45:34Z\",\r\n \"unique_check_runs_count\": 1,\r\n \"check_runs_url\": \"https://api.github.com/repos/tgstation/tgstation/check-suites/276096/check-runs\",\r\n \"head_commit\": {\r\n \"id\": \"73955d02043135d48809add98052c2170522158f\",\r\n \"tree_id\": \"ef367b2a31c69d095c45e1b357afb9c78c4b6631\",\r\n \"message\": \"Remove a duplicate pipe in MetaStation maint\",\r\n \"timestamp\": \"2018-05-07T22:36:13-07:00\",\r\n \"author\": {\r\n \"name\": \"Tad Hardesty\",\r\n \"email\": \"tad@platymuus.com\"\r\n },\r\n \"committer\": {\r\n \"name\": \"Tad Hardesty\",\r\n \"email\": \"tad@platymuus.com\"\r\n }\r\n }\r\n },\r\n \"repository\": {\r\n \"id\": 3234987,\r\n \"name\": \"tgstation\",\r\n \"full_name\": \"tgstation/tgstation\",\r\n \"owner\": {\r\n \"login\": \"tgstation\",\r\n \"id\": 1363778,\r\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/1363778?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/tgstation\",\r\n \"html_url\": \"https://github.com/tgstation\",\r\n \"followers_url\": \"https://api.github.com/users/tgstation/followers\",\r\n \"following_url\": \"https://api.github.com/users/tgstation/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/tgstation/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/tgstation/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/tgstation/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/tgstation/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/tgstation/repos\",\r\n \"events_url\": \"https://api.github.com/users/tgstation/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/tgstation/received_events\",\r\n \"type\": \"Organization\",\r\n \"site_admin\": false\r\n },\r\n \"private\": false,\r\n \"html_url\": \"https://github.com/tgstation/tgstation\",\r\n \"description\": \"the /tg/station branch of SS13\",\r\n \"fork\": false,\r\n \"url\": \"https://api.github.com/repos/tgstation/tgstation\",\r\n \"forks_url\": \"https://api.github.com/repos/tgstation/tgstation/forks\",\r\n \"keys_url\": \"https://api.github.com/repos/tgstation/tgstation/keys{/key_id}\",\r\n \"collaborators_url\": \"https://api.github.com/repos/tgstation/tgstation/collaborators{/collaborator}\",\r\n \"teams_url\": \"https://api.github.com/repos/tgstation/tgstation/teams\",\r\n \"hooks_url\": \"https://api.github.com/repos/tgstation/tgstation/hooks\",\r\n \"issue_events_url\": \"https://api.github.com/repos/tgstation/tgstation/issues/events{/number}\",\r\n \"events_url\": \"https://api.github.com/repos/tgstation/tgstation/events\",\r\n \"assignees_url\": \"https://api.github.com/repos/tgstation/tgstation/assignees{/user}\",\r\n \"branches_url\": \"https://api.github.com/repos/tgstation/tgstation/branches{/branch}\",\r\n \"tags_url\": \"https://api.github.com/repos/tgstation/tgstation/tags\",\r\n \"blobs_url\": \"https://api.github.com/repos/tgstation/tgstation/git/blobs{/sha}\",\r\n \"git_tags_url\": \"https://api.github.com/repos/tgstation/tgstation/git/tags{/sha}\",\r\n \"git_refs_url\": \"https://api.github.com/repos/tgstation/tgstation/git/refs{/sha}\",\r\n \"trees_url\": \"https://api.github.com/repos/tgstation/tgstation/git/trees{/sha}\",\r\n \"statuses_url\": \"https://api.github.com/repos/tgstation/tgstation/statuses/{sha}\",\r\n \"languages_url\": \"https://api.github.com/repos/tgstation/tgstation/languages\",\r\n \"stargazers_url\": \"https://api.github.com/repos/tgstation/tgstation/stargazers\",\r\n \"contributors_url\": \"https://api.github.com/repos/tgstation/tgstation/contributors\",\r\n \"subscribers_url\": \"https://api.github.com/repos/tgstation/tgstation/subscribers\",\r\n \"subscription_url\": \"https://api.github.com/repos/tgstation/tgstation/subscription\",\r\n \"commits_url\": \"https://api.github.com/repos/tgstation/tgstation/commits{/sha}\",\r\n \"git_commits_url\": \"https://api.github.com/repos/tgstation/tgstation/git/commits{/sha}\",\r\n \"comments_url\": \"https://api.github.com/repos/tgstation/tgstation/comments{/number}\",\r\n \"issue_comment_url\": \"https://api.github.com/repos/tgstation/tgstation/issues/comments{/number}\",\r\n \"contents_url\": \"https://api.github.com/repos/tgstation/tgstation/contents/{+path}\",\r\n \"compare_url\": \"https://api.github.com/repos/tgstation/tgstation/compare/{base}...{head}\",\r\n \"merges_url\": \"https://api.github.com/repos/tgstation/tgstation/merges\",\r\n \"archive_url\": \"https://api.github.com/repos/tgstation/tgstation/{archive_format}{/ref}\",\r\n \"downloads_url\": \"https://api.github.com/repos/tgstation/tgstation/downloads\",\r\n \"issues_url\": \"https://api.github.com/repos/tgstation/tgstation/issues{/number}\",\r\n \"pulls_url\": \"https://api.github.com/repos/tgstation/tgstation/pulls{/number}\",\r\n \"milestones_url\": \"https://api.github.com/repos/tgstation/tgstation/milestones{/number}\",\r\n \"notifications_url\": \"https://api.github.com/repos/tgstation/tgstation/notifications{?since,all,participating}\",\r\n \"labels_url\": \"https://api.github.com/repos/tgstation/tgstation/labels{/name}\",\r\n \"releases_url\": \"https://api.github.com/repos/tgstation/tgstation/releases{/id}\",\r\n \"deployments_url\": \"https://api.github.com/repos/tgstation/tgstation/deployments\",\r\n \"created_at\": \"2012-01-21T17:32:47Z\",\r\n \"updated_at\": \"2018-05-11T06:24:11Z\",\r\n \"pushed_at\": \"2018-05-11T12:11:58Z\",\r\n \"git_url\": \"git://github.com/tgstation/tgstation.git\",\r\n \"ssh_url\": \"git@github.com:tgstation/tgstation.git\",\r\n \"clone_url\": \"https://github.com/tgstation/tgstation.git\",\r\n \"svn_url\": \"https://github.com/tgstation/tgstation\",\r\n \"homepage\": \"https://www.tgstation13.org/\",\r\n \"size\": 1126165,\r\n \"stargazers_count\": 515,\r\n \"watchers_count\": 515,\r\n \"language\": \"DM\",\r\n \"has_issues\": true,\r\n \"has_projects\": true,\r\n \"has_downloads\": true,\r\n \"has_wiki\": true,\r\n \"has_pages\": false,\r\n \"forks_count\": 1783,\r\n \"mirror_url\": null,\r\n \"archived\": false,\r\n \"open_issues_count\": 1211,\r\n \"license\": {\r\n \"key\": \"agpl-3.0\",\r\n \"name\": \"GNU Affero General Public License v3.0\",\r\n \"spdx_id\": \"AGPL-3.0\",\r\n \"url\": \"https://api.github.com/licenses/agpl-3.0\"\r\n },\r\n \"forks\": 1783,\r\n \"open_issues\": 1211,\r\n \"watchers\": 515,\r\n \"default_branch\": \"master\"\r\n },\r\n \"organization\": {\r\n \"login\": \"tgstation\",\r\n \"id\": 1363778,\r\n \"url\": \"https://api.github.com/orgs/tgstation\",\r\n \"repos_url\": \"https://api.github.com/orgs/tgstation/repos\",\r\n \"events_url\": \"https://api.github.com/orgs/tgstation/events\",\r\n \"hooks_url\": \"https://api.github.com/orgs/tgstation/hooks\",\r\n \"issues_url\": \"https://api.github.com/orgs/tgstation/issues\",\r\n \"members_url\": \"https://api.github.com/orgs/tgstation/members{/member}\",\r\n \"public_members_url\": \"https://api.github.com/orgs/tgstation/public_members{/member}\",\r\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/1363778?v=4\",\r\n \"description\": \"\"\r\n },\r\n \"sender\": {\r\n \"login\": \"Cyberboss\",\r\n \"id\": 8171642,\r\n \"avatar_url\": \"https://avatars3.githubusercontent.com/u/8171642?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/Cyberboss\",\r\n \"html_url\": \"https://github.com/Cyberboss\",\r\n \"followers_url\": \"https://api.github.com/users/Cyberboss/followers\",\r\n \"following_url\": \"https://api.github.com/users/Cyberboss/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/Cyberboss/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/Cyberboss/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/Cyberboss/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/Cyberboss/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/Cyberboss/repos\",\r\n \"events_url\": \"https://api.github.com/users/Cyberboss/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/Cyberboss/received_events\",\r\n \"type\": \"User\",\r\n \"site_admin\": false\r\n },\r\n \"installation\": {\r\n \"id\": 103621\r\n }\r\n}"; + const string json = "{\r\n \"action\": \"rerequested\",\r\n \"check_suite\": {\r\n \"id\": 276096,\r\n \"head_branch\": null,\r\n \"head_sha\": \"73955d02043135d48809add98052c2170522158f\",\r\n \"status\": \"queued\",\r\n \"conclusion\": null,\r\n \"url\": \"https://api.github.com/repos/tgstation/tgstation/check-suites/276096\",\r\n \"before\": null,\r\n \"after\": null,\r\n \"pull_requests\": [\r\n\r\n ],\r\n \"app\": {\r\n \"id\": 9880,\r\n \"owner\": {\r\n \"login\": \"Cyberboss\",\r\n \"id\": 8171642,\r\n \"avatar_url\": \"https://avatars3.githubusercontent.com/u/8171642?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/Cyberboss\",\r\n \"html_url\": \"https://github.com/Cyberboss\",\r\n \"followers_url\": \"https://api.github.com/users/Cyberboss/followers\",\r\n \"following_url\": \"https://api.github.com/users/Cyberboss/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/Cyberboss/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/Cyberboss/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/Cyberboss/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/Cyberboss/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/Cyberboss/repos\",\r\n \"events_url\": \"https://api.github.com/users/Cyberboss/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/Cyberboss/received_events\",\r\n \"type\": \"User\",\r\n \"site_admin\": false\r\n },\r\n \"name\": \"MapDiffBot\",\r\n \"description\": \"Creates diff images of BYOND .dmm maps\",\r\n \"external_url\": \"https://github.com/MapDiffBot/MapDiffBot\",\r\n \"html_url\": \"https://github.com/apps/mapdiffbot\",\r\n \"created_at\": 1520618356,\r\n \"updated_at\": 1521225691\r\n },\r\n \"created_at\": \"2018-05-11T05:42:21Z\",\r\n \"updated_at\": \"2018-05-11T13:45:34Z\",\r\n \"unique_check_runs_count\": 1,\r\n \"check_runs_url\": \"https://api.github.com/repos/tgstation/tgstation/check-suites/276096/check-runs\",\r\n \"head_commit\": {\r\n \"id\": \"73955d02043135d48809add98052c2170522158f\",\r\n \"tree_id\": \"ef367b2a31c69d095c45e1b357afb9c78c4b6631\",\r\n \"message\": \"Remove a duplicate pipe in MetaStation maint\",\r\n \"timestamp\": \"2018-05-07T22:36:13-07:00\",\r\n \"author\": {\r\n \"name\": \"Tad Hardesty\",\r\n \"email\": \"tad@platymuus.com\"\r\n },\r\n \"committer\": {\r\n \"name\": \"Tad Hardesty\",\r\n \"email\": \"tad@platymuus.com\"\r\n }\r\n }\r\n },\r\n \"repository\": {\r\n \"id\": 3234987,\r\n \"name\": \"tgstation\",\r\n \"full_name\": \"tgstation/tgstation\",\r\n \"owner\": {\r\n \"login\": \"tgstation\",\r\n \"id\": 1363778,\r\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/1363778?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/tgstation\",\r\n \"html_url\": \"https://github.com/tgstation\",\r\n \"followers_url\": \"https://api.github.com/users/tgstation/followers\",\r\n \"following_url\": \"https://api.github.com/users/tgstation/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/tgstation/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/tgstation/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/tgstation/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/tgstation/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/tgstation/repos\",\r\n \"events_url\": \"https://api.github.com/users/tgstation/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/tgstation/received_events\",\r\n \"type\": \"Organization\",\r\n \"site_admin\": false\r\n },\r\n \"private\": false,\r\n \"html_url\": \"https://github.com/tgstation/tgstation\",\r\n \"description\": \"the /tg/station branch of SS13\",\r\n \"fork\": false,\r\n \"url\": \"https://api.github.com/repos/tgstation/tgstation\",\r\n \"forks_url\": \"https://api.github.com/repos/tgstation/tgstation/forks\",\r\n \"keys_url\": \"https://api.github.com/repos/tgstation/tgstation/keys{/key_id}\",\r\n \"collaborators_url\": \"https://api.github.com/repos/tgstation/tgstation/collaborators{/collaborator}\",\r\n \"teams_url\": \"https://api.github.com/repos/tgstation/tgstation/teams\",\r\n \"hooks_url\": \"https://api.github.com/repos/tgstation/tgstation/hooks\",\r\n \"issue_events_url\": \"https://api.github.com/repos/tgstation/tgstation/issues/events{/number}\",\r\n \"events_url\": \"https://api.github.com/repos/tgstation/tgstation/events\",\r\n \"assignees_url\": \"https://api.github.com/repos/tgstation/tgstation/assignees{/user}\",\r\n \"branches_url\": \"https://api.github.com/repos/tgstation/tgstation/branches{/branch}\",\r\n \"tags_url\": \"https://api.github.com/repos/tgstation/tgstation/tags\",\r\n \"blobs_url\": \"https://api.github.com/repos/tgstation/tgstation/git/blobs{/sha}\",\r\n \"git_tags_url\": \"https://api.github.com/repos/tgstation/tgstation/git/tags{/sha}\",\r\n \"git_refs_url\": \"https://api.github.com/repos/tgstation/tgstation/git/refs{/sha}\",\r\n \"trees_url\": \"https://api.github.com/repos/tgstation/tgstation/git/trees{/sha}\",\r\n \"statuses_url\": \"https://api.github.com/repos/tgstation/tgstation/statuses/{sha}\",\r\n \"languages_url\": \"https://api.github.com/repos/tgstation/tgstation/languages\",\r\n \"stargazers_url\": \"https://api.github.com/repos/tgstation/tgstation/stargazers\",\r\n \"contributors_url\": \"https://api.github.com/repos/tgstation/tgstation/contributors\",\r\n \"subscribers_url\": \"https://api.github.com/repos/tgstation/tgstation/subscribers\",\r\n \"subscription_url\": \"https://api.github.com/repos/tgstation/tgstation/subscription\",\r\n \"commits_url\": \"https://api.github.com/repos/tgstation/tgstation/commits{/sha}\",\r\n \"git_commits_url\": \"https://api.github.com/repos/tgstation/tgstation/git/commits{/sha}\",\r\n \"comments_url\": \"https://api.github.com/repos/tgstation/tgstation/comments{/number}\",\r\n \"issue_comment_url\": \"https://api.github.com/repos/tgstation/tgstation/issues/comments{/number}\",\r\n \"contents_url\": \"https://api.github.com/repos/tgstation/tgstation/contents/{+path}\",\r\n \"compare_url\": \"https://api.github.com/repos/tgstation/tgstation/compare/{base}...{head}\",\r\n \"merges_url\": \"https://api.github.com/repos/tgstation/tgstation/merges\",\r\n \"archive_url\": \"https://api.github.com/repos/tgstation/tgstation/{archive_format}{/ref}\",\r\n \"downloads_url\": \"https://api.github.com/repos/tgstation/tgstation/downloads\",\r\n \"issues_url\": \"https://api.github.com/repos/tgstation/tgstation/issues{/number}\",\r\n \"pulls_url\": \"https://api.github.com/repos/tgstation/tgstation/pulls{/number}\",\r\n \"milestones_url\": \"https://api.github.com/repos/tgstation/tgstation/milestones{/number}\",\r\n \"notifications_url\": \"https://api.github.com/repos/tgstation/tgstation/notifications{?since,all,participating}\",\r\n \"labels_url\": \"https://api.github.com/repos/tgstation/tgstation/labels{/name}\",\r\n \"releases_url\": \"https://api.github.com/repos/tgstation/tgstation/releases{/id}\",\r\n \"deployments_url\": \"https://api.github.com/repos/tgstation/tgstation/deployments\",\r\n \"created_at\": \"2012-01-21T17:32:47Z\",\r\n \"updated_at\": \"2018-05-11T06:24:11Z\",\r\n \"pushed_at\": \"2018-05-11T12:11:58Z\",\r\n \"git_url\": \"git://github.com/tgstation/tgstation.git\",\r\n \"ssh_url\": \"git@github.com:tgstation/tgstation.git\",\r\n \"clone_url\": \"https://github.com/tgstation/tgstation.git\",\r\n \"svn_url\": \"https://github.com/tgstation/tgstation\",\r\n \"homepage\": \"https://www.tgstation13.org/\",\r\n \"size\": 1126165,\r\n \"stargazers_count\": 515,\r\n \"watchers_count\": 515,\r\n \"language\": \"DM\",\r\n \"has_issues\": true,\r\n \"has_projects\": true,\r\n \"has_downloads\": true,\r\n \"has_wiki\": true,\r\n \"has_pages\": false,\r\n \"forks_count\": 1783,\r\n \"mirror_url\": null,\r\n \"archived\": false,\r\n \"open_issues_count\": 1211,\r\n \"license\": {\r\n \"key\": \"agpl-3.0\",\r\n \"name\": \"GNU Affero General Public License v3.0\",\r\n \"spdx_id\": \"AGPL-3.0\",\r\n \"url\": \"https://api.github.com/licenses/agpl-3.0\"\r\n },\r\n \"forks\": 1783,\r\n \"open_issues\": 1211,\r\n \"watchers\": 515,\r\n \"default_branch\": \"main\"\r\n },\r\n \"organization\": {\r\n \"login\": \"tgstation\",\r\n \"id\": 1363778,\r\n \"url\": \"https://api.github.com/orgs/tgstation\",\r\n \"repos_url\": \"https://api.github.com/orgs/tgstation/repos\",\r\n \"events_url\": \"https://api.github.com/orgs/tgstation/events\",\r\n \"hooks_url\": \"https://api.github.com/orgs/tgstation/hooks\",\r\n \"issues_url\": \"https://api.github.com/orgs/tgstation/issues\",\r\n \"members_url\": \"https://api.github.com/orgs/tgstation/members{/member}\",\r\n \"public_members_url\": \"https://api.github.com/orgs/tgstation/public_members{/member}\",\r\n \"avatar_url\": \"https://avatars2.githubusercontent.com/u/1363778?v=4\",\r\n \"description\": \"\"\r\n },\r\n \"sender\": {\r\n \"login\": \"Cyberboss\",\r\n \"id\": 8171642,\r\n \"avatar_url\": \"https://avatars3.githubusercontent.com/u/8171642?v=4\",\r\n \"gravatar_id\": \"\",\r\n \"url\": \"https://api.github.com/users/Cyberboss\",\r\n \"html_url\": \"https://github.com/Cyberboss\",\r\n \"followers_url\": \"https://api.github.com/users/Cyberboss/followers\",\r\n \"following_url\": \"https://api.github.com/users/Cyberboss/following{/other_user}\",\r\n \"gists_url\": \"https://api.github.com/users/Cyberboss/gists{/gist_id}\",\r\n \"starred_url\": \"https://api.github.com/users/Cyberboss/starred{/owner}{/repo}\",\r\n \"subscriptions_url\": \"https://api.github.com/users/Cyberboss/subscriptions\",\r\n \"organizations_url\": \"https://api.github.com/users/Cyberboss/orgs\",\r\n \"repos_url\": \"https://api.github.com/users/Cyberboss/repos\",\r\n \"events_url\": \"https://api.github.com/users/Cyberboss/events{/privacy}\",\r\n \"received_events_url\": \"https://api.github.com/users/Cyberboss/received_events\",\r\n \"type\": \"User\",\r\n \"site_admin\": false\r\n },\r\n \"installation\": {\r\n \"id\": 103621\r\n }\r\n}"; var serializer = new SimpleJsonSerializer(); diff --git a/Octokit.Tests/Models/MigrationTests.cs b/Octokit.Tests/Models/MigrationTests.cs index c4765a3585..0f54c916ce 100644 --- a/Octokit.Tests/Models/MigrationTests.cs +++ b/Octokit.Tests/Models/MigrationTests.cs @@ -92,7 +92,7 @@ public class MigrationTests ""stargazers_count"": 80, ""watchers_count"": 80, ""size"": 108, - ""default_branch"": ""master"", + ""default_branch"": ""main"", ""open_issues_count"": 0, ""has_issues"": true, ""has_wiki"": true, diff --git a/Octokit.Tests/Models/SearchRepositoryResultTests.cs b/Octokit.Tests/Models/SearchRepositoryResultTests.cs index d7b1a2597a..e609b00483 100644 --- a/Octokit.Tests/Models/SearchRepositoryResultTests.cs +++ b/Octokit.Tests/Models/SearchRepositoryResultTests.cs @@ -39,8 +39,8 @@ public void CanBeDeserialized() ""language"": ""Assembly"", ""forks_count"": 0, ""open_issues_count"": 0, - ""master_branch"": ""master"", - ""default_branch"": ""master"", + ""master_branch"": ""main"", + ""default_branch"": ""main"", ""score"": 10.309712 } ] diff --git a/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs index adf1186da5..400387ebf1 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs @@ -312,9 +312,9 @@ public async Task ReturnsContentsByRef() connection.Get<List<RepositoryContent>>(Args.Uri, null, null) .Returns(Task.FromResult(response)); - var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "master", "readme.md").ToList(); + var contents = await contentsClient.GetAllContentsByRef("fake", "repo", GitHubConstants.DefaultBranchName, "readme.md").ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/readme.md?ref=master"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/readme.md?ref={GitHubConstants.DefaultBranchName}"), null, null); Assert.Equal(1, contents.Count); } @@ -330,9 +330,9 @@ public async Task ReturnsContentsByRefWithRepositoryId() connection.Get<List<RepositoryContent>>(Args.Uri, null, null) .Returns(Task.FromResult(response)); - var contents = await contentsClient.GetAllContentsByRef(1, "master", "readme.md").ToList(); + var contents = await contentsClient.GetAllContentsByRef(1, GitHubConstants.DefaultBranchName, "readme.md").ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/readme.md?ref=master"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/readme.md?ref={GitHubConstants.DefaultBranchName}"), null, null); Assert.Equal(1, contents.Count); } @@ -348,9 +348,9 @@ public async Task ReturnsAllContentsByRef() connection.Get<List<RepositoryContent>>(Args.Uri, null, null) .Returns(Task.FromResult(response)); - var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "master").ToList(); + var contents = await contentsClient.GetAllContentsByRef("fake", "repo", GitHubConstants.DefaultBranchName).ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/?ref=master"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/?ref={GitHubConstants.DefaultBranchName}"), null, null); Assert.Equal(1, contents.Count); } @@ -366,9 +366,9 @@ public async Task ReturnsAllContentsByRefWithRepositoryId() connection.Get<List<RepositoryContent>>(Args.Uri, null, null) .Returns(Task.FromResult(response)); - var contents = await contentsClient.GetAllContentsByRef(1, "master").ToList(); + var contents = await contentsClient.GetAllContentsByRef(1, GitHubConstants.DefaultBranchName).ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/?ref=master"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/?ref={GitHubConstants.DefaultBranchName}"), null, null); Assert.Equal(1, contents.Count); } diff --git a/Octokit/Clients/IReferencesClient.cs b/Octokit/Clients/IReferencesClient.cs index 23369c073c..8a77dcd35a 100644 --- a/Octokit/Clients/IReferencesClient.cs +++ b/Octokit/Clients/IReferencesClient.cs @@ -23,9 +23,9 @@ public interface IReferencesClient /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] @@ -41,9 +41,9 @@ public interface IReferencesClient /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] @@ -104,9 +104,9 @@ public interface IReferencesClient /// <param name="subNamespace">The sub-namespace to get references for</param> /// <remarks> /// The subNamespace parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace); @@ -122,9 +122,9 @@ public interface IReferencesClient /// <param name="options">Options for changing the API response</param> /// <remarks> /// The subNamespace parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace, ApiOptions options); @@ -138,9 +138,9 @@ public interface IReferencesClient /// <param name="subNamespace">The sub-namespace to get references for</param> /// <remarks> /// The subNamespace parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task<IReadOnlyList<Reference>> GetAllForSubNamespace(long repositoryId, string subNamespace); @@ -155,9 +155,9 @@ public interface IReferencesClient /// <param name="options">Options for changing the API response</param> /// <remarks> /// The subNamespace parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task<IReadOnlyList<Reference>> GetAllForSubNamespace(long repositoryId, string subNamespace, ApiOptions options); @@ -172,9 +172,9 @@ public interface IReferencesClient /// <param name="reference">The reference to create</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task<Reference> Create(string owner, string name, NewReference reference); @@ -201,9 +201,9 @@ public interface IReferencesClient /// <param name="referenceUpdate">The updated reference data</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate); @@ -218,9 +218,9 @@ public interface IReferencesClient /// <param name="referenceUpdate">The updated reference data</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task<Reference> Update(long repositoryId, string reference, ReferenceUpdate referenceUpdate); @@ -235,9 +235,9 @@ public interface IReferencesClient /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task Delete(string owner, string name, string reference); @@ -251,9 +251,9 @@ public interface IReferencesClient /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> Task Delete(long repositoryId, string reference); } diff --git a/Octokit/Clients/IRepositoryContentsClient.cs b/Octokit/Clients/IRepositoryContentsClient.cs index 698a44277c..01770463ac 100644 --- a/Octokit/Clients/IRepositoryContentsClient.cs +++ b/Octokit/Clients/IRepositoryContentsClient.cs @@ -77,7 +77,7 @@ public interface IRepositoryContentsClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="path">The content path</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually main)</param> [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(string owner, string name, string path, string reference); @@ -101,7 +101,7 @@ public interface IRepositoryContentsClient /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="path">The content path</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually main)</param> [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(long repositoryId, string path, string reference); @@ -114,7 +114,7 @@ public interface IRepositoryContentsClient /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually main)</param> [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(string owner, string name, string reference); @@ -126,7 +126,7 @@ public interface IRepositoryContentsClient /// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually main)</param> [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(long repositoryId, string reference); diff --git a/Octokit/Clients/ReferencesClient.cs b/Octokit/Clients/ReferencesClient.cs index 22b0c098a8..881d0a9d0c 100644 --- a/Octokit/Clients/ReferencesClient.cs +++ b/Octokit/Clients/ReferencesClient.cs @@ -31,9 +31,9 @@ public ReferencesClient(IApiConnection apiConnection) : /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("GET", "/repos/{owner}/{repo}/git/refs/{ref}")] public Task<Reference> Get(string owner, string name, string reference) @@ -60,9 +60,9 @@ public Task<Reference> Get(string owner, string name, string reference) /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("GET", "/repositories/{id}/git/refs/{ref}")] public Task<Reference> Get(long repositoryId, string reference) @@ -171,9 +171,9 @@ public Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string /// <param name="options">Options for changing the API response</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("GET", "/repos/{owner}/{repo}/git/refs/{ref}")] public Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace, ApiOptions options) @@ -217,9 +217,9 @@ public Task<IReadOnlyList<Reference>> GetAllForSubNamespace(long repositoryId, s /// <param name="options">Options for changing the API response</param> /// <remarks> /// The subNamespace parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("GET", "/repositories/{id}/git/refs/{ref}")] public Task<IReadOnlyList<Reference>> GetAllForSubNamespace(long repositoryId, string subNamespace, ApiOptions options) @@ -284,9 +284,9 @@ public Task<Reference> Create(long repositoryId, NewReference reference) /// <param name="referenceUpdate">The updated reference data</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("PATCH", "/repos/{owner}/{repo}/git/refs/{ref}")] public Task<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate) @@ -315,9 +315,9 @@ public Task<Reference> Update(string owner, string name, string reference, Refer /// <param name="referenceUpdate">The updated reference data</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("PATCH", "/repositories/{id}/git/refs/{ref}")] public Task<Reference> Update(long repositoryId, string reference, ReferenceUpdate referenceUpdate) @@ -344,9 +344,9 @@ public Task<Reference> Update(long repositoryId, string reference, ReferenceUpda /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("PATCH", "/repos/{owner}/{repo}/git/refs/{ref}")] public Task Delete(string owner, string name, string reference) @@ -373,9 +373,9 @@ public Task Delete(string owner, string name, string reference) /// <param name="reference">The reference name</param> /// <remarks> /// The reference parameter supports either the fully-qualified ref - /// (prefixed with "refs/", e.g. "refs/heads/master" or + /// (prefixed with "refs/", e.g. "refs/heads/main" or /// "refs/tags/release-1") or the shortened form (omitting "refs/", e.g. - /// "heads/master" or "tags/release-1") + /// "heads/main" or "tags/release-1") /// </remarks> [ManualRoute("DELETE", "/repositories/{id}/git/refs/{ref}")] public Task Delete(long repositoryId, string reference) diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index e5c7a6661f..200cc473a0 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -124,7 +124,7 @@ public Task<IReadOnlyList<RepositoryContent>> GetAllContents(long repositoryId) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="path">The content path</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually main)</param> [ManualRoute("GET", "/repos/{owner}/{repo}/contents/{path}?ref={ref}")] public Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(string owner, string name, string path, string reference) { @@ -167,7 +167,7 @@ public Task<byte[]> GetRawContentByRef(string owner, string name, string path, s /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="path">The content path</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> [ManualRoute("GET", "/repositories/{id}/contents/{path}?ref={ref}")] public Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(long repositoryId, string path, string reference) { @@ -187,7 +187,7 @@ public Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(long repositor /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository�s default branch (usually main)</param> [ManualRoute("GET", "/repos/{owner}/{repo}/contents/{path}?ref={ref}")] public Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(string owner, string name, string reference) { @@ -208,7 +208,7 @@ public Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(string owner, /// See the <a href="https://developer.github.com/v3/repos/contents/#get-contents">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> [ManualRoute("GET", "/repositories/{id}/contents/{path}?ref={ref}")] public Task<IReadOnlyList<RepositoryContent>> GetAllContentsByRef(long repositoryId, string reference) { diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 32955feb11..4d3a8332ae 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2441,7 +2441,7 @@ public static Uri RepositoryArchiveLink(string owner, string name, ArchiveFormat /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="path">The path of the contents to get</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> /// <returns>The <see cref="Uri"/> for getting the contents of the specified repository and path</returns> public static Uri RepositoryContent(string owner, string name, string path, string reference) { @@ -3447,7 +3447,7 @@ public static Uri RepositoryContent(long repositoryId, string path) /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="path">The path of the contents to get</param> - /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param> + /// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually main)</param> /// <returns>The <see cref="Uri"/> for getting the contents of the specified repository and path</returns> public static Uri RepositoryContent(long repositoryId, string path, string reference) { diff --git a/Octokit/Helpers/ReferenceExtensions.cs b/Octokit/Helpers/ReferenceExtensions.cs index 1c4bd887d2..7fa716efcd 100644 --- a/Octokit/Helpers/ReferenceExtensions.cs +++ b/Octokit/Helpers/ReferenceExtensions.cs @@ -41,7 +41,7 @@ public static async Task<Reference> CreateBranch(this IReferencesClient referenc /// <param name="owner">The owner of the repository.</param> /// <param name="name">The name of the repository.</param> /// <param name="branchName">The new branch name</param> - [Obsolete("This function is hard-coded to master branch, which is no longer a valid assumption for the base branch. Instead of making a second request to figure out the default branch, this extension method will be removed in a future release. Please check the default branch on the repository and use a different overload")] + [Obsolete("This function is hard-coded to master branch, which is no longer a valid assumption for the base branch. Instead of making a second request to figure out the default branch, this extension method will be removed in a future release. Please check the default branch on the repository and use the overload passing in the default branch name")] public static async Task<Reference> CreateBranch(this IReferencesClient referencesClient, string owner, string name, string branchName) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -57,5 +57,29 @@ public static async Task<Reference> CreateBranch(this IReferencesClient referenc var newReference = new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha); return await referencesClient.Create(owner, name, newReference).ConfigureAwait(false); } + + /// <summary> + /// Creates a branch, based off the default branch. + /// </summary> + /// <param name="referencesClient">The <see cref="IReferencesClient" /> this method extends</param> + /// <param name="owner">The owner of the repository.</param> + /// <param name="name">The name of the repository.</param> + /// <param name="branchName">The new branch name</param> + /// <param name="defaultBranchName">The repository's default branch name</param> + public static async Task<Reference> CreateBranch(this IReferencesClient referencesClient, string owner, string name, string branchName, string defaultBranchName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(branchName, nameof(branchName)); + + if (branchName.StartsWith("refs/heads")) + { + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The specified branch name '{0}' appears to be a ref name and not a branch name because it starts with the string 'refs/heads'. Either specify just the branch name or use the Create method if you need to specify the full ref name", branchName), "branchName"); + } + + var baseBranch = await referencesClient.Get(owner, name, $"heads/{defaultBranchName}").ConfigureAwait(false); + var newReference = new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha); + return await referencesClient.Create(owner, name, newReference).ConfigureAwait(false); + } } } diff --git a/Octokit/Models/Request/CreateFileRequest.cs b/Octokit/Models/Request/CreateFileRequest.cs index 390fe564cc..4fc860e201 100644 --- a/Octokit/Models/Request/CreateFileRequest.cs +++ b/Octokit/Models/Request/CreateFileRequest.cs @@ -38,7 +38,7 @@ protected ContentRequest(string message, string branch) : this(message) public string Message { get; private set; } /// <summary> - /// The branch name. If null, this defaults to the default branch which is usually "master". + /// The branch name. If null, this defaults to the default branch which is usually "main". /// </summary> public string Branch { get; set; } diff --git a/Octokit/Models/Request/NewReference.cs b/Octokit/Models/Request/NewReference.cs index 95212076cb..f9bed8b87d 100644 --- a/Octokit/Models/Request/NewReference.cs +++ b/Octokit/Models/Request/NewReference.cs @@ -18,7 +18,7 @@ public class NewReference /// Initializes a new instance of the <see cref="NewReference"/> class. /// </summary> /// <param name="reference"> - /// The name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and + /// The name of the fully qualified reference (ie: refs/heads/main). If it doesn’t start with ‘refs’ and /// have at least two slashes, it will be rejected. /// </param> /// <param name="sha">The SHA1 value to set this reference to</param> @@ -32,7 +32,7 @@ public NewReference(string reference, string sha) } /// <summary> - /// The name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and + /// The name of the fully qualified reference (ie: refs/heads/main). If it doesn’t start with ‘refs’ and /// have at least two slashes, it will be rejected. /// </summary> /// <value> diff --git a/Octokit/Models/Request/NewRelease.cs b/Octokit/Models/Request/NewRelease.cs index fee5fe135d..23e561d2f0 100644 --- a/Octokit/Models/Request/NewRelease.cs +++ b/Octokit/Models/Request/NewRelease.cs @@ -33,7 +33,7 @@ public NewRelease(string tagName) /// <summary> /// Specifies the commitish value that determines where the Git tag is created from. Can be any branch or /// commit SHA. Unused if the Git tag already exists. Default: the repository�s default branch - /// (usually master). + /// (usually main). /// </summary> /// <value> /// The target commitish. diff --git a/Octokit/Models/Request/ReleaseUpdate.cs b/Octokit/Models/Request/ReleaseUpdate.cs index 6e7cf2ddeb..64399e78ab 100644 --- a/Octokit/Models/Request/ReleaseUpdate.cs +++ b/Octokit/Models/Request/ReleaseUpdate.cs @@ -23,7 +23,7 @@ public class ReleaseUpdate /// <summary> /// Specifies the commitish value that determines where the Git tag is created from. Can be any branch or /// commit SHA. Unused if the Git tag already exists. Default: the repository�s default branch - /// (usually master). + /// (usually main). /// </summary> /// <value> /// The target commitish. From cc56183da84aee27750a619b1b335bba37149a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C4=8Dera?= <10546952+miloush@users.noreply.github.com> Date: Wed, 20 Jul 2022 23:22:41 +0100 Subject: [PATCH 087/209] feat: New pull request from existing issue (#2389) --- .../Clients/PullRequestsClientTests.cs | 24 ++++++++++++++ Octokit/Models/Request/NewPullRequest.cs | 32 +++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs index c3f0ac4dcf..0b01c08507 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs @@ -49,6 +49,18 @@ public async Task CanCreateDraft() Assert.True(result.Draft); } + [IntegrationTest] + public async Task CanCreateFromIssue() + { + await CreateTheWorld(); + + var newIssue = await _github.Issue.Create(Helper.UserName, _context.RepositoryName, new NewIssue("an issue")); + var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master"); + var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); + Assert.Equal(newIssue.Number, result.Number); + Assert.Equal(newIssue.Title, result.Title); + } + [IntegrationTest] public async Task CanCreateWithRepositoryId() { @@ -70,6 +82,18 @@ public async Task CanCreateDraftWithRepositoryId() Assert.True(result.Draft); } + [IntegrationTest] + public async Task CanCreateFromIssueWithRepositoryId() + { + await CreateTheWorld(); + + var newIssue = await _github.Issue.Create(_context.RepositoryId, new NewIssue("an issue")); + var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master"); + var result = await _fixture.Create(_context.Repository.Id, newPullRequest); + Assert.Equal(newIssue.Number, result.Number); + Assert.Equal(newIssue.Title, result.Title); + } + [IntegrationTest] public async Task CanGetForRepository() { diff --git a/Octokit/Models/Request/NewPullRequest.cs b/Octokit/Models/Request/NewPullRequest.cs index d2dd58218b..cdd5f7ecd0 100644 --- a/Octokit/Models/Request/NewPullRequest.cs +++ b/Octokit/Models/Request/NewPullRequest.cs @@ -27,10 +27,31 @@ public NewPullRequest(string title, string head, string baseRef) } /// <summary> - /// Title of the pull request (required) + /// Initializes a new instance of the <see cref="NewPullRequest"/> class. + /// </summary> + /// <param name="issueId">The number of an existing issue to convert into a pull request.</param> + /// <param name="head">The branch (or git ref where your changes are implemented. In other words, the source branch/ref</param> + /// <param name="baseRef">The base (or git ref) reference you want your changes pulled into. In other words, the target branch/ref</param> + public NewPullRequest(int issueId, string head, string baseRef) + { + Ensure.ArgumentNotNullOrEmptyString(head, nameof(head)); + Ensure.ArgumentNotNullOrEmptyString(baseRef, nameof(baseRef)); + + IssueId = issueId; + Head = head; + Base = baseRef; + } + + /// <summary> + /// Title of the pull request (required if <see cref="Issue"/> not provided). /// </summary> public string Title { get; private set; } + /// <summary> + /// The number of an existing issue to convert into a pull request (required if <see cref="Title"/> not provided). + /// </summary> + public int? IssueId { get; private set; } + /// <summary> /// The branch (or git ref) you want your changes pulled into (required). /// </summary> @@ -60,7 +81,14 @@ internal string DebuggerDisplay { get { - return string.Format(CultureInfo.InvariantCulture, "Title: {0}", Title); + if (Title == null) + { + return string.Format(CultureInfo.InvariantCulture, "Title: {0}", Title); + } + else + { + return string.Format(CultureInfo.InvariantCulture, "From Issue: {0}", IssueId); + } } } } From 4f4ef5ba73257f12f3ce27cad5263b95d3f93a9b Mon Sep 17 00:00:00 2001 From: Diogo Rolo <diogo.rolo@outlook.com> Date: Thu, 21 Jul 2022 22:36:02 +0100 Subject: [PATCH 088/209] Fix null reference access when ContentType is null (#2501) --- Octokit.Tests/Exceptions/ApiExceptionTests.cs | 11 +++++++++++ Octokit/Exceptions/ApiException.cs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Exceptions/ApiExceptionTests.cs b/Octokit.Tests/Exceptions/ApiExceptionTests.cs index bad38f72fe..7daa4aec38 100644 --- a/Octokit.Tests/Exceptions/ApiExceptionTests.cs +++ b/Octokit.Tests/Exceptions/ApiExceptionTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Net; #if !NO_SERIALIZABLE @@ -141,6 +142,16 @@ public void DoesNotThrowIfBodyIsNotDefined() Assert.NotNull(stringRepresentation); } + [Fact] + public void DoesNotThrowIfContentTypeIsNotDefined() + { + var response = CreateResponse(HttpStatusCode.GatewayTimeout, null, new Dictionary<string, string>(), null); + + var exception = new ApiException(response); + var stringRepresentation = exception.ToString(); + Assert.NotNull(stringRepresentation); + } + [Fact] public void DoesNotPrintImageContent() { diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 4dd08d27e4..9c99713605 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -200,7 +200,7 @@ protected string HttpResponseBodySafe { get { - return HttpResponse != null + return HttpResponse?.ContentType != null && !HttpResponse.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) && HttpResponse.Body is string ? (string)HttpResponse.Body : string.Empty; From 251c3a26fcfcb0be235457ad5cc3939a5ef4f2b2 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 22 Jul 2022 17:28:30 +0100 Subject: [PATCH 089/209] feat: Adds 4 new Reaction delete routes and obsoleting existing routes (#2494) --- ...IObservableCommitCommentReactionsClient.cs | 22 ++++ .../IObservableIssueCommentReactionsClient.cs | 22 ++++ .../IObservableIssueReactionsClient.cs | 22 ++++ ...PullRequestReviewCommentReactionsClient.cs | 22 ++++ .../ObservableCommitCommentReactionsClient.cs | 34 ++++++ .../ObservableIssueCommentReactionsClient.cs | 34 ++++++ .../Clients/ObservableIssueReactionsClient.cs | 34 ++++++ ...PullRequestReviewCommentReactionsClient.cs | 38 ++++++- .../CommitCommentReactionsClientTests.cs | 48 ++++++++ .../IssueCommentReactionsClientTests.cs | 49 +++++++++ .../Clients/IssueReactionsClientTests.cs | 43 ++++++++ ...equestReviewCommentReactionsClientTests.cs | 58 +++++++++- .../Clients/CommitCommentReactionsClient.cs | 32 ++++++ .../Clients/ICommitCommentReactionsClient.cs | 21 ++++ .../Clients/IIssueCommentReactionsClient.cs | 21 ++++ Octokit/Clients/IIssueReactionsClient.cs | 21 ++++ ...PullRequestReviewCommentReactionsClient.cs | 21 ++++ .../Clients/IssueCommentReactionsClient.cs | 32 ++++++ Octokit/Clients/IssueReactionsClient.cs | 32 ++++++ ...PullRequestReviewCommentReactionsClient.cs | 40 ++++++- Octokit/Clients/ReactionsClient.cs | 1 + Octokit/Helpers/ApiUrls.cs | 103 +++++++++++++++++- 22 files changed, 738 insertions(+), 12 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs index 2488a6fa00..b44b78ba7b 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -70,5 +71,26 @@ public interface IObservableCommitCommentReactionsClient /// <param name="options">Options for changing the API response</param> /// <returns></returns> IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options); + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(string owner, string name, int commentId, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs index 6a8f032b90..43fcef4e4d 100644 --- a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -64,5 +65,26 @@ public interface IObservableIssueCommentReactionsClient /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options); + + /// <summary> + /// Deletes a reaction for a specified Issue Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(string owner, string name, int commentId, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index 8d76206408..6acd9b2731 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -64,5 +65,26 @@ public interface IObservableIssueReactionsClient /// <param name="number">The issue id</param> /// <param name="reaction">The reaction to create </param> IObservable<Reaction> Create(long repositoryId, int number, NewReaction reaction); + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="issueNumber">The issue number</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(string owner, string name, int issueNumber, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="issueNumber">The issue number</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(long repositoryId, int issueNumber, int reactionId); } } diff --git a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs index ced771bd5c..0c3e06e0b3 100644 --- a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -64,5 +65,26 @@ public interface IObservablePullRequestReviewCommentReactionsClient /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> IObservable<Reaction> Create(long repositoryId, int number, NewReaction reaction); + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(string owner, string name, int commentId, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + IObservable<Unit> Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index 8286a52077..c95814aeb7 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -113,5 +114,38 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, commentId, reactionId).ToObservable(); + } + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionid">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(long repositoryId, int commentId, int reactionid) + { + Ensure.ArgumentNotNull(reactionid, nameof(reactionid)); + + return _client.Delete(repositoryId, commentId, reactionid).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index f668948282..9a4d61cd04 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -110,5 +111,38 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// <summary> + /// Deletes a reaction for a specified Issue Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, commentId, reactionId).ToObservable(); + } + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(long repositoryId, int commentId, int reactionId) + { + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(repositoryId, commentId, reactionId).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index 19de83a003..12da405811 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -107,5 +108,38 @@ public IObservable<Reaction> Create(long repositoryId, int number, NewReaction r return _client.Create(repositoryId, number, reaction).ToObservable(); } + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="issueNumber">The issue number</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(string owner, string name, int issueNumber, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, issueNumber, reactionId).ToObservable(); + } + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="issueNumber">The issue number</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(long repositoryId, int issueNumber, int reactionId) + { + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(repositoryId, issueNumber, reactionId).ToObservable(); + } } } diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs index 1be8335d2d..967aaa1d2d 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -41,7 +42,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); } /// <summary> @@ -66,7 +67,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } /// <summary> @@ -99,5 +100,38 @@ public IObservable<Reaction> Create(long repositoryId, int number, NewReaction r return _client.Create(repositoryId, number, reaction).ToObservable(); } + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(owner, name, commentId, reactionId).ToObservable(); + } + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + public IObservable<Unit> Delete(long repositoryId, int commentId, int reactionId) + { + Ensure.ArgumentNotNull(reactionId, nameof(reactionId)); + + return _client.Delete(repositoryId, commentId, reactionId).ToObservable(); + } } } diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs index 7e18eb699b..237e998841 100644 --- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -352,6 +352,54 @@ public async Task CanCreateReactionWithRepositoryId() Assert.Equal(result.User.Id, reaction.User.Id); } + + [IntegrationTest] + public async Task CanDeleteReaction() + { + var commit = await SetupCommitForRepository(_github); + + var comment = new NewCommitComment("test"); + + var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, + commit.Sha, comment); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); + + await _github.Reaction.CommitComment.Delete(_context.RepositoryOwner, _context.RepositoryName, result.Id, reaction.Id); + } + + var finalComments = await _github.Reaction.CommitComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, result.Id); + + Assert.Empty(finalComments); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var commit = await SetupCommitForRepository(_github); + + var comment = new NewCommitComment("test"); + + var result = await _github.Repository.Comment.Create(_context.RepositoryId, commit.Sha, comment); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryId, result.Id, newReaction); + + await _github.Reaction.CommitComment.Delete(_context.RepositoryId, result.Id, reaction.Id); + } + + var finalComments = await _github.Reaction.CommitComment.GetAll(_context.RepositoryId, result.Id); + + Assert.Empty(finalComments); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs index 472218a010..5042413012 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs @@ -322,6 +322,55 @@ public async Task CanCreateReactionWithRepositoryId() Assert.Equal(issueComment.User.Id, issueCommentReaction.User.Id); } + [IntegrationTest] + public async Task CanDeleteReaction() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + var issueComment = await _issuesClient.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "A test comment"); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReaction); + + await _github.Reaction.IssueComment.Delete(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.IssueComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id); + + Assert.Empty(allReactions); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryId, newIssue); + + Assert.NotNull(issue); + + var issueComment = await _issuesClient.Comment.Create(_context.RepositoryId, issue.Number, "A test comment"); + + Assert.NotNull(issueComment); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.IssueComment.Create(_context.RepositoryId, issueComment.Id, newReaction); + await _github.Reaction.IssueComment.Delete(_context.RepositoryId, issueComment.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.IssueComment.GetAll(_context.RepositoryId, issueComment.Id); + + Assert.Empty(allReactions); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs index 9a396e879f..b38bee71a2 100644 --- a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs @@ -286,6 +286,49 @@ public async Task CanCreateReactionWithRepositoryId() Assert.Equal(issue.User.Id, issueReaction.User.Id); } + [IntegrationTest] + public async Task CanDeleteReaction() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReaction); + await _github.Reaction.Issue.Delete(_context.RepositoryOwner, _context.RepositoryName, issue.Number, reaction.Id); + } + + var allReactions = await _github.Reaction.Issue.GetAll(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + Assert.Empty(allReactions); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReaction); + await _github.Reaction.Issue.Delete(_context.RepositoryId, issue.Number, reaction.Id); + } + + var allReactions = await _github.Reaction.Issue.GetAll(_context.RepositoryId, issue.Number); + + Assert.Empty(allReactions); + + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index 9558c1dd07..3e05118458 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -339,6 +339,60 @@ public async Task CanCreateReactionWithRepositoryId() Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id); } + [IntegrationTest] + public async Task CanDeleteReaction() + { + var pullRequest = await CreatePullRequest(_context); + + const string body = "A review comment message"; + const int position = 1; + + var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); + + var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id); + + AssertComment(commentFromGitHub, body, position); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReaction); + await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id); + + Assert.Empty(allReactions); + } + + [IntegrationTest] + public async Task CanDeleteReactionWithRepositoryId() + { + var pullRequest = await CreatePullRequest(_context); + + const string body = "A review comment message"; + const int position = 1; + + var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); + + var commentFromGitHub = await _client.GetComment(_context.RepositoryId, createdComment.Id); + + AssertComment(commentFromGitHub, body, position); + + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); + + var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryId, commentFromGitHub.Id, newReaction); + await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryId, commentFromGitHub.Id, reaction.Id); + } + + var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryId, commentFromGitHub.Id); + + Assert.Empty(allReactions); + } + /// <summary> /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) /// </summary> @@ -349,7 +403,7 @@ async Task<PullRequestData> CreatePullRequest(RepositoryContext context) // Creating a commit in master - var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/master", "A master commit message"); + var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A master commit message"); // Creating a branch @@ -362,7 +416,7 @@ async Task<PullRequestData> CreatePullRequest(RepositoryContext context) // Creating a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "main"); var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest); var data = new PullRequestData diff --git a/Octokit/Clients/CommitCommentReactionsClient.cs b/Octokit/Clients/CommitCommentReactionsClient.cs index 674f1c6002..320c35cdb9 100644 --- a/Octokit/Clients/CommitCommentReactionsClient.cs +++ b/Octokit/Clients/CommitCommentReactionsClient.cs @@ -116,5 +116,37 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOp return ApiConnection.GetAll<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.CommitCommentReaction(owner, name, commentId, reactionId)); + } + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repositories/{id}/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int commentId, int reactionId) + { + return ApiConnection.Delete(ApiUrls.CommitCommentReaction(repositoryId, commentId, reactionId)); + } } } diff --git a/Octokit/Clients/ICommitCommentReactionsClient.cs b/Octokit/Clients/ICommitCommentReactionsClient.cs index c64c25fa19..f35bb62058 100644 --- a/Octokit/Clients/ICommitCommentReactionsClient.cs +++ b/Octokit/Clients/ICommitCommentReactionsClient.cs @@ -71,5 +71,26 @@ public interface ICommitCommentReactionsClient /// <param name="options">Options for changing the API response</param> /// <returns></returns> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options); + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(string owner, string name, int commentId, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit/Clients/IIssueCommentReactionsClient.cs b/Octokit/Clients/IIssueCommentReactionsClient.cs index 4fd60ba45d..aafaa87ea4 100644 --- a/Octokit/Clients/IIssueCommentReactionsClient.cs +++ b/Octokit/Clients/IIssueCommentReactionsClient.cs @@ -65,5 +65,26 @@ public interface IIssueCommentReactionsClient /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options); + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(string owner, string name, int commentId, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Commit Comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit/Clients/IIssueReactionsClient.cs b/Octokit/Clients/IIssueReactionsClient.cs index 0de3feff55..bcd3a0028d 100644 --- a/Octokit/Clients/IIssueReactionsClient.cs +++ b/Octokit/Clients/IIssueReactionsClient.cs @@ -65,5 +65,26 @@ public interface IIssueReactionsClient /// <param name="number">The issue id</param> /// <param name="reaction">The reaction to create</param> Task<Reaction> Create(long repositoryId, int number, NewReaction reaction); + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="issueNumber">The issue number</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(string owner, string name, int issueNumber, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="issueNumber">The issue number</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(long repositoryId, int issueNumber, int reactionId); } } diff --git a/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs index 96a47395e5..128856fb0d 100644 --- a/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs +++ b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs @@ -65,5 +65,26 @@ public interface IPullRequestReviewCommentReactionsClient /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> Task<Reaction> Create(long repositoryId, int number, NewReaction reaction); + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The issue id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(string owner, string name, int commentId, int reactionId); + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="commentId">The issue id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + Task Delete(long repositoryId, int commentId, int reactionId); } } diff --git a/Octokit/Clients/IssueCommentReactionsClient.cs b/Octokit/Clients/IssueCommentReactionsClient.cs index f8293501b2..da889c8fdf 100644 --- a/Octokit/Clients/IssueCommentReactionsClient.cs +++ b/Octokit/Clients/IssueCommentReactionsClient.cs @@ -110,5 +110,37 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOp return ApiConnection.GetAll<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } + + /// <summary> + /// Deletes a reaction for a specified Issue Comment + /// </summary> + /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The issue id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.IssueCommentReaction(owner, name, commentId, reactionId)); + } + + /// <summary> + /// Deletes a reaction for a specified Issue Comment + /// </summary> + /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="commentId">The issue id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repositories/{id}/issues/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int commentId, int reactionId) + { + return ApiConnection.Delete(ApiUrls.IssueCommentReaction(repositoryId, commentId, reactionId)); + } } } diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index 53c970e096..c8d2a2adc6 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -110,5 +110,37 @@ public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); } + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="issueNumber">The issue id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int issueNumber, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.IssueReaction(owner, name, issueNumber, reactionId)); + } + + /// <summary> + /// Deletes a reaction for a specified Issue + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="issueNumber">The issue id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repositories/{id}/issues/{issue_number}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int issueNumber, int reactionId) + { + return ApiConnection.Delete(ApiUrls.IssueReaction(repositoryId, issueNumber, reactionId)); + } } } diff --git a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs index 7acd3692e9..a76ef8c549 100644 --- a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs +++ b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs @@ -45,7 +45,7 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); } /// <summary> @@ -73,7 +73,7 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOp { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); } /// <summary> @@ -92,7 +92,7 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); } /// <summary> @@ -108,7 +108,39 @@ public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction { Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + } + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(string owner, string name, int commentId, int reactionId) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.PullRequestReviewCommentReaction(owner, name, commentId, reactionId)); + } + + /// <summary> + /// Deletes a reaction for a specified Pull Request comment + /// </summary> + /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="commentId">The comment id</param> + /// <param name="reactionId">The reaction id</param> + /// <returns></returns> + [ManualRoute("DELETE", "/repositories/{id}/pulls/comments/{comment_id}/reactions/{reaction_id}")] + public Task Delete(long repositoryId, int commentId, int reactionId) + { + return ApiConnection.Delete(ApiUrls.PullRequestReviewCommentReaction(repositoryId, commentId, reactionId)); } } } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 65747e5bd2..eabca26b22 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -58,6 +58,7 @@ public ReactionsClient(IApiConnection apiConnection) /// <returns></returns> [Preview("squirrel-girl")] [ManualRoute("DELETE", "/reactions/{reaction_id}")] + [Obsolete("This route no longer works and is replaced with individual routes in each client")] public Task Delete(int number) { return ApiConnection.Delete(ApiUrls.Reactions(number), new object(), AcceptHeaders.ReactionsPreview); diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 4d3a8332ae..df99a617c0 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -479,6 +479,29 @@ public static Uri IssueReactions(long repositoryId, int number) return "repositories/{0}/issues/{1}/reactions".FormatUri(repositoryId, number); } + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified issue. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + /// <returns></returns> + public static Uri IssueReaction(string owner, string name, int number, int reaction) + { + return "repos/{0}/{1}/issues/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified issue. + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + /// <returns></returns> + public static Uri IssueReaction(long repositoryId, int number, int reaction) + { + return "repositories/{0}/issues/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); + } + /// <summary> /// Returns the <see cref="Uri"/> for the timeline of a specified issue. /// </summary> @@ -560,6 +583,29 @@ public static Uri IssueCommentReactions(long repositoryId, int number) return "repositories/{0}/issues/comments/{1}/reactions".FormatUri(repositoryId, number); } + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified issue comment. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The comment number</param> + /// <returns></returns> + public static Uri IssueCommentReaction(string owner, string name, int number, int reaction) + { + return "repos/{0}/{1}/issues/comments/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified issue comment. + /// </summary> + /// <param name="repositoryId">The owner of the repository</param> + /// <param name="number">The comment number</param> + /// <returns></returns> + public static Uri IssueCommentReaction(long repositoryId, int number, int reaction) + { + return "repositories/{0}/issues/comments/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); + } + /// <summary> /// Returns the <see cref="Uri"/> for the specified comment. /// </summary> @@ -618,6 +664,31 @@ public static Uri CommitCommentReactions(long repositoryId, int number) return "repositories/{0}/comments/{1}/reactions".FormatUri(repositoryId, number); } + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified commit comment. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The comment number</param> + /// <param name="reaction">The reaction number</param> + /// <returns></returns> + public static Uri CommitCommentReaction(string owner, string name, int number, int reaction) + { + return "repos/{0}/{1}/comments/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified commit comment. + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The comment number</param> + /// <param name="reaction">The reaction number</param> + /// <returns></returns> + public static Uri CommitCommentReaction(long repositoryId, int number, int reaction) + { + return "repositories/{0}/comments/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); + } + /// <summary> /// Returns the <see cref="Uri"/> that returns all of the assignees to which issues may be assigned. /// </summary> @@ -1605,28 +1676,52 @@ public static Uri PullRequestReview(long repositoryId, int number, long reviewId } /// <summary> - /// Returns the <see cref="Uri"/> for the reaction of a specified pull request review comment. + /// Returns the <see cref="Uri"/> for the reactions of a specified pull request review comment. /// </summary> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment number</param> /// <returns></returns> - public static Uri PullRequestReviewCommentReaction(string owner, string name, int number) + public static Uri PullRequestReviewCommentReactions(string owner, string name, int number) { return "repos/{0}/{1}/pulls/comments/{2}/reactions".FormatUri(owner, name, number); } /// <summary> - /// Returns the <see cref="Uri"/> for the reaction of a specified pull request review comment. + /// Returns the <see cref="Uri"/> for the reactions of a specified pull request review comment. /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment number</param> /// <returns></returns> - public static Uri PullRequestReviewCommentReaction(long repositoryId, int number) + public static Uri PullRequestReviewCommentReactions(long repositoryId, int number) { return "repositories/{0}/pulls/comments/{1}/reactions".FormatUri(repositoryId, number); } + + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified pull request review comment. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The comment number</param> + /// <returns></returns> + public static Uri PullRequestReviewCommentReaction(string owner, string name, int number, int reaction) + { + return "repos/{0}/{1}/pulls/comments/{2}/reactions/{3}".FormatUri(owner, name, number, reaction); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the reaction of a specified pull request review comment. + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The comment number</param> + /// <returns></returns> + public static Uri PullRequestReviewCommentReaction(long repositoryId, int number, int reaction) + { + return "repositories/{0}/pulls/comments/{1}/reactions/{2}".FormatUri(repositoryId, number, reaction); + } + /// <summary> /// Returns the <see cref="Uri"/> for the pull request review comments on a specified repository. /// </summary> From 9af552eeaa72c309efe4475a75bf8522a721d408 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 22 Jul 2022 20:49:08 +0100 Subject: [PATCH 090/209] feat: Add missing properties to RepositoryUpdate (#2492) --- .../Clients/RepositoriesClientTests.cs | 430 ++++++++++++------ .../GitHubClientTestBase.cs | 12 + Octokit.Tests.Integration/SelfTests.cs | 10 - Octokit.Tests/Models/RepositoryUpdateTests.cs | 3 +- Octokit/Clients/RepositoriesClient.cs | 1 - Octokit/Models/Request/RepositoryUpdate.cs | 75 ++- 6 files changed, 346 insertions(+), 185 deletions(-) create mode 100644 Octokit.Tests.Integration/GitHubClientTestBase.cs diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 18b7578365..0093885264 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -506,216 +506,314 @@ public async Task ThrowsRepositoryExistsExceptionForExistingRepository() // TODO: Add a test for the team_id param once an overload that takes an organization is added } - public class TheEditMethod : IDisposable + public class TheEditMethod : GitHubClientTestBase { - Repository _repository; + [IntegrationTest] + public async Task UpdatesNothing() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate(); + + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); + + Assert.Equal(repoContext.Repository.Name, updatedRepository.Name); + Assert.Equal(repoContext.Repository.Description, updatedRepository.Description); + Assert.Equal(repoContext.Repository.Homepage, updatedRepository.Homepage); + Assert.Equal(repoContext.Repository.Private, updatedRepository.Private); + Assert.Equal(repoContext.Repository.Visibility, updatedRepository.Visibility); + Assert.Equal(repoContext.Repository.HasIssues, updatedRepository.HasIssues); + //Assert.Equal(_repository.HasProjects, updatedRepository.HasProjects); - not on response! + Assert.Equal(repoContext.Repository.HasWiki, updatedRepository.HasWiki); + Assert.Equal(repoContext.Repository.HasDownloads, updatedRepository.HasDownloads); + Assert.Equal(repoContext.Repository.IsTemplate, updatedRepository.IsTemplate); + Assert.Equal(repoContext.Repository.DefaultBranch, updatedRepository.DefaultBranch); + Assert.Equal(repoContext.Repository.AllowSquashMerge, updatedRepository.AllowSquashMerge); + Assert.Equal(repoContext.Repository.AllowMergeCommit, updatedRepository.AllowMergeCommit); + Assert.Equal(repoContext.Repository.AllowRebaseMerge, updatedRepository.AllowRebaseMerge); + Assert.Equal(repoContext.Repository.AllowAutoMerge, updatedRepository.AllowAutoMerge); + Assert.Equal(repoContext.Repository.DeleteBranchOnMerge, updatedRepository.DeleteBranchOnMerge); + // Assert.Equal(_repository.UseSquashPrTitleAsDefault, updatedRepository.UseSquashPrTitleAsDefault); - not on response! + Assert.Equal(repoContext.Repository.Archived, updatedRepository.Archived); + //Assert.Equal(_repository.AllowForking, updatedRepository.AllowForking); - not on response! + } + } [IntegrationTest] public async Task UpdatesName() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); - var update = new RepositoryUpdate(updatedName); + using (var repoContext = await _github.CreateRepositoryContext()) + { + var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); + var update = new RepositoryUpdate() { Name = updatedName }; - _repository = await github.Repository.Edit(Helper.UserName, repoName, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - Assert.Equal(update.Name, _repository.Name); + Assert.Equal(update.Name, updatedRepository.Name); + } } [IntegrationTest] public async Task UpdatesNameWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); - var update = new RepositoryUpdate(updatedName); + using (var repoContext = await _github.CreateRepositoryContext()) + { + var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); + var update = new RepositoryUpdate() { Name = updatedName }; + + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); + + Assert.Equal(update.Name, updatedRepository.Name); + } + } + + [IntegrationTest] + public async Task UpdatesNameObsolete() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); + var update = new RepositoryUpdate(updatedName); + + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); + + Assert.Equal(update.Name, updatedRepository.Name); + } + } + + [IntegrationTest] + public async Task UpdatesNameWithRepositoryIdObsolete() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); + var update = new RepositoryUpdate(updatedName); - _repository = await github.Repository.Edit(_repository.Id, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - Assert.Equal(update.Name, _repository.Name); + Assert.Equal(update.Name, updatedRepository.Name); + } } [IntegrationTest] public async Task UpdatesDescription() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { Description = "Updated description" }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { Description = "Updated description" }; - _repository = await github.Repository.Edit(Helper.UserName, repoName, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - Assert.Equal("Updated description", _repository.Description); + Assert.Equal(update.Description, updatedRepository.Description); + } } [IntegrationTest] public async Task UpdatesDescriptionWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { Description = "Updated description" }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { Description = "Updated description" }; - _repository = await github.Repository.Edit(_repository.Id, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - Assert.Equal("Updated description", _repository.Description); + Assert.Equal(update.Description, updatedRepository.Description); + } } [IntegrationTest] public async Task UpdatesHomepage() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { Homepage = "http://aUrl.to/nowhere" }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { Homepage = "http://aUrl.to/nowhere" }; - _repository = await github.Repository.Edit(Helper.UserName, repoName, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - Assert.Equal("http://aUrl.to/nowhere", _repository.Homepage); + Assert.Equal(update.Homepage, updatedRepository.Homepage); + } } [IntegrationTest] public async Task UpdatesHomepageWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { Homepage = "http://aUrl.to/nowhere" }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { Homepage = "http://aUrl.to/nowhere" }; - _repository = await github.Repository.Edit(_repository.Id, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - Assert.Equal("http://aUrl.to/nowhere", _repository.Homepage); + Assert.Equal(update.Homepage, updatedRepository.Homepage); + } } [PaidAccountTest] public async Task UpdatesPrivate() { - var github = Helper.GetAuthenticatedClient(); + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { Private = true }; - var userDetails = await github.User.Current(); - if (userDetails.Plan.PrivateRepos == 0) + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); + + Assert.True(updatedRepository.Private); + } + } + + [PaidAccountTest] + public async Task UpdatesPrivateWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) { - throw new Exception("Test cannot complete, account is on free plan"); + var update = new RepositoryUpdate() { Private = true }; + + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); + + Assert.True(updatedRepository.Private); } + } - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { Private = true }; + [IntegrationTest] + public async Task UpdatesHasIssues() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { HasIssues = false }; - _repository = await github.Repository.Edit(Helper.UserName, repoName, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - Assert.True(_repository.Private); + Assert.False(updatedRepository.HasIssues); + } } - [PaidAccountTest] - public async Task UpdatesPrivateWithRepositoryId() + [IntegrationTest] + public async Task UpdatesHasIssuesWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { HasIssues = false }; - var userDetails = await github.User.Current(); - if (userDetails.Plan.PrivateRepos == 0) + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); + + Assert.False(updatedRepository.HasIssues); + } + } + + [IntegrationTest] + public async Task UpdatesHasWiki() + { + using (var repoContext = await _github.CreateRepositoryContext()) { - throw new Exception("Test cannot complete, account is on free plan"); + var update = new RepositoryUpdate() { HasWiki = false }; + + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); + + Assert.False(updatedRepository.HasWiki); } + } - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { Private = true }; + [IntegrationTest] + public async Task UpdatesHasWikiWithRepositoryId() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { HasWiki = false }; - _repository = await github.Repository.Edit(_repository.Id, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - Assert.True(_repository.Private); + Assert.False(updatedRepository.HasWiki); + } } [IntegrationTest] public async Task UpdatesHasDownloads() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { HasDownloads = false }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { HasDownloads = false }; - _repository = await github.Repository.Edit(Helper.UserName, repoName, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - Assert.False(_repository.HasDownloads); + Assert.False(updatedRepository.HasDownloads); + } } [IntegrationTest] public async Task UpdatesHasDownloadsWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { HasDownloads = false }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { HasDownloads = false }; - _repository = await github.Repository.Edit(_repository.Id, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - Assert.False(_repository.HasDownloads); + Assert.False(updatedRepository.HasDownloads); + } } [IntegrationTest] - public async Task UpdatesHasIssues() + public async Task UpdatesIsTemplate() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { HasIssues = false }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { IsTemplate = true }; - _repository = await github.Repository.Edit(Helper.UserName, repoName, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - Assert.False(_repository.HasIssues); + Assert.True(updatedRepository.IsTemplate); + } } [IntegrationTest] - public async Task UpdatesHasIssuesWithRepositoryId() + public async Task UpdatesIsTemplateWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { HasIssues = false }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { IsTemplate = true }; - _repository = await github.Repository.Edit(_repository.Id, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - Assert.False(_repository.HasIssues); + Assert.True(updatedRepository.IsTemplate); + } } [IntegrationTest] - public async Task UpdatesHasWiki() + public async Task UpdatesDefaultBranch() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { HasWiki = false }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var reference = _github.Git.Reference.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName).Result.First(); + _github.Git.Reference.Create(repoContext.RepositoryId, new NewReference("refs/heads/primary", reference.Object.Sha)).Wait(); + var update = new RepositoryUpdate() { DefaultBranch = "primary" }; - _repository = await github.Repository.Edit(Helper.UserName, repoName, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - Assert.False(_repository.HasWiki); + Assert.Equal(update.DefaultBranch, updatedRepository.DefaultBranch); + } } [IntegrationTest] - public async Task UpdatesHasWikiWithRepositoryId() + public async Task UpdatesDefaultBranchWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - _repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true }); - var update = new RepositoryUpdate(repoName) { HasWiki = false }; + using (var repoContext = await _github.CreateRepositoryContext()) + { + var reference = _github.Git.Reference.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName).Result.First(); + _github.Git.Reference.Create(repoContext.RepositoryId, new NewReference("refs/heads/primary", reference.Object.Sha)).Wait(); + var update = new RepositoryUpdate() { DefaultBranch = "primary" }; - _repository = await github.Repository.Edit(_repository.Id, update); + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - Assert.False(_repository.HasWiki); + Assert.Equal(update.DefaultBranch, updatedRepository.DefaultBranch); + } } [IntegrationTest] public async Task UpdatesMergeMethod() { - var github = Helper.GetAuthenticatedClient(); - - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var repoContext = await _github.CreateRepositoryContext()) { - var updateRepository = new RepositoryUpdate(context.RepositoryName) + + var updateRepository = new RepositoryUpdate() { AllowMergeCommit = false, AllowSquashMerge = false, @@ -723,28 +821,20 @@ public async Task UpdatesMergeMethod() AllowAutoMerge = true }; - var editedRepository = await github.Repository.Edit(context.RepositoryOwner, context.RepositoryName, updateRepository); + var editedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, updateRepository); Assert.False(editedRepository.AllowMergeCommit); Assert.False(editedRepository.AllowSquashMerge); Assert.True(editedRepository.AllowRebaseMerge); Assert.True(editedRepository.AllowAutoMerge); - - var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); - Assert.False(repository.AllowMergeCommit); - Assert.False(repository.AllowSquashMerge); - Assert.True(repository.AllowRebaseMerge); - Assert.True(repository.AllowAutoMerge); } } [IntegrationTest] public async Task UpdatesMergeMethodWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var repoContext = await _github.CreateRepositoryContext()) { - var updateRepository = new RepositoryUpdate(context.RepositoryName) + var updateRepository = new RepositoryUpdate() { AllowMergeCommit = true, AllowSquashMerge = true, @@ -752,63 +842,62 @@ public async Task UpdatesMergeMethodWithRepositoryId() AllowAutoMerge = true }; - var editedRepository = await github.Repository.Edit(context.RepositoryId, updateRepository); + var editedRepository = await _github.Repository.Edit(repoContext.RepositoryId, updateRepository); Assert.True(editedRepository.AllowMergeCommit); Assert.True(editedRepository.AllowSquashMerge); Assert.False(editedRepository.AllowRebaseMerge); Assert.True(editedRepository.AllowAutoMerge); - - var repository = await github.Repository.Get(context.RepositoryId); - Assert.True(repository.AllowMergeCommit); - Assert.True(repository.AllowSquashMerge); - Assert.False(repository.AllowRebaseMerge); - Assert.True(editedRepository.AllowAutoMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethod() { - var github = Helper.GetAuthenticatedClient(); - - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var repoContext = await _github.CreateRepositoryContext()) { - var updateRepository = new RepositoryUpdate(context.RepositoryName) - { - DeleteBranchOnMerge = true - }; + var updateRepository = new RepositoryUpdate() { DeleteBranchOnMerge = true }; - var editedRepository = await github.Repository.Edit(context.RepositoryOwner, context.RepositoryName, updateRepository); + var editedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, updateRepository); Assert.True(editedRepository.DeleteBranchOnMerge); - - var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); - Assert.True(repository.DeleteBranchOnMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethodWithRepositoryId() { - var github = Helper.GetAuthenticatedClient(); - - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var repoContext = await _github.CreateRepositoryContext()) { - var updateRepository = new RepositoryUpdate(context.RepositoryName) - { - DeleteBranchOnMerge = true - }; + var updateRepository = new RepositoryUpdate() { DeleteBranchOnMerge = true }; - var editedRepository = await github.Repository.Edit(context.RepositoryId, updateRepository); + var editedRepository = await _github.Repository.Edit(repoContext.RepositoryId, updateRepository); Assert.True(editedRepository.DeleteBranchOnMerge); + } + } - var repository = await github.Repository.Get(context.RepositoryId); - Assert.True(repository.DeleteBranchOnMerge); + [IntegrationTest] + public async Task UpdatesArchive() + { + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { Archived = true }; + + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); + + Assert.Equal(update.Archived, updatedRepository.Archived); } } - public void Dispose() + [IntegrationTest] + public async Task UpdatesArchiveWithRepositoryId() { - Helper.DeleteRepo(Helper.GetAuthenticatedClient().Connection, _repository); + using (var repoContext = await _github.CreateRepositoryContext()) + { + var update = new RepositoryUpdate() { Archived = true }; + + var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); + + Assert.Equal(update.Archived, updatedRepository.Archived); + } } } @@ -985,7 +1074,7 @@ public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() Assert.Equal("mit", repository.License.Key); Assert.Equal("MIT License", repository.License.Name); } - + [IntegrationTest] public async Task ReturnsRepositoryDeleteBranchOnMergeOptions() { @@ -2161,4 +2250,49 @@ public async Task AreVulnerabilityAlertsEnabledReturnsTrue() Assert.True(enabled); } } + + public class RepositoryTestBaseClass : IDisposable + { + protected IGitHubClient _github; + + private readonly List<RepositoryContext> _repositories; + + protected RepositoryTestBaseClass() + { + _github = Helper.GetAuthenticatedClient(); + _repositories = new List<RepositoryContext>(); + } + + public void Dispose() + { + foreach (var repository in _repositories) + { + repository.Dispose(); + } + } + + /// <summary> + /// Returns a RepositoryContext, which will be disposed at the end of the test. + /// </summary> + /// <param name="name">Your value or uses default of Helper.MakeNameWithTimestamp("public-repo");</param> + /// <returns></returns> + internal RepositoryContext CreateRepository(string name = null) + { + var newContext = _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp(name ?? Helper.MakeNameWithTimestamp("public-repo"))) { AutoInit = true }).Result; + _repositories.Add(newContext); + return newContext; + } + + /// <summary> + /// Returns a RepositoryContext, which will be disposed at the end of the test. + /// </summary> + /// <param name="name">Your value or uses default of Helper.MakeNameWithTimestamp("public-repo");</param> + /// <returns></returns> + internal async Task<RepositoryContext> CreateRepositoryAsync(string name = null) + { + var newContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp(name ?? Helper.MakeNameWithTimestamp("public-repo"))) { AutoInit = true }); + _repositories.Add(newContext); + return newContext; + } + } } diff --git a/Octokit.Tests.Integration/GitHubClientTestBase.cs b/Octokit.Tests.Integration/GitHubClientTestBase.cs new file mode 100644 index 0000000000..269aec6a25 --- /dev/null +++ b/Octokit.Tests.Integration/GitHubClientTestBase.cs @@ -0,0 +1,12 @@ +namespace Octokit.Tests.Integration +{ + public class GitHubClientTestBase + { + protected readonly IGitHubClient _github; + + public GitHubClientTestBase() + { + _github = Helper.GetAuthenticatedClient(); + } + } +} diff --git a/Octokit.Tests.Integration/SelfTests.cs b/Octokit.Tests.Integration/SelfTests.cs index 23b286e976..418b512d32 100644 --- a/Octokit.Tests.Integration/SelfTests.cs +++ b/Octokit.Tests.Integration/SelfTests.cs @@ -15,14 +15,4 @@ public void NoTestsUseAsyncVoid() Assert.Equal("", errors); } } - - public class GitHubClientTestBase - { - protected readonly IGitHubClient _github; - - public GitHubClientTestBase() - { - _github = Helper.GetAuthenticatedClient(); - } - } } diff --git a/Octokit.Tests/Models/RepositoryUpdateTests.cs b/Octokit.Tests/Models/RepositoryUpdateTests.cs index a1b91b49f4..b5bfb93a79 100644 --- a/Octokit.Tests/Models/RepositoryUpdateTests.cs +++ b/Octokit.Tests/Models/RepositoryUpdateTests.cs @@ -21,8 +21,9 @@ public void CanSerialize() "\"has_wiki\":true," + "\"has_downloads\":true}"; - var update = new RepositoryUpdate("Hello-World") + var update = new RepositoryUpdate() { + Name = "Hello-World", Description = "This is your first repository", Homepage = "https://github.com", Private = true, diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 612de5d15e..4d4bfe3bad 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -270,7 +270,6 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(update, nameof(update)); - Ensure.ArgumentNotNull(update.Name, nameof(update.Name)); return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview)); } diff --git a/Octokit/Models/Request/RepositoryUpdate.cs b/Octokit/Models/Request/RepositoryUpdate.cs index 4a876f05d3..7e8e3438cb 100644 --- a/Octokit/Models/Request/RepositoryUpdate.cs +++ b/Octokit/Models/Request/RepositoryUpdate.cs @@ -1,7 +1,6 @@ -using System; +using Octokit.Internal; +using System; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; namespace Octokit { @@ -12,14 +11,19 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RepositoryUpdate { + /// <summary> + /// Creates an object that describes an update to a repository on GitHub. + /// </summary> + public RepositoryUpdate() { } + /// <summary> /// Creates an object that describes an update to a repository on GitHub. /// </summary> /// <param name="name">The name of the repository. This is the only required parameter.</param> + [Obsolete("Use the constructor with no parameters as name is no longer a required field")] public RepositoryUpdate(string name) { Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Name = name; } @@ -44,62 +48,83 @@ public RepositoryUpdate(string name) public bool? Private { get; set; } /// <summary> - /// Gets or sets whether to enable issues for the repository. The default is null (do not update). + /// Optional. Gets or sets whether the new repository is public, private, or internal. A value provided here overrides any value set in the existing private field. + /// </summary> + public RepositoryVisibility? Visibility { get; set; } + + // Yet to be implemented + //public object SecurityAndAnalysis { get; set; } + + /// <summary> + /// Gets or sets whether to enable issues for the repository. The default is null (do not update). The default when created is true. /// </summary> public bool? HasIssues { get; set; } /// <summary> - /// Optional. Gets or sets whether to enable the wiki for the repository. The default is null (do not update). + /// Gets or sets whether to enable projects for the repository. The default is null (do not update). The default when created is true. + /// </summary> + public bool? HasProjects { get; set; } + + /// <summary> + /// Optional. Gets or sets whether to enable the wiki for the repository. The default is null (do not update). The default when created is true. /// </summary> public bool? HasWiki { get; set; } /// <summary> - /// Optional. Gets or sets whether to enable downloads for the repository. The default is null (do not update). + /// Optional. Gets or sets whether to enable downloads for the repository. The default is null (do not update). No longer appears on the documentation but still works. /// </summary> public bool? HasDownloads { get; set; } /// <summary> - /// Optional. Gets or sets the default branch. The default is null (do not update). + /// Optional. Gets or sets whether the repository is a template. The default is null (do not update). The default when created is false. /// </summary> - public string DefaultBranch { get; set; } + public bool? IsTemplate { get; set; } /// <summary> - /// Optional. Allows the "Rebase and Merge" method to be used. + /// Optional. Gets or sets the default branch. The default is null (do not update). /// </summary> - public bool? AllowRebaseMerge { get; set; } + public string DefaultBranch { get; set; } /// <summary> - /// Optional. Allows the "Squash Merge" merge method to be used. + /// Optional. Allows the "Squash Merge" merge method to be used. The default is null (do not update). The default when created is true. /// </summary> public bool? AllowSquashMerge { get; set; } /// <summary> - /// Optional. Allows the "Create a merge commit" merge method to be used. + /// Optional. Allows the "Create a merge commit" merge method to be used. The default is null (do not update). The default when created is true. /// </summary> public bool? AllowMergeCommit { get; set; } - + /// <summary> + /// Optional. Allows the "Rebase and Merge" method to be used. The default is null (do not update). The default when created is true. + /// </summary> + public bool? AllowRebaseMerge { get; set; } + + /// <summary> + /// Optional. Allows the auto merge feature to be used. The default is null (do not update). The default when created is false. + /// </summary> + public bool? AllowAutoMerge { get; set; } + + /// <summary> + /// Optional. Automatically delete branches on PR merge. The default is null (do not update). The default when created is false. + /// </summary> public bool? DeleteBranchOnMerge { get; set; } /// <summary> - /// Optional. True to archive this repository. Note: you cannot unarchive repositories through the API. + /// Optional. Automatically set the title of squashed commits to be the PR title. The default is null (do not update). The default when created is false. /// </summary> - public bool? Archived { get; set; } + public bool? UseSquashPrTitleAsDefault { get; set; } /// <summary> - /// Optional. Gets or sets whether the new repository is public, private, or internal. A value provided here overrides any value set in the existing private field. + /// Optional. True to archive this repository. Note: you cannot unarchive repositories through the API. The default is null (do not update). The default when created is false. /// </summary> - public RepositoryVisibility? Visibility { get; set; } + public bool? Archived { get; set; } /// <summary> - /// Options. Allows the "Auto Merge" method to be used. + /// Optional. Get or set whether to allow this repository to be forked or not. The default is null (do not update). The default when created is false. /// </summary> - public bool? AllowAutoMerge { get; set; } + public bool? AllowForking { get; set; } - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal string DebuggerDisplay - { - get { return string.Format(CultureInfo.CurrentCulture, "RepositoryUpdate: Name: {0}", Name); } - } + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); } } From 5fe3ea82f03b7fe64bcf8145f3b127fa2c585665 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Mon, 25 Jul 2022 16:36:09 +0100 Subject: [PATCH 091/209] tests: Updates and fixes for tests, changing master to main and adding flaky tests marker (#2511) --- .../Clients/BlobClientTests.cs | 2 +- .../CommitCommentReactionsClientTests.cs | 2 +- .../Clients/CommitStatusClientTests.cs | 2 +- .../Clients/CommitsClientTests.cs | 4 +- .../Clients/DeploymentStatusClientTests.cs | 2 +- .../Clients/DeploymentsClientTests.cs | 2 +- .../Clients/IssueCommentsClientTests.cs | 6 +- .../Clients/IssuesClientTests.cs | 4 +- .../Clients/MergingClientTests.cs | 24 +-- .../Clients/ProjectCardsClientTests.cs | 2 +- ...equestReviewCommentReactionsClientTests.cs | 62 +------ .../PullRequestReviewCommentsClientTests.cs | 16 +- .../PullRequestReviewRequestsClientTests.cs | 18 +- .../Clients/PullRequestReviewsClientTests.cs | 36 ++-- .../Clients/PullRequestsClientTests.cs | 156 ++++++++--------- .../Clients/ReferencesClientTests.cs | 14 +- .../Clients/ReleasesClientTests.cs | 16 +- .../Clients/RepositoriesClientTests.cs | 133 ++++++-------- .../Clients/RepositoryBranchesClientTests.cs | 162 +++++++++--------- .../Clients/RepositoryCommentsClientTests.cs | 12 +- .../Clients/RepositoryCommitsClientTests.cs | 40 ++--- .../Clients/RepositoryContentsClientTests.cs | 56 +++--- .../RepositoryDeployKeysClientTests.cs | 2 +- .../Clients/SearchClientTests.cs | 2 +- .../Clients/StatisticsClientTests.cs | 20 +-- .../Clients/TagsClientTests.cs | 4 +- .../Clients/TreeClientTests.cs | 6 +- .../Clients/WatchedClientTests.cs | 2 +- Octokit.Tests.Integration/Helper.cs | 2 + .../Helpers/GithubClientExtensions.cs | 91 ++++++++-- .../Helpers/PaidAccountTestAttribute.cs | 8 + .../Helpers/ReferenceExtensionsTests.cs | 6 +- .../Helpers/RepositorySetupHelper.cs | 16 +- .../PotentiallyFlakyTestAttribute.cs | 13 ++ .../ObservableCheckRunsClientTests.cs | 20 +-- .../ObservableCheckSuitesClientTests.cs | 16 +- 36 files changed, 491 insertions(+), 488 deletions(-) create mode 100644 Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs diff --git a/Octokit.Tests.Integration/Clients/BlobClientTests.cs b/Octokit.Tests.Integration/Clients/BlobClientTests.cs index d0a3a9f87c..8aeaf306b0 100644 --- a/Octokit.Tests.Integration/Clients/BlobClientTests.cs +++ b/Octokit.Tests.Integration/Clients/BlobClientTests.cs @@ -16,7 +16,7 @@ public BlobClientTests() var github = Helper.GetAuthenticatedClient(); _fixture = github.Git.Blob; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs index 237e998841..fe008cecb4 100644 --- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -18,7 +18,7 @@ public TheCreateReactionMethod() { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task<Commit> SetupCommitForRepository(IGitHubClient client) diff --git a/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs b/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs index 8f00b43f55..3cccfd7fec 100644 --- a/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs @@ -213,7 +213,7 @@ public TheCreateMethod() { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs index c2759a7fd7..166355368a 100644 --- a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs @@ -12,7 +12,7 @@ public async Task CanCreateAndRetrieveCommit() var github = Helper.GetAuthenticatedClient(); var fixture = github.Git.Commit; - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var context = await github.CreateRepositoryContextWithAutoInit("public-repo")) { var owner = context.Repository.Owner.Login; @@ -67,7 +67,7 @@ public async Task CanCreateAndRetrieveCommitWithRepositoryId() var github = Helper.GetAuthenticatedClient(); var fixture = github.Git.Commit; - using (var context = await github.CreateRepositoryContext("public-repo")) + using (var context = await github.CreateRepositoryContextWithAutoInit("public-repo")) { var owner = context.Repository.Owner.Login; diff --git a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs index 3d19b48ed9..1fa4b89943 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs @@ -16,7 +16,7 @@ public DeploymentStatusClientTests() var github = Helper.GetAuthenticatedClient(); _deploymentsClient = github.Repository.Deployment; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { diff --git a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs index a0bc2d0d71..43902fed25 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs @@ -17,7 +17,7 @@ public DeploymentsClientTests() var github = Helper.GetAuthenticatedClient(); _deploymentsClient = github.Repository.Deployment; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { diff --git a/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs index 168b9c087f..b9343e46c6 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs @@ -45,7 +45,7 @@ public async Task ReturnsIssueCommentWithRepositoryId() [IntegrationTest] public async Task CanGetReactionPayload() { - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) { // Create a test issue var issueNumber = await HelperCreateIssue(context.RepositoryOwner, context.RepositoryName); @@ -217,7 +217,7 @@ public async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId() public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) { var commentIds = new List<int>(); @@ -402,7 +402,7 @@ public async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId() public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssueCommentsReactionTests"))) { var commentIds = new List<int>(); diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 2d887ed027..88a793f200 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -1288,7 +1288,7 @@ public async Task GetAllForOrganizationContainsRepositoryData() [IntegrationTest] public async Task CanGetReactionPayload() { - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) { // Create a test issue with reactions var issueNumber = await HelperCreateIssue(context.RepositoryOwner, context.RepositoryName); @@ -1312,7 +1312,7 @@ public async Task CanGetReactionPayload() public async Task CanGetReactionPayloadForMultipleIssues() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("IssuesReactionTests"))) { var issueNumbers = new List<int>(); diff --git a/Octokit.Tests.Integration/Clients/MergingClientTests.cs b/Octokit.Tests.Integration/Clients/MergingClientTests.cs index dcbc5be983..66cc557828 100644 --- a/Octokit.Tests.Integration/Clients/MergingClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MergingClientTests.cs @@ -22,7 +22,7 @@ public MergingClientTests() }; _fixture = _github.Repository.Merging; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -30,12 +30,12 @@ public async Task CanCreateMerge() { await CreateTheWorld(); - var newMerge = new NewMerge("master", branchName) { CommitMessage = "merge commit to master from integrationtests" }; + var newMerge = new NewMerge("main", branchName) { CommitMessage = "merge commit to main from integrationtests" }; var merge = await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newMerge); Assert.NotNull(merge); Assert.NotNull(merge.Commit); - Assert.Equal("merge commit to master from integrationtests", merge.Commit.Message); + Assert.Equal("merge commit to main from integrationtests", merge.Commit.Message); } [IntegrationTest] @@ -43,28 +43,28 @@ public async Task CanCreateMergeWithRepositoryId() { await CreateTheWorld(); - var newMerge = new NewMerge("master", branchName) { CommitMessage = "merge commit to master from integrationtests" }; + var newMerge = new NewMerge("main", branchName) { CommitMessage = "merge commit to main from integrationtests" }; var merge = await _fixture.Create(_context.Repository.Id, newMerge); Assert.NotNull(merge); Assert.NotNull(merge.Commit); - Assert.Equal("merge commit to master from integrationtests", merge.Commit.Message); + Assert.Equal("merge commit to main from integrationtests", merge.Commit.Message); } async Task CreateTheWorld() { - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World! I want to be overwritten by featurebranch!" } }); - var newMaster = await CreateCommit("baseline for merge", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World! I want to be overwritten by featurebranch!" } }); + var newMain = await CreateCommit("baseline for merge", newMainTree.Sha, main.Object.Sha); - // update master - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something new" } }); - var featureBranchCommit = await CreateCommit("this is the commit to merge", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await CreateCommit("this is the commit to merge", featureBranchTree.Sha, newMain.Sha); // create branch await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); diff --git a/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs b/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs index c48cf6757f..97568ead56 100644 --- a/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ProjectCardsClientTests.cs @@ -203,7 +203,7 @@ public TheCreateMethod() { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index 3e05118458..a6a05c8871 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -25,7 +25,7 @@ public PullRequestReviewCommentReactionsClientTests() _client = _github.PullRequest.ReviewComment; // We'll create a pull request that can be used by most tests - _context = _github.CreateRepositoryContext("test-repo").Result; + _context = _github.CreateUserRepositoryContext("test-repo").Result; } [IntegrationTest] @@ -339,60 +339,6 @@ public async Task CanCreateReactionWithRepositoryId() Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id); } - [IntegrationTest] - public async Task CanDeleteReaction() - { - var pullRequest = await CreatePullRequest(_context); - - const string body = "A review comment message"; - const int position = 1; - - var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); - - var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id); - - AssertComment(commentFromGitHub, body, position); - - foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) - { - var newReaction = new NewReaction(reactionType); - - var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReaction); - await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, reaction.Id); - } - - var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id); - - Assert.Empty(allReactions); - } - - [IntegrationTest] - public async Task CanDeleteReactionWithRepositoryId() - { - var pullRequest = await CreatePullRequest(_context); - - const string body = "A review comment message"; - const int position = 1; - - var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); - - var commentFromGitHub = await _client.GetComment(_context.RepositoryId, createdComment.Id); - - AssertComment(commentFromGitHub, body, position); - - foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) - { - var newReaction = new NewReaction(reactionType); - - var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryId, commentFromGitHub.Id, newReaction); - await _github.Reaction.PullRequestReviewComment.Delete(_context.RepositoryId, commentFromGitHub.Id, reaction.Id); - } - - var allReactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryId, commentFromGitHub.Id); - - Assert.Empty(allReactions); - } - /// <summary> /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) /// </summary> @@ -403,11 +349,11 @@ async Task<PullRequestData> CreatePullRequest(RepositoryContext context) // Creating a commit in master - var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A master commit message"); + var createdCommitInMain = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A main commit message"); // Creating a branch - var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha); + var newBranch = new NewReference(branchRef, createdCommitInMain.Sha); await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch); // Creating a commit in the branch @@ -416,7 +362,7 @@ async Task<PullRequestData> CreatePullRequest(RepositoryContext context) // Creating a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "main"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "master"); var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest); var data = new PullRequestData diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs index ad51225dbe..82e2f9bb5e 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs @@ -23,7 +23,7 @@ public PullRequestReviewCommentsClientTests() _client = _github.PullRequest.ReviewComment; // We'll create a pull request that can be used by most tests - _context = _github.CreateRepositoryContext("test-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("test-repo").Result; } [IntegrationTest] @@ -844,7 +844,7 @@ static void AssertComments(IReadOnlyList<PullRequestReviewComment> comments, Lis } /// <summary> - /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) + /// Creates the base state for testing (creates a repo, a commit in main, a branch, a commit in the branch and a pull request) /// </summary> /// <returns></returns> async Task<PullRequestData> CreatePullRequest(RepositoryContext context, string branch = branchName) @@ -855,13 +855,13 @@ async Task<PullRequestData> CreatePullRequest(RepositoryContext context, string var repoName = context.RepositoryName; - // Creating a commit in master + // Creating a commit in main - var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/master", "A master commit message"); + var createdCommitInMain = await CreateCommit(repoName, "Hello World!", "README.md", "heads/main", "A main commit message"); // Creating a branch - var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha); + var newBranch = new NewReference(branchRef, createdCommitInMain.Sha); await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch); // Creating a commit in the branch @@ -870,7 +870,7 @@ async Task<PullRequestData> CreatePullRequest(RepositoryContext context, string // Creating a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "main"); var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest); var data = new PullRequestData @@ -926,7 +926,7 @@ class PullRequestData public async Task CanGetReactionPayloadForPullRequestReviews() { int numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) { var commentIds = new List<int>(); @@ -965,7 +965,7 @@ public async Task CanGetReactionPayloadForPullRequestReviews() public async Task CanGetReactionPayloadForRepositoryPullRequestReviews() { int numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("PullRequestReviewCommentsReactionTests"))) { var commentIds = new List<int>(); diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs index 4c20d2e90f..c0ee6c0b49 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewRequestsClientTests.cs @@ -26,7 +26,7 @@ public PullRequestReviewRequestClientTestsBase() _client = _github.PullRequest.ReviewRequest; - _context = _github.CreateRepositoryContext("test-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("test-repo").Result; Task.WaitAll(_collaboratorLogins.Select(AddCollaborator).ToArray()); } @@ -144,18 +144,18 @@ public async Task CreatesRequestsWithRepositoryId() static async Task<int> CreateTheWorld(IGitHubClient github, RepositoryContext context, bool createReviewRequests = true) { - var master = await github.Git.Reference.Get(context.RepositoryOwner, context.RepositoryName, "heads/master"); + var main = await github.Git.Reference.Get(context.RepositoryOwner, context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(github, context, new Dictionary<string, string> { { "README.md", "Hello World!" } }); - var newMaster = await CreateCommit(github, context, "baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(github, context, new Dictionary<string, string> { { "README.md", "Hello World!" } }); + var newMain = await CreateCommit(github, context, "baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await github.Git.Reference.Update(context.RepositoryOwner, context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await github.Git.Reference.Update(context.RepositoryOwner, context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(github, context, new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something new" } }); - var featureBranchCommit = await CreateCommit(github, context, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await CreateCommit(github, context, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); var featureBranchTree2 = await CreateTree(github, context, new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something new a 2nd time" } }); var featureBranchCommit2 = await CreateCommit(github, context, "this is a 2nd commit to merge into the pull request", featureBranchTree2.Sha, featureBranchCommit.Sha); @@ -164,7 +164,7 @@ static async Task<int> CreateTheWorld(IGitHubClient github, RepositoryContext co await github.Git.Reference.Create(context.RepositoryOwner, context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit2.Sha)); // create a pull request - var pullRequest = new NewPullRequest("Nice title for the pull request", "my-branch", "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", "my-branch", "main"); var createdPullRequest = await github.PullRequest.Create(context.RepositoryOwner, context.RepositoryName, pullRequest); // Create review requests (optional) diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs index 3b7d521750..5e57ca592d 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewsClientTests.cs @@ -126,7 +126,7 @@ public TheCreateMethod() [DualAccountTest] public async Task CanCreatePendingReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -156,7 +156,7 @@ public async Task CanCreatePendingReview() [DualAccountTest] public async Task CanCreatePendingReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -186,7 +186,7 @@ public async Task CanCreatePendingReviewWithRepositoryId() [DualAccountTest] public async Task CanCreateCommentedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -217,7 +217,7 @@ public async Task CanCreateCommentedReview() [DualAccountTest] public async Task CanCreateCommentedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -248,7 +248,7 @@ public async Task CanCreateCommentedReviewWithRepositoryId() [DualAccountTest] public async Task CanCreateChangesRequestedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -279,7 +279,7 @@ public async Task CanCreateChangesRequestedReview() [DualAccountTest] public async Task CanCreateChangesRequestedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -310,7 +310,7 @@ public async Task CanCreateChangesRequestedReviewWithRepositoryId() [DualAccountTest] public async Task CanCreateApprovedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -341,7 +341,7 @@ public async Task CanCreateApprovedReview() [DualAccountTest] public async Task CanCreateApprovedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -388,7 +388,7 @@ public TheDeleteMethod() [DualAccountTest] public async Task CanDeleteReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -405,7 +405,7 @@ public async Task CanDeleteReview() [DualAccountTest] public async Task CanDeleteReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -438,7 +438,7 @@ public TheDismissMethod() [DualAccountTest] public async Task CanDismissReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -453,7 +453,7 @@ public async Task CanDismissReview() [DualAccountTest] public async Task CanDismissReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -565,7 +565,7 @@ public TheSubmitMethod() [DualAccountTest] public async Task CanSubmitCommentedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -586,7 +586,7 @@ public async Task CanSubmitCommentedReview() [DualAccountTest] public async Task CanSubmitCommentedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -607,7 +607,7 @@ public async Task CanSubmitCommentedReviewWithRepositoryId() [DualAccountTest] public async Task CanSubmitChangesRequestedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -628,7 +628,7 @@ public async Task CanSubmitChangesRequestedReview() [DualAccountTest] public async Task CanSubmitChangesRequestedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -649,7 +649,7 @@ public async Task CanSubmitChangesRequestedReviewWithRepositoryId() [DualAccountTest] public async Task CanSubmitApprovedReview() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); @@ -670,7 +670,7 @@ public async Task CanSubmitApprovedReview() [DualAccountTest] public async Task CanSubmitApprovedReviewWithRepositoryId() { - using (var context = await _github.CreateRepositoryContext("test-repo")) + using (var context = await _github.CreateRepositoryContextWithAutoInit("test-repo")) { await _github.CreateTheWorld(context.Repository); var pullRequest = await _github2.CreatePullRequest(context.Repository); diff --git a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs index 0b01c08507..8985e28b32 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs @@ -25,7 +25,7 @@ public PullRequestsClientTests() _fixture = _github.Repository.PullRequest; _repositoryCommentsClient = _github.Repository.Comment; - _context = _github.CreateRepositoryContext("source-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("source-repo").Result; } [IntegrationTest] @@ -33,7 +33,7 @@ public async Task CanCreate() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); Assert.Equal("a pull request", result.Title); } @@ -43,7 +43,7 @@ public async Task CanCreateDraft() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); Assert.Equal("a draft pull request", result.Title); Assert.True(result.Draft); @@ -55,7 +55,7 @@ public async Task CanCreateFromIssue() await CreateTheWorld(); var newIssue = await _github.Issue.Create(Helper.UserName, _context.RepositoryName, new NewIssue("an issue")); - var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master"); + var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); Assert.Equal(newIssue.Number, result.Number); Assert.Equal(newIssue.Title, result.Title); @@ -66,7 +66,7 @@ public async Task CanCreateWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); Assert.Equal("a pull request", result.Title); } @@ -76,7 +76,7 @@ public async Task CanCreateDraftWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(_context.Repository.Id, newPullRequest); Assert.Equal("a draft pull request", result.Title); Assert.True(result.Draft); @@ -88,7 +88,7 @@ public async Task CanCreateFromIssueWithRepositoryId() await CreateTheWorld(); var newIssue = await _github.Issue.Create(_context.RepositoryId, new NewIssue("an issue")); - var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master"); + var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); Assert.Equal(newIssue.Number, result.Number); Assert.Equal(newIssue.Title, result.Title); @@ -99,7 +99,7 @@ public async Task CanGetForRepository() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(Helper.UserName, _context.RepositoryName); @@ -114,7 +114,7 @@ public async Task CanGetDraftForRepository() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(Helper.UserName, _context.RepositoryName); @@ -130,7 +130,7 @@ public async Task CanGetForRepositoryWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(_context.Repository.Id); @@ -144,7 +144,7 @@ public async Task CanGetDraftForRepositoryWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a draft pull request", branchName, "master") { Draft = true }; + var newPullRequest = new NewPullRequest("a draft pull request", branchName, "main") { Draft = true }; var result = await _fixture.Create(_context.Repository.Id, newPullRequest); var pullRequests = await _fixture.GetAllForRepository(_context.Repository.Id); @@ -160,7 +160,7 @@ public async Task CanGetWithAssigneesForRepository() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // Add an assignee @@ -183,7 +183,7 @@ public async Task CanGetWithAssigneesForRepositoryWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); // Add an assignee @@ -206,7 +206,7 @@ public async Task CanGetWithLabelsForRepository() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // Add a label @@ -229,7 +229,7 @@ public async Task CanGetWithLabelsForRepositoryWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(_context.Repository.Id, newPullRequest); // Add a label @@ -252,7 +252,7 @@ public async Task ReturnsCorrectCountOfPullRequestsWithoutStart() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -272,7 +272,7 @@ public async Task ReturnsCorrectCountOfPullRequestsWithoutStartWithRepositoryId( { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -292,8 +292,8 @@ public async Task ReturnsCorrectCountOfPullRequestsWithStart() { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -315,8 +315,8 @@ public async Task ReturnsCorrectCountOfPullRequestsWithStartWithRepositoryId() { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -338,8 +338,8 @@ public async Task ReturnsDistinctPullRequestsBasedOnStartPage() { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -368,8 +368,8 @@ public async Task ReturnsDistinctPullRequestsBasedOnStartPageWithRepositoryId() { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -398,7 +398,7 @@ public async Task CanGetOpenPullRequest() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Open }; @@ -413,7 +413,7 @@ public async Task CanGetOpenPullRequestWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Open }; @@ -428,7 +428,7 @@ public async Task ReturnsCorrectCountOfPullRequestsWithoutStartParameterized() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -449,7 +449,7 @@ public async Task ReturnsCorrectCountOfPullRequestsWithoutStartParameterizedWith { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var options = new ApiOptions @@ -470,8 +470,8 @@ public async Task ReturnsCorrectCountOfPullRequestsWithStartParameterized() { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -494,8 +494,8 @@ public async Task ReturnsCorrectCountOfPullRequestsWithStartParameterizedWithRep { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -518,8 +518,8 @@ public async Task ReturnsDistinctPullRequestsBasedOnStartPageParameterized() { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -550,8 +550,8 @@ public async Task ReturnsDistinctPullRequestsBasedOnStartPageParameterizedWithRe { await CreateTheWorld(); - var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "master"); - var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "master"); + var newPullRequest1 = new NewPullRequest("a pull request 1", branchName, "main"); + var newPullRequest2 = new NewPullRequest("a pull request 2", otherBranchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest1); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); @@ -582,7 +582,7 @@ public async Task IgnoresOpenPullRequest() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Closed }; @@ -596,7 +596,7 @@ public async Task IgnoresOpenPullRequestWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var openPullRequests = new PullRequestRequest { State = ItemStateFilter.Closed }; @@ -610,7 +610,7 @@ public async Task CanUpdate() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { Title = "updated title", Body = "Hello New Body", Base = "my-other-branch" }; @@ -626,7 +626,7 @@ public async Task CanUpdateWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { Title = "updated title", Body = "Hello New Body", Base = "my-other-branch" }; @@ -642,7 +642,7 @@ public async Task CanClose() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { State = ItemState.Closed }; @@ -658,7 +658,7 @@ public async Task CanFindClosedPullRequest() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var updatePullRequest = new PullRequestUpdate { State = ItemState.Closed }; @@ -675,10 +675,10 @@ public async Task CanSortPullRequests() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); - var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "master"); + var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "main"); var anotherPullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); var updatePullRequest = new PullRequestUpdate { Body = "This is the body" }; @@ -698,10 +698,10 @@ public async Task CanSpecifyDirectionOfSort() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); - var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "master"); + var newPullRequest2 = new NewPullRequest("another pull request", otherBranchName, "main"); var anotherPullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest2); var pullRequests = await _fixture.GetAllForRepository(Helper.UserName, _context.RepositoryName, new PullRequestRequest { SortDirection = SortDirection.Ascending }); @@ -716,7 +716,7 @@ public async Task IsNotMergedInitially() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Merged(Helper.UserName, _context.RepositoryName, pullRequest.Number); @@ -729,7 +729,7 @@ public async Task IsNotMergedInitiallyWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Merged(_context.Repository.Id, pullRequest.Number); @@ -742,7 +742,7 @@ public async Task CanBeMerged() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing" }; @@ -756,7 +756,7 @@ public async Task CanBeMergedWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing" }; @@ -770,7 +770,7 @@ public async Task CanBeMergedWithNoOptionalInput() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest(); @@ -784,7 +784,7 @@ public async Task CanBeMergedWithShaSpecified() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing", Sha = pullRequest.Head.Sha }; @@ -798,7 +798,7 @@ public async Task CanBeMergedWithMergeMethod() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", MergeMethod = PullRequestMergeMethod.Merge }; @@ -814,7 +814,7 @@ public async Task CanBeMergedWithSquashMethod() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", MergeMethod = PullRequestMergeMethod.Squash }; @@ -830,7 +830,7 @@ public async Task CanBeMergedWithRebaseMethod() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", MergeMethod = PullRequestMergeMethod.Rebase }; @@ -847,7 +847,7 @@ public async Task CannotBeMergedDueMismatchConflict() await CreateTheWorld(); var fakeSha = new string('f', 40); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { Sha = fakeSha }; @@ -861,12 +861,12 @@ public async Task CannotBeMergedDueNotInMergeableState() { await CreateTheWorld(); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); - var newMasterTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World, we meet again!" } }); - var masterCommit = await CreateCommit("Commit in master", newMasterTree.Sha, master.Object.Sha); - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(masterCommit.Sha)); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); + var newMainTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World, we meet again!" } }); + var mainCommit = await CreateCommit("Commit in main", newMainTree.Sha, main.Object.Sha); + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(mainCommit.Sha)); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); await Task.Delay(TimeSpan.FromSeconds(5)); @@ -883,19 +883,19 @@ public async Task CannotBeMergedDueNotInMergeableState() } [IntegrationTest] - public async Task UpdatesMaster() + public async Task UpdatesMain() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var merge = new MergePullRequest { CommitMessage = "thing the thing" }; var result = await _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - Assert.Equal(result.Sha, master.Object.Sha); + Assert.Equal(result.Sha, main.Object.Sha); } [IntegrationTest] @@ -903,7 +903,7 @@ public async Task CanBrowseCommits() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Commits(Helper.UserName, _context.RepositoryName, pullRequest.Number); @@ -917,7 +917,7 @@ public async Task CanBrowseCommitsWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); var result = await _fixture.Commits(_context.Repository.Id, pullRequest.Number); @@ -931,7 +931,7 @@ public async Task CanGetCommitsAndCommentCount() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // create new commit for branch @@ -963,7 +963,7 @@ public async Task CanGetCommitsAndCommentCountWithRepositoryId() { await CreateTheWorld(); - var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); + var newPullRequest = new NewPullRequest("a pull request", branchName, "main"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); // create new commit for branch @@ -1040,18 +1040,18 @@ public async Task CanBrowseFilesWithRepositoryId() async Task CreateTheWorld() { - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World!" } }); - var newMaster = await CreateCommit("baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World!" } }); + var newMain = await CreateCommit("baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something new" } }); - var featureBranchCommit = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); var featureBranchTree2 = await CreateTree(new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something new a 2nd time" } }); var featureBranchCommit2 = await CreateCommit("this is a 2nd commit to merge into the pull request", featureBranchTree2.Sha, featureBranchCommit.Sha); @@ -1060,7 +1060,7 @@ async Task CreateTheWorld() await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit2.Sha)); var otherFeatureBranchTree = await CreateTree(new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something else" } }); - var otherFeatureBranchCommit = await CreateCommit("this is the other commit to merge into the other pull request", otherFeatureBranchTree.Sha, newMaster.Sha); + var otherFeatureBranchCommit = await CreateCommit("this is the other commit to merge into the other pull request", otherFeatureBranchTree.Sha, newMain.Sha); await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-other-branch", otherFeatureBranchCommit.Sha)); } diff --git a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs index 9f2c62bdd2..94f6157b04 100644 --- a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs @@ -18,17 +18,17 @@ public ReferencesClientTests() _fixture = _github.Git.Reference; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] public async Task CanGetAReference() { - var @ref = await _fixture.Get("octokit", "octokit.net", "heads/master"); + var @ref = await _fixture.Get("octokit", "octokit.net", "heads/main"); // validate the top-level properties - Assert.Equal("refs/heads/master", @ref.Ref); - Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/master", @ref.Url); + Assert.Equal("refs/heads/main", @ref.Ref); + Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/main", @ref.Url); // validate the git reference Assert.Equal(TaggedType.Commit, @ref.Object.Type); @@ -38,11 +38,11 @@ public async Task CanGetAReference() [IntegrationTest] public async Task CanGetAReferenceWithRepositoryId() { - var @ref = await _fixture.Get(7528679, "heads/master"); + var @ref = await _fixture.Get(7528679, "heads/main"); // validate the top-level properties - Assert.Equal("refs/heads/master", @ref.Ref); - Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/master", @ref.Url); + Assert.Equal("refs/heads/main", @ref.Ref); + Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/main", @ref.Url); // validate the git reference Assert.Equal(TaggedType.Commit, @ref.Object.Type); diff --git a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs index 58e3f6083e..258ec656f9 100644 --- a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs @@ -32,7 +32,7 @@ public TheCreateReleasesMethod() var github = Helper.GetAuthenticatedClient(); _releaseClient = github.Repository.Release; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -71,7 +71,7 @@ public TheGetReleasesMethod() var github = Helper.GetAuthenticatedClient(); _releaseClient = github.Repository.Release; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -365,7 +365,7 @@ public TheEditMethod() _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -408,7 +408,7 @@ public async Task CanChangeCommitIshOfRelease() var releaseWithNoUpdate = new NewRelease("0.1") { Draft = true }; var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate); - Assert.Equal("master", release.TargetCommitish); + Assert.Equal("main", release.TargetCommitish); var newHead = await _github.CreateTheWorld(_context.Repository); @@ -429,7 +429,7 @@ public async Task CanChangeCommitIshOfReleaseWithRepositoryId() var releaseWithNoUpdate = new NewRelease("0.1") { Draft = true }; var release = await _releaseClient.Create(_context.Repository.Id, releaseWithNoUpdate); - Assert.Equal("master", release.TargetCommitish); + Assert.Equal("main", release.TargetCommitish); var newHead = await _github.CreateTheWorld(_context.Repository); @@ -465,7 +465,7 @@ public TheUploadAssetMethod() _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -812,7 +812,7 @@ public TheDeleteAssetsMethod() _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -867,7 +867,7 @@ public TheDeleteMethod() _github = Helper.GetAuthenticatedClient(); _releaseClient = _github.Repository.Release; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 0093885264..ce2a9fa34d 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -511,7 +511,7 @@ public class TheEditMethod : GitHubClientTestBase [IntegrationTest] public async Task UpdatesNothing() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate(); @@ -542,7 +542,7 @@ public async Task UpdatesNothing() [IntegrationTest] public async Task UpdatesName() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate() { Name = updatedName }; @@ -556,7 +556,7 @@ public async Task UpdatesName() [IntegrationTest] public async Task UpdatesNameWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate() { Name = updatedName }; @@ -570,7 +570,7 @@ public async Task UpdatesNameWithRepositoryId() [IntegrationTest] public async Task UpdatesNameObsolete() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate(updatedName); @@ -584,7 +584,7 @@ public async Task UpdatesNameObsolete() [IntegrationTest] public async Task UpdatesNameWithRepositoryIdObsolete() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); var update = new RepositoryUpdate(updatedName); @@ -598,7 +598,7 @@ public async Task UpdatesNameWithRepositoryIdObsolete() [IntegrationTest] public async Task UpdatesDescription() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Description = "Updated description" }; @@ -611,7 +611,7 @@ public async Task UpdatesDescription() [IntegrationTest] public async Task UpdatesDescriptionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Description = "Updated description" }; @@ -624,7 +624,7 @@ public async Task UpdatesDescriptionWithRepositoryId() [IntegrationTest] public async Task UpdatesHomepage() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Homepage = "http://aUrl.to/nowhere" }; @@ -637,7 +637,7 @@ public async Task UpdatesHomepage() [IntegrationTest] public async Task UpdatesHomepageWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Homepage = "http://aUrl.to/nowhere" }; @@ -650,7 +650,7 @@ public async Task UpdatesHomepageWithRepositoryId() [PaidAccountTest] public async Task UpdatesPrivate() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Private = true }; @@ -663,7 +663,7 @@ public async Task UpdatesPrivate() [PaidAccountTest] public async Task UpdatesPrivateWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Private = true }; @@ -676,7 +676,7 @@ public async Task UpdatesPrivateWithRepositoryId() [IntegrationTest] public async Task UpdatesHasIssues() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasIssues = false }; @@ -689,7 +689,7 @@ public async Task UpdatesHasIssues() [IntegrationTest] public async Task UpdatesHasIssuesWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasIssues = false }; @@ -702,7 +702,7 @@ public async Task UpdatesHasIssuesWithRepositoryId() [IntegrationTest] public async Task UpdatesHasWiki() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasWiki = false }; @@ -715,7 +715,7 @@ public async Task UpdatesHasWiki() [IntegrationTest] public async Task UpdatesHasWikiWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasWiki = false }; @@ -728,7 +728,7 @@ public async Task UpdatesHasWikiWithRepositoryId() [IntegrationTest] public async Task UpdatesHasDownloads() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasDownloads = false }; @@ -741,7 +741,7 @@ public async Task UpdatesHasDownloads() [IntegrationTest] public async Task UpdatesHasDownloadsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { HasDownloads = false }; @@ -754,7 +754,7 @@ public async Task UpdatesHasDownloadsWithRepositoryId() [IntegrationTest] public async Task UpdatesIsTemplate() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { IsTemplate = true }; @@ -767,7 +767,7 @@ public async Task UpdatesIsTemplate() [IntegrationTest] public async Task UpdatesIsTemplateWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { IsTemplate = true }; @@ -780,7 +780,7 @@ public async Task UpdatesIsTemplateWithRepositoryId() [IntegrationTest] public async Task UpdatesDefaultBranch() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var reference = _github.Git.Reference.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName).Result.First(); _github.Git.Reference.Create(repoContext.RepositoryId, new NewReference("refs/heads/primary", reference.Object.Sha)).Wait(); @@ -795,7 +795,7 @@ public async Task UpdatesDefaultBranch() [IntegrationTest] public async Task UpdatesDefaultBranchWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var reference = _github.Git.Reference.GetAll(repoContext.RepositoryOwner, repoContext.RepositoryName).Result.First(); _github.Git.Reference.Create(repoContext.RepositoryId, new NewReference("refs/heads/primary", reference.Object.Sha)).Wait(); @@ -810,9 +810,8 @@ public async Task UpdatesDefaultBranchWithRepositoryId() [IntegrationTest] public async Task UpdatesMergeMethod() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { - var updateRepository = new RepositoryUpdate() { AllowMergeCommit = false, @@ -832,7 +831,7 @@ public async Task UpdatesMergeMethod() [IntegrationTest] public async Task UpdatesMergeMethodWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updateRepository = new RepositoryUpdate() { @@ -849,23 +848,26 @@ public async Task UpdatesMergeMethodWithRepositoryId() Assert.True(editedRepository.AllowAutoMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethod() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updateRepository = new RepositoryUpdate() { DeleteBranchOnMerge = true }; var editedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, updateRepository); Assert.True(editedRepository.DeleteBranchOnMerge); + + var repository = await _github.Repository.Get(repoContext.RepositoryOwner, repoContext.RepositoryName); + Assert.True(repository.DeleteBranchOnMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethodWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var updateRepository = new RepositoryUpdate() { DeleteBranchOnMerge = true }; @@ -877,7 +879,7 @@ public async Task UpdatesDeleteBranchOnMergeMethodWithRepositoryId() [IntegrationTest] public async Task UpdatesArchive() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Archived = true }; @@ -890,7 +892,7 @@ public async Task UpdatesArchive() [IntegrationTest] public async Task UpdatesArchiveWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext()) { var update = new RepositoryUpdate() { Archived = true }; @@ -928,9 +930,10 @@ public async Task DeletesRepositoryWithRepositoryId() } } - public class TheGetMethod + public class TheGetMethod : GitHubClientTestBase { [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -945,6 +948,7 @@ public async Task ReturnsSpecifiedRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -959,6 +963,7 @@ public async Task ReturnsSpecifiedRepositoryWithRepositoryId() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsOrganizationRepository() { var github = Helper.GetAuthenticatedClient(); @@ -972,6 +977,7 @@ public async Task ReturnsOrganizationRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsRenamedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -997,6 +1003,7 @@ public async Task ReturnsRenamedRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsOrganizationRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -1010,6 +1017,7 @@ public async Task ReturnsOrganizationRepositoryWithRepositoryId() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsForkedRepository() { var github = Helper.GetAuthenticatedClient(); @@ -1021,6 +1029,7 @@ public async Task ReturnsForkedRepository() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsForkedRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -1036,7 +1045,7 @@ public async Task ReturnsRepositoryMergeOptions() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); @@ -1052,7 +1061,7 @@ public async Task ReturnsRepositoryMergeOptionsWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryId); @@ -1064,6 +1073,7 @@ public async Task ReturnsRepositoryMergeOptionsWithRepositoryId() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() { var github = Helper.GetAuthenticatedClient(); @@ -1074,13 +1084,13 @@ public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() Assert.Equal("mit", repository.License.Key); Assert.Equal("MIT License", repository.License.Name); } - + [IntegrationTest] public async Task ReturnsRepositoryDeleteBranchOnMergeOptions() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryOwner, context.RepositoryName); @@ -1093,7 +1103,7 @@ public async Task ReturnsRepositoryDeleteBranchOnMergeOptionsWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var repository = await github.Repository.Get(context.RepositoryId); @@ -1632,7 +1642,7 @@ public async Task CanChangeSortDirection() } } - public class TheGetAllLanguagesMethod + public class TheGetAllLanguagesMethod : GitHubClientTestBase { [IntegrationTest] public async Task GetsLanguages() @@ -1660,7 +1670,7 @@ public async Task GetsLanguagesWithRepositoryId() public async Task GetsEmptyLanguagesWhenNone() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var languages = await github.Repository.GetAllLanguages(context.RepositoryOwner, context.RepositoryName); @@ -1672,7 +1682,7 @@ public async Task GetsEmptyLanguagesWhenNone() public async Task GetsEmptyLanguagesWhenNoneWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); - using (var context = await github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) + using (var context = await github.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp("public-repo"))) { var languages = await github.Repository.GetAllLanguages(context.RepositoryId); @@ -2250,49 +2260,4 @@ public async Task AreVulnerabilityAlertsEnabledReturnsTrue() Assert.True(enabled); } } - - public class RepositoryTestBaseClass : IDisposable - { - protected IGitHubClient _github; - - private readonly List<RepositoryContext> _repositories; - - protected RepositoryTestBaseClass() - { - _github = Helper.GetAuthenticatedClient(); - _repositories = new List<RepositoryContext>(); - } - - public void Dispose() - { - foreach (var repository in _repositories) - { - repository.Dispose(); - } - } - - /// <summary> - /// Returns a RepositoryContext, which will be disposed at the end of the test. - /// </summary> - /// <param name="name">Your value or uses default of Helper.MakeNameWithTimestamp("public-repo");</param> - /// <returns></returns> - internal RepositoryContext CreateRepository(string name = null) - { - var newContext = _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp(name ?? Helper.MakeNameWithTimestamp("public-repo"))) { AutoInit = true }).Result; - _repositories.Add(newContext); - return newContext; - } - - /// <summary> - /// Returns a RepositoryContext, which will be disposed at the end of the test. - /// </summary> - /// <param name="name">Your value or uses default of Helper.MakeNameWithTimestamp("public-repo");</param> - /// <returns></returns> - internal async Task<RepositoryContext> CreateRepositoryAsync(string name = null) - { - var newContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp(name ?? Helper.MakeNameWithTimestamp("public-repo"))) { AutoInit = true }); - _repositories.Add(newContext); - return newContext; - } - } } diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index 9632171bf3..f2798554fa 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -14,7 +14,7 @@ public class TheGetAllMethod : GitHubClientTestBase [IntegrationTest] public async Task GetsAllBranches() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -29,7 +29,7 @@ public async Task GetsAllBranches() [IntegrationTest] public async Task GetsAllBranchesWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -44,7 +44,7 @@ public async Task GetsAllBranchesWithRepositoryId() [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithoutStart() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -71,7 +71,7 @@ public async Task ReturnsCorrectCountOfBranchesWithoutStart() [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithoutStartWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -98,7 +98,7 @@ public async Task ReturnsCorrectCountOfBranchesWithoutStartWithRepositoryId() [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithStart() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -126,7 +126,7 @@ public async Task ReturnsCorrectCountOfBranchesWithStart() [IntegrationTest] public async Task ReturnsCorrectCountOfBranchesWithStartWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -154,7 +154,7 @@ public async Task ReturnsCorrectCountOfBranchesWithStartWithRepositoryId() [IntegrationTest] public async Task GetsPagesOfBranches() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -198,7 +198,7 @@ public async Task GetsPagesOfBranches() [IntegrationTest] public async Task GetsPagesOfBranchesWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-1", repoContext.Repository.DefaultBranch); await _github.Git.Reference.CreateBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, "patch-2", repoContext.Repository.DefaultBranch); @@ -245,7 +245,7 @@ public class TheGetMethod : GitHubClientTestBase [IntegrationTest] public async Task GetsABranch() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -261,7 +261,7 @@ public async Task GetsABranch() [IntegrationTest] public async Task GetsABranchWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -280,7 +280,7 @@ public class TheGetBranchProtectionMethod : GitHubClientTestBase [IntegrationTest] public async Task GetsBranchProtection() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -307,7 +307,7 @@ public async Task GetsBranchProtection() [IntegrationTest] public async Task GetsBranchProtectionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -334,7 +334,7 @@ public async Task GetsBranchProtectionWithRepositoryId() [OrganizationTest] public async Task GetsBranchProtectionForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -358,7 +358,7 @@ public async Task GetsBranchProtectionForOrgRepo() [OrganizationTest] public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -385,7 +385,7 @@ public class TheUpdateBranchProtectionMethod : GitHubClientTestBase [IntegrationTest] public async Task UpdatesBranchProtection() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -413,7 +413,7 @@ public async Task UpdatesBranchProtection() [IntegrationTest] public async Task UpdatesBranchProtectionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -441,7 +441,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId() [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -471,7 +471,7 @@ public async Task UpdatesBranchProtectionForOrgRepo() [OrganizationTest] public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); var update = new BranchProtectionSettingsUpdate( @@ -503,7 +503,7 @@ public class TheDeleteBranchProtectionMethod : GitHubClientTestBase [IntegrationTest] public async Task DeletesBranchProtection() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -516,7 +516,7 @@ public async Task DeletesBranchProtection() [IntegrationTest] public async Task DeletesBranchProtectionWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -529,7 +529,7 @@ public async Task DeletesBranchProtectionWithRepositoryId() [OrganizationTest] public async Task DeletesBranchProtectionForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -542,7 +542,7 @@ public async Task DeletesBranchProtectionForOrgRepo() [OrganizationTest] public async Task DeletesBranchProtectionForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -558,7 +558,7 @@ public class TheGetRequiredStatusChecksMethod : GitHubClientTestBase [IntegrationTest] public async Task GetsRequiredStatusChecks() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); var requiredStatusChecks = await _github.Repository.Branch.GetRequiredStatusChecks(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); @@ -573,7 +573,7 @@ public async Task GetsRequiredStatusChecks() [IntegrationTest] public async Task GetsRequiredStatusChecksWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); var requiredStatusChecks = await _github.Repository.Branch.GetRequiredStatusChecks(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); @@ -591,7 +591,7 @@ public class TheUpdateRequiredStatusChecksMethod : GitHubClientTestBase [IntegrationTest] public async Task UpdateRequiredStatusChecks() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -609,7 +609,7 @@ public async Task UpdateRequiredStatusChecks() [IntegrationTest] public async Task UpdatesRequiredStatusChecksWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -630,7 +630,7 @@ public class TheDeleteRequiredStatusChecksMethod : GitHubClientTestBase [IntegrationTest] public async Task DeletesRequiredStatusChecks() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -643,7 +643,7 @@ public async Task DeletesRequiredStatusChecks() [IntegrationTest] public async Task DeletesRequiredStatusChecksWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -659,7 +659,7 @@ public class TheGetAllRequiredStatusChecksContextsMethod : GitHubClientTestBase [IntegrationTest] public async Task GetsRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -673,7 +673,7 @@ public async Task GetsRequiredStatusChecksContexts() [IntegrationTest] public async Task GetsRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -690,7 +690,7 @@ public class TheUpdateRequiredStatusChecksContextsMethod : GitHubClientTestBase [IntegrationTest] public async Task UpdateRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -704,7 +704,7 @@ public async Task UpdateRequiredStatusChecksContexts() [IntegrationTest] public async Task UpdatesRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -721,7 +721,7 @@ public class TheAddRequiredStatusChecksContextsMethod : GitHubClientTestBase [IntegrationTest] public async Task AddsRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -736,7 +736,7 @@ public async Task AddsRequiredStatusChecksContexts() [IntegrationTest] public async Task AddsRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -754,7 +754,7 @@ public class TheDeleteRequiredStatusChecksContextsMethod : GitHubClientTestBase [IntegrationTest] public async Task DeletesRequiredStatusChecksContexts() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -769,7 +769,7 @@ public async Task DeletesRequiredStatusChecksContexts() [IntegrationTest] public async Task DeletesRequiredStatusChecksContextsWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -787,7 +787,7 @@ public class TheGetReviewEnforcementMethod : GitHubClientTestBase [IntegrationTest] public async Task GetsReviewEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -802,7 +802,7 @@ public async Task GetsReviewEnforcement() [IntegrationTest] public async Task GetsReviewEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -817,7 +817,7 @@ public async Task GetsReviewEnforcementWithRepositoryId() [OrganizationTest] public async Task GetsReviewEnforcementForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -833,7 +833,7 @@ public async Task GetsReviewEnforcementForOrgRepo() [OrganizationTest] public async Task GetsReviewEnforcementForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -852,7 +852,7 @@ public class TheUpdateReviewEnforcementMethod : GitHubClientTestBase [IntegrationTest] public async Task UpdatesReviewEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -870,7 +870,7 @@ public async Task UpdatesReviewEnforcement() [IntegrationTest] public async Task UpdatesReviewEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -888,7 +888,7 @@ public async Task UpdatesReviewEnforcementWithRepositoryId() [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -910,7 +910,7 @@ public async Task UpdatesReviewEnforcementForOrgRepo() [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -932,7 +932,7 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -955,7 +955,7 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() [OrganizationTest] public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -981,7 +981,7 @@ public class TheRemoveReviewEnforcementMethod : GitHubClientTestBase [IntegrationTest] public async Task RemovesReviewEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -994,7 +994,7 @@ public async Task RemovesReviewEnforcement() [IntegrationTest] public async Task RemovesReviewEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1007,7 +1007,7 @@ public async Task RemovesReviewEnforcementWithRepositoryId() [OrganizationTest] public async Task RemovesReviewEnforcementForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1020,7 +1020,7 @@ public async Task RemovesReviewEnforcementForOrgRepo() [OrganizationTest] public async Task RemovesReviewEnforcementForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1036,7 +1036,7 @@ public class TheGetAdminEnforcementMethod : GitHubClientTestBase [IntegrationTest] public async Task GetsAdminEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1050,7 +1050,7 @@ public async Task GetsAdminEnforcement() [IntegrationTest] public async Task GetsAdminEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1067,7 +1067,7 @@ public class TheAddAdminEnforcementMethod : GitHubClientTestBase [IntegrationTest] public async Task AddsAdminEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1082,7 +1082,7 @@ public async Task AddsAdminEnforcement() [IntegrationTest] public async Task AddsAdminEnforcementoWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1100,7 +1100,7 @@ public class TheRemoveAdminEnforcementMethod : GitHubClientTestBase [IntegrationTest] public async Task RemovesAdminEnforcement() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1118,7 +1118,7 @@ public async Task RemovesAdminEnforcement() [IntegrationTest] public async Task RemovesAdminEnforcementWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateUserRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranch(repoContext); @@ -1137,11 +1137,11 @@ public async Task RemovesAdminEnforcementWithRepositoryId() public class TheGetProtectedBranchRestrictionsMethod : GitHubClientTestBase { [OrganizationTest] - public async Task GetsRequirProtectedBranchRestrictionsForOrgRepo() + public async Task GetsProtectedBranchRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var restrictions = await _github.Repository.Branch.GetProtectedBranchRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); @@ -1153,9 +1153,9 @@ public async Task GetsRequirProtectedBranchRestrictionsForOrgRepo() [OrganizationTest] public async Task GetsProtectedBranchRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var restrictions = await _github.Repository.Branch.GetProtectedBranchRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); @@ -1170,9 +1170,9 @@ public class TheDeleteProtectedBranchRestrictionsMethod : GitHubClientTestBase [OrganizationTest] public async Task DeletesRProtectedBranchRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var deleted = await _github.Repository.Branch.DeleteProtectedBranchRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch); @@ -1183,9 +1183,9 @@ public async Task DeletesRProtectedBranchRestrictionsForOrgRepo() [OrganizationTest] public async Task DeletesProtectedBranchRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { - await _github.ProtectDefaultBranch(repoContext); + await _github.ProtectDefaultBranchWithTeam(repoContext); var deleted = await _github.Repository.Branch.DeleteProtectedBranchRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch); @@ -1199,7 +1199,7 @@ public class TheGetAllProtectedBranchTeamRestrictionsMethod : GitHubClientTestBa [OrganizationTest] public async Task GetsProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1213,7 +1213,7 @@ public async Task GetsProtectedBranchTeamRestrictionsForOrgRepo() [OrganizationTest] public async Task GetsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1230,7 +1230,7 @@ public class TheUpdateProtectedBranchTeamRestrictionsMethod : GitHubClientTestBa [OrganizationTest] public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1254,7 +1254,7 @@ await _github.Organization.Team.AddRepository( [OrganizationTest] public async Task UpdatesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1281,7 +1281,7 @@ public class TheAddProtectedBranchTeamRestrictionsMethod : GitHubClientTestBase [OrganizationTest] public async Task AddsProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1305,7 +1305,7 @@ await _github.Organization.Team.AddRepository( [OrganizationTest] public async Task AddsProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1332,7 +1332,7 @@ public class TheDeleteProtectedBranchTeamRestrictions : GitHubClientTestBase [OrganizationTest] public async Task DeletesRProtectedBranchTeamRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { var team = await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1347,7 +1347,7 @@ public async Task DeletesRProtectedBranchTeamRestrictionsForOrgRepo() [OrganizationTest] public async Task DeletesProtectedBranchTeamRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { var team = await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1365,7 +1365,7 @@ public class TheGetAllProtectedBranchUserRestrictionsMethod : GitHubClientTestBa [OrganizationTest] public async Task GetsProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1379,7 +1379,7 @@ public async Task GetsProtectedBranchUserRestrictionsForOrgRepo() [OrganizationTest] public async Task GetsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1396,7 +1396,7 @@ public class TheUpdateProtectedBranchUserRestrictionsMethod : GitHubClientTestBa [OrganizationTest] public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1412,7 +1412,7 @@ public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepo() [OrganizationTest] public async Task UpdatesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1431,7 +1431,7 @@ public class TheAddProtectedBranchUserRestrictionsMethod : GitHubClientTestBase [OrganizationTest] public async Task AddsProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { var team = await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1447,7 +1447,7 @@ public async Task AddsProtectedBranchUserRestrictionsForOrgRepo() [OrganizationTest] public async Task AddsProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1466,7 +1466,7 @@ public class TheDeleteProtectedBranchUserRestrictions : GitHubClientTestBase [OrganizationTest] public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); @@ -1486,7 +1486,7 @@ public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo() [OrganizationTest] public async Task DeletesProtectedBranchUserRestrictionsForOrgRepoWithRepositoryId() { - using (var repoContext = await _github.CreateOrganizationRepositoryContext()) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(x => x.AutoInit = true)) { await _github.ProtectDefaultBranchWithTeam(repoContext); diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index aaccd9dfe1..0cc715e992 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -41,7 +41,7 @@ public async Task CanGetCommentWithRepositoryId() [IntegrationTest] public async Task CanGetReactionPayload() { - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) { // Create a test commit var commit = await HelperCreateCommit(context.RepositoryOwner, context.RepositoryName); @@ -204,7 +204,7 @@ public async Task ReturnsDistinctResultsBasedOnStartWithRepositoryId() public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) { var commentIds = new List<int>(); @@ -379,7 +379,7 @@ public async Task ReturnsDistinctResultsBasedOnStartForCommitWithRepositoryId() public async Task CanGetReactionPayload() { var numberToCreate = 2; - using (var context = await _github.CreateRepositoryContext(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) + using (var context = await _github.CreateRepositoryContextWithAutoInit(Helper.MakeNameWithTimestamp("CommitCommentsReactionTests"))) { var commentIds = new List<int>(); @@ -423,7 +423,7 @@ public class TheCreateMethod : IDisposable public TheCreateMethod() { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task<Commit> SetupCommitForRepository(IGitHubClient client) @@ -532,7 +532,7 @@ public TheUpdateMethod() { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task<Commit> SetupCommitForRepository(IGitHubClient client) @@ -621,7 +621,7 @@ public TheDeleteMethod() { _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } private async Task<Commit> SetupCommitForRepository(IGitHubClient client) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index 3332d56d64..e1d769f872 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -285,7 +285,7 @@ public async Task CanGetCommitWithRenamedFilesWithRepositoryId() [IntegrationTest] public async Task CanGetSha1() { - var sha1 = await _fixture.GetSha1(octokitNetRepositoryOwner, octokitNetRepositorName, "master"); + var sha1 = await _fixture.GetSha1(octokitNetRepositoryOwner, octokitNetRepositorName, "main"); Assert.NotNull(sha1); } @@ -293,7 +293,7 @@ public async Task CanGetSha1() [IntegrationTest] public async Task CanGetSha1WithRepositoryId() { - var sha1 = await _fixture.GetSha1(octokitNetRepositoryId, "master"); + var sha1 = await _fixture.GetSha1(octokitNetRepositoryId, "main"); Assert.NotNull(sha1); } @@ -311,7 +311,7 @@ public TestsWithNewRepository() _fixture = _github.Repository.Commit; - _context = _github.CreateRepositoryContext("source-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("source-repo").Result; } [IntegrationTest] @@ -319,7 +319,7 @@ public async Task CanCompareReferences() { await CreateTheWorld(); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "master", "my-branch"); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "main", "my-branch"); Assert.Equal(1, result.TotalCommits); Assert.Equal(1, result.Commits.Count); @@ -332,7 +332,7 @@ public async Task CanCompareReferencesWithRepositoryId() { await CreateTheWorld(); - var result = await _fixture.Compare(_context.Repository.Id, "master", "my-branch"); + var result = await _fixture.Compare(_context.Repository.Id, "main", "my-branch"); Assert.Equal(1, result.TotalCommits); Assert.Equal(1, result.Commits.Count); @@ -345,7 +345,7 @@ public async Task CanCompareReferencesOtherWayRound() { await CreateTheWorld(); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "master"); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "main"); Assert.Equal(0, result.TotalCommits); Assert.Equal(0, result.Commits.Count); @@ -358,7 +358,7 @@ public async Task CanCompareReferencesOtherWayRoundWithRepositoryId() { await CreateTheWorld(); - var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "master"); + var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "main"); Assert.Equal(0, result.TotalCommits); Assert.Equal(0, result.Commits.Count); @@ -371,7 +371,7 @@ public async Task ReturnsUrlsToResources() { await CreateTheWorld(); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "master"); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, "my-branch", "main"); Assert.NotNull(result.DiffUrl); Assert.NotNull(result.HtmlUrl); @@ -384,7 +384,7 @@ public async Task ReturnsUrlsToResourcesWithRepositoryId() { await CreateTheWorld(); - var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "master"); + var result = await _fixture.Compare(_context.Repository.Id, "my-branch", "main"); Assert.NotNull(result.DiffUrl); Assert.NotNull(result.HtmlUrl); @@ -397,10 +397,10 @@ public async Task CanCompareUsingSha() { await CreateTheWorld(); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); var branch = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/my-branch"); - var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, master.Object.Sha, branch.Object.Sha); + var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, main.Object.Sha, branch.Object.Sha); Assert.Equal(1, result.Commits.Count); Assert.Equal(1, result.AheadBy); @@ -412,10 +412,10 @@ public async Task CanCompareUsingShaWithRepositoryId() { await CreateTheWorld(); - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); var branch = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/my-branch"); - var result = await _fixture.Compare(_context.Repository.Id, master.Object.Sha, branch.Object.Sha); + var result = await _fixture.Compare(_context.Repository.Id, main.Object.Sha, branch.Object.Sha); Assert.Equal(1, result.Commits.Count); Assert.Equal(1, result.AheadBy); @@ -444,18 +444,18 @@ public async Task GetSha1FromRepositoryWithRepositoryId() async Task<Reference> CreateTheWorld() { - var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var main = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/main"); - // create new commit for master branch - var newMasterTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World!" } }); - var newMaster = await CreateCommit("baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World!" } }); + var newMain = await CreateCommit("baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something new" } }); - var newFeature = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var newFeature = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); // create branch return await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", newFeature.Sha)); diff --git a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs index 099209d1b5..0501c092c7 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs @@ -73,7 +73,7 @@ public async Task GetsFileContent() Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -88,7 +88,7 @@ public async Task GetsFileContentWithRepositoryId() Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -131,7 +131,7 @@ public async Task GetsFileContentWholeRepo() Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -146,7 +146,7 @@ public async Task GetsFileContentWholeRepoWithRepositoryId() Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -186,11 +186,11 @@ public async Task GetsFileContent() var contents = await github .Repository .Content - .GetAllContentsByRef("octokit", "octokit.net", "Octokit.Reactive/ObservableGitHubClient.cs", "master"); + .GetAllContentsByRef("octokit", "octokit.net", "Octokit.Reactive/ObservableGitHubClient.cs", "main"); Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -201,11 +201,11 @@ public async Task GetsFileContentWithRepositoryId() var contents = await github .Repository .Content - .GetAllContentsByRef(7528679, "Octokit.Reactive/ObservableGitHubClient.cs", "master"); + .GetAllContentsByRef(7528679, "Octokit.Reactive/ObservableGitHubClient.cs", "main"); Assert.Equal(1, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octokit/octokit.net/blob/master/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octokit/octokit.net/blob/main/Octokit.Reactive/ObservableGitHubClient.cs", contents.First().HtmlUrl); } [IntegrationTest] @@ -237,7 +237,7 @@ public async Task GetsDirectoryContentWithTrailingSlash() } [IntegrationTest] - public async Task GetsContentNonMasterWithRootPath() + public async Task GetsContentNonMainWithRootPath() { var github = Helper.GetAuthenticatedClient(); @@ -256,7 +256,7 @@ public async Task GetsDirectoryContentWithRepositoryId() var contents = await github .Repository .Content - .GetAllContentsByRef(7528679, "Octokit", "master"); + .GetAllContentsByRef(7528679, "Octokit", "main"); Assert.True(contents.Count > 2); Assert.Equal(ContentType.Dir, contents.First().Type); @@ -270,11 +270,11 @@ public async Task GetsFileContentWholeRepo() var contents = await github .Repository .Content - .GetAllContentsByRef("octocat", "Spoon-Knife", "master"); + .GetAllContentsByRef("octocat", "Spoon-Knife", "main"); Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -285,11 +285,11 @@ public async Task GetsFileContentWholeRepoWithRepositoryId() var contents = await github .Repository .Content - .GetAllContentsByRef(1300192, "master"); + .GetAllContentsByRef(1300192, "main"); Assert.Equal(3, contents.Count); Assert.Equal(ContentType.File, contents.First().Type); - Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/master/README.md", contents.First().HtmlUrl); + Assert.Equal("https://github.com/octocat/Spoon-Knife/blob/main/README.md", contents.First().HtmlUrl); } [IntegrationTest] @@ -300,7 +300,7 @@ public async Task GetsDirectoryContentWholeRepo() var contents = await github .Repository .Content - .GetAllContentsByRef("octocat", "octocat.github.io", "master"); + .GetAllContentsByRef("octocat", "octocat.github.io", "main"); Assert.NotEmpty(contents); } @@ -313,7 +313,7 @@ public async Task GetsDirectoryContentWholeRepoWithRepositoryId() var contents = await github .Repository .Content - .GetAllContentsByRef(17881631, "master"); + .GetAllContentsByRef(17881631, "main"); Assert.NotEmpty(contents); } @@ -416,8 +416,8 @@ public async Task CrudTestWithNamedBranch() { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Owner.Login, repository.Name, @@ -463,8 +463,8 @@ public async Task CrudTestWithNamedBranchWithRepositoryId() { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Id, "somefile.txt", @@ -592,8 +592,8 @@ public async Task CrudTestWithNamedBranchWithExplicitBase64() { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Owner.Login, repository.Name, @@ -639,8 +639,8 @@ public async Task CrudTestWithNamedBranchWithRepositoryIdWithExplicitBase64() { var repository = context.Repository; - var master = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/master"); - await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, master.Object.Sha)); + var main = await client.Git.Reference.Get(Helper.UserName, repository.Name, "heads/main"); + await client.Git.Reference.Create(Helper.UserName, repository.Name, new NewReference("refs/heads/" + branchName, main.Object.Sha)); var file = await fixture.CreateFile( repository.Id, "somefile.txt", @@ -733,7 +733,7 @@ public async Task GetsArchiveForReleaseBranchAsTarball() var archive = await github .Repository .Content - .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "master"); + .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "main"); Assert.NotEmpty(archive); } @@ -746,7 +746,7 @@ public async Task GetsArchiveForReleaseBranchAsTarballWithRepositoryId() var archive = await github .Repository .Content - .GetArchive(1296269, ArchiveFormat.Tarball, "master"); // octocat/Hello-World repo + .GetArchive(1296269, ArchiveFormat.Tarball, "main"); // octocat/Hello-World repo Assert.NotEmpty(archive); } @@ -759,7 +759,7 @@ public async Task GetsArchiveForReleaseBranchAsTarballWithTimeout() var archive = await github .Repository .Content - .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "master", TimeSpan.FromMinutes(60)); + .GetArchive("octocat", "Hello-World", ArchiveFormat.Tarball, "main", TimeSpan.FromMinutes(60)); Assert.NotEmpty(archive); } @@ -772,7 +772,7 @@ public async Task GetsArchiveForReleaseBranchAsTarballWithTimeoutWithRepositoryI var archive = await github .Repository .Content - .GetArchive(1296269, ArchiveFormat.Tarball, "master", TimeSpan.FromMinutes(60)); // octocat/Hello-World repo + .GetArchive(1296269, ArchiveFormat.Tarball, "main", TimeSpan.FromMinutes(60)); // octocat/Hello-World repo Assert.NotEmpty(archive); } diff --git a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs index b9e29ae486..36ed67a14b 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs @@ -19,7 +19,7 @@ public RepositoryDeployKeysClientTests() var github = Helper.GetAuthenticatedClient(); _fixture = github.Repository.DeployKeys; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index 506da6f7e6..c64d6a02f2 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -640,7 +640,7 @@ public async Task SearchForExcludedHead() [IntegrationTest] public async Task SearchForExcludedBase() { - var branch = "master"; + var branch = "main"; // Search for issues by target branch var request = new SearchIssuesRequest(); diff --git a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs index 7efca125c1..9809e7ce8e 100644 --- a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs @@ -19,7 +19,7 @@ public StatisticsClientTests() [IntegrationTest] public async Task CanCreateAndRetrieveContributors() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -40,7 +40,7 @@ public async Task CanCreateAndRetrieveContributors() [IntegrationTest] public async Task CanCreateAndRetrieveContributorsWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -88,7 +88,7 @@ public async Task CanCreateAndRetrieveEmptyContributorsWithRepositoryId() [IntegrationTest] public async Task CanGetCommitActivityForTheLastYear() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -106,7 +106,7 @@ public async Task CanGetCommitActivityForTheLastYear() [IntegrationTest] public async Task CanGetCommitActivityForTheLastYearWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -124,7 +124,7 @@ public async Task CanGetCommitActivityForTheLastYearWithRepositoryId() [IntegrationTest] public async Task CanGetAdditionsAndDeletionsPerWeek() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -137,7 +137,7 @@ public async Task CanGetAdditionsAndDeletionsPerWeek() [IntegrationTest] public async Task CanGetAdditionsAndDeletionsPerWeekWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -151,7 +151,7 @@ public async Task CanGetAdditionsAndDeletionsPerWeekWithRepositoryId() [IntegrationTest] public async Task CanGetParticipationStatistics() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -163,7 +163,7 @@ public async Task CanGetParticipationStatistics() [IntegrationTest] public async Task CanGetParticipationStatisticsWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -175,7 +175,7 @@ public async Task CanGetParticipationStatisticsWithRepositoryId() [IntegrationTest] public async Task CanGetPunchCardForRepository() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); @@ -188,7 +188,7 @@ public async Task CanGetPunchCardForRepository() [IntegrationTest] public async Task CanGetPunchCardForRepositoryWithRepositoryId() { - using (var context = await _client.CreateRepositoryContext("public-repo")) + using (var context = await _client.CreateRepositoryContextWithAutoInit("public-repo")) { var repository = new RepositorySummary(context); await CommitToRepository(repository); diff --git a/Octokit.Tests.Integration/Clients/TagsClientTests.cs b/Octokit.Tests.Integration/Clients/TagsClientTests.cs index 3fc83ee5f6..3aedbaf0b2 100644 --- a/Octokit.Tests.Integration/Clients/TagsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TagsClientTests.cs @@ -17,7 +17,7 @@ public TheCreateMethod() var github = Helper.GetAuthenticatedClient(); fixture = github.Git.Tag; - context = github.CreateRepositoryContext("public-repo").Result; + context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { @@ -65,7 +65,7 @@ public TheGetMethod() var github = Helper.GetAuthenticatedClient(); fixture = github.Git.Tag; - context = github.CreateRepositoryContext("public-repo").Result; + context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; var blob = new NewBlob { diff --git a/Octokit.Tests.Integration/Clients/TreeClientTests.cs b/Octokit.Tests.Integration/Clients/TreeClientTests.cs index ea7d2b7ed6..a069bb445c 100644 --- a/Octokit.Tests.Integration/Clients/TreeClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TreeClientTests.cs @@ -17,7 +17,7 @@ public TreeClientTests() _fixture = _github.Git.Tree; - _context = _github.CreateRepositoryContext("public-repo").Result; + _context = _github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] @@ -73,7 +73,7 @@ public async Task CanCreateATreeWithRepositoryId() [IntegrationTest] public async Task CanGetATree() { - var result = await _fixture.Get("octokit", "octokit.net", "master"); + var result = await _fixture.Get("octokit", "octokit.net", "main"); Assert.NotNull(result); Assert.NotEmpty(result.Tree); @@ -82,7 +82,7 @@ public async Task CanGetATree() [IntegrationTest] public async Task CanGetATreeWithRepositoryId() { - var result = await _fixture.Get(1, "master"); + var result = await _fixture.Get(1, "main"); Assert.NotNull(result); Assert.NotEmpty(result.Tree); diff --git a/Octokit.Tests.Integration/Clients/WatchedClientTests.cs b/Octokit.Tests.Integration/Clients/WatchedClientTests.cs index e49f186a19..beb067a0b5 100644 --- a/Octokit.Tests.Integration/Clients/WatchedClientTests.cs +++ b/Octokit.Tests.Integration/Clients/WatchedClientTests.cs @@ -299,7 +299,7 @@ public TheCheckWatchedMethod() _watchingClient = github.Activity.Watching; - _context = github.CreateRepositoryContext("public-repo").Result; + _context = github.CreateRepositoryContextWithAutoInit("public-repo").Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 455b8a7de2..2bc13c74bf 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -247,6 +247,8 @@ public static string MakeNameWithTimestamp(string name) return string.Concat(name, "-", DateTime.UtcNow.ToString("yyyyMMddhhmmssfff")); } + public static bool IsNameTimestamped(string name) => name.Contains("-") && name.Substring(name.LastIndexOf("-")).Length == 18; + public static Stream LoadFixture(string fileName) { var key = "Octokit.Tests.Integration.fixtures." + fileName; diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs index a30f4e624a..941aeb9371 100644 --- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs @@ -1,39 +1,97 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; namespace Octokit.Tests.Integration.Helpers { internal static class GithubClientExtensions { /// <summary> - /// Creates a public repository with the timestamped name public-repo + /// Creates a public repository with the timestamped name public-repo and autoinit true /// </summary> - internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client) + internal static async Task<RepositoryContext> CreateRepositoryContextWithAutoInit(this IGitHubClient client) { - var repoName = Helper.MakeNameWithTimestamp("public-repo"); - var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); + return await client.CreateUserRepositoryContext(x => x.AutoInit = true); + } + + /// <summary> + /// Creates a public repository with the repository name passed in and autoinit true + /// </summary> + internal static async Task<RepositoryContext> CreateRepositoryContextWithAutoInit(this IGitHubClient client, string repositoryName) + { + return await client.CreateUserRepositoryContext(Helper.MakeNameWithTimestamp(repositoryName), x => x.AutoInit = true); + } + + internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) + { + var repo = await client.Repository.Create(newRepository); return new RepositoryContext(client.Connection, repo); } - internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string repositoryName) + /// <summary> + /// Creates a public repository with the timestamped name "public-repo" and an optional function of parameters passed in + /// </summary> + /// <param name="client"></param> + /// <param name="repositoryName">The name of the repository without the timestamp</param> + /// <param name="action">Function setting parameters on the NewRepository</param> + /// <returns></returns> + internal static async Task<RepositoryContext> CreateUserRepositoryContext(this IGitHubClient client, Action<NewRepository> action = null) { - var repoName = Helper.MakeNameWithTimestamp(repositoryName); - var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); + var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(newRepository); return new RepositoryContext(client.Connection, repo); } - internal static async Task<RepositoryContext> CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) + /// <summary> + /// Creates a public repository with the repository name and an optional function of parameters passed in + /// </summary> + /// <param name="client"></param> + /// <param name="repositoryName">The name of the repository without the timestamp</param> + /// <param name="action"></param> + /// <returns></returns> + internal static async Task<RepositoryContext> CreateUserRepositoryContext(this IGitHubClient client, string repositoryName, Action<NewRepository> action = null) { + var newRepository = new NewRepository(Helper.IsNameTimestamped(repositoryName) ? repositoryName : Helper.MakeNameWithTimestamp(repositoryName)); + action?.Invoke(newRepository); + var repo = await client.Repository.Create(newRepository); return new RepositoryContext(client.Connection, repo); } /// <summary> - /// Creates an organisationrepository with the timestamped name organisation-repo + /// Creates an organisation repository with the timestamped name organisation-repo and an optional function of parameters /// </summary> - internal static async Task<RepositoryContext> CreateOrganizationRepositoryContext(this IGitHubClient client) + internal static async Task<RepositoryContext> CreateOrganizationRepositoryContext(this IGitHubClient client, Action<NewRepository> action = null) + { + var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("organization-repo")); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(Helper.Organization, newRepository); + + return new RepositoryContext(client.Connection, repo); + } + + /// <summary> + /// Creates an organisation repository with the passed in repository name repo and an optional function of parameters + /// </summary> + internal static async Task<RepositoryContext> CreateOrganizationRepositoryContext(this IGitHubClient client, string repositoryName, Action<NewRepository> action = null) + { + var newRepository = new NewRepository(Helper.IsNameTimestamped(repositoryName) ? repositoryName : Helper.MakeNameWithTimestamp(repositoryName)); + action?.Invoke(newRepository); + + var repo = await client.Repository.Create(Helper.Organization, newRepository); + + return new RepositoryContext(client.Connection, repo); + } + + /// <summary> + /// Creates an organisation repository with the timestamped name organisation-repo + /// </summary> + internal static async Task<RepositoryContext> CreateOrganizationRepositoryContextWithAutoInit(this IGitHubClient client, Action<NewRepository> action = null) { var repoName = Helper.MakeNameWithTimestamp("organization-repo"); var repo = await client.Repository.Create(Helper.Organization, new NewRepository(repoName) { AutoInit = true }); @@ -51,6 +109,17 @@ internal static async Task<RepositoryContext> CreateOrganizationRepositoryContex return new RepositoryContext(client.Connection, repo); } + /// <summary> + /// Creates a private repository with the timestamped name private-repo + /// </summary> + internal static async Task<RepositoryContext> CreatePrivateRepositoryContext(this IGitHubClient client) + { + var repoName = Helper.MakeNameWithTimestamp("private-repo"); + var repo = await client.Repository.Create(new NewRepository(repoName) { Private = true }); + + return new RepositoryContext(client.Connection, repo); + } + internal static async Task<RepositoryContext> Generate(this IGitHubClient client, string owner, string repoName, NewRepositoryFromTemplate newRepository) { var repo = await client.Repository.Generate(owner, repoName, newRepository); diff --git a/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs b/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs index 01d1ae16fa..952b8fdf6a 100644 --- a/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs +++ b/Octokit.Tests.Integration/Helpers/PaidAccountTestAttribute.cs @@ -23,6 +23,14 @@ public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions disco if (!Helper.IsPaidAccount) return Enumerable.Empty<IXunitTestCase>(); + var github = Helper.GetAuthenticatedClient(); + + var userDetails = github.User.Current().Result; + if (userDetails.Plan.PrivateRepos == 0) + { + return Enumerable.Empty<IXunitTestCase>(); + } + return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) }; } } diff --git a/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs b/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs index 3a7f91133f..19eeddd612 100644 --- a/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs +++ b/Octokit.Tests.Integration/Helpers/ReferenceExtensionsTests.cs @@ -13,11 +13,11 @@ public async Task CreateABranch() var client = Helper.GetAuthenticatedClient(); var fixture = client.Git.Reference; - using (var context = await client.CreateRepositoryContext("public-repo")) + using (var context = await client.CreateRepositoryContextWithAutoInit("public-repo")) { - var branchFromMaster = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-1", context.Repository.DefaultBranch); + var branchFromMain = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-1", context.Repository.DefaultBranch); - var branchFromPath = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-2", branchFromMaster); + var branchFromPath = await fixture.CreateBranch(context.RepositoryOwner, context.RepositoryName, "patch-2", branchFromMain); var allBranchNames = (await client.Repository.Branch.GetAll(context.RepositoryOwner, context.RepositoryName)).Select(b => b.Name); diff --git a/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs b/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs index 3bfa7f4d02..49cbe1d88b 100644 --- a/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs +++ b/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs @@ -44,18 +44,18 @@ public static async Task<Commit> CreateCommit(this IGitHubClient client, Reposit public static async Task<Reference> CreateTheWorld(this IGitHubClient client, Repository repository) { - var master = await client.Git.Reference.Get(repository.Owner.Login, repository.Name, "heads/master"); + var main = await client.Git.Reference.Get(repository.Owner.Login, repository.Name, "heads/main"); - // create new commit for master branch - var newMasterTree = await client.CreateTree(repository, new Dictionary<string, string> { { "README.md", "Hello World!" } }); - var newMaster = await client.CreateCommit(repository, "baseline for pull request", newMasterTree.Sha, master.Object.Sha); + // create new commit for main branch + var newMainTree = await client.CreateTree(repository, new Dictionary<string, string> { { "README.md", "Hello World!" } }); + var newMain = await client.CreateCommit(repository, "baseline for pull request", newMainTree.Sha, main.Object.Sha); - // update master - await client.Git.Reference.Update(repository.Owner.Login, repository.Name, "heads/master", new ReferenceUpdate(newMaster.Sha)); + // update main + await client.Git.Reference.Update(repository.Owner.Login, repository.Name, "heads/main", new ReferenceUpdate(newMain.Sha)); // create new commit for feature branch var featureBranchTree = await client.CreateTree(repository, new Dictionary<string, string> { { "README.md", "I am overwriting this blob with something new\nand a second line too" } }); - var featureBranchCommit = await client.CreateCommit(repository, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); + var featureBranchCommit = await client.CreateCommit(repository, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMain.Sha); // create branch return await client.Git.Reference.Create(repository.Owner.Login, repository.Name, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); @@ -63,7 +63,7 @@ public static async Task<Reference> CreateTheWorld(this IGitHubClient client, Re public static async Task<PullRequest> CreatePullRequest(this IGitHubClient client, Repository repository, string branch = "my-branch") { - var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "master"); + var pullRequest = new NewPullRequest("Nice title for the pull request", branch, "main"); var createdPullRequest = await client.PullRequest.Create(repository.Owner.Login, repository.Name, pullRequest); return createdPullRequest; diff --git a/Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs b/Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs new file mode 100644 index 0000000000..4de5e69847 --- /dev/null +++ b/Octokit.Tests.Integration/PotentiallyFlakyTestAttribute.cs @@ -0,0 +1,13 @@ +using System; + +namespace Octokit.Tests.Integration +{ + /// <summary> + /// A potentially flaky test could be: + /// * Calls for details of repositories which already exist and was not created by the test itself (so could disappear over time) + /// * Calls for details of users which already exist (so could disappear over time) + /// </summary> + public class PotentiallyFlakyTestAttribute : Attribute + { + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs index c7b95c492e..dad48855c9 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckRunsClientTests.cs @@ -29,7 +29,7 @@ public async Task CreatesCheckRun() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -51,7 +51,7 @@ public async Task CreatesCheckRunWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -87,7 +87,7 @@ public async Task UpdatesCheckRun() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -119,7 +119,7 @@ public async Task UpdatesCheckRunWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -165,7 +165,7 @@ public async Task GetsAllCheckRuns() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -200,7 +200,7 @@ public async Task GetsAllCheckRunsWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -249,7 +249,7 @@ public async Task GetsAllCheckRuns() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -284,7 +284,7 @@ public async Task GetsAllCheckRunsWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -401,7 +401,7 @@ public async Task GetsAllAnnotations() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch @@ -434,7 +434,7 @@ public async Task GetsAllAnnotationsWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check run for the feature branch diff --git a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs index 68cc68df07..b9b44c28f8 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCheckSuitesClientTests.cs @@ -28,7 +28,7 @@ public async Task GetsCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -46,7 +46,7 @@ public async Task GetsCheckSuiteWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); // Get Check Suite by Id @@ -77,7 +77,7 @@ public async Task GetsAllCheckSuites() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "main"); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha); @@ -94,7 +94,7 @@ public async Task GetsAllCheckSuitesWithRepositoryId() { using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuites = await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha); @@ -178,7 +178,7 @@ public async Task CreatesCheckSuite() await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryOwner, repoContext.RepositoryName, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryOwner, repoContext.RepositoryName, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -201,7 +201,7 @@ public async Task CreatesCheckSuiteWithRepositoryId() await _githubAppInstallation.Check.Suite.UpdatePreferences(repoContext.RepositoryId, preference); // Create a new feature branch - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var featureBranch = await Helper.CreateFeatureBranch(repoContext.RepositoryOwner, repoContext.RepositoryName, headCommit.Sha, "my-feature"); // Create a check suite for the feature branch @@ -234,7 +234,7 @@ public async Task RerequestsCheckSuite() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryOwner, repoContext.RepositoryName, checkSuite.Id); @@ -249,7 +249,7 @@ public async Task RerequestsCheckSuiteWithRepositoryId() using (var repoContext = await _github.CreateRepositoryContext(new NewRepository(Helper.MakeNameWithTimestamp("public-repo")) { AutoInit = true })) { // Need to get a CheckSuiteId so we can test the Get method - var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "master"); + var headCommit = await _github.Repository.Commit.Get(repoContext.RepositoryId, "main"); var checkSuite = (await _githubAppInstallation.Check.Suite.GetAllForReference(repoContext.RepositoryId, headCommit.Sha)).CheckSuites.First(); var result = await _githubAppInstallation.Check.Suite.Rerequest(repoContext.RepositoryId, checkSuite.Id); From 6892df80fe73478d81f387ed1711ed8219b1adbe Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Wed, 27 Jul 2022 19:53:02 +0100 Subject: [PATCH 092/209] feat: Adds codeowners errors endpoint (#2512) --- .../Clients/IObservableRepositoriesClient.cs | 16 +++++ .../Clients/ObservableRepositoriesClient.cs | 26 +++++++++ .../Clients/RepositoriesClientTests.cs | 36 ++++++++++++ .../Clients/RepositoriesClientTests.cs | 36 ++++++++++++ Octokit/Clients/IRepositoriesClient.cs | 16 +++++ Octokit/Clients/RepositoriesClient.cs | 28 ++++++++- Octokit/Helpers/ApiUrls.cs | 21 +++++++ .../Response/RepositoryCodeOwnersErrors.cs | 58 +++++++++++++++++++ Octokit/Models/Response/RepositoryTag.cs | 3 +- 9 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 Octokit/Models/Response/RepositoryCodeOwnersErrors.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index dd5c78bc85..3d5167d8df 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -650,5 +650,21 @@ public interface IObservableRepositoriesClient /// <returns>All topics now associated with the repository.</returns> IObservable<RepositoryTopics> ReplaceAllTopics(string owner, string name, RepositoryTopics topics); + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/codeowners/errors")] + IObservable<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(string owner, string name); + + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repositories/{id}/codeowners/errors")] + IObservable<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(long repositoryId); } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 80f68d1009..4e23db5923 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -753,6 +753,32 @@ public IObservable<RepositoryContentLicense> GetLicenseContents(long repositoryI return _client.GetLicenseContents(repositoryId).ToObservable(); } + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/codeowners/errors")] + public IObservable<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.GetAllCodeOwnersErrors(owner, name).ToObservable(); + } + + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repositories/{id}/codeowners/errors")] + public IObservable<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(long repositoryId) + { + return _client.GetAllCodeOwnersErrors(repositoryId).ToObservable(); + } + /// <summary> /// Updates the specified repository with the values given in <paramref name="update"/> /// </summary> diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index ce2a9fa34d..6aeb8fc263 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; @@ -2102,6 +2103,7 @@ public async Task GetsPagesOfBranchesWithRepositoryId() public class TheGetLicenseContentsMethod { [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsLicenseContent() { var github = Helper.GetAuthenticatedClient(); @@ -2114,6 +2116,7 @@ public async Task ReturnsLicenseContent() } [IntegrationTest] + [PotentiallyFlakyTest] public async Task ReturnsLicenseContentWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); @@ -2126,6 +2129,39 @@ public async Task ReturnsLicenseContentWithRepositoryId() } } + public class TheGetCodeOwnersErrorsMethod : GitHubClientTestBase + { + [IntegrationTest] + public async Task ReturnsCodeOwnersErrors() + { + using (var repoContext = await _github.CreateUserRepositoryContext()) + { + await _github.Repository.Content.CreateFile(repoContext.RepositoryOwner, repoContext.RepositoryName, ".github/codeowners", new CreateFileRequest("Create codeowners", @"* snyrting6@hotmail.com")); + + // Sometimes it takes a second to create the file + Thread.Sleep(TimeSpan.FromSeconds(2)); + + var license = await _github.Repository.GetAllCodeOwnersErrors(repoContext.RepositoryOwner, repoContext.RepositoryName); + Assert.NotEmpty(license.Errors); + } + } + + [IntegrationTest] + public async Task ReturnsCodeOwnersErrorsWithRepositoryId() + { + using (var repoContext = await _github.CreateUserRepositoryContext()) + { + await _github.Repository.Content.CreateFile(repoContext.RepositoryId, ".github/codeowners", new CreateFileRequest("Create codeowners", @"* snyrting6@hotmail.com")); + + // Sometimes it takes a second to create the file + Thread.Sleep(TimeSpan.FromSeconds(2)); + + var license = await _github.Repository.GetAllCodeOwnersErrors(repoContext.RepositoryId); + Assert.NotEmpty(license.Errors); + } + } + } + public class TheTransferMethod { [IntegrationTest] diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 9d95cd1cee..7a7a88879b 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -1070,6 +1070,42 @@ public async Task EnsuresNonNullArguments() } } + public class TheGetCodeOwnersErrorsMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoriesClient(connection); + + await client.GetAllCodeOwnersErrors("owner", "name"); + + connection.Received() + .Get<RepositoryCodeOwnersErrors>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/codeowners/errors")); + } + + [Fact] + public async Task RequestsTheCorrectUrlWithRepositoryId() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoriesClient(connection); + + await client.GetAllCodeOwnersErrors(1); + + connection.Received() + .Get<RepositoryCodeOwnersErrors>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/codeowners/errors")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoriesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllCodeOwnersErrors(null, "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllCodeOwnersErrors("owner", null)); + } + } + public class TheGetAllTagsMethod { [Fact] diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 773b76353c..e4dc59a28e 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -714,5 +714,21 @@ public interface IRepositoriesClient /// <returns>All topics now associated with the repository.</returns> Task<RepositoryTopics> ReplaceAllTopics(string owner, string name, RepositoryTopics topics); + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/codeowners/errors")] + Task<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(string owner, string name); + + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repositories/{id}/codeowners/errors")] + Task<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(long repositoryId); } } diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 4d4bfe3bad..df7d3f4fe6 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -11,7 +11,7 @@ namespace Octokit /// A client for GitHub's Repositories API. /// </summary> /// <remarks> - /// See the <a href="http://developer.github.com/v3/repos/">Repositories API documentation</a> for more details. + /// See the <a href="https://docs.github.com/rest/repos/repos">Repositories API documentation</a> for more details. /// </remarks> public class RepositoriesClient : ApiClient, IRepositoriesClient { @@ -1114,6 +1114,32 @@ public Task<RepositoryContentLicense> GetLicenseContents(long repositoryId) return ApiConnection.Get<RepositoryContentLicense>(ApiUrls.RepositoryLicense(repositoryId)); } + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/codeowners/errors")] + public Task<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Get<RepositoryCodeOwnersErrors>(ApiUrls.RepositoryCodeOwnersErrors(owner, name)); + } + + /// <summary> + /// Gets the list of errors in the codeowners file + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <returns>Returns the list of errors in the codeowners files</returns> + [ManualRoute("GET", "/repositories/{id}/codeowners/errors")] + public Task<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(long repositoryId) + { + return ApiConnection.Get<RepositoryCodeOwnersErrors>(ApiUrls.RepositoryCodeOwnersErrors(repositoryId)); + } + /// <summary> /// A client for GitHub's Repository Pages API. /// </summary> diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index df99a617c0..098de9c8ef 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1995,6 +1995,27 @@ public static Uri SearchLabels() return "search/labels".FormatUri(); } + /// <summary> + /// Returns the <see cref="Uri"/> for repository codeowners errors. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>the <see cref="Uri"/> for repository topics.</returns> + public static Uri RepositoryCodeOwnersErrors(string owner, string name) + { + return "repos/{0}/{1}/codeowners/errors".FormatUri(owner, name); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for repository codeowners errors. + /// </summary> + /// <param name="repositoryId">The ID of the repository</param> + /// <returns>the <see cref="Uri"/> for repository topics.</returns> + public static Uri RepositoryCodeOwnersErrors(long repositoryId) + { + return "repositories/{0}/codeowners/errors".FormatUri(repositoryId); + } + /// <summary> /// Returns the <see cref="Uri"/> for repository contributors. /// </summary> diff --git a/Octokit/Models/Response/RepositoryCodeOwnersErrors.cs b/Octokit/Models/Response/RepositoryCodeOwnersErrors.cs new file mode 100644 index 0000000000..0248f0c190 --- /dev/null +++ b/Octokit/Models/Response/RepositoryCodeOwnersErrors.cs @@ -0,0 +1,58 @@ +using Octokit.Internal; +using System.Collections.Generic; +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositoryCodeOwnersErrors + { + public RepositoryCodeOwnersErrors() + { + } + + public RepositoryCodeOwnersErrors(List<RepositoryCodeOwnersError> errors) + { + Errors = errors; + } + + public IReadOnlyList<RepositoryCodeOwnersError> Errors { get; private set; } + + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositoryCodeOwnersError + { + public RepositoryCodeOwnersError() + { + } + + public RepositoryCodeOwnersError(int line, int column, string kind, string source, string suggestion, string message, string path) + { + Line = line; + Column = column; + Kind = kind; + Source = source; + Suggestion = suggestion; + Message = message; + Path = path; + } + + public int Line { get; private set; } + + public int Column { get; private set; } + + public string Kind { get; private set; } + + public string Source { get; private set; } + + public string Suggestion { get; private set; } + + public string Message { get; private set; } + + public string Path { get; private set; } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); + } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); + } +} diff --git a/Octokit/Models/Response/RepositoryTag.cs b/Octokit/Models/Response/RepositoryTag.cs index 37ce9baf20..74c0769246 100644 --- a/Octokit/Models/Response/RepositoryTag.cs +++ b/Octokit/Models/Response/RepositoryTag.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; From 840935a8d7c1c054c5eacedf38f8481b9357f462 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Wed, 27 Jul 2022 20:04:51 +0100 Subject: [PATCH 093/209] maint: Removes private repositories limit exception (#2514) --- .../Clients/RepositoriesClientTests.cs | 38 ------------ .../Clients/RepositoriesClientTests.cs | 24 -------- Octokit/Clients/RepositoriesClient.cs | 16 ----- ...PrivateRepositoryQuotaExceededException.cs | 58 ------------------- 4 files changed, 136 deletions(-) delete mode 100644 Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 6aeb8fc263..c3fba05f45 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -408,44 +408,6 @@ public async Task ThrowsRepositoryExistsExceptionForExistingRepository() Assert.False(thrown.OwnerIsOrganization); } } - - [PaidAccountTest(Skip = "Paid plans now have unlimited repositories. We shouldn't test this now.")] - public async Task ThrowsPrivateRepositoryQuotaExceededExceptionWhenOverQuota() - { - var github = Helper.GetAuthenticatedClient(); - - var userDetails = await github.User.Current(); - var freePrivateSlots = userDetails.Plan.PrivateRepos - userDetails.OwnedPrivateRepos; - - if (userDetails.Plan.PrivateRepos == 0) - { - throw new Exception("Test cannot complete, account is on free plan"); - } - - var createRepoTasks = - Enumerable.Range(0, (int)freePrivateSlots) - .Select(x => - { - var repoName = Helper.MakeNameWithTimestamp("private-repo-" + x); - var repository = new NewRepository(repoName) { Private = true }; - return github.Repository.Create(repository); - }); - - var createdRepositories = await Task.WhenAll(createRepoTasks); - - try - { - await Assert.ThrowsAsync<PrivateRepositoryQuotaExceededException>( - () => github.Repository.Create(new NewRepository("x-private") { Private = true })); - } - finally - { - var deleteRepos = createdRepositories - .Select(repo => github.Repository.Delete(repo.Owner.Login, repo.Name)); - - Task.WhenAll(deleteRepos).Wait(); - } - } } public class TheCreateMethodForOrganization diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 7a7a88879b..c2a77a05ce 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -85,30 +85,6 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentU Assert.Equal("aName", exception.RepositoryName); Assert.Null(exception.ExistingRepositoryWebUrl); } - - [Fact] - public async Task ThrowsExceptionWhenPrivateRepositoryQuotaExceeded() - { - var newRepository = new NewRepository("aName") { Private = true }; - var response = Substitute.For<IResponse>(); - response.StatusCode.Returns((HttpStatusCode)422); - response.Body.Returns(@"{""message"":""Validation Failed"",""documentation_url"":" - + @"""http://developer.github.com/v3/repos/#create"",""errors"":[{""resource"":""Repository""," - + @"""code"":""custom"",""field"":""name"",""message"":" - + @"""name can't be private. You are over your quota.""}]}"); - var credentials = new Credentials("haacked", "pwd"); - var connection = Substitute.For<IApiConnection>(); - connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Connection.Credentials.Returns(credentials); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") - .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); - var client = new RepositoriesClient(connection); - - var exception = await Assert.ThrowsAsync<PrivateRepositoryQuotaExceededException>( - () => client.Create(newRepository)); - - Assert.NotNull(exception); - } } public class TheCreateMethodForOrganization diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index df7d3f4fe6..46b1051923 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -131,22 +131,6 @@ async Task<Repository> Create(Uri url, string organizationLogin, NewRepository n baseAddress, e); } - if (string.Equals( - "please upgrade your plan to create a new private repository.", - errorMessage, - StringComparison.OrdinalIgnoreCase)) - { - throw new PrivateRepositoryQuotaExceededException(e); - } - - if (string.Equals( - "name can't be private. You are over your quota.", - errorMessage, - StringComparison.OrdinalIgnoreCase)) - { - throw new PrivateRepositoryQuotaExceededException(e); - } - if (errorMessage != null && errorMessage.EndsWith("is an unknown gitignore template.", StringComparison.OrdinalIgnoreCase)) { throw new InvalidGitIgnoreTemplateException(e); diff --git a/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs b/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs deleted file mode 100644 index c811b1ffa3..0000000000 --- a/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE -using System.Runtime.Serialization; -#endif - -namespace Octokit -{ - /// <summary> - /// Exception thrown when creating a private repository, but the user's private quota is or would be exceeded - /// by creating it. - /// </summary> -#if !NO_SERIALIZABLE - [Serializable] -#endif - [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", - Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] - public class PrivateRepositoryQuotaExceededException : ApiValidationException - { - /// <summary> - /// Constructs an instance of PrivateRepositoryQuotaExceededException. - /// </summary> - /// <param name="innerException">The inner validation exception.</param> - public PrivateRepositoryQuotaExceededException(ApiValidationException innerException) - : base(innerException) - { - } - - public override string Message - { - get - { - // TODO: Would be nice to show the actual numbers, but that requires another request. - return "You are currently at your limit of private repositories. Either delete a private repository you no " - + "longer use (https://help.github.com/articles/deleting-a-repository/) or upgrade your account to a plan " - + "that allows for more private repositories (https://help.github.com/articles/what-plan-should-i-choose/)."; - } - } - -#if !NO_SERIALIZABLE - /// <summary> - /// Constructs an instance of PrivateRepositoryQuotaExceededException - /// </summary> - /// <param name="info"> - /// The <see cref="SerializationInfo"/> that holds the - /// serialized object data about the exception being thrown. - /// </param> - /// <param name="context"> - /// The <see cref="StreamingContext"/> that contains - /// contextual information about the source or destination. - /// </param> - protected PrivateRepositoryQuotaExceededException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } -#endif - } -} From 2f7bd00dd604fd2387b2ec29db86223541e200fa Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Mon, 1 Aug 2022 15:37:23 +0100 Subject: [PATCH 094/209] feat: Removing accept header previews (#2515) --- ...eEnterprisePreReceiveEnvironmentsClient.cs | 2 +- .../Clients/ObservableCheckRunsClient.cs | 12 +- .../Clients/ObservableCheckSuitesClient.cs | 4 +- .../ObservableCommitCommentReactionsClient.cs | 4 +- .../ObservableGitHubAppInstallationsClient.cs | 4 +- .../Clients/ObservableGitHubAppsClient.cs | 6 +- .../ObservableIssueCommentReactionsClient.cs | 4 +- .../Clients/ObservableIssueCommentsClient.cs | 8 +- .../Clients/ObservableIssueReactionsClient.cs | 4 +- .../Clients/ObservableIssueTimelineClient.cs | 4 +- .../Clients/ObservableIssuesClient.cs | 8 +- .../Clients/ObservableMigrationsClient.cs | 2 +- .../ObservableOrganizationMembersClient.cs | 2 +- ...eOrganizationOutsideCollaboratorsClient.cs | 4 +- .../Clients/ObservableProjectCardsClient.cs | 2 +- .../Clients/ObservableProjectColumnsClient.cs | 2 +- .../Clients/ObservableProjectsClient.cs | 12 +- ...PullRequestReviewCommentReactionsClient.cs | 4 +- ...servablePullRequestReviewCommentsClient.cs | 11 +- .../Clients/ObservablePullRequestsClient.cs | 8 +- .../ObservableRepositoryCommentsClient.cs | 8 +- .../Clients/ObservableStarredClient.cs | 12 +- .../Clients/ObservableTeamsClient.cs | 2 +- .../Helpers/ConnectionExtensions.cs | 6 +- Octokit.Tests.Integration/Helper.cs | 2 +- Octokit.Tests/Clients/AssigneesClientTests.cs | 4 - .../Clients/AuthorizationsClientTests.cs | 9 +- Octokit.Tests/Clients/CheckRunsClientTests.cs | 34 +--- .../Clients/CheckSuitesClientTests.cs | 30 +-- .../CommitCommentReactionsClientTests.cs | 12 +- .../Clients/DeploymentStatusClientTests.cs | 16 +- .../Clients/DeploymentsClientTests.cs | 12 +- ...rprisePreReceiveEnvironmentsClientTests.cs | 20 +- .../GitHubAppInstallationsClientTests.cs | 4 - .../Clients/GitHubAppsClientTests.cs | 24 +-- .../IssueCommentReactionsClientTests.cs | 12 +- .../Clients/IssueCommentsClientTests.cs | 16 +- .../Clients/IssueReactionsClientTests.cs | 12 +- .../Clients/IssueTimelineClientTests.cs | 4 - Octokit.Tests/Clients/IssuesClientTests.cs | 19 +- .../Clients/IssuesEventsClientTests.cs | 20 +- .../Clients/MigrationsClientTests.cs | 23 +-- .../Clients/OrganizationMembersClientTests.cs | 4 +- ...nizationOutsideCollaboratorsClientTests.cs | 21 +-- .../Clients/ProjectCardsClientTests.cs | 16 +- .../Clients/ProjectColumnsClientTests.cs | 15 +- Octokit.Tests/Clients/ProjectsClientTests.cs | 16 +- ...equestReviewCommentReactionsClientTests.cs | 12 +- .../PullRequestReviewCommentsClientTests.cs | 21 +-- .../Clients/PullRequestsClientTests.cs | 28 +-- Octokit.Tests/Clients/ReactionsClientTests.cs | 2 +- .../Clients/RepoCollaboratorsClientTests.cs | 6 +- .../Clients/RepositoriesClientTests.cs | 89 +++------ .../Clients/RepositoryBranchesClientTests.cs | 168 ++++++----------- .../Clients/RepositoryCommentsClientTests.cs | 22 +-- .../Clients/RespositoryCommitsClientTests.cs | 6 +- Octokit.Tests/Clients/StarredClientTests.cs | 29 ++- Octokit.Tests/Clients/TeamsClientTests.cs | 1 - Octokit.Tests/Helpers/MockedIApiConnection.cs | 2 + Octokit.Tests/Http/ApiConnectionTests.cs | 5 +- ...rprisePreReceiveEnvironmentsClientTests.cs | 6 +- .../ObservableAssigneesClientTests.cs | 8 +- .../ObservableAuthorizationsClientTests.cs | 4 +- .../ObservableCheckRunsClientTests.cs | 48 ++--- .../ObservableCheckSuitesClientTests.cs | 12 +- .../ObservableDeploymentStatusClientTests.cs | 16 +- .../ObservableDeploymentsClientTests.cs | 24 +-- .../Reactive/ObservableEventsClientTests.cs | 36 ++-- .../Reactive/ObservableFollowersTest.cs | 8 +- .../Reactive/ObservableGistsTests.cs | 49 ++--- ...rvableGitHubAppInstallationsClientTests.cs | 14 +- .../ObservableGitHubAppsClientTests.cs | 12 +- .../ObservableIssueCommentsClientTests.cs | 29 +-- .../ObservableIssueTimelineClientTests.cs | 20 +- .../Reactive/ObservableIssuesClientTests.cs | 49 +++-- .../ObservableIssuesEventsClientTests.cs | 32 ++-- .../ObservableIssuesLabelsClientTests.cs | 24 +-- .../ObservableMilestonesClientTests.cs | 12 +- .../ObservableNotificationsClientTests.cs | 36 ++-- ...bservableOrganizationMembersClientTests.cs | 20 +- ...nizationOutsideCollaboratorsClientTests.cs | 18 +- .../ObservableProjectCardsClientTests.cs | 6 +- .../ObservableProjectColumnsClientTests.cs | 3 +- .../Reactive/ObservableProjectsClientTests.cs | 18 +- ...blePullRequestReviewCommentsClientTests.cs | 78 ++++---- ...ObservablePullRequestReviewsClientTests.cs | 24 +-- .../ObservablePullRequestsClientTests.cs | 40 ++-- .../Reactive/ObservableReleasesClientTests.cs | 18 +- .../ObservableRepoCollaboratorsClientTests.cs | 42 ++--- .../ObservableRepositoriesClientTests.cs | 69 ++++--- ...ObservableRepositoryBranchesClientTests.cs | 8 +- ...ObservableRepositoryCommentsClientTests.cs | 16 +- ...ObservableRepositoryContentsClientTests.cs | 32 ++-- ...servableRepositoryDeployKeysClientTests.cs | 20 +- .../Reactive/ObservableStarredClientTests.cs | 57 +++--- .../Reactive/ObservableTeamsClientTests.cs | 18 +- ...ObservableUserAdministrationClientTests.cs | 1 - .../ObservableUserEmailsClientTests.cs | 4 +- .../Reactive/ObservableWatchedClientTests.cs | 16 +- Octokit/Clients/AssigneesClient.cs | 4 +- Octokit/Clients/AuthorizationsClient.cs | 8 +- Octokit/Clients/CheckRunsClient.cs | 36 ++-- Octokit/Clients/CheckSuitesClient.cs | 30 +-- .../Clients/CommitCommentReactionsClient.cs | 12 +- Octokit/Clients/DeploymentStatusClient.cs | 26 +-- Octokit/Clients/DeploymentsClient.cs | 11 +- .../EnterprisePreReceiveEnvironmentsClient.cs | 14 +- .../Clients/GitHubAppInstallationsClient.cs | 6 +- Octokit/Clients/GitHubAppsClient.cs | 33 ++-- .../Clients/IssueCommentReactionsClient.cs | 12 +- Octokit/Clients/IssueCommentsClient.cs | 18 +- Octokit/Clients/IssueReactionsClient.cs | 12 +- Octokit/Clients/IssueTimelineClient.cs | 14 +- Octokit/Clients/IssuesClient.cs | 21 +-- Octokit/Clients/IssuesEventsClient.cs | 34 +--- Octokit/Clients/MigrationsClient.cs | 18 +- Octokit/Clients/OrganizationMembersClient.cs | 2 +- .../OrganizationOutsideCollaboratorsClient.cs | 8 +- Octokit/Clients/ProjectCardsClient.cs | 18 +- Octokit/Clients/ProjectColumnsClient.cs | 18 +- Octokit/Clients/ProjectsClient.cs | 33 ++-- ...PullRequestReviewCommentReactionsClient.cs | 12 +- .../PullRequestReviewCommentsClient.cs | 12 +- Octokit/Clients/PullRequestsClient.cs | 26 +-- Octokit/Clients/ReactionsClient.cs | 3 +- Octokit/Clients/RepoCollaboratorsClient.cs | 4 +- Octokit/Clients/RepositoriesClient.cs | 43 ++--- Octokit/Clients/RepositoryBranchesClient.cs | 171 ++++++------------ Octokit/Clients/RepositoryCommentsClient.cs | 18 +- Octokit/Clients/RepositoryCommitsClient.cs | 4 +- Octokit/Clients/RepositoryForksClient.cs | 2 - Octokit/Clients/StarredClient.cs | 12 +- Octokit/Clients/TeamsClient.cs | 2 +- Octokit/Helpers/AcceptHeaders.cs | 59 +----- Octokit/Helpers/ApiExtensions.cs | 2 +- Octokit/Helpers/PreviewAttribute.cs | 20 -- Octokit/Http/Connection.cs | 7 + Octokit/Http/IConnection.cs | 10 + 138 files changed, 954 insertions(+), 1659 deletions(-) delete mode 100644 Octokit/Helpers/PreviewAttribute.cs diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClient.cs index f49b337c06..009983feb2 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClient.cs @@ -48,7 +48,7 @@ public IObservable<PreReceiveEnvironment> GetAll(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<PreReceiveEnvironment>(ApiUrls.AdminPreReceiveEnvironments(), null, AcceptHeaders.PreReceiveEnvironmentsPreview, options); + return _connection.GetAndFlattenAllPages<PreReceiveEnvironment>(ApiUrls.AdminPreReceiveEnvironments(), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs index ee5ebb5f03..d90dbd3929 100644 --- a/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckRunsClient.cs @@ -184,7 +184,7 @@ public IObservable<CheckRunsResponse> GetAllForReference(string owner, string na Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForReference(owner, name, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForReference(owner, name, reference), checkRunRequest.ToParametersDictionary(), options); } /// <summary> @@ -203,7 +203,7 @@ public IObservable<CheckRunsResponse> GetAllForReference(long repositoryId, stri Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForReference(repositoryId, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForReference(repositoryId, reference), checkRunRequest.ToParametersDictionary(), options); } /// <summary> @@ -289,7 +289,7 @@ public IObservable<CheckRunsResponse> GetAllForCheckSuite(string owner, string n Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), options); } /// <summary> @@ -307,7 +307,7 @@ public IObservable<CheckRunsResponse> GetAllForCheckSuite(long repositoryId, lon Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), options); } /// <summary> @@ -387,7 +387,7 @@ public IObservable<CheckRunAnnotation> GetAllAnnotations(string owner, string na Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, options); } /// <summary> @@ -403,7 +403,7 @@ public IObservable<CheckRunAnnotation> GetAllAnnotations(long repositoryId, long { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, options); } } } diff --git a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs index 4cd569c465..97b662ce18 100644 --- a/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs +++ b/Octokit.Reactive/Clients/ObservableCheckSuitesClient.cs @@ -146,7 +146,7 @@ public IObservable<CheckSuitesResponse> GetAllForReference(string owner, string Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(owner, name, reference), request.ToParametersDictionary(), options); } /// <summary> @@ -165,7 +165,7 @@ public IObservable<CheckSuitesResponse> GetAllForReference(long repositoryId, st Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options); + return _connection.GetAndFlattenAllPages<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(repositoryId, reference), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index c95814aeb7..7193521746 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -85,7 +85,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.CommitCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.CommitCommentReactions(owner, name, number), null, options); } /// <summary> @@ -112,7 +112,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableGitHubAppInstallationsClient.cs b/Octokit.Reactive/Clients/ObservableGitHubAppInstallationsClient.cs index df4a4a8a04..531aa23aa8 100644 --- a/Octokit.Reactive/Clients/ObservableGitHubAppInstallationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableGitHubAppInstallationsClient.cs @@ -38,7 +38,7 @@ public IObservable<RepositoriesResponse> GetAllRepositoriesForCurrent() /// <remarks>https://developer.github.com/v3/apps/installations/#list-repositories</remarks> public IObservable<RepositoriesResponse> GetAllRepositoriesForCurrent(ApiOptions options) { - return _connection.GetAndFlattenAllPages<RepositoriesResponse>(ApiUrls.InstallationRepositories(), null, AcceptHeaders.GitHubAppsPreview, options); + return _connection.GetAndFlattenAllPages<RepositoriesResponse>(ApiUrls.InstallationRepositories(), options); } /// <summary> @@ -59,7 +59,7 @@ public IObservable<RepositoriesResponse> GetAllRepositoriesForCurrentUser(long i /// <remarks>https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation</remarks> public IObservable<RepositoriesResponse> GetAllRepositoriesForCurrentUser(long installationId, ApiOptions options) { - return _connection.GetAndFlattenAllPages<RepositoriesResponse>(ApiUrls.UserInstallationRepositories(installationId), null, AcceptHeaders.GitHubAppsPreview, options); + return _connection.GetAndFlattenAllPages<RepositoriesResponse>(ApiUrls.UserInstallationRepositories(installationId), options); } } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs b/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs index 5adc03aebe..c3baf089ec 100644 --- a/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs +++ b/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs @@ -72,7 +72,7 @@ public IObservable<Installation> GetAllInstallationsForCurrent(ApiOptions option { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Installation>(ApiUrls.Installations(), null, AcceptHeaders.GitHubAppsPreview, options); + return _connection.GetAndFlattenAllPages<Installation>(ApiUrls.Installations(), null, options); } /// <summary> @@ -102,7 +102,7 @@ public IObservable<Installation> GetInstallationForCurrent(long installationId) /// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks> public IObservable<InstallationsResponse> GetAllInstallationsForCurrentUser() { - return _connection.GetAndFlattenAllPages<InstallationsResponse>(ApiUrls.UserInstallations(), null, AcceptHeaders.GitHubAppsPreview); + return _connection.GetAndFlattenAllPages<InstallationsResponse>(ApiUrls.UserInstallations()); } /// <summary> @@ -111,7 +111,7 @@ public IObservable<InstallationsResponse> GetAllInstallationsForCurrentUser() /// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks> public IObservable<InstallationsResponse> GetAllInstallationsForCurrentUser(ApiOptions options) { - return _connection.GetAndFlattenAllPages<InstallationsResponse>(ApiUrls.UserInstallations(), null, AcceptHeaders.GitHubAppsPreview, options); + return _connection.GetAndFlattenAllPages<InstallationsResponse>(ApiUrls.UserInstallations(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index 9a4d61cd04..d8753a093c 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -84,7 +84,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueCommentReactions(owner, name, number), null, options); } /// <summary> @@ -109,7 +109,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs index e87c38bedd..fde616445a 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs @@ -147,7 +147,7 @@ public IObservable<IssueComment> GetAllForRepository(string owner, string name, Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), options); } /// <summary> @@ -162,7 +162,7 @@ public IObservable<IssueComment> GetAllForRepository(long repositoryId, IssueCom Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), options); } /// <summary> @@ -269,7 +269,7 @@ public IObservable<IssueComment> GetAllForIssue(string owner, string name, int n Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(owner, name, number), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(owner, name, number), request.ToParametersDictionary(), options); } @@ -286,7 +286,7 @@ public IObservable<IssueComment> GetAllForIssue(long repositoryId, int number, I Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(repositoryId, number), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<IssueComment>(ApiUrls.IssueComments(repositoryId, number), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index 12da405811..8a9c451e3b 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -50,7 +50,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, options); } /// <summary> @@ -75,7 +75,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.IssueReactions(repositoryId, number), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableIssueTimelineClient.cs b/Octokit.Reactive/Clients/ObservableIssueTimelineClient.cs index efc0970157..d7017fd493 100644 --- a/Octokit.Reactive/Clients/ObservableIssueTimelineClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueTimelineClient.cs @@ -53,7 +53,7 @@ public IObservable<TimelineEventInfo> GetAllForIssue(string owner, string repo, Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<TimelineEventInfo>(ApiUrls.IssueTimeline(owner, repo, number), null, AcceptHeaders.IssueTimelineApiPreview, options); + return _connection.GetAndFlattenAllPages<TimelineEventInfo>(ApiUrls.IssueTimeline(owner, repo, number), null, options); } /// <summary> @@ -82,7 +82,7 @@ public IObservable<TimelineEventInfo> GetAllForIssue(long repositoryId, int numb { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<TimelineEventInfo>(ApiUrls.IssueTimeline(repositoryId, number), null, AcceptHeaders.IssueTimelineApiPreview, options); + return _connection.GetAndFlattenAllPages<TimelineEventInfo>(ApiUrls.IssueTimeline(repositoryId, number), null, options); } } } diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index fb38ed2134..3b96237c89 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -150,7 +150,7 @@ public IObservable<Issue> GetAllForCurrent(IssueRequest request, ApiOptions opti Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.Issues(), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.Issues(), request.ToParametersDictionary(), options); } /// <summary> @@ -209,7 +209,7 @@ public IObservable<Issue> GetAllForOwnedAndMemberRepositories(IssueRequest reque Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.IssuesForOwnedAndMember(), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.IssuesForOwnedAndMember(), request.ToParametersDictionary(), options); } /// <summary> @@ -273,7 +273,7 @@ public IObservable<Issue> GetAllForOrganization(string organization, IssueReques Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.Issues(organization), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.Issues(organization), request.ToParametersDictionary(), options); } /// <summary> @@ -387,7 +387,7 @@ public IObservable<Issue> GetAllForRepository(string owner, string name, Reposit Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.Issues(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Issue>(ApiUrls.Issues(owner, name), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableMigrationsClient.cs b/Octokit.Reactive/Clients/ObservableMigrationsClient.cs index 86f9c74766..41e7021ed6 100644 --- a/Octokit.Reactive/Clients/ObservableMigrationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableMigrationsClient.cs @@ -62,7 +62,7 @@ public IObservable<Migration> GetAll(string org, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Migration>(ApiUrls.EnterpriseMigrations(org), null, AcceptHeaders.MigrationsApiPreview, options); + return _connection.GetAndFlattenAllPages<Migration>(ApiUrls.EnterpriseMigrations(org), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs index 064403740b..bda101a24a 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs @@ -470,7 +470,7 @@ public IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(st Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, AcceptHeaders.OrganizationMembershipPreview, options); + return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, options); } } } diff --git a/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs index 94d5f409dc..f4cc5bfabf 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationOutsideCollaboratorsClient.cs @@ -54,7 +54,7 @@ public IObservable<User> GetAll(string org, ApiOptions options) Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<User>(ApiUrls.OutsideCollaborators(org), null, AcceptHeaders.OrganizationMembershipPreview, options); + return _connection.GetAndFlattenAllPages<User>(ApiUrls.OutsideCollaborators(org), null, options); } /// <summary> @@ -92,7 +92,7 @@ public IObservable<User> GetAll(string org, OrganizationMembersFilter filter, Ap Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<User>(ApiUrls.OutsideCollaborators(org, filter), null, AcceptHeaders.OrganizationMembershipPreview, options); + return _connection.GetAndFlattenAllPages<User>(ApiUrls.OutsideCollaborators(org, filter), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableProjectCardsClient.cs b/Octokit.Reactive/Clients/ObservableProjectCardsClient.cs index 424f1c7cc3..23a3441354 100644 --- a/Octokit.Reactive/Clients/ObservableProjectCardsClient.cs +++ b/Octokit.Reactive/Clients/ObservableProjectCardsClient.cs @@ -81,7 +81,7 @@ public IObservable<ProjectCard> GetAll(int columnId, ProjectCardRequest request, var url = ApiUrls.ProjectCards(columnId); - return _connection.GetAndFlattenAllPages<ProjectCard>(url, request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<ProjectCard>(url, request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableProjectColumnsClient.cs b/Octokit.Reactive/Clients/ObservableProjectColumnsClient.cs index c52d51fa1f..36afe03909 100644 --- a/Octokit.Reactive/Clients/ObservableProjectColumnsClient.cs +++ b/Octokit.Reactive/Clients/ObservableProjectColumnsClient.cs @@ -44,7 +44,7 @@ public IObservable<ProjectColumn> GetAll(int projectId, ApiOptions options) var url = ApiUrls.ProjectColumns(projectId); - return _connection.GetAndFlattenAllPages<ProjectColumn>(url, new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<ProjectColumn>(url, new Dictionary<string, string>(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableProjectsClient.cs b/Octokit.Reactive/Clients/ObservableProjectsClient.cs index 76d7195400..3694f90c90 100644 --- a/Octokit.Reactive/Clients/ObservableProjectsClient.cs +++ b/Octokit.Reactive/Clients/ObservableProjectsClient.cs @@ -57,7 +57,7 @@ public IObservable<Project> GetAllForRepository(string owner, string name, ApiOp var url = ApiUrls.RepositoryProjects(owner, name); - return _connection.GetAndFlattenAllPages<Project>(url, new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<Project>(url, new Dictionary<string, string>(), options); } /// <summary> @@ -93,7 +93,7 @@ public IObservable<Project> GetAllForRepository(string owner, string name, Proje var url = ApiUrls.RepositoryProjects(owner, name); - return _connection.GetAndFlattenAllPages<Project>(url, request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<Project>(url, request.ToParametersDictionary(), options); } /// <summary> @@ -122,7 +122,7 @@ public IObservable<Project> GetAllForRepository(long repositoryId, ApiOptions op var url = ApiUrls.RepositoryProjects(repositoryId); - return _connection.GetAndFlattenAllPages<Project>(url, new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<Project>(url, new Dictionary<string, string>(), options); } /// <summary> @@ -154,7 +154,7 @@ public IObservable<Project> GetAllForRepository(long repositoryId, ProjectReques var url = ApiUrls.RepositoryProjects(repositoryId); - return _connection.GetAndFlattenAllPages<Project>(url, request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<Project>(url, request.ToParametersDictionary(), options); } /// <summary> @@ -184,7 +184,7 @@ public IObservable<Project> GetAllForOrganization(string organization, ApiOption var url = ApiUrls.OrganizationProjects(organization); - return _connection.GetAndFlattenAllPages<Project>(url, new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<Project>(url, new Dictionary<string, string>(), options); } /// <summary> @@ -217,7 +217,7 @@ public IObservable<Project> GetAllForOrganization(string organization, ProjectRe var url = ApiUrls.OrganizationProjects(organization); - return _connection.GetAndFlattenAllPages<Project>(url, request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return _connection.GetAndFlattenAllPages<Project>(url, request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs index 967aaa1d2d..858d793757 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs @@ -42,7 +42,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, options); } /// <summary> @@ -67,7 +67,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentsClient.cs index 877ff4c111..3c36d15770 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentsClient.cs @@ -64,7 +64,7 @@ public IObservable<PullRequestReviewComment> GetAll(string owner, string name, i Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), null, options); } /// <summary> @@ -178,8 +178,7 @@ public IObservable<PullRequestReviewComment> GetAllForRepository(string owner, s Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, - options); + return _connection.GetAndFlattenAllPages<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(owner, name), request.ToParametersDictionary(), options); } /// <summary> @@ -194,11 +193,7 @@ public IObservable<PullRequestReviewComment> GetAllForRepository(long repository Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<PullRequestReviewComment>( - ApiUrls.PullRequestReviewCommentsRepository(repositoryId), - request.ToParametersDictionary(), - AcceptHeaders.ReactionsPreview, - options); + return _connection.GetAndFlattenAllPages<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(repositoryId), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs index 96a1bd3fa2..9fbafba8ba 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs @@ -111,7 +111,7 @@ public IObservable<PullRequest> GetAllForRepository(string owner, string name, A Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(owner, name), null, AcceptHeaders.DraftPullRequestApiPreview, options); + return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(owner, name), null, options); } /// <summary> @@ -126,7 +126,7 @@ public IObservable<PullRequest> GetAllForRepository(long repositoryId, ApiOption { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(repositoryId), null, AcceptHeaders.DraftPullRequestApiPreview, options); + return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(repositoryId), null, options); } /// <summary> @@ -180,7 +180,7 @@ public IObservable<PullRequest> GetAllForRepository(string owner, string name, P Ensure.ArgumentNotNull(options, nameof(options)); return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(owner, name), - request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options); + request.ToParametersDictionary(), options); } /// <summary> @@ -198,7 +198,7 @@ public IObservable<PullRequest> GetAllForRepository(long repositoryId, PullReque Ensure.ArgumentNotNull(options, nameof(options)); return _connection.GetAndFlattenAllPages<PullRequest>(ApiUrls.PullRequests(repositoryId), - request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options); + request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs index 7258bfac6c..7e97fb51b2 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs @@ -87,7 +87,7 @@ public IObservable<CommitComment> GetAllForRepository(string owner, string name, Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name), null, options); } /// <summary> @@ -100,7 +100,7 @@ public IObservable<CommitComment> GetAllForRepository(long repositoryId, ApiOpti { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(repositoryId), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(repositoryId), null, options); } /// <summary> @@ -147,7 +147,7 @@ public IObservable<CommitComment> GetAllForCommit(string owner, string name, str Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name, sha), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(owner, name, sha), null, options); } /// <summary> @@ -162,7 +162,7 @@ public IObservable<CommitComment> GetAllForCommit(long repositoryId, string sha, Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), null, AcceptHeaders.ReactionsPreview, options); + return _connection.GetAndFlattenAllPages<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), null, options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableStarredClient.cs b/Octokit.Reactive/Clients/ObservableStarredClient.cs index f1c60e932b..ab2e1781b3 100644 --- a/Octokit.Reactive/Clients/ObservableStarredClient.cs +++ b/Octokit.Reactive/Clients/ObservableStarredClient.cs @@ -113,7 +113,7 @@ public IObservable<UserStar> GetAllStargazersWithTimestamps(string owner, string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarCreationTimestamps, options); + return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(owner, name), null, options); } /// <summary> @@ -126,7 +126,7 @@ public IObservable<UserStar> GetAllStargazersWithTimestamps(long repositoryId, A { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(repositoryId), null, AcceptHeaders.StarCreationTimestamps, options); + return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(repositoryId), null, options); } /// <summary> @@ -166,7 +166,7 @@ public IObservable<RepositoryStar> GetAllForCurrentWithTimestamps(ApiOptions opt { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), null, AcceptHeaders.StarCreationTimestamps, options); + return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), null, options); } /// <summary> @@ -220,7 +220,7 @@ public IObservable<RepositoryStar> GetAllForCurrentWithTimestamps(StarredRequest Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps, options); + return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), options); } /// <summary> @@ -272,7 +272,7 @@ public IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user, ApiO Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), null, AcceptHeaders.StarCreationTimestamps, options); + return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), null, options); } /// <summary> @@ -334,7 +334,7 @@ public IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user, Star Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps, options); + return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 4630bbdc99..9fa0d3f7ba 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -389,7 +389,7 @@ public IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(in Ensure.ArgumentNotNull(id, nameof(id)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.TeamPendingInvitations(id), null, AcceptHeaders.OrganizationMembershipPreview, options); + return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.TeamPendingInvitations(id), null, options); } } } diff --git a/Octokit.Reactive/Helpers/ConnectionExtensions.cs b/Octokit.Reactive/Helpers/ConnectionExtensions.cs index c60ee36666..74902050fa 100644 --- a/Octokit.Reactive/Helpers/ConnectionExtensions.cs +++ b/Octokit.Reactive/Helpers/ConnectionExtensions.cs @@ -10,7 +10,7 @@ public static class ConnectionExtensions { public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url) { - return GetPages(url, null, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, null, null).ToObservable()); + return GetPages(url, null, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, null).ToObservable()); } public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, ApiOptions options) @@ -20,7 +20,7 @@ public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connectio public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, IDictionary<string, string> parameters) { - return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, pageParams, null).ToObservable()); + return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, pageParams).ToObservable()); } public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, IDictionary<string, string> parameters, ApiOptions options) @@ -28,7 +28,7 @@ public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connectio return GetPagesWithOptions(url, parameters, options, (pageUrl, pageParams, o) => { var passingParameters = Pagination.Setup(parameters, options); - return connection.Get<List<T>>(pageUrl, passingParameters, null).ToObservable(); + return connection.Get<List<T>>(pageUrl, passingParameters).ToObservable(); }); } diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 2bc13c74bf..af7742b5e4 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -336,7 +336,7 @@ public static void DeleteInvitations(IConnection connection, List<string> invite { foreach (var invitee in invitees) { - connection.Delete(new Uri($"orgs/{Organization}/memberships/{invitee}", UriKind.Relative), null, AcceptHeaders.OrganizationMembershipPreview).Wait(TimeSpan.FromSeconds(15)); + connection.Delete(new Uri($"orgs/{Organization}/memberships/{invitee}", UriKind.Relative)).Wait(TimeSpan.FromSeconds(15)); } } catch { } diff --git a/Octokit.Tests/Clients/AssigneesClientTests.cs b/Octokit.Tests/Clients/AssigneesClientTests.cs index 652838e82c..e48998e43c 100644 --- a/Octokit.Tests/Clients/AssigneesClientTests.cs +++ b/Octokit.Tests/Clients/AssigneesClientTests.cs @@ -25,7 +25,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<User>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/assignees"), null, - AcceptHeaders.StableVersion, Args.ApiOptions); } @@ -40,7 +39,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<User>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/assignees"), null, - AcceptHeaders.StableVersion, Args.ApiOptions); } @@ -62,7 +60,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<User>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/assignees"), null, - AcceptHeaders.StableVersion, options); } @@ -84,7 +81,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() connection.Received().GetAll<User>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/assignees"), null, - AcceptHeaders.StableVersion, options); } diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs index 0464fbcc14..bb9343c5f3 100644 --- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs +++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs @@ -292,8 +292,7 @@ public async Task ChecksApplicationAuthenticateAtCorrectUrl() client.Received().Post<ApplicationAuthorization>( Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"), - Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"), - "application/vnd.github.doctor-strange-preview+json"); + Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken")); } [Fact] @@ -321,8 +320,7 @@ public async Task ResetsApplicationAuthenticationAtCorrectUrl() client.Received().Patch<ApplicationAuthorization>( Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"), - Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"), - "application/vnd.github.doctor-strange-preview+json"); + Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken")); } [Fact] @@ -350,8 +348,7 @@ public async Task RevokesApplicationAuthenticationAtCorrectUrl() client.Received().Delete( Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"), - Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"), - "application/vnd.github.doctor-strange-preview+json"); + Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken")); } [Fact] diff --git a/Octokit.Tests/Clients/CheckRunsClientTests.cs b/Octokit.Tests/Clients/CheckRunsClientTests.cs index 8cffdd3328..dd9639c3af 100644 --- a/Octokit.Tests/Clients/CheckRunsClientTests.cs +++ b/Octokit.Tests/Clients/CheckRunsClientTests.cs @@ -31,8 +31,7 @@ public async Task RequestsCorrectUrl() connection.Received().Post<CheckRun>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-runs"), - newCheckRun, - "application/vnd.github.antiope-preview+json"); + newCheckRun); } [Fact] @@ -47,8 +46,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Post<CheckRun>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-runs"), - newCheckRun, - "application/vnd.github.antiope-preview+json"); + newCheckRun); } [Fact] @@ -93,8 +91,7 @@ public async Task RequestsCorrectUrl() connection.Received().Patch<CheckRun>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1"), - update, - "application/vnd.github.antiope-preview+json"); + update); } [Fact] @@ -109,8 +106,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Patch<CheckRun>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-runs/1"), - update, - "application/vnd.github.antiope-preview+json"); + update); } [Fact] @@ -152,7 +148,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<CheckRunsResponse>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"), Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -167,7 +162,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<CheckRunsResponse>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref/check-runs"), Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -188,7 +182,6 @@ public async Task RequestsCorrectUrlWithRequest() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -209,7 +202,6 @@ public async Task RequestsCorrectUrlWithRequestWithRepositoryId() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -231,7 +223,6 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", options); } @@ -253,7 +244,6 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", options); } @@ -331,7 +321,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<CheckRunsResponse>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/check-runs"), Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -346,7 +335,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<CheckRunsResponse>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1/check-runs"), Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -367,7 +355,6 @@ public async Task RequestsCorrectUrlWithRequest() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -388,7 +375,6 @@ public async Task RequestsCorrectUrlWithRequestWithRepositoryId() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -410,7 +396,6 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", options); } @@ -432,7 +417,6 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId() && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json", options); } @@ -493,8 +477,7 @@ public async Task RequestsCorrectUrl() connection.Received().Get<CheckRun>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1"), - null, - "application/vnd.github.antiope-preview+json"); + null); } [Fact] @@ -507,8 +490,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Get<CheckRun>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-runs/1"), - null, - "application/vnd.github.antiope-preview+json"); + null); } [Fact] @@ -545,7 +527,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<CheckRunAnnotation>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1/annotations"), null, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -560,7 +541,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<CheckRunAnnotation>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-runs/1/annotations"), null, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -577,7 +557,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<CheckRunAnnotation>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1/annotations"), null, - "application/vnd.github.antiope-preview+json", options); } @@ -594,7 +573,6 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() connection.Received().GetAll<CheckRunAnnotation>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-runs/1/annotations"), null, - "application/vnd.github.antiope-preview+json", options); } diff --git a/Octokit.Tests/Clients/CheckSuitesClientTests.cs b/Octokit.Tests/Clients/CheckSuitesClientTests.cs index 194c70fcc7..f9d91ad383 100644 --- a/Octokit.Tests/Clients/CheckSuitesClientTests.cs +++ b/Octokit.Tests/Clients/CheckSuitesClientTests.cs @@ -31,8 +31,7 @@ public async Task RequestsCorrectUrl() connection.Received().Get<CheckSuite>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.antiope-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -45,8 +44,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Get<CheckSuite>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.antiope-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -84,7 +82,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<CheckSuitesResponse>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"), Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -99,7 +96,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<CheckSuitesResponse>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref/check-suites"), Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -122,7 +118,6 @@ public async Task RequestsCorrectUrlWithRequest() Arg.Is<Dictionary<string, string>>(x => x["app_id"] == "123" && x["check_name"] == "build"), - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -145,7 +140,6 @@ public async Task RequestsCorrectUrlWithRequestWithRepositoryId() Arg.Is<Dictionary<string, string>>(x => x["app_id"] == "123" && x["check_name"] == "build"), - "application/vnd.github.antiope-preview+json", Args.ApiOptions); } @@ -224,8 +218,7 @@ public async Task RequestsCorrectUrl() connection.Received().Patch<CheckSuitePreferencesResponse>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/preferences"), - preferences, - "application/vnd.github.antiope-preview+json"); + preferences); } [Fact] @@ -240,8 +233,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Patch<CheckSuitePreferencesResponse>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/preferences"), - preferences, - "application/vnd.github.antiope-preview+json"); + preferences); } [Fact] @@ -284,8 +276,7 @@ public async Task RequestsCorrectUrl() connection.Received().Post<CheckSuite>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites"), - newCheckSuite, - "application/vnd.github.antiope-preview+json"); + newCheckSuite); } [Fact] @@ -300,8 +291,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Post<CheckSuite>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites"), - newCheckSuite, - "application/vnd.github.antiope-preview+json"); + newCheckSuite); } [Fact] @@ -343,9 +333,7 @@ public async Task RequestsCorrectUrl() await client.Rerequest("fake", "repo", 1); connection.Connection.Received().Post( - Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/rerequest"), - Args.Object, - "application/vnd.github.antiope-preview+json"); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/rerequest")); } [Fact] @@ -357,9 +345,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Rerequest(1, 1); connection.Connection.Received().Post( - Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1/rerequest"), - Args.Object, - "application/vnd.github.antiope-preview+json"); + Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1/rerequest")); } [Fact] diff --git a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs index fd66b02a43..81347732b2 100644 --- a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs @@ -27,7 +27,7 @@ public async Task RequestsCorrectUrl() await client.GetAll("fake", "repo", 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -45,7 +45,7 @@ public async Task RequestsCorrectUrlApiOptions() await client.GetAll("fake", "repo", 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, options); } [Fact] @@ -56,7 +56,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAll(1, 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -74,7 +74,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions() await client.GetAll(1, 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, options); } [Fact] @@ -113,7 +113,7 @@ public void RequestsCorrectUrl() client.Create("fake", "repo", 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), newReaction); } [Fact] @@ -126,7 +126,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.Create(1, 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/1/reactions"), newReaction); } [Fact] diff --git a/Octokit.Tests/Clients/DeploymentStatusClientTests.cs b/Octokit.Tests/Clients/DeploymentStatusClientTests.cs index 9cf4c083ef..90791a3192 100644 --- a/Octokit.Tests/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentStatusClientTests.cs @@ -21,7 +21,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll< DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, - "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json", Args.ApiOptions); } @@ -36,7 +35,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, - "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json", Args.ApiOptions); } @@ -59,7 +57,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<DeploymentStatus>( Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, - "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json", options); } @@ -81,7 +78,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, - "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json", options); } @@ -137,8 +133,7 @@ public void PostsToCorrectUrl() client.Create("owner", "repo", 1, newDeploymentStatus); connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - newDeploymentStatus, - "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json"); + newDeploymentStatus); } [Fact] @@ -151,8 +146,7 @@ public void PostsToCorrectUrlWithRepositoryId() client.Create(1, 1, newDeploymentStatus); connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Any<NewDeploymentStatus>(), - "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json"); + Arg.Any<NewDeploymentStatus>()); } [Fact] @@ -194,8 +188,7 @@ public void PassesNewDeploymentRequest() client.Create("owner", "repo", 1, newDeploymentStatus); connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - newDeploymentStatus, - Arg.Any<string>()); + newDeploymentStatus); } [Fact] @@ -208,8 +201,7 @@ public void SendsPreviewAcceptHeaders() client.Create("owner", "repo", 1, newDeploymentStatus); connection.Received(1).Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Any<NewDeploymentStatus>(), - Arg.Is<string>(s => s == "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json")); + Arg.Any<NewDeploymentStatus>()); } } diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index 4605743736..5515d7d39f 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -59,9 +59,7 @@ public async Task RequestsCorrectUrl() await client.GetAll(owner, name); connection.Received(1) - .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, - "application/vnd.github.ant-man-preview+json", - Args.ApiOptions); + .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, Args.ApiOptions); } [Fact] @@ -97,7 +95,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, - "application/vnd.github.ant-man-preview+json", options); } @@ -133,7 +130,6 @@ public void RequestsCorrectUrlWithPreviewAcceptHeaders() connection.Received(1) .GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), Arg.Any<IDictionary<string, string>>(), - "application/vnd.github.ant-man-preview+json", Args.ApiOptions); } } @@ -185,8 +181,7 @@ public void PostsToDeploymentsUrl() client.Create("owner", "name", newDeployment); connection.Received(1).Post<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - newDeployment, - "application/vnd.github.ant-man-preview+json"); + newDeployment); } [Fact] @@ -211,8 +206,7 @@ public void SendsPreviewAcceptHeaders() client.Create("owner", "name", newDeployment); connection.Received(1).Post<Deployment>(Arg.Any<Uri>(), - Arg.Any<NewDeployment>(), - "application/vnd.github.ant-man-preview+json"); + Arg.Any<NewDeployment>()); } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClientTests.cs index c1ee944eca..a4c0fe950e 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClientTests.cs @@ -28,7 +28,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments"), null, - "application/vnd.github.eye-scream-preview+json", Args.ApiOptions); } @@ -49,7 +48,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments"), null, - "application/vnd.github.eye-scream-preview+json", options); } } @@ -65,8 +63,7 @@ public async Task RequestsTheCorrectUrl() await client.Get(1); connection.Received().Get<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1"), - null, - "application/vnd.github.eye-scream-preview+json"); + null); } } @@ -82,8 +79,7 @@ public async Task RequestsCorrectUrl() await client.Create(data); connection.Received().Post<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments"), - data, - "application/vnd.github.eye-scream-preview+json"); + data); } [Fact] @@ -115,8 +111,7 @@ public async Task RequestsTheCorrectUrl() await client.Edit(1, data); connection.Received().Patch<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1"), - data, - "application/vnd.github.eye-scream-preview+json"); + data); } [Fact] @@ -139,8 +134,7 @@ public async Task RequestsTheCorrectUrl() await client.Delete(1); connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1"), - Arg.Any<object>(), - "application/vnd.github.eye-scream-preview+json"); + Arg.Any<object>()); } } @@ -155,8 +149,7 @@ public async Task RequestsTheCorrectUrl() await client.DownloadStatus(1); connection.Received().Get<PreReceiveEnvironmentDownload>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1/downloads/latest"), - null, - "application/vnd.github.eye-scream-preview+json"); + null); } } @@ -171,8 +164,7 @@ public async Task RequestsTheCorrectUrl() await client.TriggerDownload(1); connection.Received().Post<PreReceiveEnvironmentDownload>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1/downloads"), - Arg.Any<object>(), - "application/vnd.github.eye-scream-preview+json"); + Arg.Any<object>()); } } } diff --git a/Octokit.Tests/Clients/GitHubAppInstallationsClientTests.cs b/Octokit.Tests/Clients/GitHubAppInstallationsClientTests.cs index cbdddc24ae..b6e77f3e77 100644 --- a/Octokit.Tests/Clients/GitHubAppInstallationsClientTests.cs +++ b/Octokit.Tests/Clients/GitHubAppInstallationsClientTests.cs @@ -30,7 +30,6 @@ public void GetsFromCorrectUrl() connection.Received().GetAll<RepositoriesResponse>( Arg.Is<Uri>(u => u.ToString() == "installation/repositories"), null, - "application/vnd.github.machine-man-preview+json", Args.ApiOptions); } @@ -52,7 +51,6 @@ public void GetsFromCorrectUrllWithApiOptions() connection.Received().GetAll<RepositoriesResponse>( Arg.Is<Uri>(u => u.ToString() == "installation/repositories"), null, - "application/vnd.github.machine-man-preview+json", options); } } @@ -70,7 +68,6 @@ public void GetsFromCorrectUrl() connection.Received().GetAll<RepositoriesResponse>( Arg.Is<Uri>(u => u.ToString() == "user/installations/1234/repositories"), null, - "application/vnd.github.machine-man-preview+json", Args.ApiOptions); } @@ -92,7 +89,6 @@ public void GetsFromCorrectUrllWithApiOptions() connection.Received().GetAll<RepositoriesResponse>( Arg.Is<Uri>(u => u.ToString() == "user/installations/1234/repositories"), null, - "application/vnd.github.machine-man-preview+json", options); } } diff --git a/Octokit.Tests/Clients/GitHubAppsClientTests.cs b/Octokit.Tests/Clients/GitHubAppsClientTests.cs index bdd26c21c4..5647679eb3 100644 --- a/Octokit.Tests/Clients/GitHubAppsClientTests.cs +++ b/Octokit.Tests/Clients/GitHubAppsClientTests.cs @@ -44,7 +44,7 @@ public void GetsFromCorrectUrl() client.Get("foobar"); - connection.Received().Get<GitHubApp>(Arg.Is<Uri>(u => u.ToString() == "apps/foobar"), null, "application/vnd.github.machine-man-preview+json"); + connection.Received().Get<GitHubApp>(Arg.Is<Uri>(u => u.ToString() == "apps/foobar"), null); } } @@ -58,7 +58,7 @@ public void GetsFromCorrectUrl() client.GetCurrent(); - connection.Received().Get<GitHubApp>(Arg.Is<Uri>(u => u.ToString() == "app"), null, "application/vnd.github.machine-man-preview+json"); + connection.Received().Get<GitHubApp>(Arg.Is<Uri>(u => u.ToString() == "app"), null); } } @@ -81,7 +81,7 @@ public async Task RequestsCorrectUrl() client.GetAllInstallationsForCurrent(); - connection.Received().GetAll<Installation>(Arg.Is<Uri>(u => u.ToString() == "app/installations"), null, "application/vnd.github.machine-man-preview+json", Args.ApiOptions); + connection.Received().GetAll<Installation>(Arg.Is<Uri>(u => u.ToString() == "app/installations"), null, Args.ApiOptions); } [Fact] @@ -99,7 +99,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAllInstallationsForCurrent(options); - connection.Received().GetAll<Installation>(Arg.Is<Uri>(u => u.ToString() == "app/installations"), null, "application/vnd.github.machine-man-preview+json", options); + connection.Received().GetAll<Installation>(Arg.Is<Uri>(u => u.ToString() == "app/installations"), null, options); } } @@ -113,7 +113,7 @@ public void GetsFromCorrectUrl() client.GetInstallationForCurrent(123); - connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "app/installations/123"), null, "application/vnd.github.machine-man-preview+json"); + connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "app/installations/123"), null); } } @@ -127,7 +127,7 @@ public async Task GetsFromCorrectUrl() await client.GetAllInstallationsForCurrentUser(); - await connection.Received().GetAll<InstallationsResponse>(Arg.Is<Uri>(u => u.ToString() == "user/installations"), null, "application/vnd.github.machine-man-preview+json"); + await connection.Received().GetAll<InstallationsResponse>(Arg.Is<Uri>(u => u.ToString() == "user/installations")); } [Fact] @@ -145,7 +145,7 @@ public async Task GetsFromCorrectUrlWithOptions() await client.GetAllInstallationsForCurrentUser(options); - await connection.Received().GetAll<InstallationsResponse>(Arg.Is<Uri>(u => u.ToString() == "user/installations"), null, "application/vnd.github.machine-man-preview+json", options); + await connection.Received().GetAll<InstallationsResponse>(Arg.Is<Uri>(u => u.ToString() == "user/installations"), null, options); } } @@ -161,7 +161,7 @@ public void PostsToCorrectUrl() client.CreateInstallationToken(fakeInstallationId); - connection.Received().Post<AccessToken>(Arg.Is<Uri>(u => u.ToString() == "app/installations/3141/access_tokens"), string.Empty, "application/vnd.github.machine-man-preview+json"); + connection.Received().Post<AccessToken>(Arg.Is<Uri>(u => u.ToString() == "app/installations/3141/access_tokens"), string.Empty); } } @@ -193,7 +193,7 @@ public void GetsFromCorrectUrl() client.GetOrganizationInstallationForCurrent("ducks"); - connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "orgs/ducks/installation"), null, "application/vnd.github.machine-man-preview+json"); + connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "orgs/ducks/installation"), null); } } @@ -227,7 +227,7 @@ public void GetsFromCorrectUrl() client.GetRepositoryInstallationForCurrent("mighty", "ducks"); - connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "repos/mighty/ducks/installation"), null, "application/vnd.github.machine-man-preview+json"); + connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "repos/mighty/ducks/installation"), null); } [Fact] @@ -238,7 +238,7 @@ public void GetsFromCorrectUrlByRepositoryId() client.GetRepositoryInstallationForCurrent(1234); - connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/installation"), null, "application/vnd.github.machine-man-preview+json"); + connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/installation"), null); } } @@ -270,7 +270,7 @@ public void GetsFromCorrectUrl() client.GetUserInstallationForCurrent("ducks"); - connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "users/ducks/installation"), null, "application/vnd.github.machine-man-preview+json"); + connection.Received().Get<Installation>(Arg.Is<Uri>(u => u.ToString() == "users/ducks/installation"), null); } } } diff --git a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs index d5c17d383c..bc25009a84 100644 --- a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() await client.GetAll("fake", "repo", 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -44,7 +44,7 @@ public async Task RequestsCorrectUrlApiOptions() await client.GetAll("fake", "repo", 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, options); } [Fact] @@ -55,7 +55,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAll(1, 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -73,7 +73,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions() await client.GetAll(1, 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, options); } [Fact] @@ -112,7 +112,7 @@ public void RequestsCorrectUrl() client.Create("fake", "repo", 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/1/reactions"), newReaction); } [Fact] @@ -125,7 +125,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.Create(1, 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/1/reactions"), newReaction); } [Fact] diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index 4decf526c1..80373e6c62 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -24,8 +24,7 @@ public async Task RequestsCorrectUrl() connection.Received().Get<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -37,8 +36,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Get(1, 42); connection.Received().Get<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -67,7 +65,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -81,7 +78,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -103,7 +99,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -124,7 +119,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -164,7 +158,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -178,7 +171,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -198,7 +190,6 @@ public async Task RequestsCorrectUrlWithIssueCommentRequest() connection.Received().GetAll<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -217,7 +208,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest() connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -239,7 +229,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -260,7 +249,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); } diff --git a/Octokit.Tests/Clients/IssueReactionsClientTests.cs b/Octokit.Tests/Clients/IssueReactionsClientTests.cs index 8d4787077b..4b891d9e83 100644 --- a/Octokit.Tests/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() await client.GetAll("fake", "repo", 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -44,7 +44,7 @@ public async Task RequestsCorrectUrlApiOptions() await client.GetAll("fake", "repo", 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, options); } [Fact] @@ -55,7 +55,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAll(1, 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -73,7 +73,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions() await client.GetAll(1, 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, options); } [Fact] @@ -112,7 +112,7 @@ public void RequestsCorrectUrl() client.Create("fake", "repo", 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), newReaction); } [Fact] @@ -125,7 +125,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.Create(1, 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/1/reactions"), newReaction); } [Fact] diff --git a/Octokit.Tests/Clients/IssueTimelineClientTests.cs b/Octokit.Tests/Clients/IssueTimelineClientTests.cs index 083f7fcd38..a22d961ef3 100644 --- a/Octokit.Tests/Clients/IssueTimelineClientTests.cs +++ b/Octokit.Tests/Clients/IssueTimelineClientTests.cs @@ -31,7 +31,6 @@ public async Task RequestsTheCorrectUrl() connection.Received().GetAll<TimelineEventInfo>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/timeline"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.mockingbird-preview+json,application/vnd.github.starfox-preview+json", Arg.Any<ApiOptions>()); } @@ -46,7 +45,6 @@ public async Task RequestsTheCorrectUrlWithApiOptions() connection.Received().GetAll<TimelineEventInfo>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/timeline"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.mockingbird-preview+json,application/vnd.github.starfox-preview+json", Arg.Is<ApiOptions>(ao => ao.PageSize == 30)); } @@ -61,7 +59,6 @@ public async Task RequestsTheCorrectUrlWithRepositoryId() connection.Received().GetAll<TimelineEventInfo>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/timeline"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.mockingbird-preview+json,application/vnd.github.starfox-preview+json", Arg.Any<ApiOptions>()); } @@ -76,7 +73,6 @@ public async Task RequestsTheCorrectUrlWithRepositoryIdAndApiOptions() connection.Received().GetAll<TimelineEventInfo>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/timeline"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.mockingbird-preview+json,application/vnd.github.starfox-preview+json", Arg.Is<ApiOptions>(ao => ao.PageSize == 30)); } diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index d30b518c31..5eaceb81d7 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -23,8 +23,7 @@ public async Task RequestsCorrectUrl() await client.Get("fake", "repo", 42); connection.Received().Get<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -36,8 +35,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Get(1, 42); connection.Received().Get<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -76,7 +74,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "issues"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -94,7 +91,6 @@ public async Task SendsAppropriateParameters() && d["sort"] == "created" && d["state"] == "open" && d["direction"] == "asc"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } } @@ -122,7 +118,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "user/issues"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } } @@ -164,7 +159,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/issues"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -185,7 +179,6 @@ public void SendsAppropriateParameters() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } } @@ -238,7 +231,6 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -252,7 +244,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -273,7 +264,6 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -294,7 +284,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() connection.Received().GetAll<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -315,7 +304,6 @@ public async Task SendsAppropriateParameters() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -336,7 +324,6 @@ public async Task SendsAppropriateParametersWithRepositoryId() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -364,7 +351,6 @@ public async Task SendsAppropriateParametersWithApiOptions() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -392,7 +378,6 @@ public async Task SendsAppropriateParametersWithRepositoryIdWithApiOptions() && d["direction"] == "asc" && d["sort"] == "created" && d["filter"] == "assigned"), - "application/vnd.github.squirrel-girl-preview+json", options); } } diff --git a/Octokit.Tests/Clients/IssuesEventsClientTests.cs b/Octokit.Tests/Clients/IssuesEventsClientTests.cs index 6ad2ccc85e..db09ae1d64 100644 --- a/Octokit.Tests/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests/Clients/IssuesEventsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() var client = new IssuesEventsClient(connection); await client.GetAllForIssue("fake", "repo", 42); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), null, "application/vnd.github.starfox-preview+json", Args.ApiOptions); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), null, Args.ApiOptions); } [Fact] @@ -37,7 +37,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAllForIssue(1, 42); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), null, "application/vnd.github.starfox-preview+json", Args.ApiOptions); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), null, Args.ApiOptions); } [Fact] @@ -55,7 +55,7 @@ public async Task RequestsCorrectUrlWithApiOptions() await client.GetAllForIssue("fake", "repo", 42, options); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), null, "application/vnd.github.starfox-preview+json", options); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), null, options); } [Fact] @@ -73,7 +73,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAllForIssue(1, 42, options); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), null, "application/vnd.github.starfox-preview+json", options); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), null, options); } [Fact] @@ -106,7 +106,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForRepository("fake", "repo"); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), null, "application/vnd.github.starfox-preview+json", Args.ApiOptions); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), null, Args.ApiOptions); } [Fact] @@ -117,7 +117,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAllForRepository(1); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), null, "application/vnd.github.starfox-preview+json", Args.ApiOptions); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), null, Args.ApiOptions); } [Fact] @@ -135,7 +135,7 @@ public async Task RequestsCorrectUrlWithApiOptions() await client.GetAllForRepository("fake", "repo", options); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), null, "application/vnd.github.starfox-preview+json", options); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), null, options); } [Fact] @@ -153,7 +153,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAllForRepository(1, options); - connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), null, "application/vnd.github.starfox-preview+json", options); + connection.Received().GetAll<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), null, options); } [Fact] @@ -186,7 +186,7 @@ public void RequestsCorrectUrl() client.Get("fake", "repo", 42); - connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events/42"), null, "application/vnd.github.starfox-preview+json"); + connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events/42"), null); } [Fact] @@ -197,7 +197,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.Get(1, 42); - connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events/42"), null, "application/vnd.github.starfox-preview+json"); + connection.Received().Get<IssueEvent>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events/42"), null); } [Fact] diff --git a/Octokit.Tests/Clients/MigrationsClientTests.cs b/Octokit.Tests/Clients/MigrationsClientTests.cs index 5556659858..26d71d16d8 100644 --- a/Octokit.Tests/Clients/MigrationsClientTests.cs +++ b/Octokit.Tests/Clients/MigrationsClientTests.cs @@ -30,8 +30,7 @@ public void RequestsCorrectUrl() connection.Received().Get<Migration>( Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations/69"), - null, - "application/vnd.github.wyandotte-preview+json"); + null); } [Fact] @@ -58,7 +57,6 @@ public void RequestsCorrectUrl() connection.Received().GetAll<Migration>( Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations"), null, - "application/vnd.github.wyandotte-preview+json", Args.ApiOptions); } @@ -79,7 +77,6 @@ public void RequestsCorrectUrlApiOptions() connection.Received().GetAll<Migration>( Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations"), null, - "application/vnd.github.wyandotte-preview+json", options); } @@ -108,8 +105,7 @@ public void RequestsCorrectUrl() connection.Received().Post<Migration>( Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations"), - Arg.Any<StartMigrationRequest>(), - "application/vnd.github.wyandotte-preview+json"); + Arg.Any<StartMigrationRequest>()); } [Fact] @@ -141,8 +137,7 @@ public void PassesRequestBody() Arg.Is<StartMigrationRequest>(m => m.Repositories.Equals(migrationRequest.Repositories) && m.LockRepositories == migrationRequest.LockRepositories && - m.ExcludeAttachments == migrationRequest.ExcludeAttachments), - "application/vnd.github.wyandotte-preview+json"); + m.ExcludeAttachments == migrationRequest.ExcludeAttachments)); } } @@ -156,10 +151,8 @@ public void RequestsCorrectUrl() client.GetArchive("fake", 69); - connection.Connection.Received().Get<byte[]>( - Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations/69/archive"), - null, - "application/vnd.github.wyandotte-preview+json"); + connection.Connection.Received().GetRaw( + Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations/69/archive"), null); } [Fact] @@ -185,8 +178,7 @@ public void RequestsCorrectUrl() connection.Received().Delete( Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations/69/archive"), - Arg.Any<object>(), - "application/vnd.github.wyandotte-preview+json"); + Arg.Any<object>()); } [Fact] @@ -212,8 +204,7 @@ public void RequestsCorrectUrl() connection.Received().Delete( Arg.Is<Uri>(u => u.ToString() == "orgs/fake/migrations/69/repos/repo/lock"), - Arg.Any<object>(), - "application/vnd.github.wyandotte-preview+json"); + Arg.Any<object>()); } [Fact] diff --git a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs index d81e6d257c..e920dcb2f2 100644 --- a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs @@ -597,7 +597,7 @@ public void RequestsTheCorrectUrl() client.GetAllPendingInvitations("org"); - connection.Received().GetAll<OrganizationMembershipInvitation>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"), null, "application/vnd.github.korra-preview+json", Args.ApiOptions); + connection.Received().GetAll<OrganizationMembershipInvitation>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"), null, Args.ApiOptions); } [Fact] @@ -612,7 +612,7 @@ public void RequestsTheCorrectUrlWithApiOptions() }; client.GetAllPendingInvitations("org", options); - connection.Received().GetAll<OrganizationMembershipInvitation>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"), null, "application/vnd.github.korra-preview+json", options); + connection.Received().GetAll<OrganizationMembershipInvitation>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"), null, options); } [Fact] diff --git a/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs index beffb970be..7d503b5e32 100644 --- a/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationOutsideCollaboratorsClientTests.cs @@ -26,7 +26,7 @@ public void RequestsTheCorrectUrl() client.GetAll("org"); - connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators"), null, "application/vnd.github.korra-preview+json", Args.ApiOptions); + connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators"), null, Args.ApiOptions); } [Fact] @@ -44,7 +44,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAll("org", options); - connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators"), null, "application/vnd.github.korra-preview+json", options); + connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators"), null, options); } [Fact] @@ -76,7 +76,7 @@ public void AllFilterRequestsTheCorrectUrl() client.GetAll("org", OrganizationMembersFilter.All); - connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), null, "application/vnd.github.korra-preview+json", Args.ApiOptions); + connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), null, Args.ApiOptions); } [Fact] @@ -94,7 +94,7 @@ public void AllFilterRequestsTheCorrectUrlWithApiOptions() client.GetAll("org", OrganizationMembersFilter.All, options); - connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), null, "application/vnd.github.korra-preview+json", options); + connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), null, options); } [Fact] @@ -105,7 +105,7 @@ public void TwoFactorFilterRequestsTheCorrectUrl() client.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled); - connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), null, "application/vnd.github.korra-preview+json", Args.ApiOptions); + connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), null, Args.ApiOptions); } [Fact] @@ -123,7 +123,7 @@ public void TwoFactorFilterRequestsTheCorrectUrlWithApiOptions() client.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options); - connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), null, "application/vnd.github.korra-preview+json", options); + connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), null, options); } } @@ -137,10 +137,7 @@ public void RequestsTheCorrectUrl() client.Delete("org", "user"); - connection.Connection.Received().Delete( - Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators/user"), - Arg.Any<object>(), - "application/vnd.github.korra-preview+json"); + connection.Connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators/user")); } [Fact] @@ -166,9 +163,7 @@ public void RequestsTheCorrectUrl() client.ConvertFromMember("org", "user"); - connection.Connection.Received().Put( - Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators/user"), - "application/vnd.github.korra-preview+json"); + connection.Connection.Received().Put(Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators/user")); } [Fact] diff --git a/Octokit.Tests/Clients/ProjectCardsClientTests.cs b/Octokit.Tests/Clients/ProjectCardsClientTests.cs index 20d1b6eb0a..b0cceb2440 100644 --- a/Octokit.Tests/Clients/ProjectCardsClientTests.cs +++ b/Octokit.Tests/Clients/ProjectCardsClientTests.cs @@ -30,7 +30,6 @@ public async Task RequestCorrectURL() connection.Received().GetAll<ProjectCard>( Arg.Is<Uri>(u => u.ToString() == "projects/columns/1/cards"), Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -47,7 +46,6 @@ public async Task SendsAppropriateParameters() Arg.Is<Dictionary<string, string>>(x => x.Count == 1 && x["archived_state"] == "not_archived"), - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -76,8 +74,7 @@ public async Task RequestCorrectURL() connection.Received().Get<ProjectCard>( Arg.Is<Uri>(u => u.ToString() == "projects/columns/cards/1"), - null, - "application/vnd.github.inertia-preview+json"); + null); } } @@ -94,8 +91,7 @@ public async Task PostsToCorrectURL() connection.Received().Post<ProjectCard>( Arg.Is<Uri>(u => u.ToString() == "projects/columns/1/cards"), - newCard, - "application/vnd.github.inertia-preview+json"); + newCard); } [Fact] @@ -124,8 +120,7 @@ public async Task PostsToCorrectURL() connection.Received().Patch<ProjectCard>( Arg.Is<Uri>(u => u.ToString() == "projects/columns/cards/1"), - updateCard, - "application/vnd.github.inertia-preview+json"); + updateCard); } [Fact] @@ -153,8 +148,7 @@ public async Task DeletesCorrectURL() connection.Connection.Received().Delete( Arg.Is<Uri>(u => u.ToString() == "projects/columns/cards/1"), - Arg.Any<object>(), - "application/vnd.github.inertia-preview+json"); + Arg.Any<object>()); } } @@ -172,7 +166,7 @@ public async Task PostsToCorrectURL() connection.Connection.Received().Post( Arg.Is<Uri>(u => u.ToString() == "projects/columns/cards/1/moves"), position, - "application/vnd.github.inertia-preview+json"); + null); } [Fact] diff --git a/Octokit.Tests/Clients/ProjectColumnsClientTests.cs b/Octokit.Tests/Clients/ProjectColumnsClientTests.cs index 7eb3c8fb99..e366b2947b 100644 --- a/Octokit.Tests/Clients/ProjectColumnsClientTests.cs +++ b/Octokit.Tests/Clients/ProjectColumnsClientTests.cs @@ -30,7 +30,6 @@ public async Task RequestCorrectURL() connection.Received().GetAll<ProjectColumn>( Arg.Is<Uri>(u => u.ToString() == "projects/1/columns"), Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -55,8 +54,7 @@ public async Task RequestCorrectURL() connection.Received().Get<ProjectColumn>( Arg.Is<Uri>(u => u.ToString() == "projects/columns/1"), - null, - "application/vnd.github.inertia-preview+json"); + null); } } @@ -73,8 +71,7 @@ public async Task PostsToCorrectURL() connection.Received().Post<ProjectColumn>( Arg.Is<Uri>(u => u.ToString() == "projects/1/columns"), - newProjectColumn, - "application/vnd.github.inertia-preview+json"); + newProjectColumn); } [Fact] @@ -100,8 +97,7 @@ public async Task PostsToCorrectURL() connection.Received().Patch<ProjectColumn>( Arg.Is<Uri>(u => u.ToString() == "projects/columns/1"), - updateProjectColumn, - "application/vnd.github.inertia-preview+json"); + updateProjectColumn); } [Fact] @@ -125,8 +121,7 @@ public async Task DeletesCorrectURL() connection.Connection.Received().Delete( Arg.Is<Uri>(u => u.ToString() == "projects/columns/1"), - Arg.Any<object>(), - "application/vnd.github.inertia-preview+json"); + Arg.Any<object>()); } } @@ -144,7 +139,7 @@ public async Task PostsToCorrectURL() connection.Connection.Received().Post( Arg.Is<Uri>(u => u.ToString() == "projects/columns/1/moves"), position, - "application/vnd.github.inertia-preview+json"); + null); } [Fact] diff --git a/Octokit.Tests/Clients/ProjectsClientTests.cs b/Octokit.Tests/Clients/ProjectsClientTests.cs index f723667d92..2f06979234 100644 --- a/Octokit.Tests/Clients/ProjectsClientTests.cs +++ b/Octokit.Tests/Clients/ProjectsClientTests.cs @@ -31,7 +31,6 @@ public async Task RequestCorrectUrl() connection.Received().GetAll<Project>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/projects"), Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -46,7 +45,6 @@ public async Task RequestCorrectUrlWithRequestParameter() connection.Received().GetAll<Project>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/projects"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -61,7 +59,6 @@ public async Task RequestCorrectUrlWithRepositoryId() connection.Received().GetAll<Project>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/projects"), Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -76,7 +73,6 @@ public async Task RequestCorrectUrlWithRequestParameterWithRepositoryId() connection.Received().GetAll<Project>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/projects"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -126,7 +122,6 @@ public async Task RequestCorrectUrl() connection.Received().GetAll<Project>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/projects"), Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -141,7 +136,6 @@ public async Task RequestCorrectUrlWithRequestParameter() connection.Received().GetAll<Project>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/projects"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), - "application/vnd.github.inertia-preview+json", Args.ApiOptions); } @@ -178,7 +172,7 @@ public async Task RequestCorrectURL() await client.Get(1); - connection.Received().Get<Project>(Arg.Is<Uri>(u => u.ToString() == "projects/1"), null, "application/vnd.github.inertia-preview+json"); + connection.Received().Get<Project>(Arg.Is<Uri>(u => u.ToString() == "projects/1"), null); } } @@ -193,7 +187,7 @@ public async Task PostsToCorrectURL() await client.CreateForRepository(1, newProject); - connection.Received().Post<Project>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/projects"), newProject, "application/vnd.github.inertia-preview+json"); + connection.Received().Post<Project>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/projects"), newProject); } [Fact] @@ -216,7 +210,7 @@ public async Task PostsToCorrectURL() await client.CreateForOrganization("org", newProject); - connection.Received().Post<Project>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/projects"), newProject, "application/vnd.github.inertia-preview+json"); + connection.Received().Post<Project>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/projects"), newProject); } [Fact] @@ -242,7 +236,7 @@ public async Task PostsToCorrectURL() await client.Update(1, updateProject); - connection.Received().Patch<Project>(Arg.Is<Uri>(u => u.ToString() == "projects/1"), updateProject, "application/vnd.github.inertia-preview+json"); + connection.Received().Patch<Project>(Arg.Is<Uri>(u => u.ToString() == "projects/1"), updateProject); } [Fact] @@ -264,7 +258,7 @@ public async Task DeletesCorrectUrl() await client.Delete(1); - connection.Connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "projects/1"), Arg.Any<object>(), "application/vnd.github.inertia-preview+json"); + connection.Connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "projects/1"), Arg.Any<object>()); } } } diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs index 099f7aa9b1..063b14ea02 100644 --- a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() await client.GetAll("fake", "repo", 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/comments/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -43,7 +43,7 @@ public async Task RequestsCorrectUrlApiOptions() await client.GetAll("fake", "repo", 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/comments/42/reactions"), null, options); } [Fact] @@ -54,7 +54,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAll(1, 42); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments/42/reactions"), null, Args.ApiOptions); } [Fact] @@ -71,7 +71,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions() await client.GetAll(1, 42, options); - connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments/42/reactions"), null, options); } [Fact] @@ -110,7 +110,7 @@ public void RequestsCorrectUrl() client.Create("fake", "repo", 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/comments/1/reactions"), newReaction); } [Fact] @@ -123,7 +123,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.Create(1, 1, newReaction); - connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments/1/reactions"), newReaction); } [Fact] diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs index 9b9c57b5e4..eae63b578a 100644 --- a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs @@ -99,8 +99,7 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<PullRequestReviewComment>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/pulls/7/comments"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + Arg.Any<Dictionary<string, string>>(), Args.ApiOptions); } [Fact] @@ -132,8 +131,7 @@ public async Task RequestsCorrectUrlWithApiOptions() connection.Received().GetAll<PullRequestReviewComment>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/pulls/7/comments"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); + Arg.Any<Dictionary<string, string>>(), options); } [Fact] @@ -200,7 +198,6 @@ public async Task RequestsCorrectUrl() && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -224,7 +221,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + Args.ApiOptions); } [Fact] @@ -254,7 +251,6 @@ public async Task RequestsCorrectUrlWithApiOptions() && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -285,7 +281,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), - "application/vnd.github.squirrel-girl-preview+json", options); + options); } [Fact] @@ -300,7 +296,6 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArguments() Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -316,7 +311,7 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsWithRepositor Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + Args.ApiOptions); } [Fact] @@ -338,7 +333,6 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsWithApiOption Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), - "application/vnd.github.squirrel-girl-preview+json", options); } @@ -361,7 +355,7 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsWithApiOption Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), - "application/vnd.github.squirrel-girl-preview+json", options); + options); } [Fact] @@ -420,8 +414,7 @@ public void RequestsCorrectUrl() connection.Received().Get<PullRequestReviewComment>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/pulls/comments/53"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] diff --git a/Octokit.Tests/Clients/PullRequestsClientTests.cs b/Octokit.Tests/Clients/PullRequestsClientTests.cs index ca0488fca9..2f10009ad5 100644 --- a/Octokit.Tests/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestsClientTests.cs @@ -18,7 +18,7 @@ public async Task RequestsCorrectUrl() await client.Get("fake", "repo", 42); - connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json"); + connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"), Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -29,7 +29,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Get(1, 42); - connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json"); + connection.Received().Get<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42"), Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -56,7 +56,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), - Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); + Arg.Any<Dictionary<string, string>>(), Args.ApiOptions); } [Fact] @@ -68,7 +68,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAllForRepository(1); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), - Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); + Arg.Any<Dictionary<string, string>>(), Args.ApiOptions); } [Fact] @@ -87,7 +87,7 @@ public async Task RequestsCorrectUrlWithApiOptions() await client.GetAllForRepository("fake", "repo", options); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), - Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", options); + Arg.Any<Dictionary<string, string>>(), options); } [Fact] @@ -106,7 +106,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() await client.GetAllForRepository(1, options); connection.Received().GetAll<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), - Arg.Any<Dictionary<string, string>>(), "application/vnd.github.shadow-cat-preview+json", options); + Arg.Any<Dictionary<string, string>>(), options); } [Fact] @@ -123,7 +123,7 @@ public async Task SendsAppropriateParameters() && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); + && d["direction"] == "desc"), Args.ApiOptions); } [Fact] @@ -140,7 +140,7 @@ public async Task SendsAppropriateParametersWithRepositoryId() && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", Args.ApiOptions); + && d["direction"] == "desc"), Args.ApiOptions); } [Fact] @@ -164,7 +164,7 @@ public async Task SendsAppropriateParametersWithApiOptions() && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", options); + && d["direction"] == "desc"), options); } [Fact] @@ -188,7 +188,7 @@ public async Task SendsAppropriateParametersWithApiOptionsWithRepositoryId() && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json", options); + && d["direction"] == "desc"), options); } [Fact] @@ -243,7 +243,7 @@ public async Task PostsToCorrectUrl() await client.Create("fake", "repo", newPullRequest); connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls"), - newPullRequest, "application/vnd.github.shadow-cat-preview+json"); + newPullRequest); } [Fact] @@ -256,7 +256,7 @@ public async Task PostsToCorrectUrlWithRepositoryId() await client.Create(1, newPullRequest); connection.Received().Post<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls"), - newPullRequest, "application/vnd.github.shadow-cat-preview+json"); + newPullRequest); } [Fact] @@ -288,7 +288,7 @@ public async Task PostsToCorrectUrl() await client.Update("fake", "repo", 42, pullRequestUpdate); connection.Received().Patch<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42"), - pullRequestUpdate, "application/vnd.github.shadow-cat-preview+json"); + pullRequestUpdate); } [Fact] @@ -301,7 +301,7 @@ public async Task PostsToCorrectUrlWithRepositoryId() await client.Update(1, 42, pullRequestUpdate); connection.Received().Patch<PullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42"), - pullRequestUpdate, "application/vnd.github.shadow-cat-preview+json"); + pullRequestUpdate); } [Fact] diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs index 681a077b51..6e311e53fe 100644 --- a/Octokit.Tests/Clients/ReactionsClientTests.cs +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task DeletesCorrectUrl() await client.Delete(42); - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "reactions/42"), Arg.Any<object>(), "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "reactions/42"), Arg.Any<object>()); } } } diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index c3177f51aa..f255388a83 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -303,8 +303,7 @@ public void RequestsCorrectUrl() client.ReviewPermission("owner", "test", "user1"); connection.Received().Get<CollaboratorPermission>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators/user1/permission"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.korra-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -316,8 +315,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.ReviewPermission(1L, "user1"); connection.Received().Get<CollaboratorPermission>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/collaborators/user1/permission"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.korra-preview+json"); + Arg.Any<Dictionary<string, string>>()); } [Fact] diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index c2a77a05ce..40f72252b2 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -44,8 +44,7 @@ public void UsesTheUserReposUrl() client.Create(new NewRepository("aName")); connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), - Arg.Any<NewRepository>(), - "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); + Arg.Any<NewRepository>()); } [Fact] @@ -57,7 +56,7 @@ public void TheNewRepositoryDescription() client.Create(newRepository); - connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); + connection.Received().Post<Repository>(Args.Uri, newRepository); } [Fact] @@ -73,7 +72,7 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentU var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); connection.Connection.Credentials.Returns(credentials); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") + connection.Post<Repository>(Args.Uri, newRepository) .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -85,6 +84,8 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForCurrentU Assert.Equal("aName", exception.RepositoryName); Assert.Null(exception.ExistingRepositoryWebUrl); } + + } public class TheCreateMethodForOrganization @@ -108,8 +109,7 @@ public async Task UsesTheOrganizationsReposUrl() connection.Received().Post<Repository>( Arg.Is<Uri>(u => u.ToString() == "orgs/theLogin/repos"), - Args.NewRepository, - "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); + Args.NewRepository); } [Fact] @@ -121,7 +121,7 @@ public async Task TheNewRepositoryDescription() await client.Create("aLogin", newRepository); - connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); + connection.Received().Post<Repository>(Args.Uri, newRepository); } [Fact] @@ -135,7 +135,7 @@ public async Task ThrowsRepositoryExistsExceptionWhenRepositoryExistsForSpecifie + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") + connection.Post<Repository>(Args.Uri, newRepository) .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -160,7 +160,7 @@ public async Task ThrowsValidationException() + @"""http://developer.github.com/v3/repos/#create"",""errors"":[]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(GitHubClient.GitHubApiUrl); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") + connection.Post<Repository>(Args.Uri, newRepository) .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -181,7 +181,7 @@ public async Task ThrowsRepositoryExistsExceptionForEnterpriseInstance() + @"""code"":""custom"",""field"":""name"",""message"":""name already exists on this account""}]}"); var connection = Substitute.For<IApiConnection>(); connection.Connection.BaseAddress.Returns(new Uri("https://example.com")); - connection.Post<Repository>(Args.Uri, newRepository, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json") + connection.Post<Repository>(Args.Uri, newRepository) .Returns<Task<Repository>>(_ => { throw new ApiValidationException(response); }); var client = new RepositoriesClient(connection); @@ -214,8 +214,7 @@ public void UsesTheUserReposUrl() client.Generate("asd", "asd", new NewRepositoryFromTemplate("aName")); connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/asd/asd/generate"), - Arg.Any<NewRepositoryFromTemplate>(), - "application/vnd.github.baptiste-preview+json"); + Arg.Any<NewRepositoryFromTemplate>()); } [Fact] @@ -227,7 +226,7 @@ public void TheNewRepositoryDescription() client.Generate("anOwner", "aRepo", newRepository); - connection.Received().Post<Repository>(Args.Uri, newRepository, "application/vnd.github.baptiste-preview+json"); + connection.Received().Post<Repository>(Args.Uri, newRepository); } } @@ -472,8 +471,7 @@ public async Task RequestsCorrectUrl() connection.Received() .Get<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name"), - null, - "application/vnd.github.nebula-preview+json"); + null); } [Fact] @@ -556,7 +554,6 @@ public async Task RequestsTheCorrectUrlAndReturnsRepositories() connection.Received() .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "user/repos"), null, - "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json", Args.ApiOptions); } @@ -577,7 +574,6 @@ public async Task CanFilterByType() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["type"] == "all"), - "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -599,7 +595,6 @@ public async Task CanFilterBySort() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["type"] == "private" && d["sort"] == "full_name"), - "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -622,7 +617,6 @@ public async Task CanFilterBySortDirection() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["type"] == "member" && d["sort"] == "updated" && d["direction"] == "asc"), - "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -643,7 +637,6 @@ public async Task CanFilterByVisibility() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["visibility"] == "private"), - "application/vnd.github.nebula-preview+json", Args.ApiOptions); } @@ -665,7 +658,6 @@ public async Task CanFilterByAffiliation() .GetAll<Repository>( Arg.Is<Uri>(u => u.ToString() == "user/repos"), Arg.Is<Dictionary<string, string>>(d => d["affiliation"] == "owner" && d["sort"] == "full_name"), - "application/vnd.github.nebula-preview+json", Args.ApiOptions); } } @@ -710,7 +702,7 @@ public async Task RequestsTheCorrectUrl() await client.GetAllForOrg("orgname"); connection.Received() - .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgname/repos"), null, "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json", Args.ApiOptions); + .GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "orgs/orgname/repos"), null, Args.ApiOptions); } [Fact] @@ -1046,42 +1038,6 @@ public async Task EnsuresNonNullArguments() } } - public class TheGetCodeOwnersErrorsMethod - { - [Fact] - public async Task RequestsTheCorrectUrl() - { - var connection = Substitute.For<IApiConnection>(); - var client = new RepositoriesClient(connection); - - await client.GetAllCodeOwnersErrors("owner", "name"); - - connection.Received() - .Get<RepositoryCodeOwnersErrors>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/codeowners/errors")); - } - - [Fact] - public async Task RequestsTheCorrectUrlWithRepositoryId() - { - var connection = Substitute.For<IApiConnection>(); - var client = new RepositoriesClient(connection); - - await client.GetAllCodeOwnersErrors(1); - - connection.Received() - .Get<RepositoryCodeOwnersErrors>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/codeowners/errors")); - } - - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new RepositoriesClient(Substitute.For<IApiConnection>()); - - await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllCodeOwnersErrors(null, "repo")); - await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllCodeOwnersErrors("owner", null)); - } - } - public class TheGetAllTagsMethod { [Fact] @@ -1179,8 +1135,7 @@ public void PatchesCorrectUrl() connection.Received() .Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo"), - Arg.Any<RepositoryUpdate>(), - "application/vnd.github.nebula-preview+json,application/vnd.github.baptiste-preview+json"); + Arg.Any<RepositoryUpdate>()); } [Fact] @@ -1350,7 +1305,7 @@ public void RequestsTheCorrectUrl() client.GetSha1("owner", "name", "reference"); connection.Received() - .Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits/reference"), null, "application/vnd.github.v3.sha"); + .Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits/reference"), null); } } @@ -1383,7 +1338,7 @@ public void RequestsTheCorrectUrlForOwnerAndRepo() client.GetAllTopics("owner", "name"); connection.Received() - .Get<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), null, "application/vnd.github.mercy-preview+json"); + .Get<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), null); } [Fact] @@ -1395,7 +1350,7 @@ public void RequestsTheCorrectUrlForRepoId() client.GetAllTopics(1234); connection.Received() - .Get<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), null, "application/vnd.github.mercy-preview+json"); + .Get<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), null); } } @@ -1434,7 +1389,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithEmptyTopics() await _client.ReplaceAllTopics("owner", "name", _emptyTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null, "application/vnd.github.mercy-preview+json"); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null); } [Fact] @@ -1443,7 +1398,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithListOfTopics() await _client.ReplaceAllTopics("owner", "name", _listOfTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics, null, "application/vnd.github.mercy-preview+json"); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics, null); } [Fact] @@ -1452,7 +1407,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithEmptyTopics() await _client.ReplaceAllTopics(1234, _emptyTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _emptyTopics, null, "application/vnd.github.mercy-preview+json"); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _emptyTopics, null); } [Fact] @@ -1461,7 +1416,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithListOfTopics() await _client.ReplaceAllTopics(1234, _listOfTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics, null, "application/vnd.github.mercy-preview+json"); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics, null); } } } diff --git a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs index 267bf4e157..de8f42424e 100644 --- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs @@ -33,7 +33,7 @@ public async Task RequestsTheCorrectUrl() await client.GetAll("owner", "name"); connection.Received() - .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.luke-cage-preview+json", Args.ApiOptions); + .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/branches"), null, Args.ApiOptions); } [Fact] @@ -45,7 +45,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryId() await client.GetAll(1); connection.Received() - .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.luke-cage-preview+json", Args.ApiOptions); + .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches"), null, Args.ApiOptions); } [Fact] @@ -64,7 +64,7 @@ public async Task RequestsTheCorrectUrlWithApiOptions() await client.GetAll("owner", "name", options); connection.Received() - .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.luke-cage-preview+json", options); + .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/branches"), null, options); } [Fact] @@ -83,7 +83,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAll(1, options); connection.Received() - .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.luke-cage-preview+json", options); + .GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches"), null, options); } [Fact] @@ -118,7 +118,7 @@ public async Task RequestsTheCorrectUrl() await client.Get("owner", "repo", "branch"); connection.Received() - .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch"), null, "application/vnd.github.luke-cage-preview+json"); + .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch"), null); } [Fact] @@ -130,7 +130,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryId() await client.Get(1, "branch"); connection.Received() - .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch"), null, "application/vnd.github.luke-cage-preview+json"); + .Get<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch"), null); } [Fact] @@ -157,12 +157,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetBranchProtection("owner", "repo", "branch"); connection.Received() - .Get<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), null, previewAcceptsHeader); + .Get<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), null); } [Fact] @@ -170,12 +169,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetBranchProtection(1, "branch"); connection.Received() - .Get<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), null, previewAcceptsHeader); + .Get<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), null); } [Fact] @@ -206,12 +204,11 @@ public void RequestsTheCorrectUrl() var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" })); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateBranchProtection("owner", "repo", "branch", update); connection.Received() - .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader); + .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null); } [Fact] @@ -221,12 +218,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" })); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateBranchProtection(1, "branch", update); connection.Received() - .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null, previewAcceptsHeader); + .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null); } [Fact] @@ -259,12 +255,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteBranchProtection("owner", "repo", "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection")); } [Fact] @@ -272,12 +267,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteBranchProtection(1, "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection")); } [Fact] @@ -306,12 +300,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetRequiredStatusChecks("owner", "repo", "branch"); connection.Received() - .Get<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks"), null, previewAcceptsHeader); + .Get<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks"), null); } [Fact] @@ -319,12 +312,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetRequiredStatusChecks(1, "branch"); connection.Received() - .Get<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks"), null, previewAcceptsHeader); + .Get<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks"), null); } [Fact] @@ -354,12 +346,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" }); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecks("owner", "repo", "branch", update); connection.Received() - .Patch<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks"), Arg.Any<BranchProtectionRequiredStatusChecksUpdate>(), previewAcceptsHeader); + .Patch<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks"), Arg.Any<BranchProtectionRequiredStatusChecksUpdate>()); } [Fact] @@ -368,12 +359,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" }); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecks(1, "branch", update); connection.Received() - .Patch<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks"), Arg.Any<BranchProtectionRequiredStatusChecksUpdate>(), previewAcceptsHeader); + .Patch<BranchProtectionRequiredStatusChecks>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks"), Arg.Any<BranchProtectionRequiredStatusChecksUpdate>()); } [Fact] @@ -405,12 +395,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecks("owner", "repo", "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks")); } [Fact] @@ -418,12 +407,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecks(1, "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks")); } [Fact] @@ -452,12 +440,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetAllRequiredStatusChecksContexts("owner", "repo", "branch"); connection.Received() - .Get<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), null, previewAcceptsHeader); + .Get<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), null); } [Fact] @@ -465,12 +452,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetAllRequiredStatusChecksContexts(1, "branch"); connection.Received() - .Get<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), null, previewAcceptsHeader); + .Get<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), null); } [Fact] @@ -500,12 +486,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new List<string>() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecksContexts("owner", "repo", "branch", update); connection.Received() - .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null, previewAcceptsHeader); + .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null); } [Fact] @@ -514,12 +499,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new List<string>() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecksContexts(1, "branch", update); connection.Received() - .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null, previewAcceptsHeader); + .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null); } [Fact] @@ -552,12 +536,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newContexts = new List<string>() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.AddRequiredStatusChecksContexts("owner", "repo", "branch", newContexts); connection.Received() - .Post<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Post<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -566,12 +549,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newContexts = new List<string>() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.AddRequiredStatusChecksContexts(1, "branch", newContexts); connection.Received() - .Post<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Post<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -604,12 +586,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var contextsToRemove = new List<string>() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecksContexts("owner", "repo", "branch", contextsToRemove); connection.Received() - .Delete<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Delete<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -618,12 +599,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var contextsToRemove = new List<string>() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecksContexts(1, "branch", contextsToRemove); connection.Received() - .Delete<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Delete<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -655,12 +635,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetReviewEnforcement("owner", "repo", "branch"); connection.Received() - .Get<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_pull_request_reviews"), null, previewAcceptsHeader); + .Get<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_pull_request_reviews"), null); } [Fact] @@ -668,12 +647,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetReviewEnforcement(1, "branch"); connection.Received() - .Get<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_pull_request_reviews"), null, previewAcceptsHeader); + .Get<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_pull_request_reviews"), null); } [Fact] @@ -703,12 +681,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateReviewEnforcement("owner", "repo", "branch", update); connection.Received() - .Patch<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_pull_request_reviews"), Arg.Any<BranchProtectionRequiredReviewsUpdate>(), previewAcceptsHeader); + .Patch<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_pull_request_reviews"), Arg.Any<BranchProtectionRequiredReviewsUpdate>()); } [Fact] @@ -717,12 +694,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateReviewEnforcement(1, "branch", update); connection.Received() - .Patch<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_pull_request_reviews"), Arg.Any<BranchProtectionRequiredReviewsUpdate>(), previewAcceptsHeader); + .Patch<BranchProtectionRequiredReviews>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_pull_request_reviews"), Arg.Any<BranchProtectionRequiredReviewsUpdate>()); } [Fact] @@ -755,12 +731,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.RemoveReviewEnforcement("owner", "repo", "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_pull_request_reviews"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_pull_request_reviews")); } [Fact] @@ -768,12 +743,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.RemoveReviewEnforcement(1, "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_pull_request_reviews"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_pull_request_reviews")); } [Fact] @@ -802,12 +776,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetAdminEnforcement("owner", "repo", "branch"); connection.Received() - .Get<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/enforce_admins"), null, previewAcceptsHeader); + .Get<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/enforce_admins"), null); } [Fact] @@ -815,12 +788,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetAdminEnforcement(1, "branch"); connection.Received() - .Get<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/enforce_admins"), null, previewAcceptsHeader); + .Get<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/enforce_admins"), null); } [Fact] @@ -849,12 +821,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.AddAdminEnforcement("owner", "repo", "branch"); connection.Received() - .Post<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/enforce_admins"), Arg.Any<object>(), previewAcceptsHeader); + .Post<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/enforce_admins"), Arg.Any<object>()); } [Fact] @@ -862,12 +833,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.AddAdminEnforcement(1, "branch"); connection.Received() - .Post<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/enforce_admins"), Arg.Any<object>(), previewAcceptsHeader); + .Post<EnforceAdmins>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/enforce_admins"), Arg.Any<object>()); } [Fact] @@ -896,12 +866,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.RemoveAdminEnforcement("owner", "repo", "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/enforce_admins"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/enforce_admins")); } [Fact] @@ -909,12 +878,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.RemoveAdminEnforcement(1, "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/enforce_admins"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/enforce_admins")); } [Fact] @@ -943,12 +911,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetProtectedBranchRestrictions("owner", "repo", "branch"); connection.Received() - .Get<BranchProtectionPushRestrictions>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions"), null, previewAcceptsHeader); + .Get<BranchProtectionPushRestrictions>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions"), null); } [Fact] @@ -956,12 +923,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetProtectedBranchRestrictions(1, "branch"); connection.Received() - .Get<BranchProtectionPushRestrictions>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions"), null, previewAcceptsHeader); + .Get<BranchProtectionPushRestrictions>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions"), null); } [Fact] @@ -990,12 +956,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchRestrictions("owner", "repo", "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions")); } [Fact] @@ -1003,12 +968,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchRestrictions(1, "branch"); connection.Connection.Received() - .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions"), Arg.Any<object>(), previewAcceptsHeader); + .Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions")); } [Fact] @@ -1043,8 +1007,7 @@ public void RequestsTheCorrectUrl() connection.Received() .Get<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), - null, - "application/vnd.github.luke-cage-preview+json"); + null); } [Fact] @@ -1058,8 +1021,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() connection.Received() .Get<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), - null, - "application/vnd.github.luke-cage-preview+json"); + null); } [Fact] @@ -1096,8 +1058,7 @@ public void RequestsTheCorrectUrl() .Put<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), Arg.Any<IReadOnlyList<string>>(), - null, - "application/vnd.github.luke-cage-preview+json"); + null); } [Fact] @@ -1113,8 +1074,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() .Put<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), Arg.Any<IReadOnlyList<string>>(), - null, - "application/vnd.github.luke-cage-preview+json"); + null); } [Fact] @@ -1153,8 +1113,7 @@ public void RequestsTheCorrectUrl() connection.Received() .Post<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), - Arg.Any<IReadOnlyList<string>>(), - "application/vnd.github.luke-cage-preview+json"); + Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1169,8 +1128,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() connection.Received() .Post<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), - Arg.Any<IReadOnlyList<string>>(), - "application/vnd.github.luke-cage-preview+json"); + Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1209,8 +1167,7 @@ public void RequestsTheCorrectUrl() connection.Received() .Delete<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), - Arg.Any<BranchProtectionTeamCollection>(), - "application/vnd.github.luke-cage-preview+json"); + Arg.Any<BranchProtectionTeamCollection>()); } [Fact] @@ -1225,8 +1182,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() connection.Received() .Delete<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), - Arg.Any<IReadOnlyList<string>>(), - "application/vnd.github.luke-cage-preview+json"); + Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1258,12 +1214,11 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetAllProtectedBranchUserRestrictions("owner", "repo", "branch"); connection.Received() - .Get<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), null, previewAcceptsHeader); + .Get<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), null); } [Fact] @@ -1271,12 +1226,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.GetAllProtectedBranchUserRestrictions(1, "branch"); connection.Received() - .Get<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), null, previewAcceptsHeader); + .Get<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), null); } [Fact] @@ -1306,12 +1260,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); connection.Received() - .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null, previewAcceptsHeader); + .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null); } [Fact] @@ -1320,12 +1273,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.UpdateProtectedBranchUserRestrictions(1, "branch", newUsers); connection.Received() - .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null, previewAcceptsHeader); + .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null); } [Fact] @@ -1358,12 +1310,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.AddProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); connection.Received() - .Post<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Post<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1372,12 +1323,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.AddProtectedBranchUserRestrictions(1, "branch", newUsers); connection.Received() - .Post<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Post<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1410,12 +1360,11 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var usersToRemove = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchUserRestrictions("owner", "repo", "branch", usersToRemove); connection.Received() - .Delete<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Delete<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1424,12 +1373,11 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new RepositoryBranchesClient(connection); var usersToRemove = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchUserRestrictions(1, "branch", usersToRemove); connection.Received() - .Delete<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), previewAcceptsHeader); + .Delete<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>()); } [Fact] diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 40432f968f..b372c6a716 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -22,7 +22,7 @@ public async Task RequestsCorrectUrl() await client.Get("fake", "repo", 42); - connection.Received().Get<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Get<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42"), Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -33,7 +33,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Get(1, 42); - connection.Received().Get<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json"); + connection.Received().Get<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42"), Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -59,7 +59,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForRepository("fake", "repo"); - connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments"), Arg.Any<Dictionary<string, string>>(), Args.ApiOptions); } [Fact] @@ -70,7 +70,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetAllForRepository(1); - connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); + connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments"), Arg.Any<Dictionary<string, string>>(), Args.ApiOptions); } [Fact] @@ -88,7 +88,7 @@ public async Task RequestsCorrectUrlWithApiOptions() await client.GetAllForRepository("fake", "repo", options); - connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments"), Arg.Any<Dictionary<string, string>>(), options); } [Fact] @@ -106,7 +106,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAllForRepository(1, options); - connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments"), Arg.Any<Dictionary<string, string>>(), options); } [Fact] @@ -143,8 +143,7 @@ public async Task RequestsCorrectUrl() connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", - Args.ApiOptions); + Args.ApiOptions); } [Fact] @@ -157,7 +156,6 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); } @@ -176,8 +174,7 @@ public async Task RequestsCorrectUrlWithApiOptions() await client.GetAllForCommit("fake", "repo", "sha", options); - connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); + connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any<Dictionary<string, string>>(), options); } [Fact] @@ -196,8 +193,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAllForCommit(1, "sha", options); connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json", options); + Arg.Any<Dictionary<string, string>>(), options); } [Fact] diff --git a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs index 234585c532..3e235c4e96 100644 --- a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs +++ b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs @@ -317,8 +317,7 @@ public async Task RequestsCorrectUrl() await client.GetSha1("fake", "repo", "ref"); - connection.Received().Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref"), - null, "application/vnd.github.v3.sha"); + connection.Received().Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref"), null); } [Fact] @@ -329,8 +328,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.GetSha1(1, "ref"); - connection.Received().Get<string>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref"), - null, "application/vnd.github.v3.sha"); + connection.Received().Get<string>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref"), null); } [Fact] diff --git a/Octokit.Tests/Clients/StarredClientTests.cs b/Octokit.Tests/Clients/StarredClientTests.cs index 5b07c2d04e..f8eca0df50 100644 --- a/Octokit.Tests/Clients/StarredClientTests.cs +++ b/Octokit.Tests/Clients/StarredClientTests.cs @@ -99,7 +99,7 @@ public async Task RequestsCorrectUrlWithTimestamps() await client.GetAllForCurrentWithTimestamps(); - connection.Received().GetAll<RepositoryStar>(endpoint, null, "application/vnd.github.v3.star+json", Args.ApiOptions); + connection.Received().GetAll<RepositoryStar>(endpoint, null, Args.ApiOptions); } [Fact] @@ -118,7 +118,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptions() await client.GetAllForCurrentWithTimestamps(options); - connection.Received().GetAll<RepositoryStar>(endpoint, null, "application/vnd.github.v3.star+json", options); + connection.Received().GetAll<RepositoryStar>(endpoint, null, options); } [Fact] @@ -132,8 +132,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrized() await client.GetAllForCurrentWithTimestamps(request); - connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), - "application/vnd.github.v3.star+json", Args.ApiOptions); + connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), Args.ApiOptions); } [Fact] @@ -154,8 +153,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions() await client.GetAllForCurrentWithTimestamps(request, options); - connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), - "application/vnd.github.v3.star+json", options); + connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), options); } [Fact] @@ -252,8 +250,7 @@ public async Task RequestsCorrectUrlWithTimestamps() await client.GetAllForUserWithTimestamps("banana"); - connection.Received().GetAll<RepositoryStar>(endpoint, null, - "application/vnd.github.v3.star+json", Args.ApiOptions); + connection.Received().GetAll<RepositoryStar>(endpoint, null, Args.ApiOptions); } [Fact] @@ -272,7 +269,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptions() await client.GetAllForUserWithTimestamps("banana", options); - connection.Received().GetAll<RepositoryStar>(endpoint, null, "application/vnd.github.v3.star+json", options); + connection.Received().GetAll<RepositoryStar>(endpoint, null, options); } [Fact] @@ -286,8 +283,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrized() await client.GetAllForUserWithTimestamps("banana", starredRequest); - connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), - "application/vnd.github.v3.star+json", Args.ApiOptions); + connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), Args.ApiOptions); } [Fact] @@ -308,8 +304,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions() await client.GetAllForUserWithTimestamps("banana", starredRequest, options); - connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), - "application/vnd.github.v3.star+json", options); + connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), options); } [Fact] @@ -417,7 +412,7 @@ public async Task RequestsCorrectUrlWithTimestamps() await client.GetAllStargazersWithTimestamps("fake", "repo"); - connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", Args.ApiOptions); + connection.Received().GetAll<UserStar>(endpoint, null, Args.ApiOptions); } [Fact] @@ -429,7 +424,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithRepositoryId() await client.GetAllStargazersWithTimestamps(1); - connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", Args.ApiOptions); + connection.Received().GetAll<UserStar>(endpoint, null, Args.ApiOptions); } [Fact] @@ -448,7 +443,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptions() await client.GetAllStargazersWithTimestamps("fake", "repo", options); - connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", options); + connection.Received().GetAll<UserStar>(endpoint, null, options); } [Fact] @@ -467,7 +462,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptionsWithRepositoryId await client.GetAllStargazersWithTimestamps(1, options); - connection.Received().GetAll<UserStar>(endpoint, null, "application/vnd.github.v3.star+json", options); + connection.Received().GetAll<UserStar>(endpoint, null, options); } [Fact] diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index ab2cad0d1a..a1b7179405 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -410,7 +410,6 @@ public async Task RequestsTheCorrectUrl() connection.Received().GetAll<OrganizationMembershipInvitation>( Arg.Is<Uri>(u => u.ToString() == "teams/1/invitations"), null, - "application/vnd.github.korra-preview+json", Args.ApiOptions); } } diff --git a/Octokit.Tests/Helpers/MockedIApiConnection.cs b/Octokit.Tests/Helpers/MockedIApiConnection.cs index 8d40a37f5d..640ad95dc8 100644 --- a/Octokit.Tests/Helpers/MockedIApiConnection.cs +++ b/Octokit.Tests/Helpers/MockedIApiConnection.cs @@ -9,6 +9,8 @@ public static class MockedIApiConnection public static IApiConnection PostReturnsHttpStatus(HttpStatusCode status) { var connection = Substitute.For<IConnection>(); + connection.Post(Arg.Any<Uri>()) + .Returns(status); connection.Post(Arg.Any<Uri>(), Arg.Any<object>(), Arg.Any<string>()) .Returns(status); diff --git a/Octokit.Tests/Http/ApiConnectionTests.cs b/Octokit.Tests/Http/ApiConnectionTests.cs index 660ee1ed19..52d981689d 100644 --- a/Octokit.Tests/Http/ApiConnectionTests.cs +++ b/Octokit.Tests/Http/ApiConnectionTests.cs @@ -22,13 +22,14 @@ public async Task MakesGetRequestForItem() var getUri = new Uri("anything", UriKind.Relative); IApiResponse<object> response = new ApiResponse<object>(CreateResponse(HttpStatusCode.OK)); var connection = Substitute.For<IConnection>(); - connection.Get<object>(Args.Uri, null, null).Returns(Task.FromResult(response)); + connection.Get<object>(Args.Uri, null).Returns(Task.FromResult(response)); var apiConnection = new ApiConnection(connection); var data = await apiConnection.Get<object>(getUri); Assert.Same(response.Body, data); - connection.Received().GetResponse<object>(getUri); + var calls = connection.ReceivedCalls(); + connection.Received().Get<object>(getUri, null, null); } [Fact] diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClientTests.cs index e6396def68..d42d6922a9 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterprisePreReceiveEnvironmentsClientTests.cs @@ -29,8 +29,7 @@ public void RequestsTheCorrectUrl() gitHubClient.Connection.Received(1).Get<List<PreReceiveEnvironment>>( new Uri("admin/pre-receive-environments", UriKind.Relative), - Args.EmptyDictionary, - "application/vnd.github.eye-scream-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -50,8 +49,7 @@ public void RequestsTheCorrectUrlWithApiOptions() gitHubClient.Connection.Received(1).Get<List<PreReceiveEnvironment>>( new Uri("admin/pre-receive-environments", UriKind.Relative), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), - "application/vnd.github.eye-scream-preview+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableAssigneesClientTests.cs b/Octokit.Tests/Reactive/ObservableAssigneesClientTests.cs index 21e11f6681..d374d9d390 100644 --- a/Octokit.Tests/Reactive/ObservableAssigneesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableAssigneesClientTests.cs @@ -37,7 +37,7 @@ public void RequestsCorrectUrl() client.GetAllForRepository(owner, name); gitHubClient.Connection.Received(1).Get<List<User>>(_expectedUri, - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -49,7 +49,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllForRepository(repositoryId); gitHubClient.Connection.Received(1).Get<List<User>>(_expectedUriWithRepositoryId, - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -68,7 +68,7 @@ public void RequestsCorrectUrlWithApiOption() client.GetAllForRepository(owner, name, options); gitHubClient.Connection.Received(2).Get<List<User>>(_expectedUri, - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] @@ -87,7 +87,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOption() client.GetAllForRepository(repositoryId, options); gitHubClient.Connection.Received(1).Get<List<User>>(_expectedUriWithRepositoryId, - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableAuthorizationsClientTests.cs b/Octokit.Tests/Reactive/ObservableAuthorizationsClientTests.cs index 99d1b55d65..c7a14d24fc 100644 --- a/Octokit.Tests/Reactive/ObservableAuthorizationsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableAuthorizationsClientTests.cs @@ -21,7 +21,7 @@ public void RequestsCorrectUrl() authEndpoint.GetAll(); client.Connection.Received(1).Get<List<Authorization>>(Arg.Is<Uri>(u => u.ToString() == "authorizations"), - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -33,7 +33,7 @@ public void RequestsCorrectUrlWithApiOption() authEndpoint.GetAll(ApiOptions.None); client.Connection.Received(1).Get<List<Authorization>>(Arg.Is<Uri>(u => u.ToString() == "authorizations"), - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableCheckRunsClientTests.cs b/Octokit.Tests/Reactive/ObservableCheckRunsClientTests.cs index 5a2036bcee..0936b82cd4 100644 --- a/Octokit.Tests/Reactive/ObservableCheckRunsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCheckRunsClientTests.cs @@ -141,8 +141,7 @@ public async Task RequestsCorrectUrl() connection.Received().Get<List<CheckRunsResponse>>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -156,8 +155,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Get<List<CheckRunsResponse>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref/check-runs"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -177,8 +175,7 @@ public async Task RequestsCorrectUrlWithRequest() x.Count == 3 && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -198,8 +195,7 @@ public async Task RequestsCorrectUrlWithRequestWithRepositoryId() x.Count == 3 && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -221,8 +217,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() && x["per_page"] == "1" && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -244,8 +239,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId() && x["per_page"] == "1" && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -322,8 +316,7 @@ public async Task RequestsCorrectUrl() connection.Received().Get<List<CheckRunsResponse>>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/check-runs"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -337,8 +330,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Get<List<CheckRunsResponse>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1/check-runs"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -358,8 +350,7 @@ public async Task RequestsCorrectUrlWithRequest() x.Count == 3 && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -379,8 +370,7 @@ public async Task RequestsCorrectUrlWithRequestWithRepositoryId() x.Count == 3 && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -402,8 +392,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() && x["per_page"] == "1" && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -425,8 +414,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId() && x["per_page"] == "1" && x["check_name"] == "build" && x["status"] == "in_progress" - && x["filter"] == "latest"), - "application/vnd.github.antiope-preview+json"); + && x["filter"] == "latest")); } [Fact] @@ -532,8 +520,7 @@ public async Task RequestsCorrectUrl() connection.Received().Get<List<CheckRunAnnotation>>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1/annotations"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -547,8 +534,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Get<List<CheckRunAnnotation>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-runs/1/annotations"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -566,8 +552,7 @@ public async Task RequestsCorrectUrlWithApiOptions() Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1/annotations"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 - && x["per_page"] == "1"), - "application/vnd.github.antiope-preview+json"); + && x["per_page"] == "1")); } [Fact] @@ -585,8 +570,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-runs/1/annotations"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 - && x["per_page"] == "1"), - "application/vnd.github.antiope-preview+json"); + && x["per_page"] == "1")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs index 8e7024c25b..a6c75dc7a5 100644 --- a/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCheckSuitesClientTests.cs @@ -77,8 +77,7 @@ public async Task RequestsCorrectUrl() connection.Received().Get<List<CheckSuitesResponse>>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -92,8 +91,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() connection.Received().Get<List<CheckSuitesResponse>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref/check-suites"), - Args.EmptyDictionary, - "application/vnd.github.antiope-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -115,8 +113,7 @@ public async Task RequestsCorrectUrlWithRequest() Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"), Arg.Is<Dictionary<string, string>>(x => x["app_id"] == "123" - && x["check_name"] == "build"), - "application/vnd.github.antiope-preview+json"); + && x["check_name"] == "build")); } [Fact] @@ -138,8 +135,7 @@ public async Task RequestsCorrectUrlWithRequestWithRepositoryId() Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref/check-suites"), Arg.Is<Dictionary<string, string>>(x => x["app_id"] == "123" - && x["check_name"] == "build"), - "application/vnd.github.antiope-preview+json"); + && x["check_name"] == "build")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs index 7a7402963d..a2c3a963e7 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs @@ -30,9 +30,7 @@ public void RequestsCorrectUrl() _client.GetAll("owner", "repo", 1); _githubClient.Connection.Received(1) - .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), - Args.EmptyDictionary, - null); + .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Args.EmptyDictionary); } [Fact] @@ -43,9 +41,7 @@ public void RequestsCorrectUrlWithRepositoryId() _client.GetAll(1, 1); _githubClient.Connection.Received(1) - .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), - Args.EmptyDictionary, - null); + .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Args.EmptyDictionary); } [Fact] @@ -63,9 +59,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll("owner", "repo", 1, options); _githubClient.Connection.Received(1) - .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] @@ -83,9 +77,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() _client.GetAll(1, 1, options); _githubClient.Connection.Received(1) - .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + .Get<List<DeploymentStatus>>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs index 58bdc62d78..f2c3054e3f 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs @@ -60,8 +60,7 @@ public void RequestsCorrectUrl() _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), - Arg.Any<string>()); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -73,8 +72,7 @@ public void RequestsCorrectUrlWithRepositoryId() _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), - Arg.Any<string>()); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -93,8 +91,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); // StartPage is setted => only 1 option (StartPage) in dictionary options = new ApiOptions @@ -105,8 +102,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); // PageCount is setted => none of options in dictionary options = new ApiOptions @@ -117,8 +113,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -138,8 +133,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); // StartPage is setted => only 1 option (StartPage) in dictionary options = new ApiOptions @@ -151,8 +145,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); // PageCount is setted => none of options in dictionary options = new ApiOptions @@ -164,8 +157,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() _githubClient.Connection.Received(1) .Get<List<Deployment>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0)); } } diff --git a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs index 30e9629664..245a04ab21 100644 --- a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs @@ -30,7 +30,7 @@ public void RequestsCorrectUrl() client.GetAll(); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("events", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("events", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -48,7 +48,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAll(options); - gitHubClient.Connection.Received().Get<List<Activity>>(new Uri("events", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + gitHubClient.Connection.Received().Get<List<Activity>>(new Uri("events", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -71,8 +71,7 @@ public void RequestsCorrectUrl() client.GetAllForRepository("fake", "repo"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("repos/fake/repo/events", UriKind.Relative), - Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("repos/fake/repo/events", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -83,8 +82,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllForRepository(1); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("repositories/1/events", UriKind.Relative), - Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("repositories/1/events", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -103,7 +101,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllForRepository("fake", "repo", options); gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("repos/fake/repo/events", UriKind.Relative), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -122,7 +120,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() client.GetAllForRepository(1, apiOptions); gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("repositories/1/events", UriKind.Relative), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -157,7 +155,7 @@ public void RequestsCorrectUrl() client.GetAllIssuesForRepository("fake", "repo"); gitHubClient.Connection.Received(1).Get<List<IssueEvent>>(new Uri("repos/fake/repo/issues/events", UriKind.Relative), - Args.EmptyDictionary, null); + Args.EmptyDictionary); } [Fact] @@ -169,7 +167,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllIssuesForRepository(1); gitHubClient.Connection.Received(1).Get<List<IssueEvent>>(new Uri("repositories/1/issues/events", UriKind.Relative), - Args.EmptyDictionary, null); + Args.EmptyDictionary); } [Fact] @@ -188,7 +186,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllIssuesForRepository("fake", "repo", options); gitHubClient.Connection.Received(1).Get<List<IssueEvent>>(new Uri("repos/fake/repo/issues/events", UriKind.Relative), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -207,7 +205,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() client.GetAllIssuesForRepository(1, options); gitHubClient.Connection.Received(1).Get<List<IssueEvent>>(new Uri("repositories/1/issues/events", UriKind.Relative), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -241,7 +239,7 @@ public void RequestsCorrectUrl() client.GetAllForRepositoryNetwork("fake", "repo"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("networks/fake/repo/events", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("networks/fake/repo/events", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -267,7 +265,7 @@ public void RequestsCorrectUrl() client.GetAllForOrganization("fake"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("orgs/fake/events", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("orgs/fake/events", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -291,7 +289,7 @@ public void RequestsCorrectUrl() client.GetAllUserReceived("fake"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/received_events", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/received_events", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -315,7 +313,7 @@ public void RequestsCorrectUrl() client.GetAllUserReceivedPublic("fake"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/received_events/public", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/received_events/public", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -339,7 +337,7 @@ public void RequestsCorrectUrl() client.GetAllUserPerformed("fake"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/events", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/events", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -363,7 +361,7 @@ public void RequestsCorrectUrl() client.GetAllUserPerformedPublic("fake"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/events/public", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/events/public", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -387,7 +385,7 @@ public void RequestsCorrectUrl() client.GetAllForAnOrganization("fake", "org"); - gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/events/orgs/org", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Activity>>(new Uri("users/fake/events/orgs/org", UriKind.Relative), Args.EmptyDictionary); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableFollowersTest.cs b/Octokit.Tests/Reactive/ObservableFollowersTest.cs index b44807e688..bf769196c2 100644 --- a/Octokit.Tests/Reactive/ObservableFollowersTest.cs +++ b/Octokit.Tests/Reactive/ObservableFollowersTest.cs @@ -25,7 +25,7 @@ public void RequestsTheCorrectUrl() client.GetAllForCurrent(); githubClient.Connection.Received(1).Get<List<User>>( - new Uri("user/followers", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("user/followers", UriKind.Relative), Args.EmptyDictionary); } } @@ -40,7 +40,7 @@ public void RequestsTheCorrectUrl() client.GetAll("alfhenrik"); githubClient.Connection.Received(1).Get<List<User>>( - new Uri("users/alfhenrik/followers", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("users/alfhenrik/followers", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -64,7 +64,7 @@ public void RequestsTheCorrectUrl() client.GetAllFollowingForCurrent(); githubClient.Connection.Received(1).Get<List<User>>( - new Uri("user/following", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("user/following", UriKind.Relative), Args.EmptyDictionary); } } @@ -79,7 +79,7 @@ public void RequestsTheCorrectUrl() client.GetAllFollowing("alfhenrik"); githubClient.Connection.Received(1).Get<List<User>>( - new Uri("users/alfhenrik/following", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("users/alfhenrik/following", UriKind.Relative), Args.EmptyDictionary); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableGistsTests.cs b/Octokit.Tests/Reactive/ObservableGistsTests.cs index 5d69a5e27d..048cd5c691 100644 --- a/Octokit.Tests/Reactive/ObservableGistsTests.cs +++ b/Octokit.Tests/Reactive/ObservableGistsTests.cs @@ -41,7 +41,7 @@ public void RequestsTheCorrectUrl() client.GetAll(); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists"), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists"), Args.EmptyDictionary); } [Fact] @@ -59,7 +59,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAll(options); gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists"), - DictionaryWithApiOptions, null); + DictionaryWithApiOptions); } [Fact] @@ -71,7 +71,7 @@ public void RequestsTheCorrectUrlWithSince() var since = DateTimeOffset.Now; client.GetAll(since); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists"), DictionaryWithSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists"), DictionaryWithSince); } [Fact] @@ -89,8 +89,7 @@ public void RequestsTheCorrectUrlWithSinceAndApiOptions() var since = DateTimeOffset.Now; client.GetAll(since, options); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists"), - DictionaryWithApiOptionsAndSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists"), DictionaryWithApiOptionsAndSince); } [Fact] @@ -113,7 +112,7 @@ public void RequestsTheCorrectUrl() client.GetAllPublic(); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), Args.EmptyDictionary); } [Fact] @@ -130,8 +129,7 @@ public void RequestsTheCorrectUrlWithApiOptions() }; client.GetAllPublic(options); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), - DictionaryWithApiOptions, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), DictionaryWithApiOptions); } [Fact] @@ -143,7 +141,7 @@ public void RequestsTheCorrectUrlWithSince() var since = DateTimeOffset.Now; client.GetAllPublic(since); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), DictionaryWithSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), DictionaryWithSince); } [Fact] @@ -161,8 +159,7 @@ public void RequestsTheCorrectUrlWithSinceAndApiOptions() var since = DateTimeOffset.Now; client.GetAllPublic(since, options); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), - DictionaryWithApiOptionsAndSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/public"), DictionaryWithApiOptionsAndSince); } [Fact] @@ -185,7 +182,7 @@ public void RequestsTheCorrectUrl() client.GetAllStarred(); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), Args.EmptyDictionary); } [Fact] @@ -202,8 +199,7 @@ public void RequestsTheCorrectUrlWithApiOptions() }; client.GetAllStarred(options); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), - DictionaryWithApiOptions, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), DictionaryWithApiOptions); } [Fact] @@ -215,7 +211,7 @@ public void RequestsTheCorrectUrlWithSince() var since = DateTimeOffset.Now; client.GetAllStarred(since); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), DictionaryWithSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), DictionaryWithSince); } [Fact] @@ -233,8 +229,7 @@ public void RequestsTheCorrectUrlWithSinceAndApiOptions() var since = DateTimeOffset.Now; client.GetAllStarred(since, options); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), - DictionaryWithApiOptionsAndSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "gists/starred"), DictionaryWithApiOptionsAndSince); } [Fact] @@ -257,7 +252,7 @@ public void RequestsTheCorrectUrl() client.GetAllForUser("samthedev"); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), Args.EmptyDictionary); } [Fact] @@ -274,8 +269,7 @@ public void RequestsTheCorrectUrlWithApiOptions() }; client.GetAllForUser("samthedev", options); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), - DictionaryWithApiOptions, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), DictionaryWithApiOptions); } [Fact] @@ -288,7 +282,7 @@ public void RequestsTheCorrectUrlWithSince() var user = "samthedev"; client.GetAllForUser(user, since); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), DictionaryWithSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), DictionaryWithSince); } [Fact] @@ -307,8 +301,7 @@ public void RequestsTheCorrectUrlWithSinceAndApiOptions() var user = "samthedev"; client.GetAllForUser(user, since, options); - gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), - DictionaryWithApiOptionsAndSince, null); + gitHubClient.Connection.Received(1).Get<List<Gist>>(Arg.Is<Uri>(u => u.ToString() == "users/samthedev/gists"), DictionaryWithApiOptionsAndSince); } [Fact] @@ -335,7 +328,7 @@ public void RequestsTheCorrectUrl() client.GetAllCommits("id"); - gitHubClient.Connection.Received(1).Get<List<GistHistory>>(Arg.Is<Uri>(u => u.ToString() == "gists/id/commits"), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<GistHistory>>(Arg.Is<Uri>(u => u.ToString() == "gists/id/commits"), Args.EmptyDictionary); } [Fact] @@ -352,8 +345,7 @@ public void RequestsTheCorrectUrlWithApiOptions() }; client.GetAllCommits("id", options); - gitHubClient.Connection.Received(1).Get<List<GistHistory>>(Arg.Is<Uri>(u => u.ToString() == "gists/id/commits"), - DictionaryWithApiOptions, null); + gitHubClient.Connection.Received(1).Get<List<GistHistory>>(Arg.Is<Uri>(u => u.ToString() == "gists/id/commits"), DictionaryWithApiOptions); } @@ -379,7 +371,7 @@ public void RequestsTheCorrectUrl() client.GetAllForks("id"); - gitHubClient.Connection.Received(1).Get<List<GistFork>>(new Uri("gists/id/forks", UriKind.Relative), Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<GistFork>>(new Uri("gists/id/forks", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -396,8 +388,7 @@ public void RequestsTheCorrectUrlWithApiOptions() }; client.GetAllForks("id", options); - gitHubClient.Connection.Received(1).Get<List<GistFork>>(new Uri("gists/id/forks", UriKind.Relative), - DictionaryWithApiOptions, null); + gitHubClient.Connection.Received(1).Get<List<GistFork>>(new Uri("gists/id/forks", UriKind.Relative), DictionaryWithApiOptions); } diff --git a/Octokit.Tests/Reactive/ObservableGitHubAppInstallationsClientTests.cs b/Octokit.Tests/Reactive/ObservableGitHubAppInstallationsClientTests.cs index d665d4419e..64eee1d501 100644 --- a/Octokit.Tests/Reactive/ObservableGitHubAppInstallationsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableGitHubAppInstallationsClientTests.cs @@ -32,8 +32,7 @@ public void GetsFromCorrectUrl() connection.Received().Get<List<RepositoriesResponse>>( Arg.Is<Uri>(u => u.ToString() == "installation/repositories"), - Args.EmptyDictionary, - "application/vnd.github.machine-man-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -54,8 +53,7 @@ public void GetsFromCorrectUrllWithApiOptions() Arg.Is<Uri>(u => u.ToString() == "installation/repositories"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 - && x["per_page"] == "1"), - "application/vnd.github.machine-man-preview+json"); + && x["per_page"] == "1")); } } @@ -72,12 +70,11 @@ public void GetsFromCorrectUrl() connection.Received().Get<List<RepositoriesResponse>>( Arg.Is<Uri>(u => u.ToString() == "user/installations/1234/repositories"), - Args.EmptyDictionary, - "application/vnd.github.machine-man-preview+json"); + Args.EmptyDictionary); } [Fact] - public void GetsFromCorrectUrllWithApiOptions() + public void GetsFromCorrectUrlWithApiOptions() { var connection = Substitute.For<IConnection>(); var gitHubClient = new GitHubClient(connection); @@ -94,8 +91,7 @@ public void GetsFromCorrectUrllWithApiOptions() Arg.Is<Uri>(u => u.ToString() == "user/installations/1234/repositories"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 - && x["per_page"] == "1"), - "application/vnd.github.machine-man-preview+json"); + && x["per_page"] == "1")); } } } diff --git a/Octokit.Tests/Reactive/ObservableGitHubAppsClientTests.cs b/Octokit.Tests/Reactive/ObservableGitHubAppsClientTests.cs index ab74074c7b..ca6f27ffd7 100644 --- a/Octokit.Tests/Reactive/ObservableGitHubAppsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableGitHubAppsClientTests.cs @@ -86,8 +86,7 @@ public void RequestsCorrectUrl() connection.Received().Get<List<Installation>>( Arg.Is<Uri>(u => u.ToString() == "app/installations"), - Args.EmptyDictionary, - "application/vnd.github.machine-man-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -108,8 +107,7 @@ public void RequestsTheCorrectUrlWithApiOptions() Arg.Is<Uri>(u => u.ToString() == "app/installations"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 - && x["per_page"] == "1"), - "application/vnd.github.machine-man-preview+json"); + && x["per_page"] == "1")); } } @@ -140,8 +138,7 @@ public void GetsFromCorrectUrl() connection.Received().Get<List<InstallationsResponse>>( Arg.Is<Uri>(u => u.ToString() == "user/installations"), - null, - "application/vnd.github.machine-man-preview+json"); + null); } [Fact] @@ -162,8 +159,7 @@ public void GetsFromCorrectUrlWithOptions() Arg.Is<Uri>(u => u.ToString() == "user/installations"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 - && x["per_page"] == "1"), - "application/vnd.github.machine-man-preview+json"); + && x["per_page"] == "1")); } } diff --git a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs index d7d4b6e6f3..26c16db495 100644 --- a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs @@ -58,8 +58,7 @@ public void RequestsCorrectUrl() gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repos/fake/repo/issues/comments", UriKind.Relative), - Arg.Any<IDictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -72,8 +71,7 @@ public void RequestsCorrectUrlWithRepositoryId() gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repositories/1/issues/comments", UriKind.Relative), - Arg.Any<IDictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -102,8 +100,7 @@ public void RequestsCorrectUrlWithApiOptions() Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["direction"] == "desc" && d["since"] == "2016-11-23T11:11:11Z" - && d["sort"] == "updated"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "updated")); } [Fact] @@ -132,8 +129,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["direction"] == "desc" && d["since"] == "2016-11-23T11:11:11Z" - && d["sort"] == "updated"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "updated")); } [Fact] @@ -171,8 +167,7 @@ public void RequestsCorrectUrl() gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), - Arg.Any<IDictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -184,7 +179,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllForIssue(1, 3); gitHubClient.Connection.Received(1).Get<List<IssueComment>>( - new Uri("repositories/1/issues/3/comments", UriKind.Relative), Arg.Any<IDictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json"); + new Uri("repositories/1/issues/3/comments", UriKind.Relative), Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -203,8 +198,7 @@ public void RequestsCorrectUrlWithIssueCommentRequest() gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 3 - && d["since"] == "2016-11-23T11:11:11Z"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["since"] == "2016-11-23T11:11:11Z")); } [Fact] @@ -223,8 +217,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest() gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repositories/1/issues/3/comments", UriKind.Relative), Arg.Is<Dictionary<string, string>>(d => d.Count == 3 - && d["since"] == "2016-11-23T11:11:11Z"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["since"] == "2016-11-23T11:11:11Z")); } [Fact] @@ -244,8 +237,7 @@ public void RequestsCorrectUrlWithApiOptions() gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), - Arg.Is<IDictionary<string, string>>(d => d.Count == 4), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 4)); } [Fact] @@ -265,8 +257,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() gitHubClient.Connection.Received(1).Get<List<IssueComment>>( new Uri("repositories/1/issues/3/comments", UriKind.Relative), - Arg.Is<Dictionary<string, string>>(d => d.Count == 4), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.Count == 4)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableIssueTimelineClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueTimelineClientTests.cs index d1cd611ba1..6e5ef0902c 100644 --- a/Octokit.Tests/Reactive/ObservableIssueTimelineClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssueTimelineClientTests.cs @@ -38,15 +38,14 @@ public async Task RequestsCorrectUrl() IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>( CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Args.EmptyDictionary, "application/vnd.github.mockingbird-preview+json") + gitHubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Args.EmptyDictionary) .Returns(Task.FromResult(response)); var timelineEvents = await client.GetAllForIssue("fake", "repo", 42).ToList(); connection.Received().Get<List<TimelineEventInfo>>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/timeline"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.mockingbird-preview+json"); + Arg.Any<Dictionary<string, string>>()); Assert.Equal(1, timelineEvents.Count); } @@ -60,15 +59,14 @@ public async Task RequestsCorrectUrlWithApiOptions() var client = new ObservableIssueTimelineClient(gitHubClient); IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 1), "application/vnd.github.mockingbird-preview+json") + gitHubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 1)) .Returns(Task.FromResult(response)); var timelineEvents = await client.GetAllForIssue("fake", "repo", 42, new ApiOptions { PageSize = 30 }).ToList(); connection.Received().Get<List<TimelineEventInfo>>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/timeline"), - Arg.Is<Dictionary<string, string>>(d => d.Count == 1 && d["per_page"] == "30"), - "application/vnd.github.mockingbird-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.Count == 1 && d["per_page"] == "30")); Assert.Equal(1, timelineEvents.Count); } @@ -81,15 +79,14 @@ public async Task RequestCorrectUrlWithRepositoryId() var client = new ObservableIssueTimelineClient(githubClient); IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(CreateResponse(HttpStatusCode.OK), result); - githubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Args.EmptyDictionary, "application/vnd.github.mockingbird-preview+json") + githubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Args.EmptyDictionary) .Returns(Task.FromResult(response)); var timelineEvents = await client.GetAllForIssue(1, 42).ToList(); connection.Received().Get<List<TimelineEventInfo>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/timeline"), - Arg.Any<Dictionary<string, string>>(), - "application/vnd.github.mockingbird-preview+json"); + Arg.Any<Dictionary<string, string>>()); Assert.Equal(1, timelineEvents.Count); } @@ -102,15 +99,14 @@ public async Task RequestCorrectUrlWithRepositoryIdAndApiOptions() var client = new ObservableIssueTimelineClient(githubClient); IApiResponse<List<TimelineEventInfo>> response = new ApiResponse<List<TimelineEventInfo>>(CreateResponse(HttpStatusCode.OK), result); - githubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 1), "application/vnd.github.mockingbird-preview+json") + githubClient.Connection.Get<List<TimelineEventInfo>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 1)) .Returns(Task.FromResult(response)); var timelineEvents = await client.GetAllForIssue(1, 42, new ApiOptions { PageSize = 30 }).ToList(); connection.Received().Get<List<TimelineEventInfo>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/timeline"), - Arg.Is<Dictionary<string, string>>(d => d.Count == 1 && d["per_page"] == "30"), - "application/vnd.github.mockingbird-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.Count == 1 && d["per_page"] == "30")); Assert.Equal(1, timelineEvents.Count); } diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index 10e1d6da1c..347f17ad9f 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -97,8 +97,7 @@ public void RequestsCorrectUrl() client.GetAllForRepository("fake", "repo"); gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues"), - Arg.Any<IDictionary<string, string>>(), - "application/vnd.github.squirrel-girl-preview+json"); + Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -110,7 +109,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllForRepository(1); gitHubClient.Connection.Received().Get<List<Issue>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues"), - Arg.Any<IDictionary<string, string>>(), null); + Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -135,8 +134,7 @@ public void RequestsCorrectUrlWithApiOptions() && d["sort"] == "created" && d["direction"] == "desc" && d["page"] == "1" - && d["per_page"] == "1"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["per_page"] == "1")); } [Fact] @@ -161,7 +159,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() && d["sort"] == "created" && d["direction"] == "desc" && d["page"] == "1" - && d["per_page"] == "1"), null); + && d["per_page"] == "1")); } [Fact] @@ -180,8 +178,7 @@ public void SendsAppropriateParameters() && d["filter"] == "assigned" && d["state"] == "open" && d["sort"] == "created" - && d["direction"] == "asc"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["direction"] == "asc")); } [Fact] @@ -200,7 +197,7 @@ public void SendsAppropriateParametersWithRepositoryId() && d["filter"] == "assigned" && d["state"] == "open" && d["sort"] == "created" - && d["direction"] == "asc"), null); + && d["direction"] == "asc")); } [Fact] @@ -228,8 +225,7 @@ public void SendsAppropriateParametersWithApiOptions() && d["sort"] == "created" && d["direction"] == "asc" && d["page"] == "1" - && d["per_page"] == "1"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["per_page"] == "1")); } [Fact] @@ -257,8 +253,7 @@ public void SendsAppropriateParametersWithRepositoryIdWithApiOptions() && d["sort"] == "created" && d["direction"] == "asc" && d["page"] == "1" - && d["per_page"] == "1"), - null); + && d["per_page"] == "1")); } [Fact] @@ -303,11 +298,11 @@ public async Task ReturnsEveryPageOfIssues() && d["direction"] == "desc" && d["state"] == "open" && d["sort"] == "created" - && d["filter"] == "assigned"), Arg.Any<string>()) + && d["filter"] == "assigned")) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(lastPageResponse)); var client = new ObservableIssuesClient(gitHubClient); @@ -379,12 +374,11 @@ public async Task ReturnsEveryPageOfIssues() && d["direction"] == "desc" && d["state"] == "open" && d["sort"] == "created" - && d["filter"] == "assigned"), - "application/vnd.github.squirrel-girl-preview+json") + && d["filter"] == "assigned")) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(lastPageResponse)); var client = new ObservableIssuesClient(gitHubClient); @@ -466,11 +460,11 @@ public async Task ReturnsEveryPageOfIssues() && d["direction"] == "desc" && d["state"] == "open" && d["sort"] == "created" - && d["filter"] == "assigned"), "application/vnd.github.squirrel-girl-preview+json") + && d["filter"] == "assigned")) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(lastPageResponse)); var client = new ObservableIssuesClient(gitHubClient); @@ -534,16 +528,17 @@ public async Task ReturnsEveryPageOfIssues() } ); var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<Issue>>(Arg.Is(firstPageUrl), + gitHubClient.Connection.Get<List<Issue>>( + Arg.Is(firstPageUrl), Arg.Is<Dictionary<string, string>>(d => d.Count == 4 && d["direction"] == "desc" && d["state"] == "open" && d["sort"] == "created" - && d["filter"] == "assigned"), "application/vnd.github.squirrel-girl-preview+json") + && d["filter"] == "assigned")) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview+json") + gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Issue>>>(lastPageResponse)); var client = new ObservableIssuesClient(gitHubClient); diff --git a/Octokit.Tests/Reactive/ObservableIssuesEventsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesEventsClientTests.cs index 5674c45415..d03d98dfca 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesEventsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesEventsClientTests.cs @@ -36,12 +36,12 @@ public async Task RequestsCorrectUrl() var client = new ObservableIssuesEventsClient(gitHubClient); IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary) .Returns(Task.FromResult(response)); var eventInfos = await client.GetAllForIssue("fake", "repo", 42).ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Args.EmptyDictionary, null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Args.EmptyDictionary); Assert.Equal(1, eventInfos.Count); } @@ -55,12 +55,12 @@ public async Task RequestsCorrectUrlWithRepositoryId() var client = new ObservableIssuesEventsClient(gitHubClient); IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary) .Returns(Task.FromResult(response)); var eventInfos = await client.GetAllForIssue(1, 42).ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Args.EmptyDictionary, null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Args.EmptyDictionary); Assert.Equal(1, eventInfos.Count); } @@ -81,12 +81,12 @@ public async Task RequestsCorrectUrlWithApiOptions() }; IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2)) .Returns(Task.FromResult(response)); var eventInfos = await client.GetAllForIssue("fake", "repo", 42, options).ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); Assert.Equal(1, eventInfos.Count); } @@ -108,12 +108,12 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>( CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2)) .Returns(Task.FromResult(response)); var eventInfos = await client.GetAllForIssue(1, 42, options).ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); Assert.Equal(1, eventInfos.Count); } @@ -149,12 +149,12 @@ public async Task RequestsCorrectUrl() var client = new ObservableIssuesEventsClient(gitHubClient); IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary) .Returns(Task.FromResult(response)); var issueEvents = await client.GetAllForRepository("fake", "repo").ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), Args.EmptyDictionary, null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), Args.EmptyDictionary); Assert.Equal(1, issueEvents.Count); } @@ -168,12 +168,12 @@ public async Task RequestsCorrectUrlWithRepositoryId() var client = new ObservableIssuesEventsClient(gitHubClient); IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Args.EmptyDictionary) .Returns(Task.FromResult(response)); var issueEvents = await client.GetAllForRepository(1).ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), Args.EmptyDictionary, null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), Args.EmptyDictionary); Assert.Equal(1, issueEvents.Count); } @@ -194,12 +194,12 @@ public async Task RequestsCorrectUrlWithApiOptions() }; IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2)) .Returns(Task.FromResult(response)); var issueEvents = await client.GetAllForRepository("fake", "repo", options).ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); Assert.Equal(1, issueEvents.Count); } @@ -220,12 +220,12 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() }; IApiResponse<List<IssueEvent>> response = new ApiResponse<List<IssueEvent>>(CreateResponse(HttpStatusCode.OK), result); - gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null) + gitHubClient.Connection.Get<List<IssueEvent>>(Args.Uri, Arg.Is<Dictionary<string, string>>(d => d.Count == 2)) .Returns(Task.FromResult(response)); var issueEvents = await client.GetAllForRepository(1, options).ToList(); - connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<IssueEvent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/events"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); Assert.Equal(1, issueEvents.Count); } diff --git a/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs index c075028d0e..81b8ac940b 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs @@ -30,7 +30,7 @@ public async Task RequestsCorrectUrl() client.GetAllForIssue("fake", "repo", 42); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.EmptyDictionary, null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.EmptyDictionary); } [Fact] @@ -42,7 +42,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() client.GetAllForIssue(1, 42); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.EmptyDictionary, null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.EmptyDictionary); } [Fact] @@ -61,7 +61,7 @@ public async Task RequestsCorrectUrlWithApiOptions() client.GetAllForIssue("fake", "repo", 42, options); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -80,7 +80,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() client.GetAllForIssue(1, 42, options); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -114,7 +114,7 @@ public async Task RequestsCorrectUrl() client.GetAllForRepository("fake", "repo"); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), Args.EmptyDictionary, null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), Args.EmptyDictionary); } [Fact] @@ -126,7 +126,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() client.GetAllForRepository(1); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Args.EmptyDictionary, null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Args.EmptyDictionary); } [Fact] @@ -145,7 +145,7 @@ public async Task RequestsCorrectUrlWithApiOptions() client.GetAllForRepository("fake", "repo", options); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -164,7 +164,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() client.GetAllForRepository(1, options); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -198,7 +198,7 @@ public async Task RequestsCorrectUrl() client.GetAllForMilestone("fake", "repo", 42); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Args.EmptyDictionary, null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Args.EmptyDictionary); } [Fact] @@ -210,7 +210,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() client.GetAllForMilestone(1, 42); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), Args.EmptyDictionary, null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), Args.EmptyDictionary); } [Fact] @@ -229,7 +229,7 @@ public async Task RequestsCorrectUrlWithApiOptions() client.GetAllForMilestone("fake", "repo", 42, options); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -248,7 +248,7 @@ public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() client.GetAllForMilestone(1, 42, options); - connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/milestones/42/labels"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs b/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs index e7c70f1963..5780a494e0 100644 --- a/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs @@ -250,11 +250,11 @@ public async Task ReturnsEveryPageOfMilestones() } ); var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<Milestone>>(firstPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<Milestone>>(firstPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<Milestone>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<Milestone>>(secondPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<Milestone>>(secondPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<Milestone>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<Milestone>>(thirdPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<Milestone>>(thirdPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<Milestone>>>(lastPageResponse)); var client = new ObservableMilestonesClient(gitHubClient); @@ -307,17 +307,17 @@ public async Task SendsAppropriateParametersMulti() Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["state"] == "open" - && d["sort"] == "due_date"), null) + && d["sort"] == "due_date")) .Returns(Task.FromResult<IApiResponse<List<Milestone>>>(firstPageResponse)); gitHubClient.Connection.Get<List<Milestone>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["state"] == "open" - && d["sort"] == "due_date"), null) + && d["sort"] == "due_date")) .Returns(Task.FromResult<IApiResponse<List<Milestone>>>(secondPageResponse)); gitHubClient.Connection.Get<List<Milestone>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["state"] == "open" - && d["sort"] == "due_date"), null) + && d["sort"] == "due_date")) .Returns(Task.FromResult<IApiResponse<List<Milestone>>>(lastPageResponse)); var client = new ObservableMilestonesClient(gitHubClient); diff --git a/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs b/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs index cbcd97c6f3..22afb7c7d9 100644 --- a/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs @@ -31,7 +31,7 @@ public void RequestsCorrectUrl() client.GetAllForCurrent(); - connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary, null); + connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -51,7 +51,7 @@ public void RequestsCorrectUrlApiOptions() client.GetAllForCurrent(options); - connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -66,8 +66,8 @@ public void RequestsCorrectUrlNotificationRequest() client.GetAllForCurrent(notificationsRequest); - connection.Received().Get<List<Notification>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 - && d["all"] == "true" && d["participating"] == "false"), null); + connection.Received().Get<List<Notification>>(endpoint, + Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false")); } [Fact] @@ -89,9 +89,11 @@ public void RequestsCorrectUrlNotificationRequestWithApiOptions() client.GetAllForCurrent(notificationsRequest, options); - connection.Received().Get<List<Notification>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 4 - && d["all"] == "true" && d["participating"] == "false" - && d["page"] == "1" && d["per_page"] == "1"), null); + connection.Received().Get<List<Notification>>(endpoint, + Arg.Is<IDictionary<string, string>>(d => + d.Count == 4 + && d["all"] == "true" && d["participating"] == "false" + && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -116,7 +118,7 @@ public void RequestsCorrectUrl() client.GetAllForRepository("banana", "split"); - connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary, null); + connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -129,7 +131,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllForRepository(1); - connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary, null); + connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -149,7 +151,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllForRepository("banana", "split", options); - connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -169,7 +171,7 @@ public void RequestsCorrectUrlWithApiOptionsWithRepositoryId() client.GetAllForRepository(1, options); - connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -185,8 +187,7 @@ public void RequestsCorrectUrlNotificationRequest() client.GetAllForRepository("banana", "split", notificationsRequest); connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>( - d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), - null); + d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false")); } [Fact] @@ -202,8 +203,7 @@ public void RequestsCorrectUrlNotificationRequestWithRepositoryId() client.GetAllForRepository(1, notificationsRequest); connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>( - d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), - null); + d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false")); } [Fact] @@ -227,8 +227,7 @@ public void RequestsCorrectUrlNotificationRequestWithApiOptions() connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 4 && d["all"] == "true" && d["participating"] == "false" - && d["page"] == "1" && d["per_page"] == "1"), - null); + && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -252,8 +251,7 @@ public void RequestsCorrectUrlNotificationRequestWithApiOptionsWithRepositoryId( connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 4 && d["all"] == "true" && d["participating"] == "false" - && d["page"] == "1" && d["per_page"] == "1"), - null); + && d["page"] == "1" && d["per_page"] == "1")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs index f64c1e8775..b06b3f9e58 100644 --- a/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs @@ -32,7 +32,7 @@ public void RequestsCorrectUrl() client.GetAll("org"); gitHubClient.Connection.Received(1).Get<List<User>>( - new Uri("orgs/org/members", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("orgs/org/members", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -51,7 +51,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAll("org", options); gitHubClient.Connection.Received(1).Get<List<User>>( - new Uri("orgs/org/members", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + new Uri("orgs/org/members", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -96,7 +96,7 @@ public void TwoFactorFilterRequestTheCorrectUrlWithApiOptions() orgMembersClient.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled, options); client.Connection.Received(1).Get<List<User>>( - new Uri("orgs/org/members?filter=2fa_disabled", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + new Uri("orgs/org/members?filter=2fa_disabled", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -114,7 +114,7 @@ public void MemberRoleFilterRequestTheCorrectUrlWithApiOptions() orgMembersClient.GetAll("org", OrganizationMembersRole.Member, options); - client.Connection.Received().Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members?role=member"), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + client.Connection.Received().Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members?role=member"), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -132,7 +132,7 @@ public void TwoFactorFilterPlusMemberRoleRequestTheCorrectUrlWithApiOptions() orgMembersClient.GetAll("org", OrganizationMembersFilter.TwoFactorAuthenticationDisabled, OrganizationMembersRole.Member, options); - client.Connection.Received().Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members?filter=2fa_disabled&role=member"), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + client.Connection.Received().Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members?filter=2fa_disabled&role=member"), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } } @@ -147,7 +147,7 @@ public void RequestsTheCorrectUrl() client.GetAllPublic("org"); gitHubClient.Connection.Received(1).Get<List<User>>( - new Uri("orgs/org/public_members", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("orgs/org/public_members", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -166,7 +166,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAllPublic("org", options); gitHubClient.Connection.Received(1).Get<List<User>>( - new Uri("orgs/org/public_members", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + new Uri("orgs/org/public_members", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -399,8 +399,7 @@ public void RequestsTheCorrectUrl() gitHubClient.Connection.Received().GetAndFlattenAllPages<OrganizationMembershipInvitation>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"), - Args.EmptyDictionary, - "application/vnd.github.korra-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -419,8 +418,7 @@ public void RequestsTheCorrectUrlWithStart() gitHubClient.Connection.Received().GetAndFlattenAllPages<OrganizationMembershipInvitation>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/invitations"), - Arg.Is<Dictionary<string, string>>(d => d.Count == 2), - "application/vnd.github.korra-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs index 31a9eeca5c..06d34c64b8 100644 --- a/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableOrganizationOutsideCollaboratorsClientTests.cs @@ -31,8 +31,7 @@ public void RequestsTheCorrectUrl() gitHubClient.Connection.Received(1).Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators"), - Args.EmptyDictionary, - "application/vnd.github.korra-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -52,8 +51,7 @@ public void RequestsTheCorrectUrlWithApiOptions() gitHubClient.Connection.Received(1).Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators"), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), - "application/vnd.github.korra-preview+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -87,8 +85,7 @@ public void AllFilterRequestsTheCorrectUrl() gitHubClient.Connection.Received(1).Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), - Args.EmptyDictionary, - "application/vnd.github.korra-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -108,8 +105,7 @@ public void AllFilterRequestsTheCorrectUrlWithApiOptions() gitHubClient.Connection.Received(1).Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=all"), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), - "application/vnd.github.korra-preview+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -122,8 +118,7 @@ public void TwoFactorFilterRequestsTheCorrectUrl() gitHubClient.Connection.Received(1).Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), - Args.EmptyDictionary, - "application/vnd.github.korra-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -143,8 +138,7 @@ public void TwoFactorFilterRequestsTheCorrectUrlWithApiOptions() gitHubClient.Connection.Received(1).Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/outside_collaborators?filter=2fa_disabled"), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), - "application/vnd.github.korra-preview+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } } diff --git a/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs b/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs index 1023bb9535..94a54b7cf3 100644 --- a/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableProjectCardsClientTests.cs @@ -33,8 +33,7 @@ public void RequestCorrectURL() connection.Received().Get<List<ProjectCard>>( Arg.Is<Uri>(u => u.ToString() == "projects/columns/1/cards"), - Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -50,8 +49,7 @@ public async Task SendsAppropriateParameters() Arg.Is<Uri>(u => u.ToString() == "projects/columns/1/cards"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 - && x["archived_state"] == "not_archived"), - "application/vnd.github.inertia-preview+json"); + && x["archived_state"] == "not_archived")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableProjectColumnsClientTests.cs b/Octokit.Tests/Reactive/ObservableProjectColumnsClientTests.cs index 39f24b8248..d370a19db0 100644 --- a/Octokit.Tests/Reactive/ObservableProjectColumnsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableProjectColumnsClientTests.cs @@ -33,8 +33,7 @@ public void RequestCorrectURL() connection.Received().Get<List<ProjectColumn>>( Arg.Is<Uri>(u => u.ToString() == "projects/1/columns"), - Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json"); + Args.EmptyDictionary); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableProjectsClientTests.cs b/Octokit.Tests/Reactive/ObservableProjectsClientTests.cs index d2cdad7785..3f2bef6898 100644 --- a/Octokit.Tests/Reactive/ObservableProjectsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableProjectsClientTests.cs @@ -34,8 +34,7 @@ public void RequestCorrectUrl() connection.Received().Get<List<Project>>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/projects"), - Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -49,8 +48,7 @@ public void RequestCorrectUrlWithRequestParameter() connection.Received().Get<List<Project>>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/projects"), - Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), - "application/vnd.github.inertia-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state"))); } [Fact] @@ -64,8 +62,7 @@ public void RequestCorrectUrlWithRepositoryId() connection.Received().Get<List<Project>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/projects"), - Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -79,8 +76,7 @@ public void RequestCorrectUrlWithRequestParameterWithRepositoryId() connection.Received().Get<List<Project>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/projects"), - Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), - "application/vnd.github.inertia-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state"))); } [Fact] @@ -131,8 +127,7 @@ public void RequestCorrectUrl() connection.Received().Get<List<Project>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/projects"), - Args.EmptyDictionary, - "application/vnd.github.inertia-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -146,8 +141,7 @@ public void RequestCorrectUrlWithRequestParameter() connection.Received().Get<List<Project>>( Arg.Is<Uri>(u => u.ToString() == "orgs/org/projects"), - Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), - "application/vnd.github.inertia-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state"))); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs index 4ae70bc8ed..5c813929a6 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs @@ -128,12 +128,11 @@ public async Task RequestsCorrectUrlMulti() ); var gitHubClient = Substitute.For<IGitHubClient>(); - var acceptHeader = "application/vnd.github.squirrel-girl-preview+json"; - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, acceptHeader) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, acceptHeader) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, acceptHeader) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); @@ -141,9 +140,9 @@ public async Task RequestsCorrectUrlMulti() var results = await client.GetAll("owner", "name", 7).ToArray(); Assert.Equal(7, results.Length); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, acceptHeader); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, acceptHeader); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, acceptHeader); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary); } [Fact] @@ -183,11 +182,11 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId() ); var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); @@ -195,9 +194,9 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId() var results = await client.GetAll(1, 7).ToArray(); Assert.Equal(7, results.Length); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary); } [Fact] @@ -347,23 +346,22 @@ public async Task RequestsCorrectUrlMulti() ); var gitHubClient = Substitute.For<IGitHubClient>(); - var previewAcceptHeader = "application/vnd.github.squirrel-girl-preview+json"; gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), previewAcceptHeader) + && d["sort"] == "updated")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), previewAcceptHeader) + && d["sort"] == "updated")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), previewAcceptHeader) + && d["sort"] == "updated")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); @@ -382,15 +380,15 @@ public async Task RequestsCorrectUrlMulti() Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), previewAcceptHeader); + && d["sort"] == "updated")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), previewAcceptHeader); + && d["sort"] == "updated")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), previewAcceptHeader); + && d["sort"] == "updated")); } [Fact] @@ -436,17 +434,17 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId() Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview+json") + && d["sort"] == "updated")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview+json") + && d["sort"] == "updated")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview+json") + && d["sort"] == "updated")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); @@ -465,15 +463,15 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId() Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "updated")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "updated")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" - && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "updated")); } [Fact] @@ -573,20 +571,18 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMulti() var gitHubClient = Substitute.For<IGitHubClient>(); - var previewAcceptHeader = "application/vnd.github.squirrel-girl-preview+json"; - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), previewAcceptHeader) + && d["sort"] == "created")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), previewAcceptHeader) + && d["sort"] == "created")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), previewAcceptHeader) + && d["sort"] == "created")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); @@ -597,13 +593,13 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMulti() gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), previewAcceptHeader); + && d["sort"] == "created")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), previewAcceptHeader); + && d["sort"] == "created")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), previewAcceptHeader); + && d["sort"] == "created")); } [Fact] @@ -648,15 +644,15 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMultiWithRepo gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview+json") + && d["sort"] == "created")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview+json") + && d["sort"] == "created")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview+json") + && d["sort"] == "created")) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); @@ -667,15 +663,13 @@ public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMultiWithRepo gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "created")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), - "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "created")); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" - && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview+json"); + && d["sort"] == "created")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewsClientTests.cs index 89bee2f933..4934d507a4 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestReviewsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewsClientTests.cs @@ -524,11 +524,11 @@ public async Task RequestsCorrectUrlMulti() var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewsClient(gitHubClient); @@ -536,9 +536,9 @@ public async Task RequestsCorrectUrlMulti() var results = await client.GetAllComments("owner", "name", 7, 1).ToArray(); Assert.Equal(7, results.Length); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary); } [Fact] @@ -579,11 +579,11 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId() var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null) + gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequestReviewComment>>>(lastPageResponse)); var client = new ObservablePullRequestReviewsClient(gitHubClient); @@ -591,9 +591,9 @@ public async Task RequestsCorrectUrlMultiWithRepositoryId() var results = await client.GetAllComments(1, 7, 1).ToArray(); Assert.Equal(7, results.Length); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, null); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, null); - gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary); + gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs index d08c94a37e..c48529d53c 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs @@ -211,11 +211,11 @@ public async Task ReturnsEveryPageOfPullRequests() } ); var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json") + gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json") + gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json") + gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(lastPageResponse)); var client = new ObservablePullRequestsClient(gitHubClient); @@ -264,11 +264,11 @@ public async Task ReturnsEveryPageOfPullRequestsWithRepositoryId() } ); var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json") + gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json") + gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary, "application/vnd.github.shadow-cat-preview+json") + gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Args.EmptyDictionary) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(lastPageResponse)); var client = new ObservablePullRequestsClient(gitHubClient); @@ -323,21 +323,21 @@ public async Task SendsAppropriateParametersMulti() && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json") + && d["direction"] == "desc")) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(firstPageResponse)); gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["head"] == "user:ref-name" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json") + && d["direction"] == "desc")) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(secondPageResponse)); gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["head"] == "user:ref-name" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json") + && d["direction"] == "desc")) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(lastPageResponse)); var client = new ObservablePullRequestsClient(gitHubClient); @@ -392,21 +392,21 @@ public async Task SendsAppropriateParametersMultiWithRepositoryId() && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json") + && d["direction"] == "desc")) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(firstPageResponse)); gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["head"] == "user:ref-name" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json") + && d["direction"] == "desc")) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(secondPageResponse)); gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 5 && d["head"] == "user:ref-name" && d["state"] == "open" && d["base"] == "fake_base_branch" && d["sort"] == "created" - && d["direction"] == "desc"), "application/vnd.github.shadow-cat-preview+json") + && d["direction"] == "desc")) .Returns(Task.FromResult<IApiResponse<List<PullRequest>>>(lastPageResponse)); var client = new ObservablePullRequestsClient(gitHubClient); @@ -640,7 +640,7 @@ public async Task FetchesAllCommitsForPullRequest() CreateResponse(HttpStatusCode.OK), new List<PullRequestCommit> { commit } ); - connection.Get<List<PullRequestCommit>>(Args.Uri, null, null) + connection.Get<List<PullRequestCommit>>(Args.Uri, null) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -649,7 +649,7 @@ public async Task FetchesAllCommitsForPullRequest() Assert.Equal(1, commits.Count); Assert.Same(commit, commits[0]); - connection.Received().Get<List<PullRequestCommit>>(new Uri(expectedUrl, UriKind.Relative), null, null); + connection.Received().Get<List<PullRequestCommit>>(new Uri(expectedUrl, UriKind.Relative), null); } [Fact] @@ -664,7 +664,7 @@ public async Task FetchesAllCommitsForPullRequestWithRepositoryId() CreateResponse(HttpStatusCode.OK), new List<PullRequestCommit> { commit } ); - connection.Get<List<PullRequestCommit>>(Args.Uri, null, null) + connection.Get<List<PullRequestCommit>>(Args.Uri, null) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -673,7 +673,7 @@ public async Task FetchesAllCommitsForPullRequestWithRepositoryId() Assert.Equal(1, commits.Count); Assert.Same(commit, commits[0]); - connection.Received().Get<List<PullRequestCommit>>(new Uri(expectedUrl, UriKind.Relative), null, null); + connection.Received().Get<List<PullRequestCommit>>(new Uri(expectedUrl, UriKind.Relative), null); } [Fact] @@ -704,7 +704,7 @@ public async Task FetchesAllFilesForPullRequest() CreateResponse(HttpStatusCode.OK), new List<PullRequestFile> { file } ); - connection.Get<List<PullRequestFile>>(Args.Uri, null, null) + connection.Get<List<PullRequestFile>>(Args.Uri, null) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -713,7 +713,7 @@ public async Task FetchesAllFilesForPullRequest() Assert.Equal(1, files.Count); Assert.Same(file, files[0]); - connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), null, null); + connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), null); } [Fact] @@ -728,7 +728,7 @@ public async Task FetchesAllFilesForPullRequestWithRepositoryId() CreateResponse(HttpStatusCode.OK), new List<PullRequestFile> { file } ); - connection.Get<List<PullRequestFile>>(Args.Uri, null, null) + connection.Get<List<PullRequestFile>>(Args.Uri, null) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -737,7 +737,7 @@ public async Task FetchesAllFilesForPullRequestWithRepositoryId() Assert.Equal(1, files.Count); Assert.Same(file, files[0]); - connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), null, null); + connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), null); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs index 438bd1fe91..71771feb90 100644 --- a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs @@ -29,7 +29,7 @@ public void RequestsTheCorrectUrl() client.GetAll("fake", "repo"); gitHubClient.Connection.Received(1).Get<List<Release>>( - new Uri("repos/fake/repo/releases", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("repos/fake/repo/releases", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -41,7 +41,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.GetAll(1); gitHubClient.Connection.Received(1).Get<List<Release>>( - new Uri("repositories/1/releases", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("repositories/1/releases", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -60,7 +60,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAll("fake", "repo", options); gitHubClient.Connection.Received(1).Get<List<Release>>( - new Uri("repos/fake/repo/releases", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + new Uri("repos/fake/repo/releases", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -79,7 +79,7 @@ public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() client.GetAll(1, options); gitHubClient.Connection.Received(1).Get<List<Release>>( - new Uri("repositories/1/releases", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + new Uri("repositories/1/releases", UriKind.Relative), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -342,7 +342,7 @@ public void RequestsTheCorrectUrl() client.GetAllAssets("fake", "repo", 1); gitHubClient.Connection.Received(1).Get<List<ReleaseAsset>>( - new Uri("repos/fake/repo/releases/1/assets", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("repos/fake/repo/releases/1/assets", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -354,7 +354,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.GetAllAssets(1, 1); gitHubClient.Connection.Received(1).Get<List<ReleaseAsset>>( - new Uri("repositories/1/releases/1/assets", UriKind.Relative), Args.EmptyDictionary, null); + new Uri("repositories/1/releases/1/assets", UriKind.Relative), Args.EmptyDictionary); } [Fact] @@ -376,8 +376,7 @@ public void RequestsTheCorrectUrlWithApiOptions() gitHubClient.Connection.Received(1).Get<List<ReleaseAsset>>( Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] @@ -399,8 +398,7 @@ public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() gitHubClient.Connection.Received(1).Get<List<ReleaseAsset>>( Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs index 8b0b78f853..d48a007a96 100644 --- a/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs @@ -69,8 +69,7 @@ public void RequestsCorrectUrl() _client.GetAll(owner, name); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); } [Fact] @@ -81,8 +80,7 @@ public void RequestsCorrectUrlWithRepositoryId() _client.GetAll(repositoryId); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); } [Fact] @@ -101,8 +99,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 3), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 3)); // StartPage is setted => only 1 option (StartPage) in dictionary options = new ApiOptions @@ -113,8 +110,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); // PageCount is setted => none of options in dictionary options = new ApiOptions @@ -125,8 +121,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); } [Fact] @@ -139,8 +134,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() _client.GetAll(owner, name, request); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "all"), - null); + Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "all")); request = new RepositoryCollaboratorListRequest { @@ -150,8 +144,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() _client.GetAll(owner, name, request); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "direct"), - null); + Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "direct")); // PageCount is setted => none of options in dictionary request = new RepositoryCollaboratorListRequest @@ -162,8 +155,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() _client.GetAll(owner, name, request); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "outside"), - null); + Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "outside")); } [Fact] @@ -182,8 +174,7 @@ public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() _client.GetAll(repositoryId, options); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 3), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 3)); // StartPage is setted => only 1 option (StartPage) in dictionary options = new ApiOptions @@ -194,8 +185,7 @@ public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() _client.GetAll(repositoryId, options); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); // PageCount is setted => none of options in dictionary options = new ApiOptions @@ -206,8 +196,7 @@ public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() _client.GetAll(repositoryId, options); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); } [Fact] @@ -220,8 +209,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() _client.GetAll(repositoryId, request); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "all"), - null); + Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "all")); request = new RepositoryCollaboratorListRequest { @@ -231,8 +219,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() _client.GetAll(repositoryId, request); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "direct"), - null); + Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "direct")); request = new RepositoryCollaboratorListRequest { @@ -242,8 +229,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() _client.GetAll(repositoryId, request); _githubClient.Connection.Received(1) .Get<List<User>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "outside"), - null); + Arg.Is<IDictionary<string, string>>(d => d["affiliation"] == "outside")); } } diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index 8bac0894d9..747fd1d4fb 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -273,20 +273,20 @@ public async Task ReturnsEveryPageOfRepositories() }); var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<Repository>>(firstPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders) + gitHubClient.Connection.Get<List<Repository>>(firstPageUrl, Arg.Any<IDictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Repository>>>(firstPageResponse)); - gitHubClient.Connection.Get<List<Repository>>(secondPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders) + gitHubClient.Connection.Get<List<Repository>>(secondPageUrl, Arg.Any<IDictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Repository>>>(secondPageResponse)); - gitHubClient.Connection.Get<List<Repository>>(thirdPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders) + gitHubClient.Connection.Get<List<Repository>>(thirdPageUrl, Arg.Any<IDictionary<string, string>>()) .Returns(Task.FromResult<IApiResponse<List<Repository>>>(lastPageResponse)); var repositoriesClient = new ObservableRepositoriesClient(gitHubClient); var results = await repositoriesClient.GetAllForCurrent().ToArray(); Assert.Equal(7, results.Length); - gitHubClient.Connection.Received(1).Get<List<Repository>>(firstPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders); - gitHubClient.Connection.Received(1).Get<List<Repository>>(secondPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders); - gitHubClient.Connection.Received(1).Get<List<Repository>>(thirdPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders); + gitHubClient.Connection.Received(1).Get<List<Repository>>(firstPageUrl, Arg.Any<IDictionary<string, string>>()); + gitHubClient.Connection.Received(1).Get<List<Repository>>(secondPageUrl, Arg.Any<IDictionary<string, string>>()); + gitHubClient.Connection.Received(1).Get<List<Repository>>(thirdPageUrl, Arg.Any<IDictionary<string, string>>()); } [Fact(Skip = "See https://github.com/octokit/octokit.net/issues/1011 for issue to investigate this further")] @@ -393,11 +393,11 @@ public async Task ReturnsEveryPageOfRepositories() }); var gitHubClient = Substitute.For<IGitHubClient>(); - gitHubClient.Connection.Get<List<Repository>>(firstPageUrl, null, Args.AnyAcceptHeaders) + gitHubClient.Connection.Get<List<Repository>>(firstPageUrl, null) .Returns(Task.FromResult(firstPageResponse)); - gitHubClient.Connection.Get<List<Repository>>(secondPageUrl, null, Args.AnyAcceptHeaders) + gitHubClient.Connection.Get<List<Repository>>(secondPageUrl, null) .Returns(Task.FromResult(secondPageResponse)); - gitHubClient.Connection.Get<List<Repository>>(thirdPageUrl, null, Args.AnyAcceptHeaders) + gitHubClient.Connection.Get<List<Repository>>(thirdPageUrl, null) .Returns(Task.FromResult(lastPageResponse)); var repositoriesClient = new ObservableRepositoriesClient(gitHubClient); @@ -405,9 +405,9 @@ public async Task ReturnsEveryPageOfRepositories() var results = await repositoriesClient.GetAllPublic(new PublicRepositoryRequest(364L)).ToArray(); Assert.Equal(7, results.Length); - gitHubClient.Connection.Received(1).Get<List<Repository>>(firstPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders); - gitHubClient.Connection.Received(1).Get<List<Repository>>(secondPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders); - gitHubClient.Connection.Received(1).Get<List<Repository>>(thirdPageUrl, Arg.Any<IDictionary<string, string>>(), Args.AnyAcceptHeaders); + gitHubClient.Connection.Received(1).Get<List<Repository>>(firstPageUrl, Arg.Any<IDictionary<string, string>>()); + gitHubClient.Connection.Received(1).Get<List<Repository>>(secondPageUrl, Arg.Any<IDictionary<string, string>>()); + gitHubClient.Connection.Received(1).Get<List<Repository>>(thirdPageUrl, Arg.Any<IDictionary<string, string>>()); } } @@ -461,7 +461,7 @@ public void RequestsTheCorrectUrl() client.Commit.GetAll("owner", "repo"); - github.Connection.Received(1).Get<List<GitHubCommit>>(expected, Arg.Any<IDictionary<string, string>>(), null); + github.Connection.Received(1).Get<List<GitHubCommit>>(expected, Arg.Any<IDictionary<string, string>>()); } } @@ -478,8 +478,7 @@ public void RequestsTheCorrectUrl() gitHubClient.Connection.Received(1) .Get<List<RepositoryContributor>>(expected, - Args.EmptyDictionary, - null); + Args.EmptyDictionary); } [Fact] @@ -493,8 +492,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() gitHubClient.Connection.Received(1) .Get<List<RepositoryContributor>>(expected, - Args.EmptyDictionary, - null); + Args.EmptyDictionary); } [Fact] @@ -515,8 +513,7 @@ public void RequestsTheCorrectUrlWithApiOptions() gitHubClient.Connection.Received(1) .Get<List<RepositoryContributor>>(expected, - Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), - null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -537,8 +534,7 @@ public void RequestsTheCorrectUrlWithApiOptionsWithRepositoryId() gitHubClient.Connection.Received(1) .Get<List<RepositoryContributor>>(expected, - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -550,7 +546,7 @@ public void RequestsTheCorrectUrlIncludeAnonymous() client.GetAllContributors("owner", "name", true); gitHubClient.Connection.Received() - .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1"), null); + .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1")); } [Fact] @@ -562,7 +558,7 @@ public void RequestsTheCorrectUrlWithRepositoryIdIncludeAnonymous() client.GetAllContributors(1, true); gitHubClient.Connection.Received() - .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1"), null); + .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Is<IDictionary<string, string>>(d => d["anon"] == "1")); } [Fact] @@ -581,7 +577,8 @@ public void RequestsTheCorrectUrlWithApiOptionsIncludeAnonymous() client.GetAllContributors("owner", "name", true, options); gitHubClient.Connection.Received() - .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), Arg.Is<IDictionary<string, string>>(d => d.Count == 3 && d["anon"] == "1" && d["page"] == "1" && d["per_page"] == "1"), null); + .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/contributors"), + Arg.Is<IDictionary<string, string>>(d => d.Count == 3 && d["anon"] == "1" && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -600,7 +597,8 @@ public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptionsIncludeAnonymous( client.GetAllContributors(1, true, options); gitHubClient.Connection.Received() - .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), Arg.Is<IDictionary<string, string>>(d => d.Count == 3 && d["anon"] == "1" && d["page"] == "1" && d["per_page"] == "1"), null); + .Get<List<RepositoryContributor>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contributors"), + Arg.Is<IDictionary<string, string>>(d => d.Count == 3 && d["anon"] == "1" && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -680,8 +678,7 @@ public void RequestsTheCorrectUrl() client.GetAllTeams("owner", "repo"); gitHubClient.Connection.Received(1).Get<List<Team>>(expected, - Arg.Any<IDictionary<string, string>>(), - Arg.Any<string>()); + Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -694,8 +691,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.GetAllTeams(1); gitHubClient.Connection.Received(1).Get<List<Team>>(expected, - Arg.Any<IDictionary<string, string>>(), - Arg.Any<string>()); + Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -715,8 +711,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAllTeams("owner", "repo", options); gitHubClient.Connection.Received(1).Get<List<Team>>(expected, - Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), - Arg.Any<string>()); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -736,8 +731,7 @@ public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() client.GetAllTeams(1, options); gitHubClient.Connection.Received(1).Get<List<Team>>(expected, - Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), - Arg.Any<string>()); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -771,7 +765,8 @@ public void RequestsTheCorrectUrl() client.GetAllTags("owner", "repo"); - gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Any<IDictionary<string, string>>(), null); + var received = gitHubClient.Connection.ReceivedCalls(); + gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -783,7 +778,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.GetAllTags(1); - gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Any<IDictionary<string, string>>(), null); + gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -802,7 +797,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAllTags("owner", "repo", options); - gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), null); + gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -821,7 +816,7 @@ public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() client.GetAllTags(1, options); - gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), null); + gitHubClient.Connection.Received(1).Get<List<RepositoryTag>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs index 0001c8c425..2135f10f5c 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -32,7 +32,7 @@ public void RequestsTheCorrectUrl() client.GetAll("owner", "repo"); - gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Args.EmptyDictionary); } [Fact] @@ -44,7 +44,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.GetAll(1); - gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Args.EmptyDictionary, null); + gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Args.EmptyDictionary); } [Fact] @@ -63,7 +63,7 @@ public void RequestsTheCorrectUrlWithApiOptions() client.GetAll("owner", "name", options); - gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), null); + gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] @@ -82,7 +82,7 @@ public void RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() client.GetAll(1, options); - gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1"), null); + gitHubClient.Connection.Received(1).Get<List<Branch>>(expected, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["page"] == "1" && d["per_page"] == "1")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs index 8945a9d145..8c12a48a0f 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs @@ -66,7 +66,7 @@ public void RequestsCorrectUrl() client.GetAllForRepository("fake", "repo"); githubClient.Connection.Received(1).Get<List<CommitComment>>(Arg.Is<Uri>(uri => uri.ToString() == "repos/fake/repo/comments"), - Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -77,7 +77,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllForRepository(1); githubClient.Connection.Received(1).Get<List<CommitComment>>(Arg.Is<Uri>(uri => uri.ToString() == "repositories/1/comments"), - Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -95,7 +95,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllForRepository("fake", "repo", options); githubClient.Connection.Received(1).Get<List<CommitComment>>(Arg.Is<Uri>(uri => uri.ToString() == "repos/fake/repo/comments"), - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2), "application/vnd.github.squirrel-girl-preview+json"); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] @@ -113,7 +113,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() client.GetAllForRepository(1, options); githubClient.Connection.Received(1).Get<List<CommitComment>>(Arg.Is<Uri>(uri => uri.ToString() == "repositories/1/comments"), - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2), "application/vnd.github.squirrel-girl-preview+json"); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2)); } [Fact] @@ -147,7 +147,7 @@ public void RequestsCorrectUrl() client.GetAllForCommit("fake", "repo", "sha"); githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repos/fake/repo/commits/sha/comments", UriKind.Relative)), - Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -158,7 +158,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllForCommit(1, "sha"); githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repositories/1/commits/sha/comments", UriKind.Relative)), - Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -176,7 +176,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllForCommit("fake", "repo", "sha", options); githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repos/fake/repo/commits/sha/comments", UriKind.Relative)), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), "application/vnd.github.squirrel-girl-preview+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -194,7 +194,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() client.GetAllForCommit(1, "sha", options); githubClient.Connection.Received().Get<List<CommitComment>>(Arg.Is(new Uri("repositories/1/commits/sha/comments", UriKind.Relative)), - Arg.Is<IDictionary<string, string>>(d => d.Count == 2), "application/vnd.github.squirrel-girl-preview+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs index 400387ebf1..4339adc41e 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryContentsClientTests.cs @@ -173,12 +173,12 @@ public async Task ReturnsContents() var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContents("fake", "repo").ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/"), null); Assert.Equal(1, contents.Count); } @@ -192,12 +192,12 @@ public async Task ReturnsContentsWithRepositoryId() var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContents(1).ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/"), null); Assert.Equal(1, contents.Count); } @@ -211,12 +211,12 @@ public async Task ReturnsAllContents() var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContents("fake", "repo").ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/"), null); Assert.Equal(1, contents.Count); } @@ -229,12 +229,12 @@ public async Task ReturnsAllContentsWithRepositoryId() var gitHubClient = new GitHubClient(connection); var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContents(1).ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/contents/"), null); Assert.Equal(1, contents.Count); } @@ -309,12 +309,12 @@ public async Task ReturnsContentsByRef() var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContentsByRef("fake", "repo", GitHubConstants.DefaultBranchName, "readme.md").ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/readme.md?ref={GitHubConstants.DefaultBranchName}"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/readme.md?ref={GitHubConstants.DefaultBranchName}"), null); Assert.Equal(1, contents.Count); } @@ -327,12 +327,12 @@ public async Task ReturnsContentsByRefWithRepositoryId() var gitHubClient = new GitHubClient(connection); var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContentsByRef(1, GitHubConstants.DefaultBranchName, "readme.md").ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/readme.md?ref={GitHubConstants.DefaultBranchName}"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/readme.md?ref={GitHubConstants.DefaultBranchName}"), null); Assert.Equal(1, contents.Count); } @@ -345,12 +345,12 @@ public async Task ReturnsAllContentsByRef() var gitHubClient = new GitHubClient(connection); var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContentsByRef("fake", "repo", GitHubConstants.DefaultBranchName).ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/?ref={GitHubConstants.DefaultBranchName}"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repos/fake/repo/contents/?ref={GitHubConstants.DefaultBranchName}"), null); Assert.Equal(1, contents.Count); } @@ -363,12 +363,12 @@ public async Task ReturnsAllContentsByRefWithRepositoryId() var gitHubClient = new GitHubClient(connection); var contentsClient = new ObservableRepositoryContentsClient(gitHubClient); IApiResponse<List<RepositoryContent>> response = new ApiResponse<List<RepositoryContent>>(CreateResponse(HttpStatusCode.OK), result); - connection.Get<List<RepositoryContent>>(Args.Uri, null, null) + connection.Get<List<RepositoryContent>>(Args.Uri, null) .Returns(Task.FromResult(response)); var contents = await contentsClient.GetAllContentsByRef(1, GitHubConstants.DefaultBranchName).ToList(); - connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/?ref={GitHubConstants.DefaultBranchName}"), null, null); + connection.Received().Get<List<RepositoryContent>>(Arg.Is<Uri>(u => u.ToString() == $"repositories/1/contents/?ref={GitHubConstants.DefaultBranchName}"), null); Assert.Equal(1, contents.Count); } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs index f0d553fe7a..c185cd9dd0 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -65,7 +65,7 @@ public void RequestsCorrectUrl() deployKeysClient.GetAll("user", "repo"); gitHubClient.Connection.Received(1).Get<List<DeployKey>>( - new Uri("repos/user/repo/keys", UriKind.Relative), Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null); + new Uri("repos/user/repo/keys", UriKind.Relative), Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -86,8 +86,7 @@ public void RequestsCorrectUrlWithApiOptions() deployKeysClient.GetAll("user", "repo", options); gitHubClient.Connection.Received(1) .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); // StartPage is setted => only 1 option (StartPage) in dictionary options = new ApiOptions @@ -98,8 +97,7 @@ public void RequestsCorrectUrlWithApiOptions() deployKeysClient.GetAll("user", "repo", options); gitHubClient.Connection.Received(1) .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); // PageCount is setted => none of options in dictionary options = new ApiOptions @@ -110,8 +108,7 @@ public void RequestsCorrectUrlWithApiOptions() deployKeysClient.GetAll("user", "repo", options); gitHubClient.Connection.Received(1) .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -132,8 +129,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() deployKeysClient.GetAll(1, options); gitHubClient.Connection.Received(1) .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); // StartPage is setted => only 1 option (StartPage) in dictionary options = new ApiOptions @@ -144,8 +140,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() deployKeysClient.GetAll(1, options); gitHubClient.Connection.Received(1) .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1)); // PageCount is setted => none of options in dictionary options = new ApiOptions @@ -156,8 +151,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() deployKeysClient.GetAll(1, options); gitHubClient.Connection.Received(1) .Get<List<DeployKey>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs index c650878f03..cd28b23dea 100644 --- a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs @@ -32,7 +32,7 @@ public void RequestsCorrectUrl() client.GetAllStargazers("fight", "club"); - connection.Received().Get<List<User>>(endpoint, Args.EmptyDictionary, null); + connection.Received().Get<List<User>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -46,7 +46,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllStargazers(1); - connection.Received().Get<List<User>>(endpoint, Args.EmptyDictionary, null); + connection.Received().Get<List<User>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -67,7 +67,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllStargazers("fight", "club", options); - connection.Received().Get<List<User>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<User>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -88,7 +88,7 @@ public void RequestsCorrectUrlWithApiOptionsWithRepositoryId() client.GetAllStargazers(1, options); - connection.Received().Get<List<User>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<User>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -102,7 +102,7 @@ public void RequestsCorrectUrlWithTimestamps() client.GetAllStargazersWithTimestamps("fight", "club"); - connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary, "application/vnd.github.v3.star+json"); + connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -116,7 +116,7 @@ public void RequestsCorrectUrlWithTimestampsWithRepositoryId() client.GetAllStargazersWithTimestamps(1); - connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary, "application/vnd.github.v3.star+json"); + connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -137,7 +137,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptions() client.GetAllStargazersWithTimestamps("fight", "club", options); - connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2), "application/vnd.github.v3.star+json"); + connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -158,7 +158,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptionsWithRepositoryId() client.GetAllStargazersWithTimestamps(1, options); - connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2), "application/vnd.github.v3.star+json"); + connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -204,7 +204,7 @@ public void RequestsCorrectUrl() client.GetAllForCurrent(); - connection.Received().Get<List<Repository>>(endpoint, Args.EmptyDictionary, null); + connection.Received().Get<List<Repository>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -225,7 +225,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllForCurrent(options); - connection.Received().Get<List<Repository>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1"), null); + connection.Received().Get<List<Repository>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1")); } [Fact] @@ -241,8 +241,7 @@ public void RequestsCorrectUrlParametrized() client.GetAllForCurrent(request); - connection.Received().Get<List<Repository>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), - null); + connection.Received().Get<List<Repository>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc")); } [Fact] @@ -266,7 +265,7 @@ public void RequestsCorrectUrlParametrizedWithApiOptions() client.GetAllForCurrent(request, options); connection.Received().Get<List<Repository>>(endpoint, - Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1"), null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1")); } [Fact] @@ -280,7 +279,7 @@ public void RequestsCorrectUrlWithTimestamps() client.GetAllForCurrentWithTimestamps(); - connection.Received().Get<List<RepositoryStar>>(endpoint, Args.EmptyDictionary, "application/vnd.github.v3.star+json"); + connection.Received().Get<List<RepositoryStar>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -302,8 +301,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptions() client.GetAllForCurrentWithTimestamps(options); connection.Received().Get<List<RepositoryStar>>(endpoint, - Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1"), - "application/vnd.github.v3.star+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1")); } [Fact] @@ -319,8 +317,7 @@ public void RequestsCorrectUrlWithTimestampsParametrized() client.GetAllForCurrentWithTimestamps(request); - connection.Received().Get<List<RepositoryStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), - "application/vnd.github.v3.star+json"); + connection.Received().Get<List<RepositoryStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc")); } [Fact] @@ -344,8 +341,7 @@ public void RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions() client.GetAllForCurrentWithTimestamps(request, options); connection.Received().Get<List<RepositoryStar>>(endpoint, - Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1"), - "application/vnd.github.v3.star+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1")); } [Fact] @@ -378,7 +374,7 @@ public void RequestsCorrectUrl() client.GetAllForUser("banana"); - connection.Received().Get<List<Repository>>(endpoint, Args.EmptyDictionary, null); + connection.Received().Get<List<Repository>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -400,7 +396,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllForUser("banana", options); connection.Received().Get<List<Repository>>(endpoint, - Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1"), null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1")); } [Fact] @@ -416,7 +412,7 @@ public void RequestsCorrectUrlParametrized() client.GetAllForUser("banana", starredRequest); - connection.Received().Get<List<Repository>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), null); + connection.Received().Get<List<Repository>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc")); } [Fact] @@ -440,8 +436,7 @@ public void RequestsCorrectUrlParametrizedWithApiOptions() client.GetAllForUser("banana", starredRequest, options); connection.Received().Get<List<Repository>>(endpoint, - Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1"), - null); + Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1")); } [Fact] @@ -455,8 +450,7 @@ public void RequestsCorrectUrlWithTimestamps() client.GetAllForUserWithTimestamps("banana"); - connection.Received().Get<List<RepositoryStar>>(endpoint, Args.EmptyDictionary, - "application/vnd.github.v3.star+json"); + connection.Received().Get<List<RepositoryStar>>(endpoint, Args.EmptyDictionary); } [Fact] @@ -478,8 +472,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptions() client.GetAllForUserWithTimestamps("banana", options); connection.Received().Get<List<RepositoryStar>>(endpoint, - Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1"), - "application/vnd.github.v3.star+json"); + Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1")); } [Fact] @@ -495,8 +488,7 @@ public void RequestsCorrectUrlWithTimestampsParametrized() client.GetAllForUserWithTimestamps("banana", starredRequest); - connection.Received().Get<List<RepositoryStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), - "application/vnd.github.v3.star+json"); + connection.Received().Get<List<RepositoryStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc")); } [Fact] @@ -519,8 +511,7 @@ public void RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions() client.GetAllForUserWithTimestamps("banana", starredRequest, options); - connection.Received().Get<List<RepositoryStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1"), - "application/vnd.github.v3.star+json"); + connection.Received().Get<List<RepositoryStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 4 && d["direction"] == "asc" && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs index 716c931b62..bca96dbc2b 100644 --- a/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs @@ -83,8 +83,7 @@ public void RequestsTheCorrectUrl() github.Connection.Received().Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "teams/1/members"), - Arg.Any<Dictionary<string, string>>(), - null); + Arg.Any<Dictionary<string, string>>()); } [Fact] @@ -97,8 +96,7 @@ public void RequestsTheCorrectUrlWithRequest() github.Connection.Received().Get<List<User>>( Arg.Is<Uri>(u => u.ToString() == "teams/1/members"), - Arg.Is<Dictionary<string, string>>(d => d["role"] == "maintainer"), - null); + Arg.Is<Dictionary<string, string>>(d => d["role"] == "maintainer")); } [Fact] @@ -164,8 +162,7 @@ public void RequestsTheCorrectUrl() gitHub.Connection.Received().Get<List<Team>>( Arg.Is<Uri>(u => u.ToString() == "teams/1/teams"), - Args.EmptyDictionary, - null); + Args.EmptyDictionary); } [Fact] @@ -183,8 +180,7 @@ public void RequestsTheCorrectUrlWithApiOptions() gitHub.Connection.Received().Get<List<Team>>( Arg.Is<Uri>(u => u.ToString() == "teams/1/teams"), - Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2), - null); + Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2)); } } @@ -208,8 +204,7 @@ public void RequestsTheCorrectUrl() gitHub.Connection.Received().GetAndFlattenAllPages<OrganizationMembershipInvitation>( Arg.Is<Uri>(u => u.ToString() == "teams/1/invitations"), - Args.EmptyDictionary, - "application/vnd.github.korra-preview+json"); + Args.EmptyDictionary); } [Fact] @@ -227,8 +222,7 @@ public void RequestsTheCorrectUrlWithApiOptions() gitHub.Connection.Received().GetAndFlattenAllPages<OrganizationMembershipInvitation>( Arg.Is<Uri>(u => u.ToString() == "teams/1/invitations"), - Arg.Is<Dictionary<string, string>>(d => d.Count == 2), - "application/vnd.github.korra-preview+json"); + Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } } } diff --git a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs index 5290511a11..9e807e25fe 100644 --- a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs @@ -144,7 +144,6 @@ public void RequestsTheCorrectUrl() gitHubClient.Connection.Received().Get<System.Collections.Generic.List<PublicKey>>( Arg.Is<Uri>(a => a.ToString() == expectedUri), - null, null); } } diff --git a/Octokit.Tests/Reactive/ObservableUserEmailsClientTests.cs b/Octokit.Tests/Reactive/ObservableUserEmailsClientTests.cs index ea7dc6886e..16a98e5965 100644 --- a/Octokit.Tests/Reactive/ObservableUserEmailsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserEmailsClientTests.cs @@ -29,7 +29,7 @@ public void GetsCorrectUrl() client.GetAll(); github.Connection.Received(1).Get<List<EmailAddress>>(_expectedUri, - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0)); } [Fact] @@ -41,7 +41,7 @@ public void GetsCorrectUrlWithApiOption() client.GetAll(ApiOptions.None); github.Connection.Received(1).Get<List<EmailAddress>>(_expectedUri, - Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null); + Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0)); } } diff --git a/Octokit.Tests/Reactive/ObservableWatchedClientTests.cs b/Octokit.Tests/Reactive/ObservableWatchedClientTests.cs index 9d9405cad9..2630974ac5 100644 --- a/Octokit.Tests/Reactive/ObservableWatchedClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableWatchedClientTests.cs @@ -28,7 +28,7 @@ public void RequestsCorrectUrl() var client = new ObservableWatchedClient(gitHubClient); client.GetAllForCurrent(); - connection.Received().Get<List<Repository>>(ApiUrls.Watched(), Args.EmptyDictionary, null); + connection.Received().Get<List<Repository>>(ApiUrls.Watched(), Args.EmptyDictionary); } [Fact] @@ -47,7 +47,7 @@ public void RequestsCorrectUrlWithApiOptions() }; client.GetAllForCurrent(options); - connection.Received().Get<List<Repository>>(ApiUrls.Watched(), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Repository>>(ApiUrls.Watched(), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -70,7 +70,7 @@ public void RequestsCorrectUrl() var client = new ObservableWatchedClient(gitHubClient); client.GetAllForUser("jugglingnutcase"); - connection.Received().Get<List<Repository>>(ApiUrls.WatchedByUser("jugglingnutcase"), Args.EmptyDictionary, null); + connection.Received().Get<List<Repository>>(ApiUrls.WatchedByUser("jugglingnutcase"), Args.EmptyDictionary); } [Fact] @@ -89,7 +89,7 @@ public void RequestsCorrectUrlWithApiOptions() }; client.GetAllForUser("jugglingnutcase", options); - connection.Received().Get<List<Repository>>(ApiUrls.WatchedByUser("jugglingnutcase"), Arg.Is<IDictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<Repository>>(ApiUrls.WatchedByUser("jugglingnutcase"), Arg.Is<IDictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -118,7 +118,7 @@ public void RequestsCorrectUrl() client.GetAllWatchers("jugglingnutcase", "katiejamie"); - connection.Received().Get<List<User>>(ApiUrls.Watchers("jugglingnutcase", "katiejamie"), Args.EmptyDictionary, null); + connection.Received().Get<List<User>>(ApiUrls.Watchers("jugglingnutcase", "katiejamie"), Args.EmptyDictionary); } [Fact] @@ -131,7 +131,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAllWatchers(1); - connection.Received().Get<List<User>>(ApiUrls.Watchers(1), Args.EmptyDictionary, null); + connection.Received().Get<List<User>>(ApiUrls.Watchers(1), Args.EmptyDictionary); } [Fact] @@ -151,7 +151,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAllWatchers("jugglingnutcase", "katiejamie", options); - connection.Received().Get<List<User>>(ApiUrls.Watchers("jugglingnutcase", "katiejamie"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<User>>(ApiUrls.Watchers("jugglingnutcase", "katiejamie"), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] @@ -171,7 +171,7 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() client.GetAllWatchers(1, options); - connection.Received().Get<List<User>>(ApiUrls.Watchers(1), Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null); + connection.Received().Get<List<User>>(ApiUrls.Watchers(1), Arg.Is<Dictionary<string, string>>(d => d.Count == 2)); } [Fact] diff --git a/Octokit/Clients/AssigneesClient.cs b/Octokit/Clients/AssigneesClient.cs index 4938d934c2..42a7f64e8c 100644 --- a/Octokit/Clients/AssigneesClient.cs +++ b/Octokit/Clients/AssigneesClient.cs @@ -58,7 +58,7 @@ public Task<IReadOnlyList<User>> GetAllForRepository(string owner, string name, var endpoint = ApiUrls.Assignees(owner, name); - return ApiConnection.GetAll<User>(endpoint, null, AcceptHeaders.StableVersion, options); + return ApiConnection.GetAll<User>(endpoint, null, options); } /// <summary> @@ -73,7 +73,7 @@ public Task<IReadOnlyList<User>> GetAllForRepository(long repositoryId, ApiOptio var endpoint = ApiUrls.Assignees(repositoryId); - return ApiConnection.GetAll<User>(endpoint, null, AcceptHeaders.StableVersion, options); + return ApiConnection.GetAll<User>(endpoint, null, options); } /// <summary> diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index d1be719133..03dedf3d1e 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -147,7 +147,7 @@ public Task<ApplicationAuthorization> Create( }; var endpoint = ApiUrls.Authorizations(); - return ApiConnection.Post<ApplicationAuthorization>(endpoint, requestData, null, null, twoFactorAuthenticationCode); + return ApiConnection.Post<ApplicationAuthorization>(endpoint, requestData, null, twoFactorAuthenticationCode); } /// <summary> @@ -357,7 +357,7 @@ public Task<ApplicationAuthorization> CheckApplicationAuthentication(string clie }; var endpoint = ApiUrls.ApplicationAuthorization(clientId); - return ApiConnection.Post<ApplicationAuthorization>(endpoint, requestData, AcceptHeaders.OAuthApplicationsPreview); + return ApiConnection.Post<ApplicationAuthorization>(endpoint, requestData); } /// <summary> @@ -382,7 +382,7 @@ public Task<ApplicationAuthorization> ResetApplicationAuthentication(string clie }; var endpoint = ApiUrls.ApplicationAuthorization(clientId); - return ApiConnection.Patch<ApplicationAuthorization>(endpoint, requestData, AcceptHeaders.OAuthApplicationsPreview); + return ApiConnection.Patch<ApplicationAuthorization>(endpoint, requestData); } /// <summary> @@ -407,7 +407,7 @@ public Task RevokeApplicationAuthentication(string clientId, string accessToken) }; var endpoint = ApiUrls.ApplicationAuthorization(clientId); - return ApiConnection.Delete(endpoint, requestData, AcceptHeaders.OAuthApplicationsPreview); + return ApiConnection.Delete(endpoint, requestData); } /// <summary> diff --git a/Octokit/Clients/CheckRunsClient.cs b/Octokit/Clients/CheckRunsClient.cs index dcefe018a9..6b8de0ed94 100644 --- a/Octokit/Clients/CheckRunsClient.cs +++ b/Octokit/Clients/CheckRunsClient.cs @@ -30,7 +30,6 @@ public CheckRunsClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="newCheckRun">Details of the Check Run to create</param> - [Preview("antiope")] [ManualRoute("POST", "/repos/{owner}/{repo}/check-runs")] public Task<CheckRun> Create(string owner, string name, NewCheckRun newCheckRun) { @@ -38,7 +37,7 @@ public Task<CheckRun> Create(string owner, string name, NewCheckRun newCheckRun) Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - return ApiConnection.Post<CheckRun>(ApiUrls.CheckRuns(owner, name), newCheckRun, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post<CheckRun>(ApiUrls.CheckRuns(owner, name), newCheckRun); } /// <summary> @@ -49,13 +48,12 @@ public Task<CheckRun> Create(string owner, string name, NewCheckRun newCheckRun) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="newCheckRun">Details of the Check Run to create</param> - [Preview("antiope")] [ManualRoute("POST", "/repositories/{id}/check-runs")] public Task<CheckRun> Create(long repositoryId, NewCheckRun newCheckRun) { Ensure.ArgumentNotNull(newCheckRun, nameof(newCheckRun)); - return ApiConnection.Post<CheckRun>(ApiUrls.CheckRuns(repositoryId), newCheckRun, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post<CheckRun>(ApiUrls.CheckRuns(repositoryId), newCheckRun); } /// <summary> @@ -68,7 +66,6 @@ public Task<CheckRun> Create(long repositoryId, NewCheckRun newCheckRun) /// <param name="name">The name of the repository</param> /// <param name="checkRunId">The Id of the check run</param> /// <param name="checkRunUpdate">The updates to the check run</param> - [Preview("antiope")] [ManualRoute("PATCH", "/repos/{owner}/{repo}/check-runs/{check_run_id}")] public Task<CheckRun> Update(string owner, string name, long checkRunId, CheckRunUpdate checkRunUpdate) { @@ -76,7 +73,7 @@ public Task<CheckRun> Update(string owner, string name, long checkRunId, CheckRu Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - return ApiConnection.Patch<CheckRun>(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Patch<CheckRun>(ApiUrls.CheckRun(owner, name, checkRunId), checkRunUpdate); } /// <summary> @@ -88,13 +85,12 @@ public Task<CheckRun> Update(string owner, string name, long checkRunId, CheckRu /// <param name="repositoryId">The Id of the repository</param> /// <param name="checkRunId">The Id of the check run</param> /// <param name="checkRunUpdate">The updates to the check run</param> - [Preview("antiope")] [ManualRoute("PATCH", "/repositories/{id}/check-runs/{check_run_id}")] public Task<CheckRun> Update(long repositoryId, long checkRunId, CheckRunUpdate checkRunUpdate) { Ensure.ArgumentNotNull(checkRunUpdate, nameof(checkRunUpdate)); - return ApiConnection.Patch<CheckRun>(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Patch<CheckRun>(ApiUrls.CheckRun(repositoryId, checkRunId), checkRunUpdate); } /// <summary> @@ -182,7 +178,6 @@ public Task<CheckRunsResponse> GetAllForReference(long repositoryId, string refe /// <param name="reference">The commit reference (can be a SHA, branch name, or a tag name)</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/check-runs")] public async Task<CheckRunsResponse> GetAllForReference(string owner, string name, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { @@ -192,7 +187,7 @@ public async Task<CheckRunsResponse> GetAllForReference(string owner, string nam Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForReference(owner, name, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForReference(owner, name, reference), checkRunRequest.ToParametersDictionary(), options).ConfigureAwait(false); return new CheckRunsResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -209,7 +204,6 @@ public async Task<CheckRunsResponse> GetAllForReference(string owner, string nam /// <param name="reference">The commit reference (can be a SHA, branch name, or a tag name)</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/check-runs")] public async Task<CheckRunsResponse> GetAllForReference(long repositoryId, string reference, CheckRunRequest checkRunRequest, ApiOptions options) { @@ -217,7 +211,7 @@ public async Task<CheckRunsResponse> GetAllForReference(long repositoryId, strin Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForReference(repositoryId, reference), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForReference(repositoryId, reference), checkRunRequest.ToParametersDictionary(), options).ConfigureAwait(false); return new CheckRunsResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -304,7 +298,6 @@ public Task<CheckRunsResponse> GetAllForCheckSuite(long repositoryId, long check /// <param name="checkSuiteId">The Id of the check suite</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repos/{owner}/{repo}/check-suite/{check_suite_id}/check-runs")] public async Task<CheckRunsResponse> GetAllForCheckSuite(string owner, string name, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { @@ -313,7 +306,7 @@ public async Task<CheckRunsResponse> GetAllForCheckSuite(string owner, string na Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(owner, name, checkSuiteId), checkRunRequest.ToParametersDictionary(), options).ConfigureAwait(false); return new CheckRunsResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -330,14 +323,13 @@ public async Task<CheckRunsResponse> GetAllForCheckSuite(string owner, string na /// <param name="checkSuiteId">The Id of the check suite</param> /// <param name="checkRunRequest">Details to filter the request, such as by check name</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/check-suites/{check_suite_id}/check-runs")] public async Task<CheckRunsResponse> GetAllForCheckSuite(long repositoryId, long checkSuiteId, CheckRunRequest checkRunRequest, ApiOptions options) { Ensure.ArgumentNotNull(checkRunRequest, nameof(checkRunRequest)); Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<CheckRunsResponse>(ApiUrls.CheckRunsForCheckSuite(repositoryId, checkSuiteId), checkRunRequest.ToParametersDictionary(), options).ConfigureAwait(false); return new CheckRunsResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -353,14 +345,13 @@ public async Task<CheckRunsResponse> GetAllForCheckSuite(long repositoryId, long /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="checkRunId">The Id of the check run</param> - [Preview("antiope")] [ManualRoute("GET", "/repos/{owner}/{repo}/check-runs/{check_run_id}")] public Task<CheckRun> Get(string owner, string name, long checkRunId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<CheckRun>(ApiUrls.CheckRun(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Get<CheckRun>(ApiUrls.CheckRun(owner, name, checkRunId), null); } /// <summary> @@ -371,11 +362,10 @@ public Task<CheckRun> Get(string owner, string name, long checkRunId) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="checkRunId">The Id of the check run</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/check-runs/{check_run_id}")] public Task<CheckRun> Get(long repositoryId, long checkRunId) { - return ApiConnection.Get<CheckRun>(ApiUrls.CheckRun(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Get<CheckRun>(ApiUrls.CheckRun(repositoryId, checkRunId), null); } /// <summary> @@ -421,7 +411,6 @@ public Task<IReadOnlyList<CheckRunAnnotation>> GetAllAnnotations(long repository /// <param name="name">The name of the repository</param> /// <param name="checkRunId">The Id of the check run</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repos/{owner}/{repo}/check-runs/{check_run_id}/annotations")] public Task<IReadOnlyList<CheckRunAnnotation>> GetAllAnnotations(string owner, string name, long checkRunId, ApiOptions options) { @@ -429,7 +418,7 @@ public Task<IReadOnlyList<CheckRunAnnotation>> GetAllAnnotations(string owner, s Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + return ApiConnection.GetAll<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(owner, name, checkRunId), null, options); } /// <summary> @@ -441,13 +430,12 @@ public Task<IReadOnlyList<CheckRunAnnotation>> GetAllAnnotations(string owner, s /// <param name="repositoryId">The Id of the repository</param> /// <param name="checkRunId">The Id of the check run</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/check-runs/{check_run_id}/annotations")] public Task<IReadOnlyList<CheckRunAnnotation>> GetAllAnnotations(long repositoryId, long checkRunId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, AcceptHeaders.ChecksApiPreview, options); + return ApiConnection.GetAll<CheckRunAnnotation>(ApiUrls.CheckRunAnnotations(repositoryId, checkRunId), null, options); } } } diff --git a/Octokit/Clients/CheckSuitesClient.cs b/Octokit/Clients/CheckSuitesClient.cs index 6102d0cb98..f3472b2e6f 100644 --- a/Octokit/Clients/CheckSuitesClient.cs +++ b/Octokit/Clients/CheckSuitesClient.cs @@ -30,14 +30,13 @@ public CheckSuitesClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> - [Preview("antiope")] [ManualRoute("GET", "/repos/{owner}/{repo}/check-suites/{id}")] public Task<CheckSuite> Get(string owner, string name, long checkSuiteId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<CheckSuite>(ApiUrls.CheckSuite(owner, name, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Get<CheckSuite>(ApiUrls.CheckSuite(owner, name, checkSuiteId), null); } /// <summary> @@ -48,11 +47,10 @@ public Task<CheckSuite> Get(string owner, string name, long checkSuiteId) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/check-suites/{check_suite_id}")] public Task<CheckSuite> Get(long repositoryId, long checkSuiteId) { - return ApiConnection.Get<CheckSuite>(ApiUrls.CheckSuite(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Get<CheckSuite>(ApiUrls.CheckSuite(repositoryId, checkSuiteId), null); } /// <summary> @@ -140,7 +138,6 @@ public Task<CheckSuitesResponse> GetAllForReference(long repositoryId, string re /// <param name="reference">The reference (SHA, branch name or tag name) to list check suites for</param> /// <param name="request">Details to filter the request, such as by App Id or Check Name</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{ref}/check-suites")] public async Task<CheckSuitesResponse> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request, ApiOptions options) { @@ -150,7 +147,7 @@ public async Task<CheckSuitesResponse> GetAllForReference(string owner, string n Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(owner, name, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(owner, name, reference), request.ToParametersDictionary(), options).ConfigureAwait(false); return new CheckSuitesResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -167,7 +164,6 @@ public async Task<CheckSuitesResponse> GetAllForReference(string owner, string n /// <param name="reference">The reference (SHA, branch name or tag name) to list check suites for</param> /// <param name="request">Details to filter the request, such as by App Id or Check Name</param> /// <param name="options">Options to change the API response</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/commits/{ref}/check-suites")] public async Task<CheckSuitesResponse> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options) { @@ -175,7 +171,7 @@ public async Task<CheckSuitesResponse> GetAllForReference(long repositoryId, str Ensure.ArgumentNotNull(options, nameof(options)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - var results = await ApiConnection.GetAll<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(repositoryId, reference), request.ToParametersDictionary(), options).ConfigureAwait(false); return new CheckSuitesResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -191,7 +187,6 @@ public async Task<CheckSuitesResponse> GetAllForReference(long repositoryId, str /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="preferences">The check suite preferences</param> - [Preview("antiope")] [ManualRoute("PATCH", "/repos/{owner}/{repo}/check-suites/preferences")] public Task<CheckSuitePreferencesResponse> UpdatePreferences(string owner, string name, CheckSuitePreferences preferences) { @@ -199,7 +194,7 @@ public Task<CheckSuitePreferencesResponse> UpdatePreferences(string owner, strin Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(preferences, nameof(preferences)); - return ApiConnection.Patch<CheckSuitePreferencesResponse>(ApiUrls.CheckSuitePreferences(owner, name), preferences, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Patch<CheckSuitePreferencesResponse>(ApiUrls.CheckSuitePreferences(owner, name), preferences); } /// <summary> @@ -210,13 +205,12 @@ public Task<CheckSuitePreferencesResponse> UpdatePreferences(string owner, strin /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="preferences">The check suite preferences</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/check-suites/preferences")] public Task<CheckSuitePreferencesResponse> UpdatePreferences(long repositoryId, CheckSuitePreferences preferences) { Ensure.ArgumentNotNull(preferences, nameof(preferences)); - return ApiConnection.Patch<CheckSuitePreferencesResponse>(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Patch<CheckSuitePreferencesResponse>(ApiUrls.CheckSuitePreferences(repositoryId), preferences); } /// <summary> @@ -228,7 +222,6 @@ public Task<CheckSuitePreferencesResponse> UpdatePreferences(long repositoryId, /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="newCheckSuite">Details of the Check Suite to create</param> - [Preview("antiope")] [ManualRoute("POST", "/repos/{owner}/{repo}/check-suites")] public Task<CheckSuite> Create(string owner, string name, NewCheckSuite newCheckSuite) { @@ -236,7 +229,7 @@ public Task<CheckSuite> Create(string owner, string name, NewCheckSuite newCheck Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - return ApiConnection.Post<CheckSuite>(ApiUrls.CheckSuites(owner, name), newCheckSuite, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post<CheckSuite>(ApiUrls.CheckSuites(owner, name), newCheckSuite); } /// <summary> @@ -247,13 +240,12 @@ public Task<CheckSuite> Create(string owner, string name, NewCheckSuite newCheck /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="newCheckSuite">Details of the Check Suite to create</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/check-suites")] public Task<CheckSuite> Create(long repositoryId, NewCheckSuite newCheckSuite) { Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite)); - return ApiConnection.Post<CheckSuite>(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview); + return ApiConnection.Post<CheckSuite>(ApiUrls.CheckSuites(repositoryId), newCheckSuite); } /// <summary> @@ -265,14 +257,13 @@ public Task<CheckSuite> Create(long repositoryId, NewCheckSuite newCheckSuite) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> - [Preview("antiope")] [ManualRoute("GET", "/repos/{owner}/{repo}/check-suites/{2}/rerequest")] public async Task<bool> Rerequest(string owner, string name, long checkSuiteId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRerequest(owner, name, checkSuiteId), null, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRerequest(owner, name, checkSuiteId)).ConfigureAwait(false); if (httpStatusCode != HttpStatusCode.Created) { @@ -290,11 +281,10 @@ public async Task<bool> Rerequest(string owner, string name, long checkSuiteId) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="checkSuiteId">The Id of the check suite</param> - [Preview("antiope")] [ManualRoute("GET", "/repositories/{id}/check-suites/{2}/rerequest")] public async Task<bool> Rerequest(long repositoryId, long checkSuiteId) { - var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRerequest(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Post(ApiUrls.CheckSuiteRerequest(repositoryId, checkSuiteId)).ConfigureAwait(false); if (httpStatusCode != HttpStatusCode.Created) { diff --git a/Octokit/Clients/CommitCommentReactionsClient.cs b/Octokit/Clients/CommitCommentReactionsClient.cs index 320c35cdb9..1c05c0f3ce 100644 --- a/Octokit/Clients/CommitCommentReactionsClient.cs +++ b/Octokit/Clients/CommitCommentReactionsClient.cs @@ -25,7 +25,6 @@ public CommitCommentReactionsClient(IApiConnection apiConnection) /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> /// <returns></returns> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repos/{owner}/{repo}/comments/{comment_id}/reactions")] public Task<Reaction> Create(string owner, string name, int number, NewReaction reaction) { @@ -33,7 +32,7 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.CommitCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.CommitCommentReactions(owner, name, number), reaction); } /// <summary> @@ -44,13 +43,12 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> /// <returns></returns> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repositories/{id}/comments/{comment_id}/reactions")] public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), reaction); } /// <summary> @@ -76,7 +74,6 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> /// <returns></returns> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/comments/{comment_id}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number, ApiOptions options) { @@ -84,7 +81,7 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.CommitCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.CommitCommentReactions(owner, name, number), null, options); } /// <summary> @@ -108,13 +105,12 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number) /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> /// <returns></returns> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/comments/{comment_id}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.CommitCommentReactions(repositoryId, number), null, options); } /// <summary> diff --git a/Octokit/Clients/DeploymentStatusClient.cs b/Octokit/Clients/DeploymentStatusClient.cs index 63eee18cc1..00d78514a2 100644 --- a/Octokit/Clients/DeploymentStatusClient.cs +++ b/Octokit/Clients/DeploymentStatusClient.cs @@ -62,8 +62,6 @@ public Task<IReadOnlyList<DeploymentStatus>> GetAll(long repositoryId, int deplo /// <param name="name">The name of the repository.</param> /// <param name="deploymentId">The id of the deployment.</param> /// <param name="options">Options for changing the API response</param> - [Preview("ant-man")] - [Preview("flash")] [ManualRoute("GET", "/repos/{owner}/{repo}/deployments/{deployment_id}/statuses")] public Task<IReadOnlyList<DeploymentStatus>> GetAll(string owner, string name, int deploymentId, ApiOptions options) { @@ -71,10 +69,7 @@ public Task<IReadOnlyList<DeploymentStatus>> GetAll(string owner, string name, i Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<DeploymentStatus>(ApiUrls.DeploymentStatuses(owner, name, deploymentId), - null, - AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview), - options); + return ApiConnection.GetAll<DeploymentStatus>(ApiUrls.DeploymentStatuses(owner, name, deploymentId), null, options); } /// <summary> @@ -87,17 +82,12 @@ public Task<IReadOnlyList<DeploymentStatus>> GetAll(string owner, string name, i /// <param name="repositoryId">The Id of the repository.</param> /// <param name="deploymentId">The id of the deployment.</param> /// <param name="options">Options for changing the API response</param> - [Preview("ant-man")] - [Preview("flash")] [ManualRoute("GET", "/repositories/{id}/deployments/{deployment_id}/statuses")] public Task<IReadOnlyList<DeploymentStatus>> GetAll(long repositoryId, int deploymentId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<DeploymentStatus>(ApiUrls.DeploymentStatuses(repositoryId, deploymentId), - null, - AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview), - options); + return ApiConnection.GetAll<DeploymentStatus>(ApiUrls.DeploymentStatuses(repositoryId, deploymentId), null, options); } /// <summary> @@ -111,8 +101,6 @@ public Task<IReadOnlyList<DeploymentStatus>> GetAll(long repositoryId, int deplo /// <param name="name">The name of the repository.</param> /// <param name="deploymentId">The id of the deployment.</param> /// <param name="newDeploymentStatus">The new deployment status to create.</param> - [Preview("ant-man")] - [Preview("flash")] [ManualRoute("POST", "/repos/{owner}/{repo}/deployments/{deployment_id}/statuses")] public Task<DeploymentStatus> Create(string owner, string name, int deploymentId, NewDeploymentStatus newDeploymentStatus) { @@ -120,9 +108,7 @@ public Task<DeploymentStatus> Create(string owner, string name, int deploymentId Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newDeploymentStatus, nameof(newDeploymentStatus)); - return ApiConnection.Post<DeploymentStatus>(ApiUrls.DeploymentStatuses(owner, name, deploymentId), - newDeploymentStatus, - AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview)); + return ApiConnection.Post<DeploymentStatus>(ApiUrls.DeploymentStatuses(owner, name, deploymentId), newDeploymentStatus); } /// <summary> @@ -135,16 +121,12 @@ public Task<DeploymentStatus> Create(string owner, string name, int deploymentId /// <param name="repositoryId">The Id of the repository.</param> /// <param name="deploymentId">The id of the deployment.</param> /// <param name="newDeploymentStatus">The new deployment status to create.</param> - [Preview("ant-man")] - [Preview("flash")] [ManualRoute("POST", "/repositories/{id}/deployments/{deployment_id}/statuses")] public Task<DeploymentStatus> Create(long repositoryId, int deploymentId, NewDeploymentStatus newDeploymentStatus) { Ensure.ArgumentNotNull(newDeploymentStatus, nameof(newDeploymentStatus)); - return ApiConnection.Post<DeploymentStatus>(ApiUrls.DeploymentStatuses(repositoryId, deploymentId), - newDeploymentStatus, - AcceptHeaders.Concat(AcceptHeaders.DeploymentApiPreview, AcceptHeaders.DeploymentStatusesPreview)); + return ApiConnection.Post<DeploymentStatus>(ApiUrls.DeploymentStatuses(repositoryId, deploymentId), newDeploymentStatus); } } } diff --git a/Octokit/Clients/DeploymentsClient.cs b/Octokit/Clients/DeploymentsClient.cs index b7eb95c177..3947911e13 100644 --- a/Octokit/Clients/DeploymentsClient.cs +++ b/Octokit/Clients/DeploymentsClient.cs @@ -64,7 +64,6 @@ public Task<IReadOnlyList<Deployment>> GetAll(long repositoryId) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="options">Options for changing the API response</param> - [Preview("ant-man")] [ManualRoute("GET", "/repos/{owner}/{repo}/deployments")] public Task<IReadOnlyList<Deployment>> GetAll(string owner, string name, ApiOptions options) { @@ -72,10 +71,7 @@ public Task<IReadOnlyList<Deployment>> GetAll(string owner, string name, ApiOpti Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Deployment>(ApiUrls.Deployments(owner, name), - null, - AcceptHeaders.DeploymentApiPreview, - options); + return ApiConnection.GetAll<Deployment>(ApiUrls.Deployments(owner, name), null, options); } /// <summary> @@ -105,7 +101,6 @@ public Task<IReadOnlyList<Deployment>> GetAll(long repositoryId, ApiOptions opti /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="newDeployment">A <see cref="NewDeployment"/> instance describing the new deployment to create</param> - [Preview("ant-man")] [ManualRoute("POST", "/repos/{owner}/{repo}/deployments")] public Task<Deployment> Create(string owner, string name, NewDeployment newDeployment) { @@ -113,9 +108,7 @@ public Task<Deployment> Create(string owner, string name, NewDeployment newDeplo Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newDeployment, nameof(newDeployment)); - return ApiConnection.Post<Deployment>(ApiUrls.Deployments(owner, name), - newDeployment, - AcceptHeaders.DeploymentApiPreview); + return ApiConnection.Post<Deployment>(ApiUrls.Deployments(owner, name), newDeployment); } /// <summary> diff --git a/Octokit/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClient.cs b/Octokit/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClient.cs index 013f2fe23f..35df6f4a63 100644 --- a/Octokit/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClient.cs +++ b/Octokit/Clients/Enterprise/EnterprisePreReceiveEnvironmentsClient.cs @@ -44,7 +44,7 @@ public Task<IReadOnlyList<PreReceiveEnvironment>> GetAll() public Task<IReadOnlyList<PreReceiveEnvironment>> GetAll(ApiOptions options) { var endpoint = ApiUrls.AdminPreReceiveEnvironments(); - return ApiConnection.GetAll<PreReceiveEnvironment>(endpoint, null, AcceptHeaders.PreReceiveEnvironmentsPreview, options); + return ApiConnection.GetAll<PreReceiveEnvironment>(endpoint, null, options); } /// <summary> @@ -60,7 +60,7 @@ public Task<IReadOnlyList<PreReceiveEnvironment>> GetAll(ApiOptions options) public Task<PreReceiveEnvironment> Get(long environmentId) { var endpoint = ApiUrls.AdminPreReceiveEnvironments(environmentId); - return ApiConnection.Get<PreReceiveEnvironment>(endpoint, null, AcceptHeaders.PreReceiveEnvironmentsPreview); + return ApiConnection.Get<PreReceiveEnvironment>(endpoint, null); } /// <summary> @@ -77,7 +77,7 @@ public Task<PreReceiveEnvironment> Create(NewPreReceiveEnvironment newPreReceive Ensure.ArgumentNotNull(newPreReceiveEnvironment, nameof(newPreReceiveEnvironment)); var endpoint = ApiUrls.AdminPreReceiveEnvironments(); - return ApiConnection.Post<PreReceiveEnvironment>(endpoint, newPreReceiveEnvironment, AcceptHeaders.PreReceiveEnvironmentsPreview); + return ApiConnection.Post<PreReceiveEnvironment>(endpoint, newPreReceiveEnvironment); } /// <summary> @@ -96,7 +96,7 @@ public Task<PreReceiveEnvironment> Edit(long environmentId, UpdatePreReceiveEnvi Ensure.ArgumentNotNull(updatePreReceiveEnvironment, nameof(updatePreReceiveEnvironment)); var endpoint = ApiUrls.AdminPreReceiveEnvironments(environmentId); - return ApiConnection.Patch<PreReceiveEnvironment>(endpoint, updatePreReceiveEnvironment, AcceptHeaders.PreReceiveEnvironmentsPreview); + return ApiConnection.Patch<PreReceiveEnvironment>(endpoint, updatePreReceiveEnvironment); } /// <summary> @@ -112,7 +112,7 @@ public Task<PreReceiveEnvironment> Edit(long environmentId, UpdatePreReceiveEnvi public Task Delete(long environmentId) { var endpoint = ApiUrls.AdminPreReceiveEnvironments(environmentId); - return ApiConnection.Delete(endpoint, new object(), AcceptHeaders.PreReceiveEnvironmentsPreview); + return ApiConnection.Delete(endpoint, new object()); } /// <summary> @@ -128,7 +128,7 @@ public Task Delete(long environmentId) public Task<PreReceiveEnvironmentDownload> DownloadStatus(long environmentId) { var endpoint = ApiUrls.AdminPreReceiveEnvironmentDownloadStatus(environmentId); - return ApiConnection.Get<PreReceiveEnvironmentDownload>(endpoint, null, AcceptHeaders.PreReceiveEnvironmentsPreview); + return ApiConnection.Get<PreReceiveEnvironmentDownload>(endpoint, null); } /// <summary> @@ -145,7 +145,7 @@ public Task<PreReceiveEnvironmentDownload> DownloadStatus(long environmentId) public Task<PreReceiveEnvironmentDownload> TriggerDownload(long environmentId) { var endpoint = ApiUrls.AdminPreReceiveEnvironmentDownload(environmentId); - return ApiConnection.Post<PreReceiveEnvironmentDownload>(endpoint, new object(), AcceptHeaders.PreReceiveEnvironmentsPreview); + return ApiConnection.Post<PreReceiveEnvironmentDownload>(endpoint, new object()); } } } diff --git a/Octokit/Clients/GitHubAppInstallationsClient.cs b/Octokit/Clients/GitHubAppInstallationsClient.cs index 7bba1e472a..4ef440f01b 100644 --- a/Octokit/Clients/GitHubAppInstallationsClient.cs +++ b/Octokit/Clients/GitHubAppInstallationsClient.cs @@ -30,13 +30,12 @@ public Task<RepositoriesResponse> GetAllRepositoriesForCurrent() /// </summary> /// <param name="options">Options for changing the API response</param> /// <remarks>https://developer.github.com/v3/apps/installations/#list-repositories</remarks> - [Preview("machine-man")] [ManualRoute("GET", "/installation/repositories")] public async Task<RepositoriesResponse> GetAllRepositoriesForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<RepositoriesResponse>(ApiUrls.InstallationRepositories(), null, AcceptHeaders.GitHubAppsPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<RepositoriesResponse>(ApiUrls.InstallationRepositories(), null, options).ConfigureAwait(false); return new RepositoriesResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -60,13 +59,12 @@ public Task<RepositoriesResponse> GetAllRepositoriesForCurrentUser(long installa /// <param name="installationId">The Id of the installation</param> /// <param name="options">Options for changing the API response</param> /// <remarks>https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation</remarks> - [Preview("machine-man")] [ManualRoute("GET", "/user/installation/{id}/repositories")] public async Task<RepositoriesResponse> GetAllRepositoriesForCurrentUser(long installationId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<RepositoriesResponse>(ApiUrls.UserInstallationRepositories(installationId), null, AcceptHeaders.GitHubAppsPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<RepositoriesResponse>(ApiUrls.UserInstallationRepositories(installationId), null, options).ConfigureAwait(false); return new RepositoriesResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, diff --git a/Octokit/Clients/GitHubAppsClient.cs b/Octokit/Clients/GitHubAppsClient.cs index 7a0f08c875..e9ee0ad2dd 100644 --- a/Octokit/Clients/GitHubAppsClient.cs +++ b/Octokit/Clients/GitHubAppsClient.cs @@ -33,24 +33,22 @@ public GitHubAppsClient(IApiConnection apiConnection) : base(apiConnection) /// </summary> /// <remarks>https://developer.github.com/v3/apps/#get-a-single-github-app</remarks> /// <param name="slug">The URL-friendly name of your GitHub App. You can find this on the settings page for your GitHub App.</param> - [Preview("machine-man")] [ManualRoute("GET", "/apps/{slug}")] public Task<GitHubApp> Get(string slug) { Ensure.ArgumentNotNullOrEmptyString(slug, nameof(slug)); - return ApiConnection.Get<GitHubApp>(ApiUrls.App(slug), null, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Get<GitHubApp>(ApiUrls.App(slug), null); } /// <summary> /// Returns the GitHub App associated with the authentication credentials used (requires GitHubApp auth). /// </summary> /// <remarks>https://developer.github.com/v3/apps/#get-the-authenticated-github-app</remarks> - [Preview("machine-man")] [ManualRoute("GET", "/app")] public Task<GitHubApp> GetCurrent() { - return ApiConnection.Get<GitHubApp>(ApiUrls.App(), null, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Get<GitHubApp>(ApiUrls.App(), null); } /// <summary> @@ -68,13 +66,12 @@ public Task<IReadOnlyList<Installation>> GetAllInstallationsForCurrent() /// </summary> /// <param name="options">Options for changing the API response</param> /// <remarks>https://developer.github.com/v3/apps/#find-installations</remarks> - [Preview("machine-man")] [ManualRoute("GET", "/app/installations")] public Task<IReadOnlyList<Installation>> GetAllInstallationsForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Installation>(ApiUrls.Installations(), null, AcceptHeaders.GitHubAppsPreview, options); + return ApiConnection.GetAll<Installation>(ApiUrls.Installations(), null, options); } /// <summary> @@ -93,22 +90,20 @@ public Task<Installation> GetInstallation(long installationId) /// </summary> /// <remarks>https://developer.github.com/v3/apps/#get-a-single-installation</remarks> /// <param name="installationId">The Id of the GitHub App Installation</param> - [Preview("machine-man")] [ManualRoute("GET", "/app/installations/{installation_id}")] public Task<Installation> GetInstallationForCurrent(long installationId) { - return ApiConnection.Get<Installation>(ApiUrls.Installation(installationId), null, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Get<Installation>(ApiUrls.Installation(installationId), null); } /// <summary> /// List installations for the currently authenticated user (requires GitHubApp User-To-Server Auth). /// </summary> /// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks> - [Preview("machine-man")] [ManualRoute("GET", "/user/installations")] public async Task<InstallationsResponse> GetAllInstallationsForCurrentUser() { - var results = await ApiConnection.GetAll<InstallationsResponse>(ApiUrls.UserInstallations(), null, AcceptHeaders.GitHubAppsPreview).ConfigureAwait(false); + var results = await ApiConnection.GetAll<InstallationsResponse>(ApiUrls.UserInstallations()).ConfigureAwait(false); return new InstallationsResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -119,13 +114,12 @@ public async Task<InstallationsResponse> GetAllInstallationsForCurrentUser() /// List installations for the currently authenticated user (requires GitHubApp User-To-Server Auth). /// </summary> /// <remarks>https://developer.github.com/v3/apps/#list-installations-for-user</remarks> - [Preview("machine-man")] [ManualRoute("GET", "/user/installations")] public async Task<InstallationsResponse> GetAllInstallationsForCurrentUser(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - var results = await ApiConnection.GetAll<InstallationsResponse>(ApiUrls.UserInstallations(), null, AcceptHeaders.GitHubAppsPreview, options).ConfigureAwait(false); + var results = await ApiConnection.GetAll<InstallationsResponse>(ApiUrls.UserInstallations(), null, options).ConfigureAwait(false); return new InstallationsResponse( results.Count > 0 ? results.Max(x => x.TotalCount) : 0, @@ -141,11 +135,10 @@ public async Task<InstallationsResponse> GetAllInstallationsForCurrentUser(ApiOp /// https://developer.github.com/v3/apps/available-endpoints/ /// </remarks> /// <param name="installationId">The Id of the GitHub App Installation</param> - [Preview("machine-man")] [ManualRoute("GET", "/app/installations/{installation_id}/access_tokens")] public Task<AccessToken> CreateInstallationToken(long installationId) { - return ApiConnection.Post<AccessToken>(ApiUrls.AccessTokens(installationId), string.Empty, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Post<AccessToken>(ApiUrls.AccessTokens(installationId), string.Empty); } /// <summary> @@ -153,13 +146,12 @@ public Task<AccessToken> CreateInstallationToken(long installationId) /// </summary> /// <remarks>https://developer.github.com/v3/apps/#find-organization-installation</remarks> /// <param name="organization">The name of the organization</param> - [Preview("machine-man")] [ManualRoute("GET", "/orgs/{org}/installation")] public Task<Installation> GetOrganizationInstallationForCurrent(string organization) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); - return ApiConnection.Get<Installation>(ApiUrls.OrganizationInstallation(organization), null, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Get<Installation>(ApiUrls.OrganizationInstallation(organization), null); } /// <summary> @@ -168,14 +160,13 @@ public Task<Installation> GetOrganizationInstallationForCurrent(string organizat /// <remarks>https://developer.github.com/v3/apps/#find-repository-installation</remarks> /// <param name="owner">The owner of the repo</param> /// <param name="repo">The name of the repo</param> - [Preview("machine-man")] [ManualRoute("GET", "/repos/{owner}/{repo}/installation")] public Task<Installation> GetRepositoryInstallationForCurrent(string owner, string repo) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); - return ApiConnection.Get<Installation>(ApiUrls.RepoInstallation(owner, repo), null, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Get<Installation>(ApiUrls.RepoInstallation(owner, repo), null); } /// <summary> @@ -183,11 +174,10 @@ public Task<Installation> GetRepositoryInstallationForCurrent(string owner, stri /// </summary> /// <remarks>https://developer.github.com/v3/apps/#find-repository-installation</remarks> /// <param name="repositoryId">The Id of the repository</param> - [Preview("machine-man")] [ManualRoute("GET", "/repositories/{id}/installation")] public Task<Installation> GetRepositoryInstallationForCurrent(long repositoryId) { - return ApiConnection.Get<Installation>(ApiUrls.RepoInstallation(repositoryId), null, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Get<Installation>(ApiUrls.RepoInstallation(repositoryId), null); } /// <summary> @@ -195,13 +185,12 @@ public Task<Installation> GetRepositoryInstallationForCurrent(long repositoryId) /// </summary> /// <remarks>https://developer.github.com/v3/apps/#find-user-installation</remarks> /// <param name="user">The name of the user</param> - [Preview("machine-man")] [ManualRoute("GET", "/users/{username}/installation")] public Task<Installation> GetUserInstallationForCurrent(string user) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); - return ApiConnection.Get<Installation>(ApiUrls.UserInstallation(user), null, AcceptHeaders.GitHubAppsPreview); + return ApiConnection.Get<Installation>(ApiUrls.UserInstallation(user), null); } } } diff --git a/Octokit/Clients/IssueCommentReactionsClient.cs b/Octokit/Clients/IssueCommentReactionsClient.cs index da889c8fdf..707272bf3f 100644 --- a/Octokit/Clients/IssueCommentReactionsClient.cs +++ b/Octokit/Clients/IssueCommentReactionsClient.cs @@ -24,7 +24,6 @@ public IssueCommentReactionsClient(IApiConnection apiConnection) /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repos/{owner}/{repo}/issues/comments/{number}/reactions")] public Task<Reaction> Create(string owner, string name, int number, NewReaction reaction) { @@ -32,7 +31,7 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.IssueCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.IssueCommentReactions(owner, name, number), reaction); } /// <summary> @@ -42,13 +41,12 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repositories/{0}/issues/comments/{number}/reactions")] public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), reaction); } /// <summary> @@ -72,7 +70,6 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repos/{owner}/{repo}/issues/comments/{number}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number, ApiOptions options) { @@ -80,7 +77,7 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.IssueCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.IssueCommentReactions(owner, name, number), null, options); } /// <summary> @@ -102,13 +99,12 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number) /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{0}/issues/comments/{number}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), null, options); } /// <summary> diff --git a/Octokit/Clients/IssueCommentsClient.cs b/Octokit/Clients/IssueCommentsClient.cs index a91648c53e..39bfa0d963 100644 --- a/Octokit/Clients/IssueCommentsClient.cs +++ b/Octokit/Clients/IssueCommentsClient.cs @@ -26,14 +26,13 @@ public IssueCommentsClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="id">The issue comment id</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/comments/{comment_id}")] public Task<IssueComment> Get(string owner, string name, int id) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<IssueComment>(ApiUrls.IssueComment(owner, name, id), null, AcceptHeaders.ReactionsPreview); + return ApiConnection.Get<IssueComment>(ApiUrls.IssueComment(owner, name, id), null); } /// <summary> @@ -42,11 +41,10 @@ public Task<IssueComment> Get(string owner, string name, int id) /// <remarks>http://developer.github.com/v3/issues/comments/#get-a-single-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="id">The issue comment id</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/issues/comments/{comment_id}")] public Task<IssueComment> Get(long repositoryId, int id) { - return ApiConnection.Get<IssueComment>(ApiUrls.IssueComment(repositoryId, id), null, AcceptHeaders.ReactionsPreview); + return ApiConnection.Get<IssueComment>(ApiUrls.IssueComment(repositoryId, id), null); } /// <summary> @@ -145,7 +143,6 @@ public Task<IReadOnlyList<IssueComment>> GetAllForRepository(long repositoryId, /// <param name="name">The name of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/comments")] public Task<IReadOnlyList<IssueComment>> GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options) { @@ -154,7 +151,7 @@ public Task<IReadOnlyList<IssueComment>> GetAllForRepository(string owner, strin Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), options); } /// <summary> @@ -164,14 +161,13 @@ public Task<IReadOnlyList<IssueComment>> GetAllForRepository(string owner, strin /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/issues/comments")] public Task<IReadOnlyList<IssueComment>> GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), options); } /// <summary> @@ -277,7 +273,6 @@ public Task<IReadOnlyList<IssueComment>> GetAllForIssue(long repositoryId, int n /// <param name="number">The issue number</param> /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{number]/comments")] public Task<IReadOnlyList<IssueComment>> GetAllForIssue(string owner, string name, int number, IssueCommentRequest request, ApiOptions options) { @@ -286,7 +281,7 @@ public Task<IReadOnlyList<IssueComment>> GetAllForIssue(string owner, string nam Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(owner, name, number), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(owner, name, number), request.ToParametersDictionary(), options); } /// <summary> @@ -298,13 +293,12 @@ public Task<IReadOnlyList<IssueComment>> GetAllForIssue(string owner, string nam /// <param name="request">The sorting <see cref="IssueCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> [ManualRoute("GET", "/repositories/{id}/issues/{number}/comments")] - [Preview("squirrel-girl")] public Task<IReadOnlyList<IssueComment>> GetAllForIssue(long repositoryId, int number, IssueCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId, number), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<IssueComment>(ApiUrls.IssueComments(repositoryId, number), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index c8d2a2adc6..65f812965d 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -37,7 +37,6 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe /// <param name="name">The name of the repository</param> /// <param name="number">The issue id</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{issue_number}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number, ApiOptions options) { @@ -45,7 +44,7 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(owner, name, number), null, options); } /// <summary> @@ -67,13 +66,12 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number) /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue id</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/issues/{number}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.IssueReactions(repositoryId, number), null, options); } /// <summary> @@ -84,7 +82,6 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOp /// <param name="name">The name of the repository</param> /// <param name="number">The issue id</param> /// <param name="reaction">The reaction to create</param> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repos/{owner}/{repo}/issues/{issue_number}/reactions")] public Task<Reaction> Create(string owner, string name, int number, NewReaction reaction) { @@ -92,7 +89,7 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(owner, name, number), reaction); } /// <summary> @@ -102,13 +99,12 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue id</param> /// <param name="reaction">The reaction to create</param> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repositories/{id}/issues/{number}/reactions")] public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(repositoryId, number), reaction); } /// <summary> diff --git a/Octokit/Clients/IssueTimelineClient.cs b/Octokit/Clients/IssueTimelineClient.cs index 00bbb3766c..bc367aa177 100644 --- a/Octokit/Clients/IssueTimelineClient.cs +++ b/Octokit/Clients/IssueTimelineClient.cs @@ -43,8 +43,6 @@ public Task<IReadOnlyList<TimelineEventInfo>> GetAllForIssue(string owner, strin /// <param name="repo">The name of the repository</param> /// <param name="number">The issue number</param> /// <param name="options">Options for changing the API repsonse</param> - [Preview("mockingbird")] - [Preview("starfox")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{issue_number}/timeline")] public Task<IReadOnlyList<TimelineEventInfo>> GetAllForIssue(string owner, string repo, int number, ApiOptions options) { @@ -52,10 +50,7 @@ public Task<IReadOnlyList<TimelineEventInfo>> GetAllForIssue(string owner, strin Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<TimelineEventInfo>(ApiUrls.IssueTimeline(owner, repo, number), - null, - AcceptHeaders.Concat(AcceptHeaders.IssueTimelineApiPreview, AcceptHeaders.IssueEventsApiPreview), - options); + return ApiConnection.GetAll<TimelineEventInfo>(ApiUrls.IssueTimeline(owner, repo, number), null, options); } /// <summary> @@ -81,17 +76,12 @@ public Task<IReadOnlyList<TimelineEventInfo>> GetAllForIssue(long repositoryId, /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> /// <param name="options">Options for changing the API response</param> - [Preview("mockingbird")] - [Preview("starfox")] [ManualRoute("GET", "/repositories/{id}/issues/{number}/timeline")] public Task<IReadOnlyList<TimelineEventInfo>> GetAllForIssue(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<TimelineEventInfo>(ApiUrls.IssueTimeline(repositoryId, number), - null, - AcceptHeaders.Concat(AcceptHeaders.IssueTimelineApiPreview, AcceptHeaders.IssueEventsApiPreview), - options); + return ApiConnection.GetAll<TimelineEventInfo>(ApiUrls.IssueTimeline(repositoryId, number), null, options); } } } diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index e5b1279329..06a0fbf30b 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -66,14 +66,13 @@ public IssuesClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{issue_number}")] public Task<Issue> Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<Issue>(ApiUrls.Issue(owner, name, number), null, AcceptHeaders.ReactionsPreview); + return ApiConnection.Get<Issue>(ApiUrls.Issue(owner, name, number), null); } /// <summary> @@ -84,11 +83,10 @@ public Task<Issue> Get(string owner, string name, int number) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/issues/{number}")] public Task<Issue> Get(long repositoryId, int number) { - return ApiConnection.Get<Issue>(ApiUrls.Issue(repositoryId, number), null, AcceptHeaders.ReactionsPreview); + return ApiConnection.Get<Issue>(ApiUrls.Issue(repositoryId, number), null); } /// <summary> @@ -147,14 +145,13 @@ public Task<IReadOnlyList<Issue>> GetAllForCurrent(IssueRequest request) /// </remarks> /// <param name="request">Used to filter and sort the list of issues returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/issues")] public Task<IReadOnlyList<Issue>> GetAllForCurrent(IssueRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Issue>(ApiUrls.Issues(), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Issue>(ApiUrls.Issues(), request.ToParametersDictionary(), options); } /// <summary> @@ -211,14 +208,13 @@ public Task<IReadOnlyList<Issue>> GetAllForOwnedAndMemberRepositories(IssueReque /// </remarks> /// <param name="request">Used to filter and sort the list of issues returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/user/issues")] public Task<IReadOnlyList<Issue>> GetAllForOwnedAndMemberRepositories(IssueRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Issue>(ApiUrls.IssuesForOwnedAndMember(), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Issue>(ApiUrls.IssuesForOwnedAndMember(), request.ToParametersDictionary(), options); } /// <summary> @@ -279,7 +275,6 @@ public Task<IReadOnlyList<Issue>> GetAllForOrganization(string organization, Iss /// <param name="organization">The name of the organization</param> /// <param name="request">Used to filter and sort the list of issues returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/orgs/{org}/issues")] public Task<IReadOnlyList<Issue>> GetAllForOrganization(string organization, IssueRequest request, ApiOptions options) { @@ -287,7 +282,7 @@ public Task<IReadOnlyList<Issue>> GetAllForOrganization(string organization, Iss Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Issue>(ApiUrls.Issues(organization), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Issue>(ApiUrls.Issues(organization), request.ToParametersDictionary(), options); } /// <summary> @@ -400,7 +395,6 @@ public Task<IReadOnlyList<Issue>> GetAllForRepository(long repositoryId, Reposit /// <param name="name">The name of the repository</param> /// <param name="request">Used to filter and sort the list of issues returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues")] public Task<IReadOnlyList<Issue>> GetAllForRepository(string owner, string name, RepositoryIssueRequest request, ApiOptions options) { @@ -409,7 +403,7 @@ public Task<IReadOnlyList<Issue>> GetAllForRepository(string owner, string name, Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Issue>(ApiUrls.Issues(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Issue>(ApiUrls.Issues(owner, name), request.ToParametersDictionary(), options); } /// <summary> @@ -421,14 +415,13 @@ public Task<IReadOnlyList<Issue>> GetAllForRepository(string owner, string name, /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">Used to filter and sort the list of issues returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/issues")] public Task<IReadOnlyList<Issue>> GetAllForRepository(long repositoryId, RepositoryIssueRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Issue>(ApiUrls.Issues(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Issue>(ApiUrls.Issues(repositoryId), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit/Clients/IssuesEventsClient.cs b/Octokit/Clients/IssuesEventsClient.cs index eb782471a2..57f8f1c88d 100644 --- a/Octokit/Clients/IssuesEventsClient.cs +++ b/Octokit/Clients/IssuesEventsClient.cs @@ -57,7 +57,6 @@ public Task<IReadOnlyList<IssueEvent>> GetAllForIssue(long repositoryId, int num /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> /// <param name="options">Options for changing the API response</param> - [Preview("starfox")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/{issue_number}/events")] public Task<IReadOnlyList<IssueEvent>> GetAllForIssue(string owner, string name, int number, ApiOptions options) { @@ -65,10 +64,7 @@ public Task<IReadOnlyList<IssueEvent>> GetAllForIssue(string owner, string name, Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(owner, name, number), - null, - AcceptHeaders.IssueEventsApiPreview, - options); + return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(owner, name, number), null, options); } /// <summary> @@ -80,16 +76,12 @@ public Task<IReadOnlyList<IssueEvent>> GetAllForIssue(string owner, string name, /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> /// <param name="options">Options for changing the API response</param> - [Preview("starfox")] [ManualRoute("GET", "/repositories/{id}/issues/{number}/events")] public Task<IReadOnlyList<IssueEvent>> GetAllForIssue(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(repositoryId, number), - null, - AcceptHeaders.IssueEventsApiPreview, - options); + return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(repositoryId, number), null, options); } /// <summary> @@ -131,7 +123,6 @@ public Task<IReadOnlyList<IssueEvent>> GetAllForRepository(long repositoryId) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="options">Options for changing the API response</param> - [Preview("starfox")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/events")] public Task<IReadOnlyList<IssueEvent>> GetAllForRepository(string owner, string name, ApiOptions options) { @@ -139,10 +130,7 @@ public Task<IReadOnlyList<IssueEvent>> GetAllForRepository(string owner, string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(owner, name), - null, - AcceptHeaders.IssueEventsApiPreview, - options); + return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(owner, name), null, options); } /// <summary> @@ -153,16 +141,12 @@ public Task<IReadOnlyList<IssueEvent>> GetAllForRepository(string owner, string /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="options">Options for changing the API response</param> - [Preview("starfox")] [ManualRoute("GET", "/repositories/{id}/issues/events")] public Task<IReadOnlyList<IssueEvent>> GetAllForRepository(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(repositoryId), - null, - AcceptHeaders.IssueEventsApiPreview, - options); + return ApiConnection.GetAll<IssueEvent>(ApiUrls.IssuesEvents(repositoryId), null, options); } /// <summary> @@ -174,16 +158,13 @@ public Task<IReadOnlyList<IssueEvent>> GetAllForRepository(long repositoryId, Ap /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="eventId">The event id</param> - [Preview("starfox")] [ManualRoute("GET", "/repos/{owner}/{repo}/issues/events/{event_id}")] public Task<IssueEvent> Get(string owner, string name, long eventId) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<IssueEvent>(ApiUrls.IssuesEvent(owner, name, eventId), - null, - AcceptHeaders.IssueEventsApiPreview); + return ApiConnection.Get<IssueEvent>(ApiUrls.IssuesEvent(owner, name, eventId), null); } /// <summary> @@ -194,13 +175,10 @@ public Task<IssueEvent> Get(string owner, string name, long eventId) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="eventId">The event id</param> - [Preview("starfox")] [ManualRoute("GET", "/repositories/{id}/issues/events/{event_id}")] public Task<IssueEvent> Get(long repositoryId, long eventId) { - return ApiConnection.Get<IssueEvent>(ApiUrls.IssuesEvent(repositoryId, eventId), - null, - AcceptHeaders.IssueEventsApiPreview); + return ApiConnection.Get<IssueEvent>(ApiUrls.IssuesEvent(repositoryId, eventId), null); } } } diff --git a/Octokit/Clients/MigrationsClient.cs b/Octokit/Clients/MigrationsClient.cs index 4f5a0e2d07..a7feeae4c8 100644 --- a/Octokit/Clients/MigrationsClient.cs +++ b/Octokit/Clients/MigrationsClient.cs @@ -30,7 +30,6 @@ public MigrationsClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="migration">Specifies parameters for the migration in a /// <see cref="StartMigrationRequest"/> object.</param> /// <returns>The started migration.</returns> - [Preview("wyandotte")] [ManualRoute("POST", "/orgs/{org}/migrations")] public async Task<Migration> Start(string org, StartMigrationRequest migration) { @@ -39,7 +38,7 @@ public async Task<Migration> Start(string org, StartMigrationRequest migration) var endpoint = ApiUrls.EnterpriseMigrations(org); - return await ApiConnection.Post<Migration>(endpoint, migration, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false); + return await ApiConnection.Post<Migration>(endpoint, migration).ConfigureAwait(false); } /// <summary> @@ -66,7 +65,6 @@ public async Task<IReadOnlyList<Migration>> GetAll(string org) /// <param name="options">Options for changing the API response</param> /// <returns>List of most recent <see cref="Migration"/>s.</returns> [ManualRoute("GET", "/orgs/{org}/migrations")] - [Preview("wyandotte")] public async Task<IReadOnlyList<Migration>> GetAll(string org, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); @@ -74,7 +72,7 @@ public async Task<IReadOnlyList<Migration>> GetAll(string org, ApiOptions option var endpoint = ApiUrls.EnterpriseMigrations(org); - return await ApiConnection.GetAll<Migration>(endpoint, null, AcceptHeaders.MigrationsApiPreview, options).ConfigureAwait(false); + return await ApiConnection.GetAll<Migration>(endpoint, null, options).ConfigureAwait(false); } /// <summary> @@ -86,7 +84,6 @@ public async Task<IReadOnlyList<Migration>> GetAll(string org, ApiOptions option /// <param name="org">The organization which is migrating.</param> /// <param name="id">Migration Id of the organization.</param> /// <returns>A <see cref="Migration"/> object representing the state of migration.</returns> - [Preview("wyandotte")] [ManualRoute("GET", "/orgs/{org}/migrations/{id}")] public async Task<Migration> Get(string org, int id) { @@ -94,7 +91,7 @@ public async Task<Migration> Get(string org, int id) var endpoint = ApiUrls.EnterpriseMigrationById(org, id); - return await ApiConnection.Get<Migration>(endpoint, null, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false); + return await ApiConnection.Get<Migration>(endpoint, null).ConfigureAwait(false); } /// <summary> @@ -106,14 +103,13 @@ public async Task<Migration> Get(string org, int id) /// <param name="org">The organization of which the migration was.</param> /// <param name="id">The Id of the migration.</param> /// <returns>The binary contents of the archive as a byte array.</returns> - [Preview("wyandotte")] [ManualRoute("GET", "/orgs/{org}/migrations/{id}/archive")] public async Task<byte[]> GetArchive(string org, int id) { Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); var endpoint = ApiUrls.EnterpriseMigrationArchive(org, id); - var response = await Connection.Get<byte[]>(endpoint, null, AcceptHeaders.MigrationsApiPreview).ConfigureAwait(false); + var response = await Connection.GetRaw(endpoint, null).ConfigureAwait(false); return response.Body; } @@ -127,7 +123,6 @@ public async Task<byte[]> GetArchive(string org, int id) /// <param name="org">The organization of which the migration was.</param> /// <param name="id">The Id of the migration.</param> /// <returns></returns> - [Preview("wyandotte")] [ManualRoute("DELETE", "/orgs/{org}/migrations/{id}/archive")] public Task DeleteArchive(string org, int id) { @@ -135,7 +130,7 @@ public Task DeleteArchive(string org, int id) var endpoint = ApiUrls.EnterpriseMigrationArchive(org, id); - return ApiConnection.Delete(endpoint, new object(), AcceptHeaders.MigrationsApiPreview); + return ApiConnection.Delete(endpoint, new object()); } /// <summary> @@ -148,7 +143,6 @@ public Task DeleteArchive(string org, int id) /// <param name="id">The Id of the migration.</param> /// <param name="repo">The repo to unlock.</param> /// <returns></returns> - [Preview("wyandotte")] [ManualRoute("GET", "/orgs/{org}/migrations/{id}/repos/{name}/lock")] public Task UnlockRepository(string org, int id, string repo) { @@ -157,7 +151,7 @@ public Task UnlockRepository(string org, int id, string repo) var endpoint = ApiUrls.EnterpriseMigrationUnlockRepository(org, id, repo); - return ApiConnection.Delete(endpoint, new object(), AcceptHeaders.MigrationsApiPreview); + return ApiConnection.Delete(endpoint, new object()); } } } diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index 53714bddca..ca2931ed37 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -565,7 +565,7 @@ public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvita Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, AcceptHeaders.OrganizationMembershipPreview, options); + return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, options); } } } diff --git a/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs b/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs index 6194da1b66..244981920f 100644 --- a/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs +++ b/Octokit/Clients/OrganizationOutsideCollaboratorsClient.cs @@ -57,7 +57,7 @@ public Task<IReadOnlyList<User>> GetAll(string org, ApiOptions options) Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<User>(ApiUrls.OutsideCollaborators(org), null, AcceptHeaders.OrganizationMembershipPreview, options); + return ApiConnection.GetAll<User>(ApiUrls.OutsideCollaborators(org), null, options); } /// <summary> @@ -97,7 +97,7 @@ public Task<IReadOnlyList<User>> GetAll(string org, OrganizationMembersFilter fi Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<User>(ApiUrls.OutsideCollaborators(org, filter), null, AcceptHeaders.OrganizationMembershipPreview, options); + return ApiConnection.GetAll<User>(ApiUrls.OutsideCollaborators(org, filter), null, options); } /// <summary> @@ -119,7 +119,7 @@ public async Task<bool> Delete(string org, string user) try { - var statusCode = await Connection.Delete(ApiUrls.OutsideCollaborator(org, user), null, AcceptHeaders.OrganizationMembershipPreview).ConfigureAwait(false); + var statusCode = await Connection.Delete(ApiUrls.OutsideCollaborator(org, user)).ConfigureAwait(false); if (statusCode != HttpStatusCode.NoContent && statusCode != (HttpStatusCode)422) @@ -160,7 +160,7 @@ public async Task<bool> ConvertFromMember(string org, string user) try { - var statusCode = await Connection.Put(ApiUrls.OutsideCollaborator(org, user), AcceptHeaders.OrganizationMembershipPreview); + var statusCode = await Connection.Put(ApiUrls.OutsideCollaborator(org, user)); if (statusCode != HttpStatusCode.NoContent && statusCode != HttpStatusCode.Forbidden) diff --git a/Octokit/Clients/ProjectCardsClient.cs b/Octokit/Clients/ProjectCardsClient.cs index 93556e26ca..0b3cb81f37 100644 --- a/Octokit/Clients/ProjectCardsClient.cs +++ b/Octokit/Clients/ProjectCardsClient.cs @@ -71,14 +71,13 @@ public Task<IReadOnlyList<ProjectCard>> GetAll(int columnId, ProjectCardRequest /// <param name="columnId">The id of the column</param> /// <param name="request">Used to filter the list of project cards returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/projects/columns/{column_id}/cards")] public Task<IReadOnlyList<ProjectCard>> GetAll(int columnId, ProjectCardRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<ProjectCard>(ApiUrls.ProjectCards(columnId), request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<ProjectCard>(ApiUrls.ProjectCards(columnId), request.ToParametersDictionary(), options); } /// <summary> @@ -88,11 +87,10 @@ public Task<IReadOnlyList<ProjectCard>> GetAll(int columnId, ProjectCardRequest /// See the <a href="https://developer.github.com/v3/repos/projects/#get-a-project-card">API documentation</a> for more information. /// </remarks> /// <param name="id">The id of the card</param> - [Preview("inertia")] [ManualRoute("GET", "/projects/columns/cards/{card_id}")] public Task<ProjectCard> Get(int id) { - return ApiConnection.Get<ProjectCard>(ApiUrls.ProjectCard(id), null, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Get<ProjectCard>(ApiUrls.ProjectCard(id), null); } /// <summary> @@ -103,13 +101,12 @@ public Task<ProjectCard> Get(int id) /// </remarks> /// <param name="columnId">The id of the column</param> /// <param name="newProjectCard">The card to create</param> - [Preview("inertia")] [ManualRoute("POST", "/projects/columns/{column_id}/cards")] public Task<ProjectCard> Create(int columnId, NewProjectCard newProjectCard) { Ensure.ArgumentNotNull(newProjectCard, nameof(newProjectCard)); - return ApiConnection.Post<ProjectCard>(ApiUrls.ProjectCards(columnId), newProjectCard, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Post<ProjectCard>(ApiUrls.ProjectCards(columnId), newProjectCard); } /// <summary> @@ -120,13 +117,12 @@ public Task<ProjectCard> Create(int columnId, NewProjectCard newProjectCard) /// </remarks> /// <param name="id">The id of the card</param> /// <param name="projectCardUpdate">New values to update the card with</param> - [Preview("inertia")] [ManualRoute("GET", "/projects/columns/cards/{card_id}")] public Task<ProjectCard> Update(int id, ProjectCardUpdate projectCardUpdate) { Ensure.ArgumentNotNull(projectCardUpdate, nameof(projectCardUpdate)); - return ApiConnection.Patch<ProjectCard>(ApiUrls.ProjectCard(id), projectCardUpdate, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Patch<ProjectCard>(ApiUrls.ProjectCard(id), projectCardUpdate); } /// <summary> @@ -136,7 +132,6 @@ public Task<ProjectCard> Update(int id, ProjectCardUpdate projectCardUpdate) /// See the <a href="https://developer.github.com/v3/repos/projects/#delete-a-project-card">API documentation</a> for more information. /// </remarks> /// <param name="id">The id of the card</param> - [Preview("inertia")] [ManualRoute("DELETE", "/projects/columns/cards/{card_id}")] public async Task<bool> Delete(int id) { @@ -144,7 +139,7 @@ public async Task<bool> Delete(int id) try { - var httpStatusCode = await Connection.Delete(endpoint, new object(), AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, new object()).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -161,7 +156,6 @@ public async Task<bool> Delete(int id) /// </remarks> /// <param name="id">The id of the card</param> /// <param name="position">The position to move the card</param> - [Preview("inertia")] [ManualRoute("POST", "/projects/columns/cards/{card_id}/moves")] public async Task<bool> Move(int id, ProjectCardMove position) { @@ -170,7 +164,7 @@ public async Task<bool> Move(int id, ProjectCardMove position) var endpoint = ApiUrls.ProjectCardMove(id); try { - var httpStatusCode = await Connection.Post(endpoint, position, AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Post(endpoint, position, null).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.Created; } catch (NotFoundException) diff --git a/Octokit/Clients/ProjectColumnsClient.cs b/Octokit/Clients/ProjectColumnsClient.cs index 4c9fc2b7f0..5dce16f23f 100644 --- a/Octokit/Clients/ProjectColumnsClient.cs +++ b/Octokit/Clients/ProjectColumnsClient.cs @@ -38,13 +38,12 @@ public Task<IReadOnlyList<ProjectColumn>> GetAll(int projectId) /// </remarks> /// <param name="projectId">The Id of the project</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/projects/{project_id}/columns")] public Task<IReadOnlyList<ProjectColumn>> GetAll(int projectId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<ProjectColumn>(ApiUrls.ProjectColumns(projectId), new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<ProjectColumn>(ApiUrls.ProjectColumns(projectId), new Dictionary<string, string>(), options); } /// <summary> @@ -54,11 +53,10 @@ public Task<IReadOnlyList<ProjectColumn>> GetAll(int projectId, ApiOptions optio /// See the <a href="https://developer.github.com/v3/projects/columns/#get-a-project-column">API documentation</a> for more information. /// </remarks> /// <param name="id">The id of the column</param> - [Preview("inertia")] [ManualRoute("GET", "/projects/columns/{column_id}")] public Task<ProjectColumn> Get(int id) { - return ApiConnection.Get<ProjectColumn>(ApiUrls.ProjectColumn(id), null, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Get<ProjectColumn>(ApiUrls.ProjectColumn(id), null); } /// <summary> @@ -69,13 +67,12 @@ public Task<ProjectColumn> Get(int id) /// </remarks> /// <param name="projectId">The Id of the project</param> /// <param name="newProjectColumn">The column to create</param> - [Preview("inertia")] [ManualRoute("POST", "/projects/{project_id}/columns")] public Task<ProjectColumn> Create(int projectId, NewProjectColumn newProjectColumn) { Ensure.ArgumentNotNull(newProjectColumn, nameof(newProjectColumn)); - return ApiConnection.Post<ProjectColumn>(ApiUrls.ProjectColumns(projectId), newProjectColumn, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Post<ProjectColumn>(ApiUrls.ProjectColumns(projectId), newProjectColumn); } /// <summary> @@ -86,13 +83,12 @@ public Task<ProjectColumn> Create(int projectId, NewProjectColumn newProjectColu /// </remarks> /// <param name="id">The id of the column</param> /// <param name="projectColumnUpdate">New values to update the column with</param> - [Preview("inertia")] [ManualRoute("PATCH", "/projects/columns/{column_id}")] public Task<ProjectColumn> Update(int id, ProjectColumnUpdate projectColumnUpdate) { Ensure.ArgumentNotNull(projectColumnUpdate, nameof(projectColumnUpdate)); - return ApiConnection.Patch<ProjectColumn>(ApiUrls.ProjectColumn(id), projectColumnUpdate, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Patch<ProjectColumn>(ApiUrls.ProjectColumn(id), projectColumnUpdate); } /// <summary> @@ -102,14 +98,13 @@ public Task<ProjectColumn> Update(int id, ProjectColumnUpdate projectColumnUpdat /// See the <a href="https://developer.github.com/v3/projects/columns/#delete-a-project-column">API documentation</a> for more information. /// </remarks> /// <param name="id">The id of the column</param> - [Preview("inertia")] [ManualRoute("DELETE", "/projects/columns/{column_id}")] public async Task<bool> Delete(int id) { var endpoint = ApiUrls.ProjectColumn(id); try { - var httpStatusCode = await Connection.Delete(endpoint, new object(), AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, new object()).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -126,7 +121,6 @@ public async Task<bool> Delete(int id) /// </remarks> /// <param name="id">The id of the column</param> /// <param name="position">The position to move the column</param> - [Preview("inertia")] [ManualRoute("POST", "/projects/columns/{column_id}/moves")] public async Task<bool> Move(int id, ProjectColumnMove position) { @@ -135,7 +129,7 @@ public async Task<bool> Move(int id, ProjectColumnMove position) var endpoint = ApiUrls.ProjectColumnMove(id); try { - var httpStatusCode = await Connection.Post(endpoint, position, AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Post(endpoint, position, null).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.Created; } catch (NotFoundException) diff --git a/Octokit/Clients/ProjectsClient.cs b/Octokit/Clients/ProjectsClient.cs index 97e3d108b2..c7b30ec3ca 100644 --- a/Octokit/Clients/ProjectsClient.cs +++ b/Octokit/Clients/ProjectsClient.cs @@ -43,7 +43,6 @@ public Task<IReadOnlyList<Project>> GetAllForRepository(string owner, string nam /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/repos/{owner}/{repo}/projects")] public Task<IReadOnlyList<Project>> GetAllForRepository(string owner, string name, ApiOptions options) { @@ -51,7 +50,7 @@ public Task<IReadOnlyList<Project>> GetAllForRepository(string owner, string nam Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(owner, name), new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(owner, name), new Dictionary<string, string>(), options); } /// <summary> @@ -79,7 +78,6 @@ public Task<IReadOnlyList<Project>> GetAllForRepository(string owner, string nam /// <param name="name">The name of the repository</param> /// <param name="request">Used to filter the list of projects returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/repos/{owner}/{repo}/projects")] public Task<IReadOnlyList<Project>> GetAllForRepository(string owner, string name, ProjectRequest request, ApiOptions options) { @@ -88,7 +86,7 @@ public Task<IReadOnlyList<Project>> GetAllForRepository(string owner, string nam Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(owner, name), request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(owner, name), request.ToParametersDictionary(), options); } /// <summary> @@ -112,13 +110,12 @@ public Task<IReadOnlyList<Project>> GetAllForRepository(long repositoryId) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/repositories/{id}/projects")] public Task<IReadOnlyList<Project>> GetAllForRepository(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(repositoryId), new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(repositoryId), new Dictionary<string, string>(), options); } /// <summary> @@ -144,14 +141,13 @@ public Task<IReadOnlyList<Project>> GetAllForRepository(long repositoryId, Proje /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">Used to filter the list of projects returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/repositories/{id}/projects")] public Task<IReadOnlyList<Project>> GetAllForRepository(long repositoryId, ProjectRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<Project>(ApiUrls.RepositoryProjects(repositoryId), request.ToParametersDictionary(), options); } /// <summary> @@ -175,7 +171,6 @@ public Task<IReadOnlyList<Project>> GetAllForOrganization(string organization) /// </remarks> /// <param name="organization">The name of the organization</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/orgs/{org}/projects")] public Task<IReadOnlyList<Project>> GetAllForOrganization(string organization, ApiOptions options) { @@ -183,7 +178,7 @@ public Task<IReadOnlyList<Project>> GetAllForOrganization(string organization, A Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Project>(ApiUrls.OrganizationProjects(organization), new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<Project>(ApiUrls.OrganizationProjects(organization), new Dictionary<string, string>(), options); } /// <summary> @@ -212,7 +207,6 @@ public Task<IReadOnlyList<Project>> GetAllForOrganization(string organization, P /// <param name="organization">The name of the organization</param> /// <param name="request">Used to filter the list of projects returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("inertia")] [ManualRoute("GET", "/orgs/{org}/projects")] public Task<IReadOnlyList<Project>> GetAllForOrganization(string organization, ProjectRequest request, ApiOptions options) { @@ -220,7 +214,7 @@ public Task<IReadOnlyList<Project>> GetAllForOrganization(string organization, P Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Project>(ApiUrls.OrganizationProjects(organization), request.ToParametersDictionary(), AcceptHeaders.ProjectsApiPreview, options); + return ApiConnection.GetAll<Project>(ApiUrls.OrganizationProjects(organization), request.ToParametersDictionary(), options); } /// <summary> @@ -230,11 +224,10 @@ public Task<IReadOnlyList<Project>> GetAllForOrganization(string organization, P /// See the <a href="https://developer.github.com/v3/repos/projects/#get-a-project">API documentation</a> for more information. /// </remarks> /// <param name="id">The Id of the project</param> - [Preview("inertia")] [ManualRoute("GET", "/projects/{project_id}")] public Task<Project> Get(int id) { - return ApiConnection.Get<Project>(ApiUrls.Project(id), null, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Get<Project>(ApiUrls.Project(id), null); } // NOTE: I think we're missing a Task<Project> CreateForRepository(owner, name, newProject) @@ -248,13 +241,12 @@ public Task<Project> Get(int id) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="newProject">The new project to create for this repository</param> - [Preview("inertia")] [ManualRoute("POST", "/repositories/{id}/projects")] public Task<Project> CreateForRepository(long repositoryId, NewProject newProject) { Ensure.ArgumentNotNull(newProject, nameof(newProject)); - return ApiConnection.Post<Project>(ApiUrls.RepositoryProjects(repositoryId), newProject, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Post<Project>(ApiUrls.RepositoryProjects(repositoryId), newProject); } /// <summary> @@ -265,14 +257,13 @@ public Task<Project> CreateForRepository(long repositoryId, NewProject newProjec /// </remarks> /// <param name="organization">The name of the organization</param> /// <param name="newProject">The new project to create for this repository</param> - [Preview("inertia")] [ManualRoute("POST", "/orgs/{org}/projects")] public Task<Project> CreateForOrganization(string organization, NewProject newProject) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); Ensure.ArgumentNotNull(newProject, nameof(newProject)); - return ApiConnection.Post<Project>(ApiUrls.OrganizationProjects(organization), newProject, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Post<Project>(ApiUrls.OrganizationProjects(organization), newProject); } /// <summary> @@ -283,13 +274,12 @@ public Task<Project> CreateForOrganization(string organization, NewProject newPr /// </remarks> /// <param name="id">The Id of the project</param> /// <param name="projectUpdate">The modified project</param> - [Preview("inertia")] [ManualRoute("PATCH", "/project/{project_id}")] public Task<Project> Update(int id, ProjectUpdate projectUpdate) { Ensure.ArgumentNotNull(projectUpdate, nameof(projectUpdate)); - return ApiConnection.Patch<Project>(ApiUrls.Project(id), projectUpdate, AcceptHeaders.ProjectsApiPreview); + return ApiConnection.Patch<Project>(ApiUrls.Project(id), projectUpdate); } /// <summary> @@ -299,7 +289,6 @@ public Task<Project> Update(int id, ProjectUpdate projectUpdate) /// See the <a href="https://developer.github.com/v3/repos/projects/#delete-a-project">API documentation</a> for more information. /// </remarks> /// <param name="id">The Id of the project</param> - [Preview("inertia")] [ManualRoute("DELETE", "/project/{project_id}")] public async Task<bool> Delete(int id) { @@ -307,7 +296,7 @@ public async Task<bool> Delete(int id) try { - var httpStatusCode = await Connection.Delete(endpoint, new object(), AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, new object()).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) diff --git a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs index a76ef8c549..09876a507d 100644 --- a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs +++ b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs @@ -37,7 +37,6 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number, ApiOptions options) { @@ -45,7 +44,7 @@ public Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int numbe Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), null, options); } /// <summary> @@ -67,13 +66,12 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number) /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/pulls/comments/{comment_id}/reactions")] public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), null, options); } /// <summary> @@ -84,7 +82,6 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOp /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions")] public Task<Reaction> Create(string owner, string name, int number, NewReaction reaction) { @@ -92,7 +89,7 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReactions(owner, name, number), reaction); } /// <summary> @@ -102,13 +99,12 @@ public Task<Reaction> Create(string owner, string name, int number, NewReaction /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> - [Preview("squirrel-girl")] [ManualRoute("POST", "/repositories/{id}/pulls/comments/{comment_id}/reactions")] public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, nameof(reaction)); - return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReactions(repositoryId, number), reaction); } /// <summary> diff --git a/Octokit/Clients/PullRequestReviewCommentsClient.cs b/Octokit/Clients/PullRequestReviewCommentsClient.cs index d0682d2e84..658146d025 100644 --- a/Octokit/Clients/PullRequestReviewCommentsClient.cs +++ b/Octokit/Clients/PullRequestReviewCommentsClient.cs @@ -54,14 +54,13 @@ public Task<IReadOnlyList<PullRequestReviewComment>> GetAll(long repositoryId, i /// <param name="number">The pull request number</param> /// <param name="options">Options for changing the API response</param> [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/{pull_number}/comments")] - [Preview("squirrel-girl")] public Task<IReadOnlyList<PullRequestReviewComment>> GetAll(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), null, options); } /// <summary> @@ -175,7 +174,6 @@ public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(long re /// <param name="name">The name of the repository</param> /// <param name="request">The sorting <see cref="PullRequestReviewCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/comments")] public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(string owner, string name, PullRequestReviewCommentRequest request, ApiOptions options) { @@ -184,7 +182,7 @@ public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(string Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(owner, name), request.ToParametersDictionary(), options); } /// <summary> @@ -194,14 +192,13 @@ public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(string /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">The sorting <see cref="PullRequestReviewCommentRequest">parameters</see></param> /// <param name="options">Options for changing the API response</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/pulls/comments")] public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(long repositoryId, PullRequestReviewCommentRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<PullRequestReviewComment>(ApiUrls.PullRequestReviewCommentsRepository(repositoryId), request.ToParametersDictionary(), options); } /// <summary> @@ -211,14 +208,13 @@ public Task<IReadOnlyList<PullRequestReviewComment>> GetAllForRepository(long re /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The pull request review comment number</param> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/comments/{comment_id}")] public Task<PullRequestReviewComment> GetComment(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<PullRequestReviewComment>(ApiUrls.PullRequestReviewComment(owner, name, number), new Dictionary<string, string>(), AcceptHeaders.ReactionsPreview); + return ApiConnection.Get<PullRequestReviewComment>(ApiUrls.PullRequestReviewComment(owner, name, number), new Dictionary<string, string>()); } /// <summary> diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 0a60cb862c..07c63b9748 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -41,14 +41,13 @@ public PullRequestsClient(IApiConnection apiConnection) : base(apiConnection) /// <remarks> /// http://developer.github.com/v3/pulls/#get-a-single-pull-request /// </remarks> - [Preview("shadow-cat")] [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/{pull_number}")] public Task<PullRequest> Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(owner, name, number), null, AcceptHeaders.DraftPullRequestApiPreview); + return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(owner, name, number), null); } /// <summary> @@ -57,11 +56,10 @@ public Task<PullRequest> Get(string owner, string name, int number) /// <remarks> /// http://developer.github.com/v3/pulls/#get-a-single-pull-request /// </remarks> - [Preview("shadow-cat")] [ManualRoute("GET", "/repositories/{id}/pulls/{number}")] public Task<PullRequest> Get(long repositoryId, int number) { - return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(repositoryId, number), null, AcceptHeaders.DraftPullRequestApiPreview); + return ApiConnection.Get<PullRequest>(ApiUrls.PullRequest(repositoryId, number), null); } /// <summary> @@ -174,7 +172,6 @@ public Task<IReadOnlyList<PullRequest>> GetAllForRepository(long repositoryId, P /// <param name="name">The name of the repository</param> /// <param name="request">Used to filter and sort the list of pull requests returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("shadow-cat")] [ManualRoute("GET", "/repos/{owner}/{repo}/pulls")] public Task<IReadOnlyList<PullRequest>> GetAllForRepository(string owner, string name, PullRequestRequest request, ApiOptions options) { @@ -183,8 +180,7 @@ public Task<IReadOnlyList<PullRequest>> GetAllForRepository(string owner, string Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<PullRequest>(ApiUrls.PullRequests(owner, name), - request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options); + return ApiConnection.GetAll<PullRequest>(ApiUrls.PullRequests(owner, name), request.ToParametersDictionary(), options); } /// <summary> @@ -196,15 +192,13 @@ public Task<IReadOnlyList<PullRequest>> GetAllForRepository(string owner, string /// <param name="repositoryId">The Id of the repository</param> /// <param name="request">Used to filter and sort the list of pull requests returned</param> /// <param name="options">Options for changing the API response</param> - [Preview("shadow-cat")] [ManualRoute("GET", "/repositories/{id}/pulls")] public Task<IReadOnlyList<PullRequest>> GetAllForRepository(long repositoryId, PullRequestRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<PullRequest>(ApiUrls.PullRequests(repositoryId), - request.ToParametersDictionary(), AcceptHeaders.DraftPullRequestApiPreview, options); + return ApiConnection.GetAll<PullRequest>(ApiUrls.PullRequests(repositoryId), request.ToParametersDictionary(), options); } /// <summary> @@ -214,7 +208,6 @@ public Task<IReadOnlyList<PullRequest>> GetAllForRepository(long repositoryId, P /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="newPullRequest">A <see cref="NewPullRequest"/> instance describing the new PullRequest to create</param> - [Preview("shadow-cat")] [ManualRoute("POST", "/repos/{owner}/{repo}/pulls")] public Task<PullRequest> Create(string owner, string name, NewPullRequest newPullRequest) { @@ -222,7 +215,7 @@ public Task<PullRequest> Create(string owner, string name, NewPullRequest newPul Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(newPullRequest, nameof(newPullRequest)); - return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(owner, name), newPullRequest, AcceptHeaders.DraftPullRequestApiPreview); + return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(owner, name), newPullRequest); } /// <summary> @@ -231,13 +224,12 @@ public Task<PullRequest> Create(string owner, string name, NewPullRequest newPul /// <remarks>http://developer.github.com/v3/pulls/#create-a-pull-request</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="newPullRequest">A <see cref="NewPullRequest"/> instance describing the new PullRequest to create</param> - [Preview("shadow-cat")] [ManualRoute("POST", "/repositories/{id}/pulls")] public Task<PullRequest> Create(long repositoryId, NewPullRequest newPullRequest) { Ensure.ArgumentNotNull(newPullRequest, nameof(newPullRequest)); - return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(repositoryId), newPullRequest, AcceptHeaders.DraftPullRequestApiPreview); + return ApiConnection.Post<PullRequest>(ApiUrls.PullRequests(repositoryId), newPullRequest); } /// <summary> @@ -249,7 +241,6 @@ public Task<PullRequest> Create(long repositoryId, NewPullRequest newPullRequest /// <param name="number">The PullRequest number</param> /// <param name="pullRequestUpdate">An <see cref="PullRequestUpdate"/> instance describing the changes to make to the PullRequest /// </param> - [Preview("shadow-cat")] [ManualRoute("PATCH", "/repos/{owner}/{repo}/pulls/{pull_number}")] public Task<PullRequest> Update(string owner, string name, int number, PullRequestUpdate pullRequestUpdate) { @@ -257,7 +248,7 @@ public Task<PullRequest> Update(string owner, string name, int number, PullReque Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(pullRequestUpdate, nameof(pullRequestUpdate)); - return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(owner, name, number), pullRequestUpdate, AcceptHeaders.DraftPullRequestApiPreview); + return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(owner, name, number), pullRequestUpdate); } /// <summary> @@ -268,13 +259,12 @@ public Task<PullRequest> Update(string owner, string name, int number, PullReque /// <param name="number">The PullRequest number</param> /// <param name="pullRequestUpdate">An <see cref="PullRequestUpdate"/> instance describing the changes to make to the PullRequest /// </param> - [Preview("shadow-cat")] [ManualRoute("PATCH", "/repositories/{id}/pulls/{number}")] public Task<PullRequest> Update(long repositoryId, int number, PullRequestUpdate pullRequestUpdate) { Ensure.ArgumentNotNull(pullRequestUpdate, nameof(pullRequestUpdate)); - return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(repositoryId, number), pullRequestUpdate, AcceptHeaders.DraftPullRequestApiPreview); + return ApiConnection.Patch<PullRequest>(ApiUrls.PullRequest(repositoryId, number), pullRequestUpdate); } /// <summary> diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index eabca26b22..4d1f3947a6 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -56,12 +56,11 @@ public ReactionsClient(IApiConnection apiConnection) /// <remarks>https://developer.github.com/v3/reactions/#delete-a-reaction</remarks> /// <param name="number">The reaction id</param> /// <returns></returns> - [Preview("squirrel-girl")] [ManualRoute("DELETE", "/reactions/{reaction_id}")] [Obsolete("This route no longer works and is replaced with individual routes in each client")] public Task Delete(int number) { - return ApiConnection.Delete(ApiUrls.Reactions(number), new object(), AcceptHeaders.ReactionsPreview); + return ApiConnection.Delete(ApiUrls.Reactions(number), new object()); } } } diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index 656e282e36..c91639d535 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -239,7 +239,7 @@ public Task<CollaboratorPermission> ReviewPermission(string owner, string name, Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); return ApiConnection - .Get<CollaboratorPermission>(ApiUrls.RepoCollaboratorPermission(owner, name, user), null, AcceptHeaders.OrganizationMembershipPreview); + .Get<CollaboratorPermission>(ApiUrls.RepoCollaboratorPermission(owner, name, user), null); } /// <summary> @@ -257,7 +257,7 @@ public Task<CollaboratorPermission> ReviewPermission(long repositoryId, string u Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); return ApiConnection - .Get<CollaboratorPermission>(ApiUrls.RepoCollaboratorPermission(repositoryId, user), null, AcceptHeaders.OrganizationMembershipPreview); + .Get<CollaboratorPermission>(ApiUrls.RepoCollaboratorPermission(repositoryId, user), null); } /// <summary> diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 46b1051923..bd1f5d6ee8 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -50,7 +50,6 @@ public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/> instance for the created repository.</returns> - [Preview("nebula")] [ManualRoute("POST", "/user/repos")] public Task<Repository> Create(NewRepository newRepository) { @@ -69,8 +68,6 @@ public Task<Repository> Create(NewRepository newRepository) /// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/> instance for the created repository</returns> - [Preview("nebula")] - [Preview("baptiste")] [ManualRoute("POST", "/orgs/{org}/repos")] public Task<Repository> Create(string organizationLogin, NewRepository newRepository) { @@ -89,7 +86,6 @@ public Task<Repository> Create(string organizationLogin, NewRepository newReposi /// <param name="templateRepo">The name of template repository to work from</param> /// <param name="newRepository"></param> /// <returns></returns> - [Preview("baptiste")] [ManualRoute("POST", "/repos/{owner}/{repo}/generate")] public Task<Repository> Generate(string templateOwner, string templateRepo, NewRepositoryFromTemplate newRepository) { @@ -99,14 +95,14 @@ public Task<Repository> Generate(string templateOwner, string templateRepo, NewR if (string.IsNullOrEmpty(newRepository.Name)) throw new ArgumentException("The new repository's name must not be null."); - return ApiConnection.Post<Repository>(ApiUrls.Repositories(templateOwner, templateRepo), newRepository, AcceptHeaders.TemplatePreview); + return ApiConnection.Post<Repository>(ApiUrls.Repositories(templateOwner, templateRepo), newRepository); } async Task<Repository> Create(Uri url, string organizationLogin, NewRepository newRepository) { try { - return await ApiConnection.Post<Repository>(url, newRepository, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview)).ConfigureAwait(false); + return await ApiConnection.Post<Repository>(url, newRepository).ConfigureAwait(false); } catch (ApiValidationException e) { @@ -184,7 +180,6 @@ public Task Delete(long repositoryId) /// <param name="name">The name of the repository</param> /// <param name="repositoryTransfer">Repository transfer information</param> /// <returns>A <see cref="Repository"/></returns> - [Preview("mercy")] [ManualRoute("POST", "/repos/{owner}/{repo}/transfer")] public Task<Repository> Transfer(string owner, string name, RepositoryTransfer repositoryTransfer) { @@ -204,7 +199,6 @@ public Task<Repository> Transfer(string owner, string name, RepositoryTransfer r /// <param name="repositoryId">The id of the repository</param> /// <param name="repositoryTransfer">Repository transfer information</param> /// <returns>A <see cref="Repository"/></returns> - [Preview("mercy")] [ManualRoute("POST", "/repositories/{id}/transfer")] public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositoryTransfer) { @@ -246,8 +240,6 @@ public async Task<bool> AreVulnerabilityAlertsEnabled(string owner, string name) /// <param name="name">The name of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> - [Preview("nebula")] - [Preview("baptiste")] [ManualRoute("PATCH", "/repos/{owner}/{repo}")] public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) { @@ -255,7 +247,7 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview)); + return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update); } /// <summary> @@ -264,7 +256,6 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update) /// <param name="repositoryId">The Id of the repository</param> /// <param name="update">New values to update the repository with</param> /// <returns>The updated <see cref="T:Octokit.Repository"/></returns> - [Preview("mercy")] [ManualRoute("PATCH", "/repositories/{id}")] public Task<Repository> Edit(long repositoryId, RepositoryUpdate update) { @@ -283,14 +274,13 @@ public Task<Repository> Edit(long repositoryId, RepositoryUpdate update) /// <param name="name">The name of the repository</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/></returns> - [Preview("nebula")] [ManualRoute("GET", "/repos/{owner}/{repo}")] public Task<Repository> Get(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<Repository>(ApiUrls.Repository(owner, name), null, AcceptHeaders.VisibilityPreview); + return ApiConnection.Get<Repository>(ApiUrls.Repository(owner, name), null); } /// <summary> @@ -302,7 +292,6 @@ public Task<Repository> Get(string owner, string name) /// <param name="repositoryId">The Id of the repository</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="Repository"/></returns> - [Preview("mercy")] [ManualRoute("GET", "/repositories/{id}")] public Task<Repository> Get(long repositoryId) { @@ -356,8 +345,6 @@ public Task<IReadOnlyList<Repository>> GetAllPublic(PublicRepositoryRequest requ /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> - [Preview("nebula")] - [Preview("baptiste")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent() { @@ -374,14 +361,12 @@ public Task<IReadOnlyList<Repository>> GetAllForCurrent() /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> - [Preview("nebula")] - [Preview("baptiste")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent(ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), null, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview), options); + return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), null, options); } /// <summary> @@ -395,7 +380,6 @@ public Task<IReadOnlyList<Repository>> GetAllForCurrent(ApiOptions options) /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> - [Preview("nebula")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent(RepositoryRequest request) { @@ -416,14 +400,13 @@ public Task<IReadOnlyList<Repository>> GetAllForCurrent(RepositoryRequest reques /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> - [Preview("nebula")] [ManualRoute("GET", "/user/repos")] public Task<IReadOnlyList<Repository>> GetAllForCurrent(RepositoryRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), request.ToParametersDictionary(), AcceptHeaders.VisibilityPreview, options); + return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(), request.ToParametersDictionary(), options); } /// <summary> @@ -472,8 +455,6 @@ public Task<IReadOnlyList<Repository>> GetAllForUser(string login, ApiOptions op /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> - [Preview("nebula")] - [Preview("baptiste")] [ManualRoute("GET", "/orgs/{org}/repos")] public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization) { @@ -492,15 +473,13 @@ public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization) /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> - [Preview("nebula")] - [Preview("baptiste")] [ManualRoute("GET", "/orgs/{org}/repos")] public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization), null, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview), options); + return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization), null, options); } /// <summary> @@ -780,7 +759,7 @@ public async Task<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions o { Ensure.ArgumentNotNull(options, nameof(options)); var endpoint = ApiUrls.RepositoryTopics(repositoryId); - var data = await ApiConnection.Get<RepositoryTopics>(endpoint, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + var data = await ApiConnection.Get<RepositoryTopics>(endpoint, null).ConfigureAwait(false); return data ?? new RepositoryTopics(); } @@ -818,7 +797,7 @@ public async Task<RepositoryTopics> GetAllTopics(string owner, string name, ApiO Ensure.ArgumentNotNull(options, nameof(options)); var endpoint = ApiUrls.RepositoryTopics(owner, name); - var data = await ApiConnection.Get<RepositoryTopics>(endpoint, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + var data = await ApiConnection.Get<RepositoryTopics>(endpoint, null).ConfigureAwait(false); return data ?? new RepositoryTopics(); } @@ -859,7 +838,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(string owner, string name, Ensure.ArgumentNotNull(topics, nameof(topics)); var endpoint = ApiUrls.RepositoryTopics(owner, name); - var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null).ConfigureAwait(false); return data ?? new RepositoryTopics(); } @@ -881,7 +860,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(long repositoryId, Reposito Ensure.ArgumentNotNull(topics, nameof(topics)); var endpoint = ApiUrls.RepositoryTopics(repositoryId); - var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false); + var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null).ConfigureAwait(false); return data ?? new RepositoryTopics(); } diff --git a/Octokit/Clients/RepositoryBranchesClient.cs b/Octokit/Clients/RepositoryBranchesClient.cs index 87944a2822..852bc5bb34 100644 --- a/Octokit/Clients/RepositoryBranchesClient.cs +++ b/Octokit/Clients/RepositoryBranchesClient.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Net; using System.Threading.Tasks; @@ -62,7 +61,6 @@ public Task<IReadOnlyList<Branch>> GetAll(long repositoryId) /// <param name="name">The name of the repository</param> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches")] public Task<IReadOnlyList<Branch>> GetAll(string owner, string name, ApiOptions options) { @@ -70,7 +68,7 @@ public Task<IReadOnlyList<Branch>> GetAll(string owner, string name, ApiOptions Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(owner, name), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview, options); + return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(owner, name), null, options); } /// <summary> @@ -81,13 +79,12 @@ public Task<IReadOnlyList<Branch>> GetAll(string owner, string name, ApiOptions /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="options">Options for changing the API response</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches")] public Task<IReadOnlyList<Branch>> GetAll(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(repositoryId), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview, options); + return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(repositoryId), null, options); } /// <summary> @@ -99,7 +96,6 @@ public Task<IReadOnlyList<Branch>> GetAll(long repositoryId, ApiOptions options) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}")] public Task<Branch> Get(string owner, string name, string branch) { @@ -107,7 +103,7 @@ public Task<Branch> Get(string owner, string name, string branch) Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, name, branch), null); } /// <summary> @@ -118,13 +114,12 @@ public Task<Branch> Get(string owner, string name, string branch) /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}")] public Task<Branch> Get(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(repositoryId, branch), null); } /// <summary> @@ -136,7 +131,6 @@ public Task<Branch> Get(long repositoryId, string branch) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection")] public Task<BranchProtectionSettings> GetBranchProtection(string owner, string name, string branch) { @@ -144,7 +138,7 @@ public Task<BranchProtectionSettings> GetBranchProtection(string owner, string n Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), null); } /// <summary> @@ -155,13 +149,12 @@ public Task<BranchProtectionSettings> GetBranchProtection(string owner, string n /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection")] public Task<BranchProtectionSettings> GetBranchProtection(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), null); } /// <summary> @@ -174,7 +167,6 @@ public Task<BranchProtectionSettings> GetBranchProtection(long repositoryId, str /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="update">Branch protection settings</param> - [Preview("luke-cage")] [ManualRoute("PUT", "/repos/{owner}/{repo}/branches/{branch}/protection")] public Task<BranchProtectionSettings> UpdateBranchProtection(string owner, string name, string branch, BranchProtectionSettingsUpdate update) { @@ -183,7 +175,7 @@ public Task<BranchProtectionSettings> UpdateBranchProtection(string owner, strin Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, null); } /// <summary> @@ -195,14 +187,13 @@ public Task<BranchProtectionSettings> UpdateBranchProtection(string owner, strin /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="update">Branch protection settings</param> - [Preview("luke-cage")] [ManualRoute("PUT", "/repositories/{id}/branches/{branch}/protection")] public Task<BranchProtectionSettings> UpdateBranchProtection(long repositoryId, string branch, BranchProtectionSettingsUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null); } /// <summary> @@ -214,7 +205,6 @@ public Task<BranchProtectionSettings> UpdateBranchProtection(long repositoryId, /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection")] public async Task<bool> DeleteBranchProtection(string owner, string name, string branch) { @@ -225,7 +215,7 @@ public async Task<bool> DeleteBranchProtection(string owner, string name, string var endpoint = ApiUrls.RepoBranchProtection(owner, name, branch); try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -242,7 +232,6 @@ public async Task<bool> DeleteBranchProtection(string owner, string name, string /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection")] public async Task<bool> DeleteBranchProtection(long repositoryId, string branch) { @@ -251,7 +240,7 @@ public async Task<bool> DeleteBranchProtection(long repositoryId, string branch) var endpoint = ApiUrls.RepoBranchProtection(repositoryId, branch); try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -269,7 +258,6 @@ public async Task<bool> DeleteBranchProtection(long repositoryId, string branch) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks")] public Task<BranchProtectionRequiredStatusChecks> GetRequiredStatusChecks(string owner, string name, string branch) { @@ -277,7 +265,7 @@ public Task<BranchProtectionRequiredStatusChecks> GetRequiredStatusChecks(string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), null); } /// <summary> @@ -288,13 +276,12 @@ public Task<BranchProtectionRequiredStatusChecks> GetRequiredStatusChecks(string /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/required_status_checks")] public Task<BranchProtectionRequiredStatusChecks> GetRequiredStatusChecks(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), null); } /// <summary> @@ -307,7 +294,6 @@ public Task<BranchProtectionRequiredStatusChecks> GetRequiredStatusChecks(long r /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="update">Required status checks</param> - [Preview("luke-cage")] [ManualRoute("PATCH", "/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks")] public Task<BranchProtectionRequiredStatusChecks> UpdateRequiredStatusChecks(string owner, string name, string branch, BranchProtectionRequiredStatusChecksUpdate update) { @@ -316,7 +302,7 @@ public Task<BranchProtectionRequiredStatusChecks> UpdateRequiredStatusChecks(str Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), update, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), update); } /// <summary> @@ -328,14 +314,13 @@ public Task<BranchProtectionRequiredStatusChecks> UpdateRequiredStatusChecks(str /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="update">Required status checks</param> - [Preview("luke-cage")] [ManualRoute("PATCH", "/repositories/{id}/branches/{branch}/protection/required_status_checks")] public Task<BranchProtectionRequiredStatusChecks> UpdateRequiredStatusChecks(long repositoryId, string branch, BranchProtectionRequiredStatusChecksUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), update); } /// <summary> @@ -347,7 +332,6 @@ public Task<BranchProtectionRequiredStatusChecks> UpdateRequiredStatusChecks(lon /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks")] public async Task<bool> DeleteRequiredStatusChecks(string owner, string name, string branch) { @@ -359,7 +343,7 @@ public async Task<bool> DeleteRequiredStatusChecks(string owner, string name, st try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -376,7 +360,6 @@ public async Task<bool> DeleteRequiredStatusChecks(string owner, string name, st /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection/required_status_checks")] public async Task<bool> DeleteRequiredStatusChecks(long repositoryId, string branch) { @@ -386,7 +369,7 @@ public async Task<bool> DeleteRequiredStatusChecks(long repositoryId, string bra try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -404,7 +387,6 @@ public async Task<bool> DeleteRequiredStatusChecks(long repositoryId, string bra /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> GetAllRequiredStatusChecksContexts(string owner, string name, string branch) { @@ -412,7 +394,7 @@ public Task<IReadOnlyList<string>> GetAllRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), null); } /// <summary> @@ -423,13 +405,12 @@ public Task<IReadOnlyList<string>> GetAllRequiredStatusChecksContexts(string own /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> GetAllRequiredStatusChecksContexts(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), null); } /// <summary> @@ -442,7 +423,6 @@ public Task<IReadOnlyList<string>> GetAllRequiredStatusChecksContexts(long repos /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="contexts">The contexts to replace</param> - [Preview("luke-cage")] [ManualRoute("PUT", "/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(string owner, string name, string branch, IReadOnlyList<string> contexts) { @@ -451,7 +431,7 @@ public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null); } /// <summary> @@ -463,14 +443,13 @@ public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(string own /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="contexts">The contexts to replace</param> - [Preview("luke-cage")] [ManualRoute("PUT", "/repositories/{id}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(long repositoryId, string branch, IReadOnlyList<string> contexts) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null); } /// <summary> @@ -483,7 +462,6 @@ public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(long repos /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="contexts">The contexts to add</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> AddRequiredStatusChecksContexts(string owner, string name, string branch, IReadOnlyList<string> contexts) { @@ -492,7 +470,7 @@ public Task<IReadOnlyList<string>> AddRequiredStatusChecksContexts(string owner, Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts); } /// <summary> @@ -504,14 +482,13 @@ public Task<IReadOnlyList<string>> AddRequiredStatusChecksContexts(string owner, /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="contexts">The contexts to add</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repositories/{id}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> AddRequiredStatusChecksContexts(long repositoryId, string branch, IReadOnlyList<string> contexts) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts); } /// <summary> @@ -524,7 +501,6 @@ public Task<IReadOnlyList<string>> AddRequiredStatusChecksContexts(long reposito /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="contexts">The contexts to remove</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> DeleteRequiredStatusChecksContexts(string owner, string name, string branch, IReadOnlyList<string> contexts) { @@ -533,7 +509,7 @@ public Task<IReadOnlyList<string>> DeleteRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts); } /// <summary> @@ -545,14 +521,13 @@ public Task<IReadOnlyList<string>> DeleteRequiredStatusChecksContexts(string own /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="contexts">The contexts to remove</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection/required_status_checks/contexts")] public Task<IReadOnlyList<string>> DeleteRequiredStatusChecksContexts(long repositoryId, string branch, IReadOnlyList<string> contexts) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts); } /// <summary> @@ -564,7 +539,6 @@ public Task<IReadOnlyList<string>> DeleteRequiredStatusChecksContexts(long repos /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews")] public Task<BranchProtectionRequiredReviews> GetReviewEnforcement(string owner, string name, string branch) { @@ -572,7 +546,7 @@ public Task<BranchProtectionRequiredReviews> GetReviewEnforcement(string owner, Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), null); } /// <summary> @@ -583,13 +557,12 @@ public Task<BranchProtectionRequiredReviews> GetReviewEnforcement(string owner, /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/required_pull_request_reviews")] public Task<BranchProtectionRequiredReviews> GetReviewEnforcement(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), null); } /// <summary> @@ -602,7 +575,6 @@ public Task<BranchProtectionRequiredReviews> GetReviewEnforcement(long repositor /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="update">The required pull request review settings</param> - [Preview("luke-cage")] [ManualRoute("PATCH", "/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews")] public Task<BranchProtectionRequiredReviews> UpdateReviewEnforcement(string owner, string name, string branch, BranchProtectionRequiredReviewsUpdate update) { @@ -611,7 +583,7 @@ public Task<BranchProtectionRequiredReviews> UpdateReviewEnforcement(string owne Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), update, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), update); } /// <summary> @@ -623,14 +595,13 @@ public Task<BranchProtectionRequiredReviews> UpdateReviewEnforcement(string owne /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="update">The required pull request review settings</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/required_pull_request_reviews")] public Task<BranchProtectionRequiredReviews> UpdateReviewEnforcement(long repositoryId, string branch, BranchProtectionRequiredReviewsUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), update); } /// <summary> @@ -642,7 +613,6 @@ public Task<BranchProtectionRequiredReviews> UpdateReviewEnforcement(long reposi /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews")] public async Task<bool> RemoveReviewEnforcement(string owner, string name, string branch) { @@ -654,7 +624,7 @@ public async Task<bool> RemoveReviewEnforcement(string owner, string name, strin try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -671,7 +641,6 @@ public async Task<bool> RemoveReviewEnforcement(string owner, string name, strin /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection/required_pull_request_reviews")] public async Task<bool> RemoveReviewEnforcement(long repositoryId, string branch) { @@ -681,7 +650,7 @@ public async Task<bool> RemoveReviewEnforcement(long repositoryId, string branch try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -699,7 +668,6 @@ public async Task<bool> RemoveReviewEnforcement(long repositoryId, string branch /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins")] public Task<EnforceAdmins> GetAdminEnforcement(string owner, string name, string branch) { @@ -707,7 +675,7 @@ public Task<EnforceAdmins> GetAdminEnforcement(string owner, string name, string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), null); } /// <summary> @@ -718,13 +686,12 @@ public Task<EnforceAdmins> GetAdminEnforcement(string owner, string name, string /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/enforce_admins")] public Task<EnforceAdmins> GetAdminEnforcement(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), null); } /// <summary> @@ -736,7 +703,6 @@ public Task<EnforceAdmins> GetAdminEnforcement(long repositoryId, string branch) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins")] public Task<EnforceAdmins> AddAdminEnforcement(string owner, string name, string branch) { @@ -744,7 +710,7 @@ public Task<EnforceAdmins> AddAdminEnforcement(string owner, string name, string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), new object(), AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), new object()); } /// <summary> @@ -755,13 +721,12 @@ public Task<EnforceAdmins> AddAdminEnforcement(string owner, string name, string /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repositories/{id}/branches/{branch}/protection/enforce_admins")] public Task<EnforceAdmins> AddAdminEnforcement(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), new object(), AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), new object()); } /// <summary> @@ -773,7 +738,6 @@ public Task<EnforceAdmins> AddAdminEnforcement(long repositoryId, string branch) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins")] public async Task<bool> RemoveAdminEnforcement(string owner, string name, string branch) { @@ -785,7 +749,7 @@ public async Task<bool> RemoveAdminEnforcement(string owner, string name, string try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -802,7 +766,6 @@ public async Task<bool> RemoveAdminEnforcement(string owner, string name, string /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection/enforce_admins")] public async Task<bool> RemoveAdminEnforcement(long repositoryId, string branch) { @@ -812,7 +775,7 @@ public async Task<bool> RemoveAdminEnforcement(long repositoryId, string branch) try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -830,7 +793,6 @@ public async Task<bool> RemoveAdminEnforcement(long repositoryId, string branch) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions")] public Task<BranchProtectionPushRestrictions> GetProtectedBranchRestrictions(string owner, string name, string branch) { @@ -838,7 +800,7 @@ public Task<BranchProtectionPushRestrictions> GetProtectedBranchRestrictions(str Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(owner, name, branch), null); } /// <summary> @@ -849,13 +811,12 @@ public Task<BranchProtectionPushRestrictions> GetProtectedBranchRestrictions(str /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/restrictions")] public Task<BranchProtectionPushRestrictions> GetProtectedBranchRestrictions(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(repositoryId, branch), null); } /// <summary> @@ -867,7 +828,6 @@ public Task<BranchProtectionPushRestrictions> GetProtectedBranchRestrictions(lon /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions")] public async Task<bool> DeleteProtectedBranchRestrictions(string owner, string name, string branch) { @@ -879,7 +839,7 @@ public async Task<bool> DeleteProtectedBranchRestrictions(string owner, string n try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -896,7 +856,6 @@ public async Task<bool> DeleteProtectedBranchRestrictions(string owner, string n /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection/restrictions")] public async Task<bool> DeleteProtectedBranchRestrictions(long repositoryId, string branch) { @@ -906,7 +865,7 @@ public async Task<bool> DeleteProtectedBranchRestrictions(long repositoryId, str try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -924,7 +883,6 @@ public async Task<bool> DeleteProtectedBranchRestrictions(long repositoryId, str /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> GetAllProtectedBranchTeamRestrictions(string owner, string name, string branch) { @@ -932,7 +890,7 @@ public Task<IReadOnlyList<Team>> GetAllProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), null); } /// <summary> @@ -943,13 +901,12 @@ public Task<IReadOnlyList<Team>> GetAllProtectedBranchTeamRestrictions(string ow /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> GetAllProtectedBranchTeamRestrictions(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), null); } /// <summary> @@ -962,7 +919,6 @@ public Task<IReadOnlyList<Team>> GetAllProtectedBranchTeamRestrictions(long repo /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="teams">List of teams with push access</param> - [Preview("luke-cage")] [ManualRoute("PUT", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(string owner, string name, string branch, BranchProtectionTeamCollection teams) { @@ -971,7 +927,7 @@ public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null); } /// <summary> @@ -983,14 +939,13 @@ public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(string ow /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="teams">List of teams with push access</param> - [Preview("luke-cage")] [ManualRoute("PUT", "/repositories/{id}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(long repositoryId, string branch, BranchProtectionTeamCollection teams) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null); } /// <summary> @@ -1003,7 +958,6 @@ public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(long repo /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="teams">List of teams with push access to add</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> AddProtectedBranchTeamRestrictions(string owner, string name, string branch, BranchProtectionTeamCollection teams) { @@ -1012,7 +966,7 @@ public Task<IReadOnlyList<Team>> AddProtectedBranchTeamRestrictions(string owner Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams); } /// <summary> @@ -1024,14 +978,13 @@ public Task<IReadOnlyList<Team>> AddProtectedBranchTeamRestrictions(string owner /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="teams">List of teams with push access to add</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repositories/{id}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> AddProtectedBranchTeamRestrictions(long repositoryId, string branch, BranchProtectionTeamCollection teams) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams); } /// <summary> @@ -1044,7 +997,6 @@ public Task<IReadOnlyList<Team>> AddProtectedBranchTeamRestrictions(long reposit /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="teams">List of teams to remove</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> DeleteProtectedBranchTeamRestrictions(string owner, string name, string branch, BranchProtectionTeamCollection teams) { @@ -1053,7 +1005,7 @@ public Task<IReadOnlyList<Team>> DeleteProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams); } /// <summary> @@ -1065,14 +1017,13 @@ public Task<IReadOnlyList<Team>> DeleteProtectedBranchTeamRestrictions(string ow /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="teams">List of teams to remove</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection/restrictions/teams")] public Task<IReadOnlyList<Team>> DeleteProtectedBranchTeamRestrictions(long repositoryId, string branch, BranchProtectionTeamCollection teams) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams); } /// <summary> @@ -1084,7 +1035,6 @@ public Task<IReadOnlyList<Team>> DeleteProtectedBranchTeamRestrictions(long repo /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> GetAllProtectedBranchUserRestrictions(string owner, string name, string branch) { @@ -1092,7 +1042,7 @@ public Task<IReadOnlyList<User>> GetAllProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), null); } /// <summary> @@ -1103,13 +1053,12 @@ public Task<IReadOnlyList<User>> GetAllProtectedBranchUserRestrictions(string ow /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> - [Preview("luke-cage")] [ManualRoute("GET", "/repositories/{id}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> GetAllProtectedBranchUserRestrictions(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), null); } /// <summary> @@ -1122,7 +1071,6 @@ public Task<IReadOnlyList<User>> GetAllProtectedBranchUserRestrictions(long repo /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="users">List of users with push access</param> - [Preview("luke-cage")] [ManualRoute("UPDATE", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(string owner, string name, string branch, BranchProtectionUserCollection users) { @@ -1131,7 +1079,7 @@ public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null); } /// <summary> @@ -1143,14 +1091,13 @@ public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(string ow /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="users">List of users with push access</param> - [Preview("luke-cage")] [ManualRoute("PUT", "/repositories/{id}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(long repositoryId, string branch, BranchProtectionUserCollection users) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null); } /// <summary> @@ -1163,7 +1110,6 @@ public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(long repo /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="users">List of users with push access to add</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> AddProtectedBranchUserRestrictions(string owner, string name, string branch, BranchProtectionUserCollection users) { @@ -1172,7 +1118,7 @@ public Task<IReadOnlyList<User>> AddProtectedBranchUserRestrictions(string owner Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users); } /// <summary> @@ -1184,14 +1130,13 @@ public Task<IReadOnlyList<User>> AddProtectedBranchUserRestrictions(string owner /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="users">List of users with push access to add</param> - [Preview("luke-cage")] [ManualRoute("POST", "/repositories/{id}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> AddProtectedBranchUserRestrictions(long repositoryId, string branch, BranchProtectionUserCollection users) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users); } /// <summary> @@ -1204,7 +1149,6 @@ public Task<IReadOnlyList<User>> AddProtectedBranchUserRestrictions(long reposit /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="users">List of users with push access to remove</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> DeleteProtectedBranchUserRestrictions(string owner, string name, string branch, BranchProtectionUserCollection users) { @@ -1213,7 +1157,7 @@ public Task<IReadOnlyList<User>> DeleteProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users); } /// <summary> @@ -1225,14 +1169,13 @@ public Task<IReadOnlyList<User>> DeleteProtectedBranchUserRestrictions(string ow /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> /// <param name="users">List of users with push access to remove</param> - [Preview("luke-cage")] [ManualRoute("DELETE", "/repositories/{id}/branches/{branch}/protection/restrictions/users")] public Task<IReadOnlyList<User>> DeleteProtectedBranchUserRestrictions(long repositoryId, string branch, BranchProtectionUserCollection users) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users); } } } diff --git a/Octokit/Clients/RepositoryCommentsClient.cs b/Octokit/Clients/RepositoryCommentsClient.cs index acaa6b41ac..ff28b1a152 100644 --- a/Octokit/Clients/RepositoryCommentsClient.cs +++ b/Octokit/Clients/RepositoryCommentsClient.cs @@ -27,14 +27,13 @@ public RepositoryCommentsClient(IApiConnection apiConnection) /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/comments/{comment_id}")] public Task<CommitComment> Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Get<CommitComment>(ApiUrls.CommitComment(owner, name, number), null, AcceptHeaders.ReactionsPreview); + return ApiConnection.Get<CommitComment>(ApiUrls.CommitComment(owner, name, number), null); } /// <summary> @@ -43,11 +42,10 @@ public Task<CommitComment> Get(string owner, string name, int number) /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> /// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/comments/{number}")] public Task<CommitComment> Get(long repositoryId, int number) { - return ApiConnection.Get<CommitComment>(ApiUrls.CommitComment(repositoryId, number), null, AcceptHeaders.ReactionsPreview); + return ApiConnection.Get<CommitComment>(ApiUrls.CommitComment(repositoryId, number), null); } /// <summary> @@ -83,7 +81,6 @@ public Task<IReadOnlyList<CommitComment>> GetAllForRepository(long repositoryId) /// <param name="name">The name of the repository</param> /// <param name="options">Options to change the API response</param> /// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/comments")] public Task<IReadOnlyList<CommitComment>> GetAllForRepository(string owner, string name, ApiOptions options) { @@ -91,7 +88,7 @@ public Task<IReadOnlyList<CommitComment>> GetAllForRepository(string owner, stri Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(owner, name), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(owner, name), null, options); } /// <summary> @@ -100,13 +97,12 @@ public Task<IReadOnlyList<CommitComment>> GetAllForRepository(string owner, stri /// <param name="repositoryId">The Id of the repository</param> /// <param name="options">Options to change the API response</param> /// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/comments")] public Task<IReadOnlyList<CommitComment>> GetAllForRepository(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(repositoryId), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(repositoryId), null, options); } /// <summary> @@ -148,7 +144,6 @@ public Task<IReadOnlyList<CommitComment>> GetAllForCommit(long repositoryId, str /// <param name="sha">The sha of the commit</param> /// <param name="options">Options to change the API response</param> /// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/comments")] public Task<IReadOnlyList<CommitComment>> GetAllForCommit(string owner, string name, string sha, ApiOptions options) { @@ -157,7 +152,7 @@ public Task<IReadOnlyList<CommitComment>> GetAllForCommit(string owner, string n Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(owner, name, sha), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(owner, name, sha), null, options); } /// <summary> @@ -167,14 +162,13 @@ public Task<IReadOnlyList<CommitComment>> GetAllForCommit(string owner, string n /// <param name="sha">The sha of the commit</param> /// <param name="options">Options to change the API response</param> /// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks> - [Preview("squirrel-girl")] [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/comments")] public Task<IReadOnlyList<CommitComment>> GetAllForCommit(long repositoryId, string sha, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(sha, nameof(sha)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), null, AcceptHeaders.ReactionsPreview, options); + return ApiConnection.GetAll<CommitComment>(ApiUrls.CommitComments(repositoryId, sha), null, options); } /// <summary> diff --git a/Octokit/Clients/RepositoryCommitsClient.cs b/Octokit/Clients/RepositoryCommitsClient.cs index 52dc0326dd..8f03bdc7a9 100644 --- a/Octokit/Clients/RepositoryCommitsClient.cs +++ b/Octokit/Clients/RepositoryCommitsClient.cs @@ -203,7 +203,7 @@ public Task<string> GetSha1(string owner, string name, string reference) Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(owner, name, reference), null, AcceptHeaders.CommitReferenceSha1MediaType); + return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(owner, name, reference), null); } /// <summary> @@ -216,7 +216,7 @@ public Task<string> GetSha1(long repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(repositoryId, reference), null, AcceptHeaders.CommitReferenceSha1MediaType); + return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(repositoryId, reference), null); } } } diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs index 89496dddab..3a32b59b70 100644 --- a/Octokit/Clients/RepositoryForksClient.cs +++ b/Octokit/Clients/RepositoryForksClient.cs @@ -168,7 +168,6 @@ public Task<IReadOnlyList<Repository>> GetAll(long repositoryId, RepositoryForks /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="fork">Used to fork a repository</param> - [Preview("mercy")] [ManualRoute("POST", "/repos/{owner}/{repo}/forks")] public Task<Repository> Create(string owner, string name, NewRepositoryFork fork) { @@ -187,7 +186,6 @@ public Task<Repository> Create(string owner, string name, NewRepositoryFork fork /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="fork">Used to fork a repository</param> - [Preview("mercy")] [ManualRoute("POST", "/repositories/{id}/forks")] public Task<Repository> Create(long repositoryId, NewRepositoryFork fork) { diff --git a/Octokit/Clients/StarredClient.cs b/Octokit/Clients/StarredClient.cs index 94cef3dfa9..05374044fd 100644 --- a/Octokit/Clients/StarredClient.cs +++ b/Octokit/Clients/StarredClient.cs @@ -117,7 +117,7 @@ public Task<IReadOnlyList<UserStar>> GetAllStargazersWithTimestamps(string owner Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarCreationTimestamps, options); + return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(owner, name), null, options); } /// <summary> @@ -131,7 +131,7 @@ public Task<IReadOnlyList<UserStar>> GetAllStargazersWithTimestamps(long reposit { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(repositoryId), null, AcceptHeaders.StarCreationTimestamps, options); + return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(repositoryId), null, options); } /// <summary> @@ -177,7 +177,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps(ApiOpt { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), null, AcceptHeaders.StarCreationTimestamps, options); + return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), null, options); } /// <summary> @@ -237,7 +237,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps(Starre Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps, options); + return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), options); } /// <summary> @@ -293,7 +293,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string us Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), null, AcceptHeaders.StarCreationTimestamps, options); + return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), null, options); } /// <summary> @@ -359,7 +359,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string us Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps, options); + return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), options); } /// <summary> diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 08a1bfd65b..2d01a3445b 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -503,7 +503,7 @@ public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvita [ManualRoute("GET", "/teams/{team_id}/invitations")] public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvitations(int id, ApiOptions options) { - return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.TeamPendingInvitations(id), null, AcceptHeaders.OrganizationMembershipPreview, options); + return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.TeamPendingInvitations(id), null, options); } } } diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index a2723a8e27..c39c1baddf 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -1,7 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Octokit +namespace Octokit { public static class AcceptHeaders { @@ -11,64 +8,10 @@ public static class AcceptHeaders public const string StableVersionJson = "application/vnd.github.v3+json"; - public const string CommitReferenceSha1MediaType = "application/vnd.github.v3.sha"; - /// <summary> /// Support for retrieving raw file content with the <see cref="IConnection.GetRaw"/> method. /// </summary> /// <remarks>https://developer.github.com/v3/repos/contents/#custom-media-types</remarks> public const string RawContentMediaType = "application/vnd.github.v3.raw"; - - public const string StarCreationTimestamps = "application/vnd.github.v3.star+json"; - - public const string MigrationsApiPreview = "application/vnd.github.wyandotte-preview+json"; - - public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview+json"; - - public const string DeploymentApiPreview = "application/vnd.github.ant-man-preview+json"; - - public const string IssueTimelineApiPreview = "application/vnd.github.mockingbird-preview+json"; - - public const string DraftPullRequestApiPreview = "application/vnd.github.shadow-cat-preview+json"; - - public const string ProjectsApiPreview = "application/vnd.github.inertia-preview+json"; - - [Obsolete("API is considered legacy")] - public const string OrganizationMembershipPreview = "application/vnd.github.korra-preview+json"; - - public const string GitHubAppsPreview = "application/vnd.github.machine-man-preview+json"; - - public const string PreReceiveEnvironmentsPreview = "application/vnd.github.eye-scream-preview+json"; - - public const string ChecksApiPreview = "application/vnd.github.antiope-preview+json"; - - public const string ProtectedBranchesRequiredApprovingApiPreview = "application/vnd.github.luke-cage-preview+json"; - - public const string IssueEventsApiPreview = "application/vnd.github.starfox-preview+json"; - - public const string DeploymentStatusesPreview = "application/vnd.github.flash-preview+json"; - - public const string OAuthApplicationsPreview = "application/vnd.github.doctor-strange-preview+json"; - - public const string RepositoryTopicsPreview = "application/vnd.github.mercy-preview+json"; - - public const string VisibilityPreview = "application/vnd.github.nebula-preview+json"; - - public const string TemplatePreview = "application/vnd.github.baptiste-preview+json"; - - /// <summary> - /// Combines multiple preview headers. GitHub API supports Accept header with multiple - /// values separated by comma. - /// </summary> - /// <param name="headers">Accept header values that will be combine to single Accept header.</param> - /// <remarks> - /// This Accept header <c>application/vnd.github.loki-preview+json,application/vnd.github.drax-preview+json</c> - /// indicated we want both Protected Branches and Licenses preview APIs. - /// </remarks> - /// <returns>Accept header value.</returns> - public static string Concat(params string[] headers) - { - return string.Join(",", headers); - } } } diff --git a/Octokit/Helpers/ApiExtensions.cs b/Octokit/Helpers/ApiExtensions.cs index 7cd04ab9ca..4c7e88d648 100644 --- a/Octokit/Helpers/ApiExtensions.cs +++ b/Octokit/Helpers/ApiExtensions.cs @@ -69,7 +69,7 @@ public static Task<IApiResponse<T>> GetResponse<T>(this IConnection connection, Ensure.ArgumentNotNull(connection, nameof(connection)); Ensure.ArgumentNotNull(uri, nameof(uri)); - return connection.Get<T>(uri, null, null); + return connection.Get<T>(uri, null); } /// <summary> diff --git a/Octokit/Helpers/PreviewAttribute.cs b/Octokit/Helpers/PreviewAttribute.cs deleted file mode 100644 index 5a125a3507..0000000000 --- a/Octokit/Helpers/PreviewAttribute.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace Octokit -{ - /// <summary> - /// Metadata for tracking which endpoints rely on preview API behaviour - /// </summary> - /// <remarks>https://developer.github.com/v3/previews/</remarks> - - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)] - public class PreviewAttribute : Attribute - { - public string Name { get; private set; } - - public PreviewAttribute(string name) - { - this.Name = name; - } - } -} diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 4f30d5c0ed..9c247c502c 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -172,6 +172,13 @@ public ApiInfo GetLastApiInfo() } private ApiInfo _lastApiInfo; + public Task<IApiResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters) + { + Ensure.ArgumentNotNull(uri, nameof(uri)); + + return SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Get, null, null, null, CancellationToken.None); + } + public Task<IApiResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts) { Ensure.ArgumentNotNull(uri, nameof(uri)); diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 73594c3441..f53f361be9 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -29,6 +29,16 @@ public interface IConnection : IApiInfoProvider /// <remarks>The <see cref="IResponse.Body"/> property will be <c>null</c> if the <paramref name="uri"/> points to a directory instead of a file</remarks> Task<IApiResponse<byte[]>> GetRaw(Uri uri, IDictionary<string, string> parameters); + /// <summary> + /// Performs an asynchronous HTTP GET request. + /// Attempts to map the response to an object of type <typeparamref name="T"/> + /// </summary> + /// <typeparam name="T">The type to map the response to</typeparam> + /// <param name="uri">URI endpoint to send request to</param> + /// <param name="parameters">Querystring parameters for the request</param> + /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> + Task<IApiResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters); + /// <summary> /// Performs an asynchronous HTTP GET request. /// Attempts to map the response to an object of type <typeparamref name="T"/> From e8418085f8c8c07053454595fbefe003d21dc563 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Aug 2022 14:46:17 -0500 Subject: [PATCH 095/209] deps: Bump xunit from 2.4.1 to 2.4.2 (#2518) --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 3ecc8effd1..5bcbc497db 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -34,7 +34,7 @@ <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> - <PackageReference Include="xunit" Version="2.4.1" /> + <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 02e69f70ba..513f252fe3 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -38,7 +38,7 @@ <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> - <PackageReference Include="xunit" Version="2.4.1" /> + <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 08e3d1a926..1ca561e217 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -38,7 +38,7 @@ <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> - <PackageReference Include="xunit" Version="2.4.1" /> + <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> From 80b82aa97301485a3d0922757f23f349a3e59576 Mon Sep 17 00:00:00 2001 From: Brend Smits <brend_smits@hotmail.com> Date: Tue, 2 Aug 2022 21:55:18 +0200 Subject: [PATCH 096/209] docs: Moves deprecation warning from subscribers_count to watchers_count. (#2519) Subscribers_count shows the actual watchers_count. Many people think they are retrieving the watchers_count, but are actually retrieving the stargazers_count... This is because the GitHub UI is still calling subscribers, "Watchers". To prevent many others from falling into this trap, a warning should be added to the watchers_count property. On top of this, subscribers_count is no longer deprecated as far as the GitHub documentation goes. Fixes #2509 Signed-off-by: Brend Smits <brend.smits@philips.com> --- Octokit/Models/Response/Repository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 9a078ece9c..a017d694a0 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -108,6 +108,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public int StargazersCount { get; protected set; } + [Obsolete("WatchersCount returns the same data as StargazersCount. You are likely looking to use SubscribersCount. Update your code to use SubscribersCount, as this field will stop containing data in the future")] public int WatchersCount { get; protected set; } public string DefaultBranch { get; protected set; } @@ -142,7 +143,6 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public bool HasPages { get; protected set; } - [Obsolete("Update your code to use WatchersCount as this field will stop containing data in the future")] public int SubscribersCount { get; protected set; } public long Size { get; protected set; } From 4d46d5fb41b30baad29b5c6199a5efe6f25679f0 Mon Sep 17 00:00:00 2001 From: notauserx <82922717+notauserx@users.noreply.github.com> Date: Wed, 3 Aug 2022 21:17:48 +0600 Subject: [PATCH 097/209] docs: update code docs for SetRequestTimeout (#2520) --- Octokit.Reactive/IObservableGitHubClient.cs | 3 ++- Octokit.Reactive/ObservableGitHubClient.cs | 3 ++- Octokit/GitHubClient.cs | 2 +- Octokit/Http/Connection.cs | 2 +- Octokit/Http/IConnection.cs | 2 +- Octokit/Http/IHttpClient.cs | 2 +- Octokit/IGitHubClient.cs | 3 ++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index bacdc13d72..e4f91ec061 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -7,7 +7,8 @@ public interface IObservableGitHubClient : IApiInfoProvider IConnection Connection { get; } /// <summary> - /// Set the GitHub Api request timeout. + /// Sets the timeout for the connection between the client and the server. + /// Github will terminate the request if it takes more than 10 seconds to process the request /// Useful to set a specific timeout for lengthy operations, such as uploading release assets /// </summary> /// <remarks> diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index f891ec847d..a063faae62 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -57,7 +57,8 @@ public IConnection Connection } /// <summary> - /// Set the GitHub Api request timeout. + /// Sets the timeout for the connection between the client and the server. + /// Github will terminate the request if it takes more than 10 seconds to process the request /// Useful to set a specific timeout for lengthy operations, such as uploading release assets /// </summary> /// <remarks> diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index df766a1ed9..f030540853 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -114,7 +114,7 @@ public GitHubClient(IConnection connection) } /// <summary> - /// Set the GitHub Api request timeout. + /// Sets the timeout for the connection between the client and the server. /// Useful to set a specific timeout for lengthy operations, such as uploading release assets /// </summary> /// <remarks> diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 9c247c502c..17cfce19fb 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -832,7 +832,7 @@ static string GetVersionInformation() } /// <summary> - /// Set the GitHub Api request timeout. + /// Sets the timeout for the connection between the client and the server. /// </summary> /// <param name="timeout">The Timeout value</param> public void SetRequestTimeout(TimeSpan timeout) diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index f53f361be9..ff4b6359f1 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -327,7 +327,7 @@ Task<IApiResponse<T>> Post<T>( Credentials Credentials { get; set; } /// <summary> - /// Set the GitHub Api request timeout. + /// Sets the timeout for the connection between the client and the server. /// </summary> /// <param name="timeout">The Timeout value</param> void SetRequestTimeout(TimeSpan timeout); diff --git a/Octokit/Http/IHttpClient.cs b/Octokit/Http/IHttpClient.cs index bda7a0409f..95e0d5055d 100644 --- a/Octokit/Http/IHttpClient.cs +++ b/Octokit/Http/IHttpClient.cs @@ -22,7 +22,7 @@ public interface IHttpClient : IDisposable /// <summary> - /// Set the GitHub API request timeout. + /// Sets the timeout for the connection between the client and the server. /// </summary> /// <param name="timeout">The Timeout value</param> void SetRequestTimeout(TimeSpan timeout); diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index d6aa599f8a..43b0179335 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -8,7 +8,8 @@ namespace Octokit public interface IGitHubClient : IApiInfoProvider { /// <summary> - /// Set the GitHub API request timeout. + /// Sets the timeout for the connection between the client and the server. + /// Github will terminate the request if it takes more than 10 seconds to process the request /// Useful to set a specific timeout for lengthy operations, such as uploading release assets /// </summary> /// <remarks> From 6e72fdaa5984700b23959d00ed2a6cb46739587c Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Thu, 4 Aug 2022 12:12:49 -0500 Subject: [PATCH 098/209] feat: Drop support for .NET 4.6 (#2521) --- Octokit.Reactive/Octokit.Reactive.csproj | 16 ++------ .../Clients/RepositoriesClientTests.cs | 38 +++---------------- .../Clients/RepositoriesClientTests.cs | 6 +-- .../ObservableRepositoriesClientTests.cs | 6 +-- Octokit/Models/Request/RepositoryUpdate.cs | 11 ------ Octokit/Octokit.csproj | 19 +--------- build/Context.cs | 6 +-- build/Lifetime.cs | 4 +- build/Tasks/Build.cs | 6 +-- build/Tasks/ConventionTests.cs | 4 +- build/Tasks/IntegrationTests.cs | 6 +-- build/Tasks/Package.cs | 6 +-- build/Tasks/Restore.cs | 6 +-- build/Tasks/UnitTests.cs | 7 ++-- build/Tasks/ValidateLINQPadSamples.cs | 2 +- build/Utilities/ToolInstaller.cs | 16 ++++---- 16 files changed, 48 insertions(+), 111 deletions(-) diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 6bcbbfae72..0ba912abf4 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -6,7 +6,8 @@ <Authors>GitHub</Authors> <Version>0.0.0-dev</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> - <TargetFrameworks>netstandard2.0;net46</TargetFrameworks> + <TargetFramework>netstandard2.0</TargetFramework> + <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <AssemblyName>Octokit.Reactive</AssemblyName> <PackageId>Octokit.Reactive</PackageId> <DebugType>embedded</DebugType> @@ -19,10 +20,6 @@ <Copyright>Copyright GitHub 2017</Copyright> </PropertyGroup> - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> - </PropertyGroup> - <PropertyGroup> <NoWarn>1591;1701;1702;1705</NoWarn> </PropertyGroup> @@ -41,14 +38,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="System.Reactive" Version="4.4.1" /> + <PackageReference Include="System.Reactive" Version="5.0.0" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/> </ItemGroup> - - <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> - <Reference Include="System" /> - <Reference Include="Microsoft.CSharp" /> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> - </ItemGroup> - </Project> diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index c3fba05f45..0492ffa1b4 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -530,34 +530,6 @@ public async Task UpdatesNameWithRepositoryId() } } - [IntegrationTest] - public async Task UpdatesNameObsolete() - { - using (var repoContext = await _github.CreateUserRepositoryContext()) - { - var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); - var update = new RepositoryUpdate(updatedName); - - var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryOwner, repoContext.RepositoryName, update); - - Assert.Equal(update.Name, updatedRepository.Name); - } - } - - [IntegrationTest] - public async Task UpdatesNameWithRepositoryIdObsolete() - { - using (var repoContext = await _github.CreateUserRepositoryContext()) - { - var updatedName = Helper.MakeNameWithTimestamp("updated-repo"); - var update = new RepositoryUpdate(updatedName); - - var updatedRepository = await _github.Repository.Edit(repoContext.RepositoryId, update); - - Assert.Equal(update.Name, updatedRepository.Name); - } - } - [IntegrationTest] public async Task UpdatesDescription() { @@ -811,7 +783,7 @@ public async Task UpdatesMergeMethodWithRepositoryId() Assert.True(editedRepository.AllowAutoMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethod() { @@ -826,7 +798,7 @@ public async Task UpdatesDeleteBranchOnMergeMethod() Assert.True(repository.DeleteBranchOnMerge); } } - + [IntegrationTest] public async Task UpdatesDeleteBranchOnMergeMethodWithRepositoryId() { @@ -1047,7 +1019,7 @@ public async Task ReturnsSpecifiedRepositoryWithLicenseInformation() Assert.Equal("mit", repository.License.Key); Assert.Equal("MIT License", repository.License.Name); } - + [IntegrationTest] public async Task ReturnsRepositoryDeleteBranchOnMergeOptions() { @@ -2099,10 +2071,10 @@ public async Task ReturnsCodeOwnersErrors() using (var repoContext = await _github.CreateUserRepositoryContext()) { await _github.Repository.Content.CreateFile(repoContext.RepositoryOwner, repoContext.RepositoryName, ".github/codeowners", new CreateFileRequest("Create codeowners", @"* snyrting6@hotmail.com")); - + // Sometimes it takes a second to create the file Thread.Sleep(TimeSpan.FromSeconds(2)); - + var license = await _github.Repository.GetAllCodeOwnersErrors(repoContext.RepositoryOwner, repoContext.RepositoryName); Assert.NotEmpty(license.Errors); } diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 40f72252b2..c7496d35b8 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -1129,7 +1129,7 @@ public void PatchesCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); - var update = new RepositoryUpdate("repo"); + var update = new RepositoryUpdate() { Name= "repo" }; client.Edit("owner", "repo", update); @@ -1143,7 +1143,7 @@ public void PatchesCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoriesClient(connection); - var update = new RepositoryUpdate("repo"); + var update = new RepositoryUpdate() { Name= "repo" }; client.Edit(1, update); @@ -1155,7 +1155,7 @@ public void PatchesCorrectUrlWithRepositoryId() public async Task EnsuresNonNullArguments() { var client = new RepositoriesClient(Substitute.For<IApiConnection>()); - var update = new RepositoryUpdate("anyreponame"); + var update = new RepositoryUpdate() { Name= "anyreponame" }; await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit(null, "repo", update)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Edit("owner", null, update)); diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index 747fd1d4fb..469d0a9c62 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -846,7 +846,7 @@ public void PatchsTheCorrectUrl() { var github = Substitute.For<IGitHubClient>(); var client = new ObservableRepositoriesClient(github); - var update = new RepositoryUpdate("anyreponame"); + var update = new RepositoryUpdate(){ Name= "anyreponame" }; client.Edit("owner", "repo", update); @@ -858,7 +858,7 @@ public void PatchsTheCorrectUrlWithRepositoryId() { var github = Substitute.For<IGitHubClient>(); var client = new ObservableRepositoriesClient(github); - var update = new RepositoryUpdate("anyreponame"); + var update = new RepositoryUpdate(){ Name= "anyreponame" }; client.Edit(1, update); @@ -869,7 +869,7 @@ public void PatchsTheCorrectUrlWithRepositoryId() public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoriesClient(Substitute.For<IGitHubClient>()); - var update = new RepositoryUpdate("anyreponame"); + var update = new RepositoryUpdate() { Name= "anyreponame" }; Assert.Throws<ArgumentNullException>(() => client.Edit(null, "repo", update)); Assert.Throws<ArgumentNullException>(() => client.Edit("owner", null, update)); diff --git a/Octokit/Models/Request/RepositoryUpdate.cs b/Octokit/Models/Request/RepositoryUpdate.cs index 7e8e3438cb..02dda177e3 100644 --- a/Octokit/Models/Request/RepositoryUpdate.cs +++ b/Octokit/Models/Request/RepositoryUpdate.cs @@ -16,17 +16,6 @@ public class RepositoryUpdate /// </summary> public RepositoryUpdate() { } - /// <summary> - /// Creates an object that describes an update to a repository on GitHub. - /// </summary> - /// <param name="name">The name of the repository. This is the only required parameter.</param> - [Obsolete("Use the constructor with no parameters as name is no longer a required field")] - public RepositoryUpdate(string name) - { - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - Name = name; - } - /// <summary> /// Required. Gets or sets the repository name. /// </summary> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index ace89edc6b..0148ebc3eb 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -6,7 +6,7 @@ <Authors>GitHub</Authors> <Version>0.0.0-dev</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> - <TargetFrameworks>netstandard2.0;net46</TargetFrameworks> + <TargetFramework>netstandard2.0</TargetFramework> <AssemblyName>Octokit</AssemblyName> <PackageId>Octokit</PackageId> <DebugType>embedded</DebugType> @@ -19,26 +19,11 @@ <Copyright>Copyright GitHub 2017</Copyright> </PropertyGroup> - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <DefineConstants>$(DefineConstants);HAS_TYPEINFO;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> - <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> - </PropertyGroup> - - <PropertyGroup Condition=" '$(TargetFramework)' == 'net46' "> - <DefineConstants>$(DefineConstants);HAS_ENVIRONMENT;HAS_REGEX_COMPILED_OPTIONS;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;HAS_SERVICEPOINTMANAGER</DefineConstants> - </PropertyGroup> - <PropertyGroup> + <DefineConstants>$(DefineConstants);HAS_TYPEINFO;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> <NoWarn>1591;1701;1702;1705</NoWarn> </PropertyGroup> - <ItemGroup Condition=" '$(TargetFramework)' == 'net46' "> - <Reference Include="System.Net.Http" /> - <Reference Include="System" /> - <Reference Include="Microsoft.CSharp" /> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> - </ItemGroup> - <ItemGroup> <None Include="images\octokit.png" Pack="true" PackagePath="\" /> </ItemGroup> diff --git a/build/Context.cs b/build/Context.cs index e0af2ff004..f9ede409e5 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -1,6 +1,6 @@ using Cake.Common; using Cake.Common.Diagnostics; -using Cake.Common.Tools.DotNetCore.Test; +using Cake.Common.Tools.DotNet.Test; using Cake.Core; using Cake.Core.IO; using Cake.Frosting; @@ -28,9 +28,9 @@ public class Context : FrostingContext public FilePath GitVersionToolPath { get; set; } - public DotNetCoreTestSettings GetTestSettings() + public DotNetTestSettings GetTestSettings() { - var settings = new DotNetCoreTestSettings + var settings = new DotNetTestSettings { Configuration = Configuration, NoBuild = true diff --git a/build/Lifetime.cs b/build/Lifetime.cs index a28729bb13..310841b202 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -51,8 +51,8 @@ public override void Setup(Context context) new Project { Name = "Octokit.Tests.Integration", Path = "./Octokit.Tests.Integration/Octokit.Tests.Integration.csproj", IntegrationTests = true } }; - context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.6.5", "dotnet-gitversion"); - ToolInstaller.DotNetCoreToolInstall(context, "coverlet.console", "1.7.2", "coverlet"); + context.GitVersionToolPath = ToolInstaller.DotNetToolInstall(context, "GitVersion.Tool", "5.6.5", "dotnet-gitversion"); + ToolInstaller.DotNetToolInstall(context, "coverlet.console", "1.7.2", "coverlet"); // Calculate semantic version. context.Version = BuildVersion.Calculate(context); diff --git a/build/Tasks/Build.cs b/build/Tasks/Build.cs index 353c9e10b1..2e1af6c0ac 100644 --- a/build/Tasks/Build.cs +++ b/build/Tasks/Build.cs @@ -1,5 +1,5 @@ -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.Build; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Build; using Cake.Core; using Cake.Frosting; @@ -9,7 +9,7 @@ public class Build : FrostingTask<Context> { public override void Run(Context context) { - context.DotNetCoreBuild("./Octokit.sln", new DotNetCoreBuildSettings + context.DotNetBuild("./Octokit.sln", new DotNetBuildSettings { Configuration = context.Configuration, ArgumentCustomization = args => args diff --git a/build/Tasks/ConventionTests.cs b/build/Tasks/ConventionTests.cs index d79c7c84e9..41018d2449 100644 --- a/build/Tasks/ConventionTests.cs +++ b/build/Tasks/ConventionTests.cs @@ -1,6 +1,6 @@ using System.Linq; using Cake.Common.Diagnostics; -using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNet; using Cake.Frosting; [IsDependentOn(typeof(Build))] @@ -11,7 +11,7 @@ public override void Run(Context context) foreach (var project in context.Projects.Where(x => x.ConventionTests)) { context.Information("Executing Convention Tests Project {0}...", project.Name); - context.DotNetCoreTest(project.Path.FullPath, context.GetTestSettings()); + context.DotNetTest(project.Path.FullPath, context.GetTestSettings()); } } } diff --git a/build/Tasks/IntegrationTests.cs b/build/Tasks/IntegrationTests.cs index 9acafeaef7..879305b9e5 100644 --- a/build/Tasks/IntegrationTests.cs +++ b/build/Tasks/IntegrationTests.cs @@ -1,7 +1,7 @@ using System.Linq; using Cake.Common.Diagnostics; -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.Test; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Test; using Cake.Frosting; [IsDependentOn(typeof(Build))] @@ -12,7 +12,7 @@ public override void Run(Context context) foreach (var project in context.Projects.Where(x => x.IntegrationTests)) { context.Information("Executing Integration Tests Project {0}...", project.Name); - context.DotNetCoreTest(project.Path.FullPath, context.GetTestSettings()); + context.DotNetTest(project.Path.FullPath, context.GetTestSettings()); } } diff --git a/build/Tasks/Package.cs b/build/Tasks/Package.cs index bbaddd9223..ed0ecadbc6 100644 --- a/build/Tasks/Package.cs +++ b/build/Tasks/Package.cs @@ -1,6 +1,6 @@ using Cake.Common.Diagnostics; -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.Pack; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Pack; using Cake.Core; using Cake.Frosting; @@ -16,7 +16,7 @@ public override void Run(Context context) if (project.Publish) { context.Information("Packing {0}...", project.Name); - context.DotNetCorePack(project.Path.FullPath, new DotNetCorePackSettings() + context.DotNetPack(project.Path.FullPath, new DotNetPackSettings() { Configuration = context.Configuration, NoBuild = true, diff --git a/build/Tasks/Restore.cs b/build/Tasks/Restore.cs index e84cf90bca..34500c3830 100644 --- a/build/Tasks/Restore.cs +++ b/build/Tasks/Restore.cs @@ -1,5 +1,5 @@ -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.Restore; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Restore; using Cake.Core; using Cake.Frosting; @@ -8,7 +8,7 @@ public sealed class Restore : FrostingTask<Context> { public override void Run(Context context) { - context.DotNetCoreRestore(".", new DotNetCoreRestoreSettings + context.DotNetRestore(".", new DotNetRestoreSettings { ArgumentCustomization = args => args .Append("/p:Version={0}", context.Version.GetSemanticVersion()) diff --git a/build/Tasks/UnitTests.cs b/build/Tasks/UnitTests.cs index 620cd3838f..e3ae4682ae 100644 --- a/build/Tasks/UnitTests.cs +++ b/build/Tasks/UnitTests.cs @@ -1,7 +1,8 @@ using System.Linq; -using Cake.Common.Diagnostics; -using Cake.Common.Tools.DotNetCore; using Cake.Frosting; +using Cake.Common.Diagnostics; +using Cake.Common.Tools; +using Cake.Common.Tools.DotNet; [IsDependentOn(typeof(Build))] public sealed class UnitTests : FrostingTask<Context> @@ -11,7 +12,7 @@ public override void Run(Context context) foreach (var project in context.Projects.Where(x => x.UnitTests)) { context.Information("Executing Unit Tests Project {0}...", project.Name); - context.DotNetCoreTest(project.Path.FullPath, context.GetTestSettings()); + context.DotNetTest(project.Path.FullPath, context.GetTestSettings()); } } } diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index 1bfaf1b758..77797757f5 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -17,7 +17,7 @@ public override void Run(Context context) .Combine("Octokit.Reactive") .Combine("bin") .Combine(context.Configuration) - .Combine("net46") + .Combine("netstandard2.0") .MakeAbsolute(context.Environment) .FullPath; diff --git a/build/Utilities/ToolInstaller.cs b/build/Utilities/ToolInstaller.cs index 1a03d21526..c2e0fcb21f 100644 --- a/build/Utilities/ToolInstaller.cs +++ b/build/Utilities/ToolInstaller.cs @@ -1,6 +1,6 @@ using Cake.Common.IO; -using Cake.Common.Tools.DotNetCore; -using Cake.Common.Tools.DotNetCore.Tool; +using Cake.Common.Tools.DotNet; +using Cake.Common.Tools.DotNet.Tool; using Cake.Common.Tools.NuGet; using Cake.Common.Tools.NuGet.Install; using Cake.Core; @@ -8,7 +8,7 @@ public static class ToolInstaller { - private static DirectoryPath ToolsPath { get; } = "./tools"; + private static DirectoryPath ToolsPath { get; } = "./tools"; public static void Install(ICakeContext context, string package, string version) { context.NuGetInstall(package, new NuGetInstallSettings @@ -19,7 +19,7 @@ public static void Install(ICakeContext context, string package, string version) }); } - public static FilePath DotNetCoreToolInstall( + public static FilePath DotNetToolInstall( this ICakeContext context, string package, string version, @@ -42,10 +42,10 @@ public static FilePath DotNetCoreToolInstall( : ".exe" ) ); - + if (!context.DirectoryExists(toolInstallPath) && context.FileExists(toolPath)) { - context.DotNetCoreTool("tool", new DotNetCoreToolSettings + context.DotNetTool("tool", new DotNetToolSettings { ArgumentCustomization = args => args .Append("uninstall") @@ -56,7 +56,7 @@ public static FilePath DotNetCoreToolInstall( if (!context.FileExists(toolPath)) { - context.DotNetCoreTool("tool", new DotNetCoreToolSettings + context.DotNetTool("tool", new DotNetToolSettings { ArgumentCustomization = args => args .Append("install") @@ -73,4 +73,4 @@ public static FilePath DotNetCoreToolInstall( return toolPath; } -} \ No newline at end of file +} From a7d5e339d5aad1b83856ccd3f3a2fa4467b351aa Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Thu, 4 Aug 2022 21:39:47 +0100 Subject: [PATCH 099/209] bug: Fixing issues with two factor authentication overload and certain endpoints (#2524) --- .../Clients/RepositoriesClientTests.cs | 8 ++++---- .../Clients/RepositoryBranchesClientTests.cs | 18 ++++++++---------- Octokit/Clients/RepositoriesClient.cs | 4 ++-- Octokit/Clients/RepositoryBranchesClient.cs | 16 ++++++++-------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index c7496d35b8..9ed62ed435 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -1389,7 +1389,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithEmptyTopics() await _client.ReplaceAllTopics("owner", "name", _emptyTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics); } [Fact] @@ -1398,7 +1398,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithListOfTopics() await _client.ReplaceAllTopics("owner", "name", _listOfTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics, null); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics); } [Fact] @@ -1407,7 +1407,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithEmptyTopics() await _client.ReplaceAllTopics(1234, _emptyTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _emptyTopics, null); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _emptyTopics); } [Fact] @@ -1416,7 +1416,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithListOfTopics() await _client.ReplaceAllTopics(1234, _listOfTopics); _connection.Received() - .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics, null); + .Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics); } } } diff --git a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs index de8f42424e..6d5160ec55 100644 --- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs @@ -208,7 +208,7 @@ public void RequestsTheCorrectUrl() client.UpdateBranchProtection("owner", "repo", "branch", update); connection.Received() - .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null); + .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>()); } [Fact] @@ -222,7 +222,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.UpdateBranchProtection(1, "branch", update); connection.Received() - .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null); + .Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>()); } [Fact] @@ -490,7 +490,7 @@ public void RequestsTheCorrectUrl() client.UpdateRequiredStatusChecksContexts("owner", "repo", "branch", update); connection.Received() - .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null); + .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -503,7 +503,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.UpdateRequiredStatusChecksContexts(1, "branch", update); connection.Received() - .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null); + .Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1057,8 +1057,7 @@ public void RequestsTheCorrectUrl() connection.Received() .Put<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), - Arg.Any<IReadOnlyList<string>>(), - null); + Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1073,8 +1072,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() connection.Received() .Put<IReadOnlyList<Team>>( Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), - Arg.Any<IReadOnlyList<string>>(), - null); + Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1264,7 +1262,7 @@ public void RequestsTheCorrectUrl() client.UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); connection.Received() - .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null); + .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>()); } [Fact] @@ -1277,7 +1275,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.UpdateProtectedBranchUserRestrictions(1, "branch", newUsers); connection.Received() - .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null); + .Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>()); } [Fact] diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index bd1f5d6ee8..803361991f 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -838,7 +838,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(string owner, string name, Ensure.ArgumentNotNull(topics, nameof(topics)); var endpoint = ApiUrls.RepositoryTopics(owner, name); - var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null).ConfigureAwait(false); + var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics).ConfigureAwait(false); return data ?? new RepositoryTopics(); } @@ -860,7 +860,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(long repositoryId, Reposito Ensure.ArgumentNotNull(topics, nameof(topics)); var endpoint = ApiUrls.RepositoryTopics(repositoryId); - var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null).ConfigureAwait(false); + var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics).ConfigureAwait(false); return data ?? new RepositoryTopics(); } diff --git a/Octokit/Clients/RepositoryBranchesClient.cs b/Octokit/Clients/RepositoryBranchesClient.cs index 852bc5bb34..8126fc0ea6 100644 --- a/Octokit/Clients/RepositoryBranchesClient.cs +++ b/Octokit/Clients/RepositoryBranchesClient.cs @@ -175,7 +175,7 @@ public Task<BranchProtectionSettings> UpdateBranchProtection(string owner, strin Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, null); + return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update); } /// <summary> @@ -193,7 +193,7 @@ public Task<BranchProtectionSettings> UpdateBranchProtection(long repositoryId, Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null); + return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update); } /// <summary> @@ -431,7 +431,7 @@ public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null); + return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts); } /// <summary> @@ -449,7 +449,7 @@ public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(long repos Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null); + return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts); } /// <summary> @@ -927,7 +927,7 @@ public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null); + return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams); } /// <summary> @@ -945,7 +945,7 @@ public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null); + return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams); } /// <summary> @@ -1079,7 +1079,7 @@ public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null); + return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users); } /// <summary> @@ -1097,7 +1097,7 @@ public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null); + return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users); } /// <summary> From 536e5c373709df261cf01c9f9cfb13b9c26ae461 Mon Sep 17 00:00:00 2001 From: notauserx <82922717+notauserx@users.noreply.github.com> Date: Sat, 6 Aug 2022 03:44:17 +0600 Subject: [PATCH 100/209] feat: adds active lock reason to issue (#2525) --- .../Clients/IObservableIssuesClient.cs | 6 +++-- .../Clients/ObservableIssuesClient.cs | 10 ++++--- .../Clients/IssuesClientTests.cs | 14 ++++++++++ Octokit.Tests/Models/IssueTest.cs | 6 +++-- Octokit/Clients/IIssuesClient.cs | 6 +++-- Octokit/Clients/IssuesClient.cs | 10 ++++--- Octokit/Models/Common/LockReason.cs | 26 +++++++++++++++++++ Octokit/Models/Response/Issue.cs | 9 ++++++- 8 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 Octokit/Models/Common/LockReason.cs diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs index 8abef9a88a..3081488e98 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs @@ -324,7 +324,8 @@ public interface IObservableIssuesClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> - IObservable<Unit> Lock(string owner, string name, int number); + /// <param name="lockReason">The reason for locking the issue</param> + IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null); /// <summary> /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. @@ -332,7 +333,8 @@ public interface IObservableIssuesClient /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> - IObservable<Unit> Lock(long repositoryId, int number); + /// <param name="lockReason">The reason for locking the issue</param> + IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null); /// <summary> /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index 3b96237c89..2f2df7c915 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -480,12 +480,13 @@ public IObservable<Issue> Update(long repositoryId, int number, IssueUpdate issu /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> - public IObservable<Unit> Lock(string owner, string name, int number) + /// <param name="lockReason">The reason for locking the issue</param> + public IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return _client.Lock(owner, name, number).ToObservable(); + return _client.Lock(owner, name, number, lockReason).ToObservable(); } /// <summary> @@ -494,9 +495,10 @@ public IObservable<Unit> Lock(string owner, string name, int number) /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> - public IObservable<Unit> Lock(long repositoryId, int number) + /// <param name="lockReason">The reason for locking the issue</param> + public IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null) { - return _client.Lock(repositoryId, number).ToObservable(); + return _client.Lock(repositoryId, number, lockReason).ToObservable(); } /// <summary> diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 88a793f200..16bf28f76f 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -252,6 +252,20 @@ public async Task CanLockAndUnlockIssue() Assert.False(retrieved.Locked); } + [IntegrationTest] + public async Task CanAccessActiveLockReason() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + Assert.False(issue.Locked); + + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number, LockReason.OffTopic); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.True(retrieved.Locked); + Assert.Equal(retrieved.ActiveLockReason, LockReason.OffTopic); + } + [IntegrationTest] public async Task CanLockAndUnlockIssueWithRepositoryId() { diff --git a/Octokit.Tests/Models/IssueTest.cs b/Octokit.Tests/Models/IssueTest.cs index b55b4e416d..7d0e910f5e 100644 --- a/Octokit.Tests/Models/IssueTest.cs +++ b/Octokit.Tests/Models/IssueTest.cs @@ -120,8 +120,9 @@ public void CanBeDeserialized() ""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 -} +""site_admin"": false, +}, +""active_lock_reason"": null }"; var serializer = new SimpleJsonSerializer(); @@ -130,6 +131,7 @@ public void CanBeDeserialized() Assert.Equal(1347, issue.Number); Assert.Equal("octocat", issue.User.Login); Assert.Equal("bug", issue.Labels.First().Name); + Assert.Null(issue.ActiveLockReason); } public class TheToUpdateMethod diff --git a/Octokit/Clients/IIssuesClient.cs b/Octokit/Clients/IIssuesClient.cs index 4a71cc86fc..63f5611d09 100644 --- a/Octokit/Clients/IIssuesClient.cs +++ b/Octokit/Clients/IIssuesClient.cs @@ -321,7 +321,8 @@ public interface IIssuesClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> - Task Lock(string owner, string name, int number); + /// <param name="lockReason">The reason for locking the issue</param> + Task Lock(string owner, string name, int number, LockReason? lockReason = null); /// <summary> /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. @@ -329,7 +330,8 @@ public interface IIssuesClient /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> - Task Lock(long repositoryId, int number); + /// <param name="lockReason">The reason for locking the issue</param> + Task Lock(long repositoryId, int number, LockReason? lockReason = null); /// <summary> /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 06a0fbf30b..508e6c2180 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -500,13 +500,14 @@ public Task<Issue> Update(long repositoryId, int number, IssueUpdate issueUpdate /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> [ManualRoute("PUT", "/repos/{owner}/{repo}/issues/{issue_number}/lock")] - public Task Lock(string owner, string name, int number) + public Task Lock(string owner, string name, int number, LockReason? lockReason = null) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.Put<Issue>(ApiUrls.IssueLock(owner, name, number), new object()); + return ApiConnection.Put<Issue>(ApiUrls.IssueLock(owner, name, number), lockReason.HasValue ? new { LockReason = lockReason } : new object()); } /// <summary> @@ -515,10 +516,11 @@ public Task Lock(string owner, string name, int number) /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> [ManualRoute("PUT", "/repositories/{id}/issues/{number}/lock")] - public Task Lock(long repositoryId, int number) + public Task Lock(long repositoryId, int number, LockReason? lockReason = null) { - return ApiConnection.Put<Issue>(ApiUrls.IssueLock(repositoryId, number), new object()); + return ApiConnection.Put<Issue>(ApiUrls.IssueLock(repositoryId, number), lockReason.HasValue ? new { LockReaons = lockReason } : new object()); } /// <summary> diff --git a/Octokit/Models/Common/LockReason.cs b/Octokit/Models/Common/LockReason.cs new file mode 100644 index 0000000000..1f13621928 --- /dev/null +++ b/Octokit/Models/Common/LockReason.cs @@ -0,0 +1,26 @@ +using Octokit.Internal; + +namespace Octokit +{ + /// <summary> + /// The possible reasons that an issue or pull request was locked. + /// </summary> + public enum LockReason + { + // The issue or pull request was locked because the conversation was off-topic. + [Parameter(Value = "off-topic")] + OffTopic, + + // The issue or pull request was locked because the conversation was resolved. + [Parameter(Value = "resolved")] + Resolved, + + // The issue or pull request was locked because the conversation was spam. + [Parameter(Value = "spam")] + Spam, + + // The issue or pull request was locked because the conversation was too heated. + [Parameter(Value = "too heated")] + TooHeated + } +} diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index 4a0add46fa..0a33673c56 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.Linq; + namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] @@ -11,7 +12,7 @@ public class Issue { public Issue() { } - public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList<Label> labels, User assignee, IReadOnlyList<User> assignees, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, string nodeId, bool locked, Repository repository, ReactionSummary reactions) + public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList<Label> labels, User assignee, IReadOnlyList<User> assignees, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, string nodeId, bool locked, Repository repository, ReactionSummary reactions, LockReason? activeLockReason) { Id = id; NodeId = nodeId; @@ -37,6 +38,7 @@ public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, i Locked = locked; Repository = repository; Reactions = reactions; + ActiveLockReason = activeLockReason; } /// <summary> @@ -156,6 +158,11 @@ public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, i /// </summary> public ReactionSummary Reactions { get; protected set; } + /// <summary> + /// Reason that the conversation was locked. + /// </summary> + public StringEnum<LockReason>? ActiveLockReason { get; protected set; } + internal string DebuggerDisplay { get From 879c3e53dd20ea43fa4ddc4049ae4f7fcb0ff28b Mon Sep 17 00:00:00 2001 From: Idan Ben Dror <idanbendror@apiiro.com> Date: Sun, 7 Aug 2022 11:44:56 +0300 Subject: [PATCH 101/209] ActivityPayload related changes --- .../ActivityPayloads/ActivityWithActionPayload.cs | 10 ++++++++++ .../Response/ActivityPayloads/CheckRunEventPayload.cs | 3 +-- .../ActivityPayloads/CheckSuiteEventPayload.cs | 3 +-- .../ActivityPayloads/InstallationEventPayload.cs | 11 +++++++++++ .../Response/ActivityPayloads/IssueCommentPayload.cs | 3 +-- .../Response/ActivityPayloads/IssueEventPayload.cs | 3 +-- .../ActivityPayloads/PullRequestCommentPayload.cs | 3 +-- .../ActivityPayloads/PullRequestEventPayload.cs | 3 +-- .../ActivityPayloads/PullRequestReviewEventPayload.cs | 3 +-- .../Response/ActivityPayloads/ReleaseEventPayload.cs | 4 +--- .../Response/ActivityPayloads/StarredEventPayload.cs | 3 +-- Octokit/Octokit.csproj | 2 +- 12 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 Octokit/Models/Response/ActivityPayloads/ActivityWithActionPayload.cs create mode 100644 Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityWithActionPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityWithActionPayload.cs new file mode 100644 index 0000000000..8a568d41f5 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/ActivityWithActionPayload.cs @@ -0,0 +1,10 @@ +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class ActivityWithActionPayload : ActivityPayload + { + public string Action { get; protected set; } + } +} diff --git a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs index 9bc83e6f84..b610d549da 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs @@ -3,9 +3,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunEventPayload : ActivityPayload + public class CheckRunEventPayload : ActivityWithActionPayload { - public string Action { get; protected set; } public CheckRun CheckRun { get; protected set; } public CheckRunRequestedAction RequestedAction { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs index 3a0d324d8a..c922e6b3f6 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs @@ -3,9 +3,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuiteEventPayload : ActivityPayload + public class CheckSuiteEventPayload : ActivityWithActionPayload { - public string Action { get; protected set; } public CheckSuite CheckSuite { get; protected set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs new file mode 100644 index 0000000000..bfea8006fd --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class InstallationEventPayload : ActivityWithActionPayload + { + public IReadOnlyCollection<Repository> Repositories { get; set; } + } +} diff --git a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs index 0b2989df36..935fcff071 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs @@ -3,10 +3,9 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class IssueCommentPayload : ActivityPayload + public class IssueCommentPayload : ActivityWithActionPayload { // should always be "created" according to github api docs - public string Action { get; protected set; } public Issue Issue { get; protected set; } public IssueComment Comment { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs index 1f40a122df..f22693389a 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs @@ -3,9 +3,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class IssueEventPayload : ActivityPayload + public class IssueEventPayload : ActivityWithActionPayload { - public string Action { get; protected set; } public Issue Issue { get; protected set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs index 026935e018..df8a4c620e 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs @@ -3,9 +3,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestCommentPayload : ActivityPayload + public class PullRequestCommentPayload : ActivityWithActionPayload { - public string Action { get; protected set; } public PullRequest PullRequest { get; protected set; } public PullRequestReviewComment Comment { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs index ebaf48de57..73a1f326d7 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs @@ -3,9 +3,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestEventPayload : ActivityPayload + public class PullRequestEventPayload : ActivityWithActionPayload { - public string Action { get; protected set; } public int Number { get; protected set; } public PullRequest PullRequest { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs index c0a7b10b5d..80693881f8 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs @@ -3,9 +3,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestReviewEventPayload : ActivityPayload + public class PullRequestReviewEventPayload : ActivityWithActionPayload { - public string Action { get; protected set; } public PullRequest PullRequest { get; protected set; } public PullRequestReview Review { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs index ffaac4cc76..a6903e3802 100644 --- a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs @@ -3,10 +3,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class ReleaseEventPayload : ActivityPayload + public class ReleaseEventPayload : ActivityWithActionPayload { - public string Action { get; protected set; } - public Release Release { get; protected set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs index 7bc43a2aac..ab55890c9d 100644 --- a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs @@ -3,8 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class StarredEventPayload : ActivityPayload + public class StarredEventPayload : ActivityWithActionPayload { - public string Action { get; protected set; } } } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index c070cfc6a3..3d7159cb59 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.5</Version> + <Version>1.0.6</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 5d4c928ee65430bc0be3db67c6fed0034a6006da Mon Sep 17 00:00:00 2001 From: Fredi Kats <fredikats@outlook.com> Date: Mon, 8 Aug 2022 19:18:06 +0400 Subject: [PATCH 102/209] docs: Update dotnet supported version in readme (#2532) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21b439b034..dd0de1d7e1 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Console.WriteLine(user.Followers + " folks love the half ogre!"); ## Supported Platforms -* .NET 4.6 (Desktop / Server) or greater +* .NET 4.6.1 (Desktop / Server) or greater * [.NET Standard 2.0](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) or greater ## Getting Started From 651d9818c745383501048fe0ee5a1daa6dc94de7 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Mon, 8 Aug 2022 16:20:37 +0100 Subject: [PATCH 103/209] ci(build): Fixes a number of warnings for a cleaner build (#2529) * Fixing a number of warnings for a cleaner build * Removing extra Summary slashes --- .../Clients/IObservableReactionsClient.cs | 8 -------- .../Clients/ObservableReactionsClient.cs | 11 ----------- .../Clients/RepositoriesClientTests.cs | 2 -- Octokit.Tests/Clients/ReactionsClientTests.cs | 14 -------------- Octokit.Tests/Exceptions/ApiExceptionTests.cs | 3 ++- .../Reactive/ObservableReactionsClientTests.cs | 14 -------------- Octokit/Clients/IReactionsClient.cs | 8 -------- Octokit/Clients/ReactionsClient.cs | 13 ------------- Octokit/Exceptions/ApiException.cs | 6 ++++-- Octokit/Helpers/ApiUrls.cs | 8 +++++++- Octokit/Models/Response/Repository.cs | 2 ++ 11 files changed, 15 insertions(+), 74 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index 2cedf69afd..c07a44d8eb 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -36,13 +36,5 @@ public interface IObservableReactionsClient /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// </remarks> IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } - - /// <summary> - /// Delete a reaction. - /// </summary> - /// <remarks>https://developer.github.com/v3/reactions/#delete-a-reaction</remarks> - /// <param name="number">The reaction id</param> - /// <returns></returns> - IObservable<Unit> Delete(int number); } } diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index 8cf793931d..509bff62c2 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -51,16 +51,5 @@ public ObservableReactionsClient(IGitHubClient client) /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// </remarks> public IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } - - /// <summary> - /// Delete a reaction. - /// </summary> - /// <remarks>https://developer.github.com/v3/reactions/#delete-a-reaction</remarks> - /// <param name="number">The reaction id</param> - /// <returns></returns> - public IObservable<Unit> Delete(int number) - { - return _client.Delete(number).ToObservable(); - } } } diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index 0492ffa1b4..b45c63d9c0 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -879,7 +879,6 @@ public async Task ReturnsSpecifiedRepository() Assert.False(repository.Private); Assert.False(repository.Fork); Assert.Equal(AccountType.User, repository.Owner.Type); - Assert.True(repository.WatchersCount > 0); } [IntegrationTest] @@ -894,7 +893,6 @@ public async Task ReturnsSpecifiedRepositoryWithRepositoryId() Assert.False(repository.Private); Assert.False(repository.Fork); Assert.Equal(AccountType.User, repository.Owner.Type); - Assert.True(repository.WatchersCount > 0); } [IntegrationTest] diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs index 6e311e53fe..fda4b5d909 100644 --- a/Octokit.Tests/Clients/ReactionsClientTests.cs +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -15,19 +15,5 @@ public void EnsuresNonNullArguments() Assert.Throws<ArgumentNullException>(() => new ReactionsClient(null)); } } - - public class TheDeleteMethod - { - [Fact] - public async Task DeletesCorrectUrl() - { - var connection = Substitute.For<IApiConnection>(); - var client = new ReactionsClient(connection); - - await client.Delete(42); - - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "reactions/42"), Arg.Any<object>()); - } - } } } diff --git a/Octokit.Tests/Exceptions/ApiExceptionTests.cs b/Octokit.Tests/Exceptions/ApiExceptionTests.cs index 7daa4aec38..e9ef9ec678 100644 --- a/Octokit.Tests/Exceptions/ApiExceptionTests.cs +++ b/Octokit.Tests/Exceptions/ApiExceptionTests.cs @@ -108,7 +108,8 @@ public void CanPopulateObjectFromSerializedData() var formatter = new BinaryFormatter(); formatter.Serialize(stream, exception); stream.Position = 0; - var deserialized = (ApiException)formatter.Deserialize(stream); + var deserializedObject = formatter.Deserialize(stream); + var deserialized = (ApiException)deserializedObject; Assert.Equal("Validation Failed", deserialized.ApiError.Message); Assert.Equal("key is already in use", exception.ApiError.Errors.First().Message); } diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs index 054fe574dc..7dc503fdae 100644 --- a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs @@ -17,19 +17,5 @@ public void EnsuresNonNullArguments() Assert.Throws<ArgumentNullException>(() => new ObservableReactionsClient(null)); } } - - public class TheDeleteMethod - { - [Fact] - public void PostsToCorrectUrl() - { - var gitHubClient = Substitute.For<IGitHubClient>(); - var client = new ObservableReactionsClient(gitHubClient); - - client.Delete(13); - - gitHubClient.Reaction.Received().Delete(13); - } - } } } diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index fbf765691a..1a67bfa5a3 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -41,13 +41,5 @@ public interface IReactionsClient /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// </remarks> IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } - - /// <summary> - /// Delete a reaction. - /// </summary> - /// <remarks>https://developer.github.com/v3/reactions/#delete-a-reaction</remarks> - /// <param name="number">The reaction id</param> - /// <returns></returns> - Task Delete(int number); } } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 4d1f3947a6..a42dfbf81b 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -49,18 +49,5 @@ public ReactionsClient(IApiConnection apiConnection) /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// </remarks> public IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } - - /// <summary> - /// Delete a reaction. - /// </summary> - /// <remarks>https://developer.github.com/v3/reactions/#delete-a-reaction</remarks> - /// <param name="number">The reaction id</param> - /// <returns></returns> - [ManualRoute("DELETE", "/reactions/{reaction_id}")] - [Obsolete("This route no longer works and is replaced with individual routes in each client")] - public Task Delete(int number) - { - return ApiConnection.Delete(ApiUrls.Reactions(number), new object()); - } } } diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 9c99713605..91f255975d 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -25,7 +25,9 @@ public class ApiException : Exception /// <summary> /// Constructs an instance of ApiException /// </summary> +#pragma warning disable CS0618 // Response() is obsolete but we need this as a default as Response passed down cannot be null public ApiException() : this(new Response()) +#pragma warning restore CS0618 // Response() is obsolete but we need this as a default as Response passed down cannot be null { } @@ -202,8 +204,8 @@ protected string HttpResponseBodySafe { return HttpResponse?.ContentType != null && !HttpResponse.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase) - && HttpResponse.Body is string - ? (string)HttpResponse.Body : string.Empty; + && HttpResponse.Body is string @string + ? @string : string.Empty; } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 098de9c8ef..be9f561037 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -109,7 +109,7 @@ public static Uri AllOrganizations() /// <summary> /// Returns the <see cref="Uri"/> that returns all of the organizations. /// </summary> - /// /// <param name="since">The integer Id of the last Organization that you’ve seen.</param> + /// <param name="since">The integer Id of the last Organization that you’ve seen.</param> /// <returns></returns> public static Uri AllOrganizations(long since) { @@ -485,6 +485,7 @@ public static Uri IssueReactions(long repositoryId, int number) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue number</param> + /// <param name="reaction">The reactionid for the issue</param> /// <returns></returns> public static Uri IssueReaction(string owner, string name, int number, int reaction) { @@ -496,6 +497,7 @@ public static Uri IssueReaction(string owner, string name, int number, int react /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> + /// <param name="reaction">The reactionid for the issue</param> /// <returns></returns> public static Uri IssueReaction(long repositoryId, int number, int reaction) { @@ -589,6 +591,7 @@ public static Uri IssueCommentReactions(long repositoryId, int number) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment number</param> + /// <param name="reaction">The reactionid for the comment</param> /// <returns></returns> public static Uri IssueCommentReaction(string owner, string name, int number, int reaction) { @@ -600,6 +603,7 @@ public static Uri IssueCommentReaction(string owner, string name, int number, in /// </summary> /// <param name="repositoryId">The owner of the repository</param> /// <param name="number">The comment number</param> + /// <param name="reaction">The reactionid for the comment</param> /// <returns></returns> public static Uri IssueCommentReaction(long repositoryId, int number, int reaction) { @@ -1705,6 +1709,7 @@ public static Uri PullRequestReviewCommentReactions(long repositoryId, int numbe /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment number</param> + /// <param name="reaction">The reactionid for the comment</param> /// <returns></returns> public static Uri PullRequestReviewCommentReaction(string owner, string name, int number, int reaction) { @@ -1716,6 +1721,7 @@ public static Uri PullRequestReviewCommentReaction(string owner, string name, in /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment number</param> + /// <param name="reaction">The reactionid for the comment</param> /// <returns></returns> public static Uri PullRequestReviewCommentReaction(long repositoryId, int number, int reaction) { diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index a017d694a0..33e53e1a56 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -58,7 +58,9 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st AllowSquashMerge = allowSquashMerge; AllowMergeCommit = allowMergeCommit; Archived = archived; +#pragma warning disable CS0618 // Type or member is obsolete WatchersCount = watchersCount; +#pragma warning restore CS0618 // Type or member is obsolete Topics = topics.ToList(); DeleteBranchOnMerge = deleteBranchOnMerge; Visibility = visibility; From eaef1eee2610c52e5a4ebd6e9fae25cb56c0218f Mon Sep 17 00:00:00 2001 From: Stefan <29021710+Saalvage@users.noreply.github.com> Date: Mon, 8 Aug 2022 17:27:46 +0200 Subject: [PATCH 104/209] feat: Adds AsyncPaginationExtensions (#2516) --- .../Extensions.cs | 870 ++++++++++++++++++ .../IPaginatedList.cs | 27 + Octokit.AsyncPaginationExtension/LazyList.cs | 40 + .../Octokit.AsyncPaginationExtension.csproj | 40 + .../PaginatedList.cs | 44 + .../AsyncEnumerableExtensionTests.cs | 81 ++ Octokit.Tests/Octokit.Tests.csproj | 1 + Octokit.sln | 6 + 8 files changed, 1109 insertions(+) create mode 100644 Octokit.AsyncPaginationExtension/Extensions.cs create mode 100644 Octokit.AsyncPaginationExtension/IPaginatedList.cs create mode 100644 Octokit.AsyncPaginationExtension/LazyList.cs create mode 100644 Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj create mode 100644 Octokit.AsyncPaginationExtension/PaginatedList.cs create mode 100644 Octokit.Tests/AsyncEnumerableExtensionTests.cs diff --git a/Octokit.AsyncPaginationExtension/Extensions.cs b/Octokit.AsyncPaginationExtension/Extensions.cs new file mode 100644 index 0000000000..2781ce2ea6 --- /dev/null +++ b/Octokit.AsyncPaginationExtension/Extensions.cs @@ -0,0 +1,870 @@ +using System; +using System.Collections.Generic; + +namespace Octokit.AsyncPaginationExtension +{ + /// <summary> + /// Provides all extensions for pagination. + /// </summary> + /// <remarks> + /// The <code>pageSize</code> parameter at the end of all methods allows for specifying the amount of elements to be fetched per page. + /// Only useful to optimize the amount of API calls made. + /// </remarks> + public static class Extensions + { + private const int DEFAULT_PAGE_SIZE = 30; + + /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IAuthorizationsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Authorization> GetAllAsync(this IAuthorizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Authorization>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(string, string, long, ApiOptions)"/> + public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, string owner, string name, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(owner, name, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(long, long, ApiOptions)"/> + public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, long repositoryId, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(repositoryId, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="ICommitStatusClient.GetAll(string, string, string, ApiOptions)"/> + public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, string owner, string name, string reference, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitStatus>(options => t.GetAll(owner, name, reference, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICommitStatusClient.GetAll(long, string, ApiOptions)"/> + public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, long repositoryId, string reference, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitStatus>(options => t.GetAll(repositoryId, reference, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IDeploymentsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IDeploymentsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IDeploymentStatusClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, string owner, string name, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(owner, name, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IDeploymentStatusClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, long repositoryId, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(repositoryId, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IEventsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Activity> GetAllAsync(this IEventsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForRepositoryNetwork(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryNetworkAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepositoryNetwork(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForOrganizationAsync(this IEventsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserReceived(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserReceivedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceived(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserReceivedPublic(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserReceivedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceivedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserPerformed(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserPerformedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformed(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserPerformedPublic(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserPerformedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForAnOrganization(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForAnOrganizationAsync(this IEventsClient t, string user, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForAnOrganization(user, organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IFollowersClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<User> GetAllForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IFollowersClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IFollowersClient.GetAllFollowingForCurrent(ApiOptions)"/> + public static IPaginatedList<User> GetAllFollowingForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(t.GetAllFollowingForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IFollowersClient.GetAllFollowing(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllFollowingAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllFollowing(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IGistCommentsClient.GetAllForGist(string, ApiOptions)"/> + public static IPaginatedList<GistComment> GetAllForGistAsync(this IGistCommentsClient t, string gistId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GistComment>(options => t.GetAllForGist(gistId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IGistsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Gist> GetAllAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAll(DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAll(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllPublic(ApiOptions)"/> + public static IPaginatedList<Gist> GetAllPublicAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(t.GetAllPublic, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllPublic(DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllPublicAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllPublic(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllStarred(ApiOptions)"/> + public static IPaginatedList<Gist> GetAllStarredAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(t.GetAllStarred, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllStarred(DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllStarredAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllStarred(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllForUserAsync(this IGistsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllForUser(string, DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllForUserAsync(this IGistsClient t, string user, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllForUser(user, since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllCommits(string, ApiOptions)"/> + public static IPaginatedList<GistHistory> GetAllCommitsAsync(this IGistsClient t, string id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GistHistory>(options => t.GetAllCommits(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllForks(string, ApiOptions)"/> + public static IPaginatedList<GistFork> GetAllForksAsync(this IGistsClient t, string id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GistFork>(options => t.GetAllForks(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IGitHubAppsClient.GetAllInstallationsForCurrent(ApiOptions)"/> + public static IPaginatedList<Installation> GetAllInstallationsForCurrentAsync(this IGitHubAppsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Installation>(t.GetAllInstallationsForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(string, string, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, string owner, string name, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(long, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, long repositoryId, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(string, string, int, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, string owner, string name, int number, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(owner, name, number, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(long, int, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, long repositoryId, int number, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(repositoryId, number, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IIssueReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForOwnedAndMemberRepositories, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOwnedAndMemberRepositories(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, RepositoryIssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, RepositoryIssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForIssueAsync(this IIssuesLabelsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForIssueAsync(this IIssuesLabelsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForRepositoryAsync(this IIssuesLabelsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForRepositoryAsync(this IIssuesLabelsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForMilestone(string, string, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForMilestone(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForMilestone(long, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForMilestone(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, string owner, string repo, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(owner, repo, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, MilestoneRequest, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, MilestoneRequest, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IMiscellaneousClient.GetAllLicenses(ApiOptions)"/> + public static IPaginatedList<LicenseMetadata> GetAllLicensesAsync(this IMiscellaneousClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<LicenseMetadata>(t.GetAllLicenses, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IOrganizationHooksClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<OrganizationHook> GetAllAsync(this IOrganizationHooksClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationHook>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersRole, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, OrganizationMembersRole, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllPublic(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllPublicAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllPublic(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllPendingInvitations(string, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IOrganizationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Organization> GetAllForCurrentAsync(this IOrganizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Organization>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationsClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Organization> GetAllForUserAsync(this IOrganizationsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Organization>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IProjectCardsClient.GetAll(int, ApiOptions)"/> + public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ProjectCard>(options => t.GetAll(columnId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectCardsClient.GetAll(int, ProjectCardRequest, ApiOptions)"/> + public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, ProjectCardRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ProjectCard>(options => t.GetAll(columnId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IProjectColumnsClient.GetAll(int, ApiOptions)"/> + public static IPaginatedList<ProjectColumn> GetAllAsync(this IProjectColumnsClient t, int projectId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ProjectColumn>(options => t.GetAll(projectId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(string, string, ProjectRequest, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, string owner, string name, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(long, ProjectRequest, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, long repositoryId, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForOrganization(string, ProjectRequest, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsClient t, string organization, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, PullRequestReviewCommentRequest, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, PullRequestReviewCommentRequest, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(string, string, int, long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, string owner, string name, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(owner, name, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(long, int, long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, long repositoryId, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(repositoryId, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, PullRequestRequest, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, PullRequestRequest, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IReferencesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReferencesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(string, string, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, string owner, string name, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(owner, name, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(long, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, long repositoryId, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(repositoryId, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IReleasesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReleasesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReleasesClient.GetAllAssets(string, string, int, ApiOptions)"/> + public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, string owner, string name, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(owner, name, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReleasesClient.GetAllAssets(long, int, ApiOptions)"/> + public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, long repositoryId, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(repositoryId, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, RepositoryCollaboratorListRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, RepositoryCollaboratorListRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(RepositoryRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, RepositoryRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IRepositoriesClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForOrg(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForOrgAsync(this IRepositoriesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForOrg(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, bool, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, bool, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(string, string, ApiOptions)"/> + public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(long, ApiOptions)"/> + public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTags(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTags(long, ApiOptions)"/> + public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(string, string, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, string owner, string name, string sha, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(owner, name, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(long, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, long repositoryId, string sha, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(repositoryId, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, CommitRequest, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, CommitRequest, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(string, string, RepositoryForksListRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, string owner, string name, RepositoryForksListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(long, RepositoryForksListRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, long repositoryId, RepositoryForksListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryHooksClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryHooksClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<RepositoryInvitation> GetAllForCurrentAsync(this IRepositoryInvitationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<RepositoryInvitation> GetAllForRepositoryAsync(this IRepositoryInvitationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IRepositoryPagesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryPagesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IStarredClient.GetAllStargazers(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllStargazersAsync(this IStarredClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllStargazers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllStargazers(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllStargazersAsync(this IStarredClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllStargazers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllStargazersWithTimestamps(string, string, ApiOptions)"/> + public static IPaginatedList<UserStar> GetAllStargazersWithTimestampsAsync(this IStarredClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<UserStar>(options => t.GetAllStargazersWithTimestamps(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllStargazersWithTimestamps(long, ApiOptions)"/> + public static IPaginatedList<UserStar> GetAllStargazersWithTimestampsAsync(this IStarredClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<UserStar>(options => t.GetAllStargazersWithTimestamps(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IStarredClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrentWithTimestamps(ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForCurrentWithTimestampsAsync(this IStarredClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(t.GetAllForCurrentWithTimestamps, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrent(StarredRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IStarredClient t, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrentWithTimestamps(StarredRequest, ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForCurrentWithTimestampsAsync(this IStarredClient t, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForCurrentWithTimestamps(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IStarredClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUserWithTimestamps(string, ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForUserWithTimestampsAsync(this IStarredClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForUserWithTimestamps(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUser(string, StarredRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IStarredClient t, string user, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUserWithTimestamps(string, StarredRequest, ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForUserWithTimestampsAsync(this IStarredClient t, string user, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForUserWithTimestamps(user, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="ITeamsClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<Team> GetAllAsync(this ITeamsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Team> GetAllForCurrentAsync(this ITeamsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllChildTeams(int, ApiOptions)"/> + public static IPaginatedList<Team> GetAllChildTeamsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllChildTeams(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, ApiOptions)"/> + public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, TeamMembersRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, TeamMembersRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllRepositories(int, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllRepositoriesAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllRepositories(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllPendingInvitations(int, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IUserEmailsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<EmailAddress> GetAllAsync(this IUserEmailsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<EmailAddress>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IUserGpgKeysClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<GpgKey> GetAllForCurrentAsync(this IUserGpgKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GpgKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IUserKeysClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<PublicKey> GetAllAsync(this IUserKeysClient t, string userName, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PublicKey>(options => t.GetAll(userName, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserKeysClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<PublicKey> GetAllForCurrentAsync(this IUserKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PublicKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IWatchedClient.GetAllWatchers(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllWatchers(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IWatchedClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IWatchedClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IApiConnection.GetAll(Uri, ApiOptions)"/> + public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IApiConnection.GetAll(Uri, IDictionary{string, string}, ApiOptions)"/> + public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, IDictionary<string, string> parameters, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, parameters, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IApiConnection.GetAll(Uri, IDictionary{string, string}, string, ApiOptions)"/> + public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, IDictionary<string, string> parameters, string accepts, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, parameters, accepts, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IEnterprisePreReceiveEnvironmentsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<PreReceiveEnvironment> GetAllAsync(this IEnterprisePreReceiveEnvironmentsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PreReceiveEnvironment>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + + /// <inheritdoc cref="IEnterprisePreReceiveHooksClient.GetAll(ApiOptions)"/> + public static IPaginatedList<PreReceiveHook> GetAllAsync(this IEnterprisePreReceiveHooksClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PreReceiveHook>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + } +} diff --git a/Octokit.AsyncPaginationExtension/IPaginatedList.cs b/Octokit.AsyncPaginationExtension/IPaginatedList.cs new file mode 100644 index 0000000000..264ec6bc41 --- /dev/null +++ b/Octokit.AsyncPaginationExtension/IPaginatedList.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit.AsyncPaginationExtension +{ + /// <summary> + /// <cref cref="IAsyncEnumerable{T}"/> additionally allowing for random access. + /// </summary> + /// <remarks> + /// <para> + /// Intended to abstract from a series of a API calls requiring pagination. + /// </para> + /// <para> + /// Intended to be implemented supporting caching, making repeated enumerations not require any API calls. + /// </para> + /// </remarks> + /// <typeparam name="T">The type of values to access.</typeparam> + public interface IPaginatedList<T> : IAsyncEnumerable<T> + { + /// <summary> + /// Gets a value at the specified index. + /// </summary> + /// <param name="index">The index at which to fetch the value.</param> + /// <returns>The value at the specified index or null if it is outside of the range.</returns> + public Task<T?> this[int index] { get; } + } +} diff --git a/Octokit.AsyncPaginationExtension/LazyList.cs b/Octokit.AsyncPaginationExtension/LazyList.cs new file mode 100644 index 0000000000..6bcc0f7c74 --- /dev/null +++ b/Octokit.AsyncPaginationExtension/LazyList.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Linq; +using System; +using System.Collections; + +namespace Octokit.AsyncPaginationExtension +{ + internal class LazyList<T> : IReadOnlyList<T> + { + private readonly Func<int, T> _generator; + private readonly List<T?> _list = new(); + + public LazyList(Func<int, T> generator) + { + _generator = generator; + } + + public IEnumerator<T> GetEnumerator() + { + var i = 0; + while (true) yield return this[i++]; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public int Count => int.MaxValue; + + public T this[int index] + { + get + { + if (_list.Count <= index) _list.AddRange(Enumerable.Repeat<T?>(default, index - _list.Count + 1)); + return _list[index] ??= _generator(index); + } + } + } +} diff --git a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj new file mode 100644 index 0000000000..4c6ea5f302 --- /dev/null +++ b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj @@ -0,0 +1,40 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <Description>A set of extension methods for the GitHub API client library for .NET and .NET Core providing IAsyncEnumerable abstractions for paginated web requests</Description> + <AssemblyTitle>Octokit.AsyncPaginationExtension</AssemblyTitle> + <Authors>GitHub</Authors> + <Version>0.0.0-dev</Version> + <GenerateDocumentationFile>true</GenerateDocumentationFile> + <TargetFrameworks>netstandard2.0;net461</TargetFrameworks> + <AssemblyName>Octokit.AsyncPaginationExtension</AssemblyName> + <PackageId>Octokit.AsyncPaginationExtension</PackageId> + <DebugType>embedded</DebugType> + <RepositoryUrl>https://github.com/octokit/octokit.net</RepositoryUrl> + <PackageProjectUrl>https://github.com/octokit/octokit.net</PackageProjectUrl> + <PackageIconUrl>https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png</PackageIconUrl> + <PackageIcon>octokit.png</PackageIcon> + <PackageLicenseExpression>MIT</PackageLicenseExpression> + <PackageTags>GitHub API Octokit linqpad-samples dotnetcore</PackageTags> + <Copyright>Copyright GitHub 2017</Copyright> + <LangVersion>9</LangVersion> + <Nullable>enable</Nullable> + </PropertyGroup> + + <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> + <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> + </PropertyGroup> + + <ItemGroup Condition=" '$(TargetFramework)' == 'net461' "> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\Octokit\Octokit.csproj" /> + </ItemGroup> + +</Project> diff --git a/Octokit.AsyncPaginationExtension/PaginatedList.cs b/Octokit.AsyncPaginationExtension/PaginatedList.cs new file mode 100644 index 0000000000..67f0d08fa1 --- /dev/null +++ b/Octokit.AsyncPaginationExtension/PaginatedList.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Threading; +using System; + +namespace Octokit.AsyncPaginationExtension +{ + internal class PaginatedList<T> : IPaginatedList<T> + { + private readonly LazyList<Task<IReadOnlyList<T>>> _pages; + private readonly int _pageSize; + + internal PaginatedList(Func<ApiOptions, Task<IReadOnlyList<T>>> getPage, int pageSize) + { + _pages = new(i => getPage(new() + { + StartPage = i, + PageSize = pageSize, + })); + _pageSize = pageSize; + } + + private async Task<T?> Get(int index) + { + var page = await _pages[index / _pageSize].ConfigureAwait(false); + index %= _pageSize; + return page.Count > index ? page[index] : default; + } + + public Task<T?> this[int index] => index >= 0 ? Get(index) : throw new ArgumentOutOfRangeException(nameof(index), index, "The index must be positive."); + + public async IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = new()) + { + var pageNum = 0; + while (await _pages[pageNum++].ConfigureAwait(false) is { Count: > 0 } page) + { + foreach (var t in page) + { + yield return t; + } + } + } + } +} diff --git a/Octokit.Tests/AsyncEnumerableExtensionTests.cs b/Octokit.Tests/AsyncEnumerableExtensionTests.cs new file mode 100644 index 0000000000..77d5196196 --- /dev/null +++ b/Octokit.Tests/AsyncEnumerableExtensionTests.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.AsyncPaginationExtension; +using Xunit; + +namespace Octokit.Tests +{ + public class AsyncEnumerableExtensionTests + { + public class ThePaginatedList + { + [Fact] + public void RejectsInvalidValues() + { + var client = Substitute.For<IRepositoriesClient>(); + + Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => client.GetAllForOrgAsync("octokit")[-1]); + } + + [Fact] + public async Task ReturnsNullOnExceedingTotalSize() + { + var client = Substitute.For<IRepositoriesClient>(); + + Assert.Null(await client.GetAllForOrgAsync("octokit")[int.MaxValue]); + } + + [Fact] + public async Task EnumeratesCorrectValues() + { + var client = Substitute.For<IRepositoriesClient>(); + + var list = new List<Repository>(); + var enumerator = client.GetAllForOrgAsync("octokit").GetAsyncEnumerator(); + while (await enumerator.MoveNextAsync()) + { + list.Add(enumerator.Current); + } + + Assert.Equal(await client.GetAllForOrg("octokit"), list); + } + + [Fact] + public async Task HandlesZeroCorrectly() + { + var client = Substitute.For<IRepositoriesClient>(); + client.GetAllForOrg(Arg.Any<string>(), Arg.Any<ApiOptions>()) + .Returns(Enumerable.Repeat(new Repository(), 24).ToList()); + + Assert.NotNull(await client.GetAllForOrgAsync("octokit")[0]); + } + + [Fact] + public async Task HandlesPageEdgesCorrectly() + { + var client = Substitute.For<IRepositoriesClient>(); + client.GetAllForOrg(Arg.Any<string>(), Arg.Any<ApiOptions>()) + .Returns(Enumerable.Repeat(new Repository(), 5).ToList()); + + var repos = client.GetAllForOrgAsync("octokit", 5); + Assert.NotNull(await repos[4]); + Assert.NotNull(await repos[5]); + } + } + + public class ThePaginationOverloads + { + [Fact] + public void RejectInvalidValues() + { + var client = Substitute.For<IRepositoriesClient>(); + + Assert.Throws<ArgumentOutOfRangeException>(() => client.GetAllForUserAsync("fake", -1)); + Assert.Throws<ArgumentOutOfRangeException>(() => client.GetAllForUserAsync("fake", 0)); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 1ca561e217..3eb7e6c47a 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -28,6 +28,7 @@ <ItemGroup> <ProjectReference Include="..\Octokit\Octokit.csproj" /> <ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj" /> + <ProjectReference Include="..\Octokit.AsyncPaginationExtension\Octokit.AsyncPaginationExtension.csproj" /> <PackageReference Include="NSubstitute" Version="4.4.0" /> </ItemGroup> diff --git a/Octokit.sln b/Octokit.sln index cd54847945..43c06fa141 100644 --- a/Octokit.sln +++ b/Octokit.sln @@ -15,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Octokit.Tests.Integration", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{64FD6CD6-3714-4A7B-AF5A-B8E7DFEEC807}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Octokit.AsyncPaginationExtension", "Octokit.AsyncPaginationExtension\Octokit.AsyncPaginationExtension.csproj", "{0E8013E0-0CCF-4433-9E01-51AC288824C5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +43,10 @@ Global {EF19E577-D810-4357-BF95-9029A359CB4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF19E577-D810-4357-BF95-9029A359CB4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF19E577-D810-4357-BF95-9029A359CB4E}.Release|Any CPU.Build.0 = Release|Any CPU + {0E8013E0-0CCF-4433-9E01-51AC288824C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E8013E0-0CCF-4433-9E01-51AC288824C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E8013E0-0CCF-4433-9E01-51AC288824C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E8013E0-0CCF-4433-9E01-51AC288824C5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From bc156af4e654c706f7bafeccd069ed5f7c61a74b Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Tue, 9 Aug 2022 15:04:06 +0100 Subject: [PATCH 105/209] maint: Fixing the use of the binary formatter in net461 so all unit tests now pass. (#2535) --- Octokit.Tests/Clients/UsersClientTests.cs | 3 -- Octokit.Tests/Exceptions/ApiExceptionTests.cs | 20 +++-------- .../Exceptions/ApiValidationExceptionTests.cs | 19 +++------- .../RateLimitExceededExceptionTests.cs | 36 +++++++------------ .../Helpers/BindaryFormatterHelpers.cs | 34 ++++++++++++++++++ Octokit.Tests/Http/RateLimitTests.cs | 33 ++++++----------- 6 files changed, 65 insertions(+), 80 deletions(-) create mode 100644 Octokit.Tests/Helpers/BindaryFormatterHelpers.cs diff --git a/Octokit.Tests/Clients/UsersClientTests.cs b/Octokit.Tests/Clients/UsersClientTests.cs index 92b288b8f1..9b2bd03c22 100644 --- a/Octokit.Tests/Clients/UsersClientTests.cs +++ b/Octokit.Tests/Clients/UsersClientTests.cs @@ -1,7 +1,4 @@ using System; -#if NET_45 -using System.Collections.ObjectModel; -#endif using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; diff --git a/Octokit.Tests/Exceptions/ApiExceptionTests.cs b/Octokit.Tests/Exceptions/ApiExceptionTests.cs index e9ef9ec678..4783874ffd 100644 --- a/Octokit.Tests/Exceptions/ApiExceptionTests.cs +++ b/Octokit.Tests/Exceptions/ApiExceptionTests.cs @@ -2,11 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Net; -#if !NO_SERIALIZABLE -using System.Runtime.Serialization.Formatters.Binary; -using System.IO; -#endif using NSubstitute; +using Octokit.Tests.Helpers; using Xunit; using static Octokit.Internal.TestSetup; @@ -92,7 +89,6 @@ public void CreatesEmptyGitHubErrorWhenResponseBodyIsNull() Assert.Equal("message2", thirdException.ApiError.Message); } -#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { @@ -102,19 +98,11 @@ public void CanPopulateObjectFromSerializedData() @"already in use"",""resource"":""PublicKey""}],""message"":""Validation Failed""}"); var exception = new ApiException(response); + var deserialized = BinaryFormatterExtensions.SerializeAndDeserializeObject(exception); - using (var stream = new MemoryStream()) - { - var formatter = new BinaryFormatter(); - formatter.Serialize(stream, exception); - stream.Position = 0; - var deserializedObject = formatter.Deserialize(stream); - var deserialized = (ApiException)deserializedObject; - Assert.Equal("Validation Failed", deserialized.ApiError.Message); - Assert.Equal("key is already in use", exception.ApiError.Errors.First().Message); - } + Assert.Equal("Validation Failed", deserialized.ApiError.Message); + Assert.Equal("key is already in use", exception.ApiError.Errors.First().Message); } -#endif } public class TheToStringMethod diff --git a/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs b/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs index 00575f127e..b1f2746630 100644 --- a/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs +++ b/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs @@ -1,12 +1,9 @@ using System.Linq; using System.Net; -#if !NO_SERIALIZABLE -using System.Runtime.Serialization.Formatters.Binary; -using System.IO; -#endif using Xunit; using static Octokit.Internal.TestSetup; +using Octokit.Tests.Helpers; namespace Octokit.Tests.Exceptions { @@ -38,7 +35,6 @@ public void ProvidesDefaultMessage() Assert.Equal("Validation Failed", exception.Message); } -#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { @@ -48,18 +44,11 @@ public void CanPopulateObjectFromSerializedData() @"already in use"",""resource"":""PublicKey""}],""message"":""Validation Failed""}"); var exception = new ApiValidationException(response); + var deserialized = BinaryFormatterExtensions.SerializeAndDeserializeObject(exception); - using (var stream = new MemoryStream()) - { - var formatter = new BinaryFormatter(); - formatter.Serialize(stream, exception); - stream.Position = 0; - var deserialized = (ApiValidationException)formatter.Deserialize(stream); - Assert.Equal("Validation Failed", deserialized.ApiError.Message); - Assert.Equal("key is already in use", exception.ApiError.Errors.First().Message); - } + Assert.Equal("Validation Failed", deserialized.ApiError.Message); + Assert.Equal("key is already in use", exception.ApiError.Errors.First().Message); } -#endif } } } diff --git a/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs b/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs index fc6848a4a5..14aef82ae0 100644 --- a/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs +++ b/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs @@ -4,14 +4,10 @@ using System.Collections.Generic; using System.Globalization; using System.Net; -using System.Net.Http; -#if !NO_SERIALIZABLE -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -#endif using Xunit; using static Octokit.Internal.TestSetup; +using Octokit.Tests.Helpers; namespace Octokit.Tests.Exceptions { @@ -86,7 +82,6 @@ public void HandlesMissingHeaderValues() Assert.Equal(TimeSpan.Zero, exception.GetRetryAfterTimeSpan()); } -#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { @@ -99,24 +94,17 @@ public void CanPopulateObjectFromSerializedData() var exception = new RateLimitExceededException(response); - using (var stream = new MemoryStream()) - { - var formatter = new BinaryFormatter(); - formatter.Serialize(stream, exception); - stream.Position = 0; - var deserialized = (RateLimitExceededException)formatter.Deserialize(stream); - - Assert.Equal(HttpStatusCode.Forbidden, deserialized.StatusCode); - Assert.Equal(100, deserialized.Limit); - Assert.Equal(42, deserialized.Remaining); - var expectedReset = DateTimeOffset.ParseExact( - "Mon 01 Jul 2013 5:47:53 PM -00:00", - "ddd dd MMM yyyy h:mm:ss tt zzz", - CultureInfo.InvariantCulture); - Assert.Equal(expectedReset, deserialized.Reset); - } + var deserialized = BinaryFormatterExtensions.SerializeAndDeserializeObject(exception); + + Assert.Equal(HttpStatusCode.Forbidden, deserialized.StatusCode); + Assert.Equal(100, deserialized.Limit); + Assert.Equal(42, deserialized.Remaining); + var expectedReset = DateTimeOffset.ParseExact( + "Mon 01 Jul 2013 5:47:53 PM -00:00", + "ddd dd MMM yyyy h:mm:ss tt zzz", + CultureInfo.InvariantCulture); + Assert.Equal(expectedReset, deserialized.Reset); } -#endif } public class GetRetryAfterTimeSpanMethod @@ -153,7 +141,7 @@ public void ReturnsZeroIfSkewedResetInPast() { var beginTime = DateTimeOffset.Now; var resetTime = beginTime - TimeSpan.FromHours(1); - + var response = CreateResponse(HttpStatusCode.Forbidden, new Dictionary<string, string> { diff --git a/Octokit.Tests/Helpers/BindaryFormatterHelpers.cs b/Octokit.Tests/Helpers/BindaryFormatterHelpers.cs new file mode 100644 index 0000000000..aa1314a04b --- /dev/null +++ b/Octokit.Tests/Helpers/BindaryFormatterHelpers.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; + +namespace Octokit.Tests.Helpers +{ + public class BinaryFormatterExtensions + { + public static T SerializeAndDeserializeObject<T>(T input) + { + using (var stream = new MemoryStream()) + { + var formatter = new BinaryFormatter(); + formatter.Serialize(stream, input); + stream.Position = 0; + formatter.Binder = new SerializationBinderHelper(); + var deserializedObject = formatter.Deserialize(stream); + var deserialized = (T)deserializedObject; + return deserialized; + } + } + + internal class SerializationBinderHelper : SerializationBinder + { + public string Name { get; set; } + + public override Type BindToType(string i_AssemblyName, string i_TypeName) + { + Type typeToDeserialize = Type.GetType(String.Format(" {0}, {1}", i_TypeName, i_AssemblyName)); return typeToDeserialize; + } + } + } +} diff --git a/Octokit.Tests/Http/RateLimitTests.cs b/Octokit.Tests/Http/RateLimitTests.cs index b0c3eaf0c0..d16082a3a8 100644 --- a/Octokit.Tests/Http/RateLimitTests.cs +++ b/Octokit.Tests/Http/RateLimitTests.cs @@ -1,10 +1,7 @@ -using System; +using Octokit.Tests.Helpers; +using System; using System.Collections.Generic; using System.Globalization; -#if !NO_SERIALIZABLE -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; -#endif using Xunit; namespace Octokit.Tests.Http @@ -71,7 +68,6 @@ public void HandlesMissingHeaderValues() Assert.Equal(expectedReset, rateLimit.Reset); } -#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { @@ -83,24 +79,17 @@ public void CanPopulateObjectFromSerializedData() }; var rateLimit = new RateLimit(headers); + var deserialized = BinaryFormatterExtensions.SerializeAndDeserializeObject(rateLimit); - using (var stream = new MemoryStream()) - { - var formatter = new BinaryFormatter(); - formatter.Serialize(stream, rateLimit); - stream.Position = 0; - var deserialized = (RateLimit)formatter.Deserialize(stream); - - Assert.Equal(100, deserialized.Limit); - Assert.Equal(42, deserialized.Remaining); - var expectedReset = DateTimeOffset.ParseExact( - "Mon 01 Jul 2013 5:47:53 PM -00:00", - "ddd dd MMM yyyy h:mm:ss tt zzz", - CultureInfo.InvariantCulture); - Assert.Equal(expectedReset, deserialized.Reset); - } + Assert.Equal(100, deserialized.Limit); + Assert.Equal(42, deserialized.Remaining); + var expectedReset = DateTimeOffset.ParseExact( + "Mon 01 Jul 2013 5:47:53 PM -00:00", + "ddd dd MMM yyyy h:mm:ss tt zzz", + CultureInfo.InvariantCulture); + Assert.Equal(expectedReset, deserialized.Reset); } -#endif + [Fact] public void EnsuresHeadersNotNull() { From 5386257a3f6c0e645c46685e71850c02692d9830 Mon Sep 17 00:00:00 2001 From: Fredi Kats <fredikats@outlook.com> Date: Tue, 9 Aug 2022 18:10:12 +0400 Subject: [PATCH 106/209] feat: implement getting failed org invites (#2533) --- .../IObservableOrganizationMembersClient.cs | 23 +++++++++++ .../ObservableOrganizationMembersClient.cs | 36 +++++++++++++++++- .../Clients/OrganizationMembersClientTests.cs | 18 +++++++++ Octokit/Clients/IOrganizationMembersClient.cs | 23 +++++++++++ Octokit/Clients/OrganizationMembersClient.cs | 38 ++++++++++++++++++- Octokit/Helpers/ApiUrls.cs | 12 +++++- 6 files changed, 147 insertions(+), 3 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs index a775e5f0e7..7bdea7fff3 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs @@ -340,5 +340,28 @@ public interface IObservableOrganizationMembersClient /// <param name="options">Options to change API behaviour</param> /// <returns></returns> IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(string org, ApiOptions options); + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <returns></returns> + IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org); + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <param name="options">Options to change API behaviour</param> + /// <returns></returns> + IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org, ApiOptions options); } } diff --git a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs index bda101a24a..64a97cbcbe 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs @@ -470,7 +470,41 @@ public IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(st Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, options); + return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvitations(org), null, options); + } + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <returns></returns> + public IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return GetAllFailedInvitations(org, ApiOptions.None); + } + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <param name="options">Options to change API behaviour</param> + /// <returns></returns> + public IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationFailedInvitations(org), null, options); } } } diff --git a/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs index a86793f3c1..5e8dc01c04 100644 --- a/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs +++ b/Octokit.Tests.Integration/Clients/OrganizationMembersClientTests.cs @@ -275,5 +275,23 @@ public async Task ReturnsCorrectCountOfPendingInvitationsWithStart() } } } + + public class TheGetAllFailedInvitationsMethod + { + readonly IGitHubClient _gitHub; + + public TheGetAllFailedInvitationsMethod() + { + _gitHub = Helper.GetAuthenticatedClient(); + } + + [OrganizationTest] + public async Task ReturnsNoFailedInvitations() + { + var pendingInvitations = await _gitHub.Organization.Member.GetAllFailedInvitations(Helper.Organization); + Assert.NotNull(pendingInvitations); + Assert.Empty(pendingInvitations); + } + } } } diff --git a/Octokit/Clients/IOrganizationMembersClient.cs b/Octokit/Clients/IOrganizationMembersClient.cs index cb33f5aed7..91f102daec 100644 --- a/Octokit/Clients/IOrganizationMembersClient.cs +++ b/Octokit/Clients/IOrganizationMembersClient.cs @@ -346,5 +346,28 @@ public interface IOrganizationMembersClient /// <param name="options">Options to change API behaviour</param> /// <returns></returns> Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvitations(string org, ApiOptions options); + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <returns></returns> + Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org); + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <param name="options">Options to change API behaviour</param> + /// <returns></returns> + Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org, ApiOptions options); } } diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index ca2931ed37..4bed05e1ad 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -565,7 +565,43 @@ public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvita Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvititations(org), null, options); + return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationPendingInvitations(org), null, options); + } + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <returns></returns> + [ManualRoute("GET", "/orgs/{org}/failed_invitations")] + public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return GetAllFailedInvitations(org, ApiOptions.None); + } + + /// <summary> + /// List failed organization invitations. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The login for the organization</param> + /// <param name="options">Options to change API behaviour</param> + /// <returns></returns> + [ManualRoute("GET", "/orgs/{org}/failed_invitations")] + public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitations(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.OrganizationFailedInvitations(org), null, options); } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index be9f561037..de890c6247 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -850,11 +850,21 @@ public static Uri OrganizationMemberships(string org, string name) /// </summary> /// <param name="org">The name of the organization</param> /// <returns></returns> - public static Uri OrganizationPendingInvititations(string org) + public static Uri OrganizationPendingInvitations(string org) { return "orgs/{0}/invitations".FormatUri(org); } + /// <summary> + /// Returns the <see cref="Uri"/> for the organizations failed invitations + /// </summary> + /// <param name="org">The name of the organization</param> + /// <returns></returns> + public static Uri OrganizationFailedInvitations(string org) + { + return "orgs/{0}/failed_invitations".FormatUri(org); + } + /// <summary> /// Returns the <see cref="Uri"/> that returns all of the outside collaborators of the organization /// </summary> From 1e3fa1d770c888b48757e31b2b3a87c714545fcb Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Thu, 11 Aug 2022 01:34:16 -0500 Subject: [PATCH 107/209] feat: Adds generators project and AsyncPaginationExtension generator (#2537) --- .devcontainer/Dockerfile | 1 + .github/workflows/netcore.yml | 4 + .github/workflows/publish.yml | 5 +- .vscode/launch.json | 10 + .../Extensions.cs | 1684 ++++++++--------- .../Octokit.AsyncPaginationExtension.csproj | 26 +- .../AsyncPaginationExtensionsGenerator.cs | 119 ++ Octokit.Generators/Generator.cs | 29 + Octokit.Generators/Octokit.Generators.csproj | 23 + Octokit.Generators/README.md | 58 + Octokit.sln | 6 + 11 files changed, 1085 insertions(+), 880 deletions(-) create mode 100644 Octokit.Generators/AsyncPaginationExtensionsGenerator.cs create mode 100644 Octokit.Generators/Generator.cs create mode 100644 Octokit.Generators/Octokit.Generators.csproj create mode 100644 Octokit.Generators/README.md diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2e0527ea2c..048069c31a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,6 +7,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/dotnet # "install" the dotnet 3.1 & 5.0 runtime for tests COPY --from=mcr.microsoft.com/dotnet/sdk:3.1 /usr/share/dotnet/shared /usr/share/dotnet/shared COPY --from=mcr.microsoft.com/dotnet/sdk:5.0 /usr/share/dotnet/shared /usr/share/dotnet/shared +COPY --from=mcr.microsoft.com/dotnet/sdk:6.0 /usr/share/dotnet/shared /usr/share/dotnet/shared # # Add mkdocs for doc generation RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends python3-pip diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index 5f924b9ed9..d7c39fdcf9 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -23,6 +23,10 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.* + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.* - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 82203bd62c..e6c84a6813 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,10 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: 5.0.* - + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.* - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: diff --git a/.vscode/launch.json b/.vscode/launch.json index dd7b108d27..73a4369e41 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,6 +1,16 @@ { "version": "0.2.0", "configurations": [ + { + "name": "Run Generator", + "type": "coreclr", + "request": "launch", + "program": "${workspaceFolder}/Octokit.Generators/bin/Debug/net6.0/Octokit.Generators", + "args": [], + "cwd": "${workspaceFolder}/Octokit.Generators", + "console": "internalConsole", + "stopAtEntry": false + }, { "name": "Run unit tests", "type": "coreclr", diff --git a/Octokit.AsyncPaginationExtension/Extensions.cs b/Octokit.AsyncPaginationExtension/Extensions.cs index 2781ce2ea6..a9009f3b76 100644 --- a/Octokit.AsyncPaginationExtension/Extensions.cs +++ b/Octokit.AsyncPaginationExtension/Extensions.cs @@ -1,870 +1,822 @@ -using System; +using System; using System.Collections.Generic; namespace Octokit.AsyncPaginationExtension { - /// <summary> - /// Provides all extensions for pagination. - /// </summary> - /// <remarks> - /// The <code>pageSize</code> parameter at the end of all methods allows for specifying the amount of elements to be fetched per page. - /// Only useful to optimize the amount of API calls made. - /// </remarks> - public static class Extensions - { - private const int DEFAULT_PAGE_SIZE = 30; - - /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IAuthorizationsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<Authorization> GetAllAsync(this IAuthorizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Authorization>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(string, string, long, ApiOptions)"/> - public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, string owner, string name, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(owner, name, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(long, long, ApiOptions)"/> - public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, long repositoryId, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(repositoryId, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="ICommitStatusClient.GetAll(string, string, string, ApiOptions)"/> - public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, string owner, string name, string reference, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitStatus>(options => t.GetAll(owner, name, reference, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ICommitStatusClient.GetAll(long, string, ApiOptions)"/> - public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, long repositoryId, string reference, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitStatus>(options => t.GetAll(repositoryId, reference, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IDeploymentsClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IDeploymentsClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IDeploymentStatusClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, string owner, string name, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(owner, name, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IDeploymentStatusClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, long repositoryId, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(repositoryId, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IEventsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<Activity> GetAllAsync(this IEventsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(long, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllForRepositoryNetwork(string, string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForRepositoryNetworkAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepositoryNetwork(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllForOrganization(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForOrganizationAsync(this IEventsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllUserReceived(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserReceivedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceived(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllUserReceivedPublic(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserReceivedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceivedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllUserPerformed(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserPerformedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformed(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllUserPerformedPublic(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserPerformedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IEventsClient.GetAllForAnOrganization(string, string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForAnOrganizationAsync(this IEventsClient t, string user, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForAnOrganization(user, organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IFollowersClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<User> GetAllForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IFollowersClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IFollowersClient.GetAllFollowingForCurrent(ApiOptions)"/> - public static IPaginatedList<User> GetAllFollowingForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(t.GetAllFollowingForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IFollowersClient.GetAllFollowing(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllFollowingAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllFollowing(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IGistCommentsClient.GetAllForGist(string, ApiOptions)"/> - public static IPaginatedList<GistComment> GetAllForGistAsync(this IGistCommentsClient t, string gistId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GistComment>(options => t.GetAllForGist(gistId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IGistsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<Gist> GetAllAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAll(DateTimeOffset, ApiOptions)"/> - public static IPaginatedList<Gist> GetAllAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAll(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllPublic(ApiOptions)"/> - public static IPaginatedList<Gist> GetAllPublicAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(t.GetAllPublic, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllPublic(DateTimeOffset, ApiOptions)"/> - public static IPaginatedList<Gist> GetAllPublicAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllPublic(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllStarred(ApiOptions)"/> - public static IPaginatedList<Gist> GetAllStarredAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(t.GetAllStarred, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllStarred(DateTimeOffset, ApiOptions)"/> - public static IPaginatedList<Gist> GetAllStarredAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllStarred(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Gist> GetAllForUserAsync(this IGistsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllForUser(string, DateTimeOffset, ApiOptions)"/> - public static IPaginatedList<Gist> GetAllForUserAsync(this IGistsClient t, string user, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllForUser(user, since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllCommits(string, ApiOptions)"/> - public static IPaginatedList<GistHistory> GetAllCommitsAsync(this IGistsClient t, string id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GistHistory>(options => t.GetAllCommits(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IGistsClient.GetAllForks(string, ApiOptions)"/> - public static IPaginatedList<GistFork> GetAllForksAsync(this IGistsClient t, string id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GistFork>(options => t.GetAllForks(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IGitHubAppsClient.GetAllInstallationsForCurrent(ApiOptions)"/> - public static IPaginatedList<Installation> GetAllInstallationsForCurrentAsync(this IGitHubAppsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Installation>(t.GetAllInstallationsForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(string, string, IssueCommentRequest, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, string owner, string name, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(long, IssueCommentRequest, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, long repositoryId, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(string, string, int, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(long, int, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(string, string, int, IssueCommentRequest, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, string owner, string name, int number, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(owner, name, number, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(long, int, IssueCommentRequest, ApiOptions)"/> - public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, long repositoryId, int number, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(repositoryId, number, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IIssueReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(IssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForOwnedAndMemberRepositories, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(IssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOwnedAndMemberRepositories(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, IssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, RepositoryIssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, RepositoryIssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(string, string, int, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(long, int, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IIssuesLabelsClient.GetAllForIssue(string, string, int, ApiOptions)"/> - public static IPaginatedList<Label> GetAllForIssueAsync(this IIssuesLabelsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesLabelsClient.GetAllForIssue(long, int, ApiOptions)"/> - public static IPaginatedList<Label> GetAllForIssueAsync(this IIssuesLabelsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesLabelsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Label> GetAllForRepositoryAsync(this IIssuesLabelsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesLabelsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Label> GetAllForRepositoryAsync(this IIssuesLabelsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesLabelsClient.GetAllForMilestone(string, string, int, ApiOptions)"/> - public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForMilestone(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesLabelsClient.GetAllForMilestone(long, int, ApiOptions)"/> - public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForMilestone(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(string, string, int, ApiOptions)"/> - public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, string owner, string repo, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(owner, repo, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(long, int, ApiOptions)"/> - public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, MilestoneRequest, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, MilestoneRequest, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IMiscellaneousClient.GetAllLicenses(ApiOptions)"/> - public static IPaginatedList<LicenseMetadata> GetAllLicensesAsync(this IMiscellaneousClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<LicenseMetadata>(t.GetAllLicenses, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(NotificationsRequest, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, NotificationsRequest, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, NotificationsRequest, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IOrganizationHooksClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<OrganizationHook> GetAllAsync(this IOrganizationHooksClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<OrganizationHook>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersRole, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, OrganizationMembersRole, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationMembersClient.GetAllPublic(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllPublicAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllPublic(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationMembersClient.GetAllPendingInvitations(string, ApiOptions)"/> - public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IOrganizationsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Organization> GetAllForCurrentAsync(this IOrganizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Organization>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationsClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Organization> GetAllForUserAsync(this IOrganizationsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Organization>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IProjectCardsClient.GetAll(int, ApiOptions)"/> - public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ProjectCard>(options => t.GetAll(columnId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IProjectCardsClient.GetAll(int, ProjectCardRequest, ApiOptions)"/> - public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, ProjectCardRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ProjectCard>(options => t.GetAll(columnId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IProjectColumnsClient.GetAll(int, ApiOptions)"/> - public static IPaginatedList<ProjectColumn> GetAllAsync(this IProjectColumnsClient t, int projectId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ProjectColumn>(options => t.GetAll(projectId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IProjectsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IProjectsClient.GetAllForRepository(string, string, ProjectRequest, ApiOptions)"/> - public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, string owner, string name, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IProjectsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IProjectsClient.GetAllForRepository(long, ProjectRequest, ApiOptions)"/> - public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, long repositoryId, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IProjectsClient.GetAllForOrganization(string, ApiOptions)"/> - public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IProjectsClient.GetAllForOrganization(string, ProjectRequest, ApiOptions)"/> - public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsClient t, string organization, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, PullRequestReviewCommentRequest, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, PullRequestReviewCommentRequest, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(string, string, int, long, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, string owner, string name, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(owner, name, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(long, int, long, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, long repositoryId, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(repositoryId, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, PullRequestRequest, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, PullRequestRequest, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IReferencesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReferencesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(string, string, string, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, string owner, string name, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(owner, name, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(long, string, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, long repositoryId, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(repositoryId, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IReleasesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReleasesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReleasesClient.GetAllAssets(string, string, int, ApiOptions)"/> - public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, string owner, string name, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(owner, name, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReleasesClient.GetAllAssets(long, int, ApiOptions)"/> - public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, long repositoryId, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(repositoryId, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, RepositoryCollaboratorListRequest, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, RepositoryCollaboratorListRequest, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(RepositoryRequest, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, RepositoryRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForUserAsync(this IRepositoriesClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllForOrg(string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForOrgAsync(this IRepositoriesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForOrg(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, bool, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, bool, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(string, string, ApiOptions)"/> - public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(long, ApiOptions)"/> - public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllTags(string, string, ApiOptions)"/> - public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllTags(long, ApiOptions)"/> - public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(string, string, string, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, string owner, string name, string sha, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(owner, name, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(long, string, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, long repositoryId, string sha, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(repositoryId, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, CommitRequest, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, CommitRequest, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryForksClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryForksClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryForksClient.GetAll(string, string, RepositoryForksListRequest, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, string owner, string name, RepositoryForksListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryForksClient.GetAll(long, RepositoryForksListRequest, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, long repositoryId, RepositoryForksListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryHooksClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryHooksClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<RepositoryInvitation> GetAllForCurrentAsync(this IRepositoryInvitationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<RepositoryInvitation> GetAllForRepositoryAsync(this IRepositoryInvitationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IRepositoryPagesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryPagesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IStarredClient.GetAllStargazers(string, string, ApiOptions)"/> - public static IPaginatedList<User> GetAllStargazersAsync(this IStarredClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllStargazers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllStargazers(long, ApiOptions)"/> - public static IPaginatedList<User> GetAllStargazersAsync(this IStarredClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllStargazers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllStargazersWithTimestamps(string, string, ApiOptions)"/> - public static IPaginatedList<UserStar> GetAllStargazersWithTimestampsAsync(this IStarredClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<UserStar>(options => t.GetAllStargazersWithTimestamps(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllStargazersWithTimestamps(long, ApiOptions)"/> - public static IPaginatedList<UserStar> GetAllStargazersWithTimestampsAsync(this IStarredClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<UserStar>(options => t.GetAllStargazersWithTimestamps(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IStarredClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForCurrentWithTimestamps(ApiOptions)"/> - public static IPaginatedList<RepositoryStar> GetAllForCurrentWithTimestampsAsync(this IStarredClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryStar>(t.GetAllForCurrentWithTimestamps, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForCurrent(StarredRequest, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IStarredClient t, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForCurrentWithTimestamps(StarredRequest, ApiOptions)"/> - public static IPaginatedList<RepositoryStar> GetAllForCurrentWithTimestampsAsync(this IStarredClient t, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForCurrentWithTimestamps(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForUserAsync(this IStarredClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForUserWithTimestamps(string, ApiOptions)"/> - public static IPaginatedList<RepositoryStar> GetAllForUserWithTimestampsAsync(this IStarredClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForUserWithTimestamps(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForUser(string, StarredRequest, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForUserAsync(this IStarredClient t, string user, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IStarredClient.GetAllForUserWithTimestamps(string, StarredRequest, ApiOptions)"/> - public static IPaginatedList<RepositoryStar> GetAllForUserWithTimestampsAsync(this IStarredClient t, string user, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForUserWithTimestamps(user, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="ITeamsClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<Team> GetAllAsync(this ITeamsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Team> GetAllForCurrentAsync(this ITeamsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllChildTeams(int, ApiOptions)"/> - public static IPaginatedList<Team> GetAllChildTeamsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllChildTeams(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, ApiOptions)"/> - public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, TeamMembersRequest, ApiOptions)"/> - public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, TeamMembersRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllRepositories(int, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllRepositoriesAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllRepositories(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllPendingInvitations(int, ApiOptions)"/> - public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IUserEmailsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<EmailAddress> GetAllAsync(this IUserEmailsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<EmailAddress>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IUserGpgKeysClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<GpgKey> GetAllForCurrentAsync(this IUserGpgKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GpgKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IUserKeysClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<PublicKey> GetAllAsync(this IUserKeysClient t, string userName, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PublicKey>(options => t.GetAll(userName, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IUserKeysClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<PublicKey> GetAllForCurrentAsync(this IUserKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PublicKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IWatchedClient.GetAllWatchers(string, string, ApiOptions)"/> - public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IWatchedClient.GetAllWatchers(long, ApiOptions)"/> - public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IWatchedClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IWatchedClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IWatchedClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForUserAsync(this IWatchedClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IApiConnection.GetAll(Uri, ApiOptions)"/> - public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IApiConnection.GetAll(Uri, IDictionary{string, string}, ApiOptions)"/> - public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, IDictionary<string, string> parameters, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, parameters, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IApiConnection.GetAll(Uri, IDictionary{string, string}, string, ApiOptions)"/> - public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, IDictionary<string, string> parameters, string accepts, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, parameters, accepts, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IEnterprisePreReceiveEnvironmentsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<PreReceiveEnvironment> GetAllAsync(this IEnterprisePreReceiveEnvironmentsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PreReceiveEnvironment>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - - /// <inheritdoc cref="IEnterprisePreReceiveHooksClient.GetAll(ApiOptions)"/> - public static IPaginatedList<PreReceiveHook> GetAllAsync(this IEnterprisePreReceiveHooksClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PreReceiveHook>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - } -} + /// <summary> + /// Provides all extensions for pagination. + /// </summary> + /// <remarks> + /// The <code>pageSize</code> parameter at the end of all methods allows for specifying the amount of elements to be fetched per page. + /// Only useful to optimize the amount of API calls made. + /// </remarks> + public static class Extensions + { + private const int DEFAULT_PAGE_SIZE = 30; + + /// <inheritdoc cref="IIssueReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<Team> GetAllAsync(this ITeamsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Team> GetAllForCurrentAsync(this ITeamsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllChildTeams(int, ApiOptions)"/> + public static IPaginatedList<Team> GetAllChildTeamsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllChildTeams(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, ApiOptions)"/> + public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, TeamMembersRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, TeamMembersRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllRepositories(int, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllRepositoriesAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllRepositories(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllPendingInvitations(int, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, RepositoryCollaboratorListRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, RepositoryCollaboratorListRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICommitStatusClient.GetAll(string, string, string, ApiOptions)"/> + public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, string owner, string name, string reference, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitStatus>(options => t.GetAll(owner, name, reference, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICommitStatusClient.GetAll(long, string, ApiOptions)"/> + public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, long repositoryId, string reference, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitStatus>(options => t.GetAll(repositoryId, reference, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, MilestoneRequest, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, MilestoneRequest, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IAuthorizationsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Authorization> GetAllAsync(this IAuthorizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Authorization>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(RepositoryRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, RepositoryRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IRepositoriesClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForOrg(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForOrgAsync(this IRepositoriesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForOrg(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, bool, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, bool, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(string, string, ApiOptions)"/> + public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(long, ApiOptions)"/> + public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTags(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllTags(long, ApiOptions)"/> + public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReferencesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReferencesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(string, string, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, string owner, string name, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(owner, name, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(long, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, long repositoryId, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(repositoryId, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationHooksClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<OrganizationHook> GetAllAsync(this IOrganizationHooksClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationHook>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersRole, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, OrganizationMembersRole, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllPublic(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllPublicAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllPublic(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllPendingInvitations(string, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllFailedInvitations(string, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllFailedInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllFailedInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Gist> GetAllAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAll(DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAll(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllPublic(ApiOptions)"/> + public static IPaginatedList<Gist> GetAllPublicAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(t.GetAllPublic, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllPublic(DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllPublicAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllPublic(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllStarred(ApiOptions)"/> + public static IPaginatedList<Gist> GetAllStarredAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(t.GetAllStarred, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllStarred(DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllStarredAsync(this IGistsClient t, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllStarred(since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllForUserAsync(this IGistsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllForUser(string, DateTimeOffset, ApiOptions)"/> + public static IPaginatedList<Gist> GetAllForUserAsync(this IGistsClient t, string user, DateTimeOffset since, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Gist>(options => t.GetAllForUser(user, since, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllCommits(string, ApiOptions)"/> + public static IPaginatedList<GistHistory> GetAllCommitsAsync(this IGistsClient t, string id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GistHistory>(options => t.GetAllCommits(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistsClient.GetAllForks(string, ApiOptions)"/> + public static IPaginatedList<GistFork> GetAllForksAsync(this IGistsClient t, string id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GistFork>(options => t.GetAllForks(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<RepositoryInvitation> GetAllForCurrentAsync(this IRepositoryInvitationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<RepositoryInvitation> GetAllForRepositoryAsync(this IRepositoryInvitationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReleasesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReleasesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReleasesClient.GetAllAssets(string, string, int, ApiOptions)"/> + public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, string owner, string name, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(owner, name, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IReleasesClient.GetAllAssets(long, int, ApiOptions)"/> + public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, long repositoryId, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(repositoryId, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(string, string, int, long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, string owner, string name, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(owner, name, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(long, int, long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, long repositoryId, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(repositoryId, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IDeploymentsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IDeploymentsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserEmailsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<EmailAddress> GetAllAsync(this IUserEmailsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<EmailAddress>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, PullRequestReviewCommentRequest, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, PullRequestReviewCommentRequest, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserKeysClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<PublicKey> GetAllAsync(this IUserKeysClient t, string userName, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PublicKey>(options => t.GetAll(userName, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserKeysClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<PublicKey> GetAllForCurrentAsync(this IUserKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PublicKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(string, string, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, string owner, string name, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(long, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, long repositoryId, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(string, string, int, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, string owner, string name, int number, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(owner, name, number, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueCommentsClient.GetAllForIssue(long, int, IssueCommentRequest, ApiOptions)"/> + public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, long repositoryId, int number, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(repositoryId, number, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForIssueAsync(this IIssuesLabelsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForIssueAsync(this IIssuesLabelsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForRepositoryAsync(this IIssuesLabelsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForRepositoryAsync(this IIssuesLabelsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForMilestone(string, string, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForMilestone(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForMilestone(long, int, ApiOptions)"/> + public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForMilestone(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGistCommentsClient.GetAllForGist(string, ApiOptions)"/> + public static IPaginatedList<GistComment> GetAllForGistAsync(this IGistCommentsClient t, string gistId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GistComment>(options => t.GetAllForGist(gistId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectCardsClient.GetAll(int, ApiOptions)"/> + public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ProjectCard>(options => t.GetAll(columnId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectCardsClient.GetAll(int, ProjectCardRequest, ApiOptions)"/> + public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, ProjectCardRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ProjectCard>(options => t.GetAll(columnId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMiscellaneousClient.GetAllLicenses(ApiOptions)"/> + public static IPaginatedList<LicenseMetadata> GetAllLicensesAsync(this IMiscellaneousClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<LicenseMetadata>(t.GetAllLicenses, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(string, string, ProjectRequest, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, string owner, string name, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForRepository(long, ProjectRequest, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, long repositoryId, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectsClient.GetAllForOrganization(string, ProjectRequest, ApiOptions)"/> + public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsClient t, string organization, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(string, string, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, string owner, string name, string sha, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(owner, name, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(long, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, long repositoryId, string sha, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(repositoryId, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IDeploymentStatusClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, string owner, string name, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(owner, name, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IDeploymentStatusClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, long repositoryId, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(repositoryId, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, CommitRequest, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, CommitRequest, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryPagesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryPagesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IProjectColumnsClient.GetAll(int, ApiOptions)"/> + public static IPaginatedList<ProjectColumn> GetAllAsync(this IProjectColumnsClient t, int projectId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ProjectColumn>(options => t.GetAll(projectId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Activity> GetAllAsync(this IEventsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForRepositoryNetwork(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryNetworkAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepositoryNetwork(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForOrganizationAsync(this IEventsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserReceived(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserReceivedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceived(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserReceivedPublic(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserReceivedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceivedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserPerformed(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserPerformedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformed(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllUserPerformedPublic(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserPerformedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEventsClient.GetAllForAnOrganization(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForAnOrganizationAsync(this IEventsClient t, string user, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForAnOrganization(user, organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, PullRequestRequest, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, PullRequestRequest, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForOwnedAndMemberRepositories, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOwnedAndMemberRepositories(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, RepositoryIssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, RepositoryIssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Organization> GetAllForCurrentAsync(this IOrganizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Organization>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationsClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Organization> GetAllForUserAsync(this IOrganizationsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Organization>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserGpgKeysClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<GpgKey> GetAllForCurrentAsync(this IUserGpgKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GpgKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(string, string, RepositoryForksListRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, string owner, string name, RepositoryForksListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryForksClient.GetAll(long, RepositoryForksListRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, long repositoryId, RepositoryForksListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IGitHubAppsClient.GetAllInstallationsForCurrent(ApiOptions)"/> + public static IPaginatedList<Installation> GetAllInstallationsForCurrentAsync(this IGitHubAppsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Installation>(t.GetAllInstallationsForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(string, string, long, ApiOptions)"/> + public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, string owner, string name, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(owner, name, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(long, long, ApiOptions)"/> + public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, long repositoryId, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(repositoryId, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryHooksClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryHooksClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllWatchers(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllWatchers(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IWatchedClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IWatchedClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllStargazers(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllStargazersAsync(this IStarredClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllStargazers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllStargazers(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllStargazersAsync(this IStarredClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllStargazers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllStargazersWithTimestamps(string, string, ApiOptions)"/> + public static IPaginatedList<UserStar> GetAllStargazersWithTimestampsAsync(this IStarredClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<UserStar>(options => t.GetAllStargazersWithTimestamps(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllStargazersWithTimestamps(long, ApiOptions)"/> + public static IPaginatedList<UserStar> GetAllStargazersWithTimestampsAsync(this IStarredClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<UserStar>(options => t.GetAllStargazersWithTimestamps(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IStarredClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrentWithTimestamps(ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForCurrentWithTimestampsAsync(this IStarredClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(t.GetAllForCurrentWithTimestamps, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrent(StarredRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IStarredClient t, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForCurrentWithTimestamps(StarredRequest, ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForCurrentWithTimestampsAsync(this IStarredClient t, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForCurrentWithTimestamps(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IStarredClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUserWithTimestamps(string, ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForUserWithTimestampsAsync(this IStarredClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForUserWithTimestamps(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUser(string, StarredRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IStarredClient t, string user, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IStarredClient.GetAllForUserWithTimestamps(string, StarredRequest, ApiOptions)"/> + public static IPaginatedList<RepositoryStar> GetAllForUserWithTimestampsAsync(this IStarredClient t, string user, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForUserWithTimestamps(user, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IFollowersClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<User> GetAllForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IFollowersClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IFollowersClient.GetAllFollowingForCurrent(ApiOptions)"/> + public static IPaginatedList<User> GetAllFollowingForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(t.GetAllFollowingForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IFollowersClient.GetAllFollowing(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllFollowingAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllFollowing(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, string owner, string repo, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(owner, repo, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IApiConnection.GetAll(Uri, ApiOptions)"/> + public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IApiConnection.GetAll(Uri, IDictionary{string, string}, ApiOptions)"/> + public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, IDictionary<string, string> parameters, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, parameters, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IApiConnection.GetAll(Uri, IDictionary{string, string}, string, ApiOptions)"/> + public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, IDictionary<string, string> parameters, string accepts, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<T>(options => t.GetAll<T>(uri, parameters, accepts, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEnterprisePreReceiveEnvironmentsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<PreReceiveEnvironment> GetAllAsync(this IEnterprisePreReceiveEnvironmentsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PreReceiveEnvironment>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IEnterprisePreReceiveHooksClient.GetAll(ApiOptions)"/> + public static IPaginatedList<PreReceiveHook> GetAllAsync(this IEnterprisePreReceiveHooksClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PreReceiveHook>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + } +} \ No newline at end of file diff --git a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj index 4c6ea5f302..38c33b9357 100644 --- a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj +++ b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj @@ -18,23 +18,23 @@ <PackageTags>GitHub API Octokit linqpad-samples dotnetcore</PackageTags> <Copyright>Copyright GitHub 2017</Copyright> <LangVersion>9</LangVersion> - <Nullable>enable</Nullable> + <Nullable>enable</Nullable> </PropertyGroup> - <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> - <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> - </PropertyGroup> + <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> + <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> + </PropertyGroup> - <ItemGroup Condition=" '$(TargetFramework)' == 'net461' "> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> - </ItemGroup> + <ItemGroup Condition=" '$(TargetFramework)' == 'net461' "> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> + </ItemGroup> - <ItemGroup> - <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" /> - </ItemGroup> + <ItemGroup> + <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" /> + </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\Octokit\Octokit.csproj" /> - </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Octokit\Octokit.csproj" /> + </ItemGroup> </Project> diff --git a/Octokit.Generators/AsyncPaginationExtensionsGenerator.cs b/Octokit.Generators/AsyncPaginationExtensionsGenerator.cs new file mode 100644 index 0000000000..d3621f047f --- /dev/null +++ b/Octokit.Generators/AsyncPaginationExtensionsGenerator.cs @@ -0,0 +1,119 @@ +using System.Linq; +using System.IO; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Data; +using System.Text; + +namespace Octokit.Generators +{ + + /// <summary> + /// AsyncPaginationExtensionsGenerator for generating pagination extensions for Octokit.net Clients that return collections. + /// </summary> + /// <remarks> + /// This generator originally appeared in https://github.com/octokit/octokit.net/pull/2516 + /// The generator solves a small part of a larger effort that is being discussed: + /// https://github.com/octokit/octokit.net/discussions/2499 + /// https://github.com/octokit/octokit.net/discussions/2495 + /// https://github.com/octokit/octokit.net/issues/2517 + /// In the future, we should be able to unify generation for + /// * models (request and response) + /// * clients + /// * routing and related helpers + /// TODO: Convert to use Rosyln source generators + /// </remarks> + class AsyncPaginationExtensionsGenerator + { + + private const string HEADER = ( +@"using System; +using System.Collections.Generic; + +namespace Octokit.AsyncPaginationExtension +{ + /// <summary> + /// Provides all extensions for pagination. + /// </summary> + /// <remarks> + /// The <code>pageSize</code> parameter at the end of all methods allows for specifying the amount of elements to be fetched per page. + /// Only useful to optimize the amount of API calls made. + /// </remarks> + public static class Extensions + { + private const int DEFAULT_PAGE_SIZE = 30; + "); + + private const string FOOTER = ( +@" + } +}"); + + /// <summary> + /// GenerateAsync static entry point for generating pagination extensions. + /// </summary> + /// <remarks> + /// This defaults the search path to the root of the project + /// This expects to generate the resulting code and put it in Octokit.AsyncPaginationExtension + /// This does a wholesale overwrite on ./Octokit.AsyncPaginationExtension/Extensions.cs + /// </remarks> + public static async Task GenerateAsync(string root = "./") + { + var sb = new StringBuilder(HEADER); + var enumOptions = new EnumerationOptions { RecurseSubdirectories = true }; + var paginatedCallRegex = new Regex(@".*Task<IReadOnlyList<(?<returnType>\w+)>>\s*(?<name>\w+)(?<template><.*>)?\((?<arg>.*?)(, )?ApiOptions \w*\);"); + + foreach (var file in Directory.EnumerateFiles(root, "I*.cs", enumOptions)) { + var type = Path.GetFileNameWithoutExtension(file); + + foreach (var line in File.ReadAllLines(file)) { + var match = paginatedCallRegex.Match(line); + + if (!match.Success) { continue; } + sb.Append(BuildBodyFromTemplate(match, type)); + } + } + + sb.Append(FOOTER); + + await File.WriteAllTextAsync("./Octokit.AsyncPaginationExtension/Extensions.cs", sb.ToString()); + } + + /// <summary> + /// BuildBodyFromTemplate uses the match from the regex search and parses values from the given source + /// to use to generate the paging implementations. + /// </summary> + /// <remarks> + /// TODO: This should be reworked to use source templates + /// </remarks> + private static string BuildBodyFromTemplate(Match match, string type) + { + var argSplitRegex = new Regex(@" (?![^<]*>)"); + var returnType = match.Groups["returnType"].Value; + var name = match.Groups["name"].Value; + var arg = match.Groups["arg"].Value; + var template = match.Groups["template"]; + var templateStr = template.Success ? template.Value : string.Empty; + var splitArgs = argSplitRegex.Split(arg).ToArray(); + + var lambda = arg.Length == 0 + ? $"t.{name}{templateStr}" + : $"options => t.{name}{templateStr}({string.Join(' ', splitArgs.Where((_, i) => i % 2 == 1))}, options)"; + + var docArgs = string.Join(", ", splitArgs.Where((_, i) => i % 2 == 0)).Replace('<', '{').Replace('>', '}'); + if (docArgs.Length != 0) { + docArgs += ", "; + } + + if (arg.Length != 0) { + arg += ", "; + } + + return ($@" + /// <inheritdoc cref=""{type}.{name}({docArgs}ApiOptions)""/> + public static IPaginatedList<{returnType}> {name}Async{templateStr}(this {type} t, {arg}int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<{returnType}>({lambda}, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, ""The page size must be positive.""); + "); + } + } +} diff --git a/Octokit.Generators/Generator.cs b/Octokit.Generators/Generator.cs new file mode 100644 index 0000000000..f89463b7af --- /dev/null +++ b/Octokit.Generators/Generator.cs @@ -0,0 +1,29 @@ +using System.Threading.Tasks; + +namespace Octokit.Generators +{ + /// <summary> + /// Provides an entry point for code generation of various types. + /// </summary> + /// <remarks> + /// The backing source for generation will either be the source files in this repo or + /// the OpenAPI Descriptions from the GitHub REST API: https://github.com/github/rest-api-description + /// </remarks> + class Generator + { + + static void Main(string[] args) + { + + var operation = args.Length != 0 ? args[0] : "AsyncPaginationExtensions"; + + if (operation == "AsyncPaginationExtensions") + { + Task task = Task.Run( () => AsyncPaginationExtensionsGenerator.GenerateAsync()); + task.Wait(); + } + + // Put more generation operations here, convert to case when needed. + } + } +} diff --git a/Octokit.Generators/Octokit.Generators.csproj b/Octokit.Generators/Octokit.Generators.csproj new file mode 100644 index 0000000000..051275a5e5 --- /dev/null +++ b/Octokit.Generators/Octokit.Generators.csproj @@ -0,0 +1,23 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <Description>A set of code generators for Octokit.NET backed by the GitHub REST API Open API descriptions</Description> + <AssemblyTitle>Octokit.Generators</AssemblyTitle> + <Authors>GitHub</Authors> + <Version>0.0.0-dev</Version> + <GenerateDocumentationFile>true</GenerateDocumentationFile> + <OutputType>Exe</OutputType> + <TargetFramework>net6.0</TargetFramework> + <AssemblyName>Octokit.Generators</AssemblyName> + <PackageId>Octokit.Generators</PackageId> + <DebugType>embedded</DebugType> + <RepositoryUrl>https://github.com/octokit/octokit.net</RepositoryUrl> + <PackageProjectUrl>https://github.com/octokit/octokit.net</PackageProjectUrl> + <PackageIconUrl>https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png</PackageIconUrl> + <PackageIcon>octokit.png</PackageIcon> + <PackageLicenseExpression>MIT</PackageLicenseExpression> + <PackageTags>GitHub API Octokit dotnetcore dotnetstandard2.0</PackageTags> + <Copyright>Copyright GitHub 2022</Copyright> + <LangVersion>9</LangVersion> + <Nullable>enable</Nullable> + </PropertyGroup> +</Project> diff --git a/Octokit.Generators/README.md b/Octokit.Generators/README.md new file mode 100644 index 0000000000..b7a1d7b99c --- /dev/null +++ b/Octokit.Generators/README.md @@ -0,0 +1,58 @@ +# Octokit.net Generators + +## About + +We've been discussing and thinking about code generators for a [while now](https://github.com/octokit/octokit.net/discussions/2527) and they are part of the [future vision](https://github.com/octokit/octokit.net/discussions/2495) for where we'd like to head with this SDK. + +Consider this to be iteration 0, meaning while we want to potentially move to source generators, templates, and using the features that Rosyln offers we need to do some functional experiments and solve our current needs while iterating on the future. Acknowledging that code generation is a solved problem (menaing there is existing work out there) we should be intentional with the direction we take. + +---- + +## Getting started + +From the Octokit .NET root run: + +`dotnet run --project Octokit.Generators` + +---- + +## Debugging + +There is a launch config defined for this project named `Run Generator` + +---- + +## CI/Actions + +Currently no generation is automatically run as a build/release step. Once the vision solidifies here a bit we'll begin introducing automation so that whatever is generated is always up to date. + +---- + +## Notes and thoughts on code generation for Octokit.net + +### Code generation, interpreters, and language interpolation + +Hoisted from this [discussion](https://github.com/octokit/octokit.net/discussions/2495) + +As you know there are loads of things that we can do here - especially given the power of .NET, reflection, and Rosyln. Just two thoughts on the cautious side of things here: + +1. Just because we can generate things, it does not mean we should. As we roll through discovery on all of this we might find out some areas where generation would be trying to put a square peg in a round hole. We need to have the courage to stand down when needed. +2. Our long-term goal should be language and platform independence. Meaning, we might nail down incredible generative aspects for the .NET SDK but we should always be targeting things like versioned, package distributed, models that the core SDK can reference as well as a generative engine that could potentially generate the models and implementations based on language templates, RFCs, and the like for any reference language - so generating models and SDK methods should be doable for both .NET and Go (for instance) using the same "engine" if possible. It's lofty but I feel that it could be possible. + +So what might the future look like for code generation given the above statements? Let's have a look a what might be a really naive/potential roadmap (again we need the community's input and involvement here - which is why I am grateful for the questions): + +1. Make sure our current solution addresses the community needs: All SDKs have been synchronized with the current API surface +2. Standardize implementations - testing, models, API methods, etc... (this is a critical step to get us to generation) +3. As we go through the above we will learn more about what works and what doesn't. Armed with that knowledge, begin prototyping generative models for each SDK +4. Solve OpenAPI generation for at least 1 SDK and implement - again with our sights on other languages +5. Publish (but don't reference yet) SDK models to packaging platforms (in this case nuget) +6. Work on Generative API implementations - methods etc.. +7. Model generation is unified in the SDK (i.e. we used the published / versioned models in the SDK) and published to package platforms. + + +After this point, things get really interesting with things like: + +- Recipe and workflow generation - think of things like plugins for the SDKs to do things like instantiating project boards with teams and referenced repos all in one SDK call. SDKs shouldn't be reflective API implementations, but rather tools that simplify our approach to getting things done. +- We could start generating SDKs using language specifications - imagine pairing our OpenAPI specification with a language RFC to spit out a baseline SDK that could be extended. +- Generating language agnostic SDKs - what if we could maximize code reuse by implementing interpreted recipes or code +- Building workflow interpolation based on user patterns present in GitHub - this comes back to the community and GitHub joining up to make consistent workflows no matter where the users are - in community apps or GitHub proper. diff --git a/Octokit.sln b/Octokit.sln index 43c06fa141..6f2762cc39 100644 --- a/Octokit.sln +++ b/Octokit.sln @@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{64FD6CD6 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Octokit.AsyncPaginationExtension", "Octokit.AsyncPaginationExtension\Octokit.AsyncPaginationExtension.csproj", "{0E8013E0-0CCF-4433-9E01-51AC288824C5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit.Generators", "Octokit.Generators\Octokit.Generators.csproj", "{6A577AD0-2319-4FFC-8EF2-3CCDD31B0CD9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -47,6 +49,10 @@ Global {0E8013E0-0CCF-4433-9E01-51AC288824C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E8013E0-0CCF-4433-9E01-51AC288824C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E8013E0-0CCF-4433-9E01-51AC288824C5}.Release|Any CPU.Build.0 = Release|Any CPU + {6A577AD0-2319-4FFC-8EF2-3CCDD31B0CD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A577AD0-2319-4FFC-8EF2-3CCDD31B0CD9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A577AD0-2319-4FFC-8EF2-3CCDD31B0CD9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A577AD0-2319-4FFC-8EF2-3CCDD31B0CD9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From b4ca7c7c57deb04add7f3c3aae8017ea95902f31 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Thu, 11 Aug 2022 07:35:54 +0100 Subject: [PATCH 108/209] docs: Adds documentation on how to create a branch (#2541) --- docs/git-database.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/git-database.md b/docs/git-database.md index e135b139bb..56aba79aa6 100644 --- a/docs/git-database.md +++ b/docs/git-database.md @@ -1,5 +1,19 @@ # Working with the Git Database +### Create a Branch + +Branches can be created through the Git client. These are known as References. To create a reference, the first property you need is the name of the branch you want to create. You must ensure the reference starts with "refs" and contain two "/", otherwise it will be rejected. The second property is the SHA of the commit you want to branch from. This can be any commit but it must exist in the repository to be accepted. + +```csharp +var reference = new NewReference($"refs/heads/{branchName}", commit.Sha); +``` + +You can then create the Reference using the Reference.Create Api, either passing in the Repository Owner and Name or the Repository Id. +```csharp +var branch = await github.Git.Reference.Create(owner, repo, reference); +var branch = await github.Git.Reference.Create(id, reference); +``` + ### Tag a Commit Tags can be created through the GitHub API From 176bf386a056e89444bf38a2d6db09cf601c72ac Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 12 Aug 2022 18:19:26 +0100 Subject: [PATCH 109/209] maint: Tidying up DefineConstants (#2538) --- Octokit.Tests.Integration/Helper.cs | 7 ---- .../Octokit.Tests.Integration.csproj | 21 ++++-------- Octokit.Tests/Fixtures/EmbeddedResource.cs | 8 +---- Octokit.Tests/Fixtures/Fixtures.cs | 33 +------------------ Octokit.Tests/Http/RateLimitTests.cs | 1 + Octokit.Tests/Octokit.Tests.csproj | 4 --- Octokit.Tests/SelfTests.cs | 8 +---- Octokit/Exceptions/AbuseException.cs | 6 ---- Octokit/Exceptions/ApiException.cs | 6 ---- Octokit/Exceptions/ApiValidationException.cs | 6 ---- Octokit/Exceptions/AuthorizationException.cs | 6 ---- Octokit/Exceptions/ForbiddenException.cs | 6 ---- .../InvalidGitIgnoreTemplateException.cs | 6 ---- .../Exceptions/LegalRestrictionException.cs | 6 ---- .../LoginAttemptsExceededException.cs | 6 ---- Octokit/Exceptions/NotFoundException.cs | 6 ---- .../PullRequestMismatchException.cs | 6 ---- .../PullRequestNotMergeableException.cs | 6 ---- .../Exceptions/RateLimitExceededException.cs | 6 ---- .../Exceptions/RepositoryExistsException.cs | 6 ---- .../Exceptions/RepositoryFormatException.cs | 6 ---- .../SecondaryRateLimitExceededException.cs | 6 ---- .../TwoFactorAuthorizationException.cs | 7 ---- .../TwoFactorChallengeFailedException.cs | 6 ---- .../Exceptions/TwoFactorRequiredException.cs | 6 ---- .../UserIsLastOwnerOfOrganizationException.cs | 6 ---- .../UserIsNotMemberOfOrganizationException.cs | 6 ---- .../UserIsOrganizationMemberException.cs | 6 ---- Octokit/Helpers/ReflectionExtensions.cs | 11 ------- Octokit/Http/Connection.cs | 11 +------ Octokit/Http/HttpClientAdapter.cs | 25 -------------- Octokit/Http/RateLimit.cs | 11 +------ Octokit/Models/Response/ApiError.cs | 2 -- Octokit/Models/Response/ApiErrorDetail.cs | 2 -- Octokit/Octokit.csproj | 2 +- Octokit/SimpleJson.cs | 6 ---- 36 files changed, 14 insertions(+), 265 deletions(-) diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index af7742b5e4..49ca013140 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -74,8 +74,6 @@ public static class Helper static readonly Lazy<Credentials> _githubAppCredentials = new Lazy<Credentials>(() => { - // GitHubJwt nuget package only available for netstandard2.0+ -#if GITHUBJWT_HELPER_AVAILABLE var generator = new GitHubJwt.GitHubJwtFactory( new GitHubJwt.FilePrivateKeySource(GitHubAppPemFile), new GitHubJwt.GitHubJwtFactoryOptions @@ -87,11 +85,6 @@ public static class Helper var jwtToken = generator.CreateEncodedJwtToken(); return new Credentials(jwtToken, AuthenticationType.Bearer); -#else - // return null, which will cause the [GitHubAppTest]'s to not be discovered - return null; -#endif - }); static readonly Lazy<Uri> _customUrl = new Lazy<Uri>(() => diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 513f252fe3..a99961f414 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -19,16 +19,12 @@ <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> </PropertyGroup> - <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' "> - <DefineConstants>$(DefineConstants);GITHUBJWT_HELPER_AVAILABLE</DefineConstants> - </PropertyGroup> - <ItemGroup> <Compile Include="..\Octokit.Tests\Helpers\AssertEx.cs" /> <EmbeddedResource Include="fixtures\hello-world.txt;fixtures\hello-world.zip" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" /> <None Include="app.config" /> </ItemGroup> - + <ItemGroup> <ProjectReference Include="..\Octokit\Octokit.csproj" /> <ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj" /> @@ -36,18 +32,15 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> - <PackageReference Include="System.IO.Compression" Version="4.3.0" /> - <PackageReference Include="xunit" Version="2.4.2" /> - <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> + <PackageReference Include="GitHubJwt" Version="0.0.5" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> + <PackageReference Include="System.IO.Compression" Version="4.3.0" /> + <PackageReference Include="xunit" Version="2.4.2" /> + <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> <ItemGroup> - <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> - </ItemGroup> - - <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'"> - <PackageReference Include="GitHubJwt" Version="0.0.5" /> + <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> diff --git a/Octokit.Tests/Fixtures/EmbeddedResource.cs b/Octokit.Tests/Fixtures/EmbeddedResource.cs index 445f00e19a..375312e508 100644 --- a/Octokit.Tests/Fixtures/EmbeddedResource.cs +++ b/Octokit.Tests/Fixtures/EmbeddedResource.cs @@ -20,13 +20,7 @@ public EmbeddedResource(Assembly assembly, string resourceName) public string GetResourceAsString(Encoding encoding = null) { - encoding = encoding ?? -#if HAS_DEFAULT_ENCODING - Encoding.Default; -#else - // http://stackoverflow.com/questions/35929391/how-can-i-determine-the-default-encoding-in-a-portable-class-library - Encoding.GetEncoding(0); -#endif + encoding = encoding ?? Encoding.GetEncoding(0); using (var sr = new StreamReader(GetResourceStream(), encoding)) { diff --git a/Octokit.Tests/Fixtures/Fixtures.cs b/Octokit.Tests/Fixtures/Fixtures.cs index edc9aef620..13bedb3d79 100644 --- a/Octokit.Tests/Fixtures/Fixtures.cs +++ b/Octokit.Tests/Fixtures/Fixtures.cs @@ -1,12 +1,9 @@ -#if HAS_TYPEINFO -using System.Reflection; -#endif +using System.Reflection; namespace Octokit.Tests { public static class Fixtures { -#if HAS_TYPEINFO public static EmbeddedResource AuthorizationsJson = new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.authorizations.json"); @@ -33,33 +30,5 @@ public static class Fixtures public static EmbeddedResource ReleaseAssetJson = new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.release_asset.json"); -#else - public static EmbeddedResource AuthorizationsJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.authorizations.json"); - - public static EmbeddedResource AuthorizationJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.authorization.json"); - - public static EmbeddedResource UserJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.user.json"); - - public static EmbeddedResource UserFullJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.user_full.json"); - - public static EmbeddedResource RepositoryJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.repository.json"); - - public static EmbeddedResource RepositoriesJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.repositories.json"); - - public static EmbeddedResource ReleasesJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.releases.json"); - - public static EmbeddedResource ReleaseJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.release.json"); - - public static EmbeddedResource ReleaseAssetJson = - new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.release_asset.json"); -#endif } } diff --git a/Octokit.Tests/Http/RateLimitTests.cs b/Octokit.Tests/Http/RateLimitTests.cs index d16082a3a8..2e298aaa54 100644 --- a/Octokit.Tests/Http/RateLimitTests.cs +++ b/Octokit.Tests/Http/RateLimitTests.cs @@ -79,6 +79,7 @@ public void CanPopulateObjectFromSerializedData() }; var rateLimit = new RateLimit(headers); + var deserialized = BinaryFormatterExtensions.SerializeAndDeserializeObject(rateLimit); Assert.Equal(100, deserialized.Limit); diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 3eb7e6c47a..92ec09d1dc 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -32,10 +32,6 @@ <PackageReference Include="NSubstitute" Version="4.4.0" /> </ItemGroup> - <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' "> - <DefineConstants>$(DefineConstants);NO_SERIALIZABLE;HAS_TYPEINFO</DefineConstants> - </PropertyGroup> - <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> diff --git a/Octokit.Tests/SelfTests.cs b/Octokit.Tests/SelfTests.cs index 98701b9394..c419425785 100644 --- a/Octokit.Tests/SelfTests.cs +++ b/Octokit.Tests/SelfTests.cs @@ -1,6 +1,4 @@ -#if HAS_TYPEINFO -using System.Reflection; -#endif +using System.Reflection; using Xunit; /// <summary> @@ -11,11 +9,7 @@ public class SelfTests [Fact] public void NoTestsUseAsyncVoid() { -#if HAS_TYPEINFO var errors = typeof(SelfTests).GetTypeInfo().Assembly.GetAsyncVoidMethodsList(); -#else - var errors = typeof(SelfTests).Assembly.GetAsyncVoidMethodsList(); -#endif Assert.Equal("", errors); } } diff --git a/Octokit/Exceptions/AbuseException.cs b/Octokit/Exceptions/AbuseException.cs index 5e94754b95..3a8d13406f 100644 --- a/Octokit/Exceptions/AbuseException.cs +++ b/Octokit/Exceptions/AbuseException.cs @@ -4,10 +4,8 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; using System.Security; -#endif namespace Octokit { @@ -15,9 +13,7 @@ namespace Octokit /// Represents a subset of the HTTP 403 - Forbidden response returned from the API when the forbidden response is related to an abuse detection mechanism. /// Contains the amount of seconds after which it's safe to retry the request. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class AbuseException : ForbiddenException @@ -63,7 +59,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Request Forbidden - Abuse Detection"; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of AbuseException /// </summary> @@ -86,6 +81,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("RetryAfterSeconds", RetryAfterSeconds); } -#endif } } diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 91f255975d..99d2fa1b6b 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -1,9 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Security; using Octokit.Internal; @@ -12,9 +10,7 @@ namespace Octokit /// <summary> /// Represents errors that occur from the GitHub API. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class ApiException : Exception @@ -143,7 +139,6 @@ static ApiError GetApiErrorFromExceptionMessage(string responseContent) return new ApiError(responseContent); } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of ApiException. /// </summary> @@ -170,7 +165,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("HttpStatusCode", StatusCode); info.AddValue("ApiError", ApiError); } -#endif /// <summary> /// Get the inner error message from the API response diff --git a/Octokit/Exceptions/ApiValidationException.cs b/Octokit/Exceptions/ApiValidationException.cs index 3b76a8ed52..e349830ffa 100644 --- a/Octokit/Exceptions/ApiValidationException.cs +++ b/Octokit/Exceptions/ApiValidationException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// <summary> /// Represents a HTTP 422 - Unprocessable Entity response returned from the API. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class ApiValidationException : ApiException @@ -60,7 +56,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Validation Failed"; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of ApiValidationException /// </summary> @@ -76,6 +71,5 @@ protected ApiValidationException(SerializationInfo info, StreamingContext contex : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/AuthorizationException.cs b/Octokit/Exceptions/AuthorizationException.cs index f47bb0deb7..4ab2e4e09f 100644 --- a/Octokit/Exceptions/AuthorizationException.cs +++ b/Octokit/Exceptions/AuthorizationException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// <summary> /// Represents a HTTP 401 - Unauthorized response returned from the API. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class AuthorizationException : ApiException @@ -51,7 +47,6 @@ public AuthorizationException(HttpStatusCode httpStatusCode, Exception innerExce { } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of AuthorizationException. /// </summary> @@ -67,6 +62,5 @@ protected AuthorizationException(SerializationInfo info, StreamingContext contex : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/ForbiddenException.cs b/Octokit/Exceptions/ForbiddenException.cs index 9f15d11786..1988286735 100644 --- a/Octokit/Exceptions/ForbiddenException.cs +++ b/Octokit/Exceptions/ForbiddenException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// <summary> /// Represents a HTTP 403 - Forbidden response returned from the API. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class ForbiddenException : ApiException @@ -43,7 +39,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Request Forbidden"; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of ForbiddenException /// </summary> @@ -59,6 +54,5 @@ protected ForbiddenException(SerializationInfo info, StreamingContext context) : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs index 6e0d8db546..7c8f354e51 100644 --- a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs +++ b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs @@ -1,17 +1,13 @@ using System; using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// <summary> /// Represents a HTTP 403 - Forbidden response returned from the API. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class InvalidGitIgnoreTemplateException : ApiValidationException @@ -38,7 +34,6 @@ public override string Message } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of InvalidGitignoreTemplateException /// </summary> @@ -53,6 +48,5 @@ public override string Message protected InvalidGitIgnoreTemplateException(SerializationInfo info, StreamingContext context) : base(info, context) { } -#endif } } \ No newline at end of file diff --git a/Octokit/Exceptions/LegalRestrictionException.cs b/Octokit/Exceptions/LegalRestrictionException.cs index d7ac60c22e..6868949eac 100644 --- a/Octokit/Exceptions/LegalRestrictionException.cs +++ b/Octokit/Exceptions/LegalRestrictionException.cs @@ -2,9 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { @@ -13,9 +11,7 @@ namespace Octokit /// This will returned if GitHub has been asked to takedown the requested resource due to /// a DMCA takedown. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class LegalRestrictionException : ApiException @@ -54,7 +50,6 @@ public LegalRestrictionException(IResponse response, Exception innerException) "LegalRestrictionException created with wrong status code"); } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of LegalRestrictionException /// </summary> @@ -70,6 +65,5 @@ protected LegalRestrictionException(SerializationInfo info, StreamingContext con : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/LoginAttemptsExceededException.cs b/Octokit/Exceptions/LoginAttemptsExceededException.cs index 56269c98fc..fe6fab01a6 100644 --- a/Octokit/Exceptions/LoginAttemptsExceededException.cs +++ b/Octokit/Exceptions/LoginAttemptsExceededException.cs @@ -1,17 +1,13 @@ using System; using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// <summary> /// Represents a "Login Attempts Exceeded" response returned from the API. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class LoginAttemptsExceededException : ForbiddenException @@ -40,7 +36,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Maximum number of login attempts exceeded"; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of LoginAttemptsExceededException /// </summary> @@ -56,6 +51,5 @@ protected LoginAttemptsExceededException(SerializationInfo info, StreamingContex : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/NotFoundException.cs b/Octokit/Exceptions/NotFoundException.cs index 4f64b26b86..d4943867a7 100644 --- a/Octokit/Exceptions/NotFoundException.cs +++ b/Octokit/Exceptions/NotFoundException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// <summary> /// Represents a HTTP 404 - Not Found response returned from the API. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class NotFoundException : ApiException @@ -47,7 +43,6 @@ public NotFoundException(IResponse response, Exception innerException) "NotFoundException created with wrong status code"); } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of NotFoundException /// </summary> @@ -63,6 +58,5 @@ protected NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/PullRequestMismatchException.cs b/Octokit/Exceptions/PullRequestMismatchException.cs index 83df68cc66..310fc264af 100644 --- a/Octokit/Exceptions/PullRequestMismatchException.cs +++ b/Octokit/Exceptions/PullRequestMismatchException.cs @@ -2,9 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { @@ -12,9 +10,7 @@ namespace Octokit /// Represents an error that occurs when the specified SHA /// doesn't match the current pull request's HEAD /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class PullRequestMismatchException : ApiException @@ -45,7 +41,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Head branch was modified. Review and try the merge again."; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of <see cref="Octokit.PullRequestNotMergeableException"/>. /// </summary> @@ -61,6 +56,5 @@ protected PullRequestMismatchException(SerializationInfo info, StreamingContext : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/PullRequestNotMergeableException.cs b/Octokit/Exceptions/PullRequestNotMergeableException.cs index 89ce79e158..4e92e16dfb 100644 --- a/Octokit/Exceptions/PullRequestNotMergeableException.cs +++ b/Octokit/Exceptions/PullRequestNotMergeableException.cs @@ -2,9 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { @@ -12,9 +10,7 @@ namespace Octokit /// Represents an error that occurs when the pull request is in an /// unmergeable state /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class PullRequestNotMergeableException : ApiException @@ -45,7 +41,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Pull Request is not mergeable"; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of <see cref="Octokit.PullRequestNotMergeableException"/>. /// </summary> @@ -61,6 +56,5 @@ protected PullRequestNotMergeableException(SerializationInfo info, StreamingCont : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/RateLimitExceededException.cs b/Octokit/Exceptions/RateLimitExceededException.cs index 537d9c82d1..61a17ca10a 100644 --- a/Octokit/Exceptions/RateLimitExceededException.cs +++ b/Octokit/Exceptions/RateLimitExceededException.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Security; namespace Octokit @@ -18,9 +16,7 @@ namespace Octokit /// </para> /// <para>See http://developer.github.com/v3/#rate-limiting for more details.</para> /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class RateLimitExceededException : ForbiddenException @@ -102,7 +98,6 @@ public TimeSpan GetRetryAfterTimeSpan() return ts > TimeSpan.Zero ? ts : TimeSpan.Zero; } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of RateLimitExceededException /// </summary> @@ -131,6 +126,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("RateLimit", _rateLimit); info.AddValue(nameof(ApiInfo.ServerTimeDifference), _severTimeDiff); } -#endif } } diff --git a/Octokit/Exceptions/RepositoryExistsException.cs b/Octokit/Exceptions/RepositoryExistsException.cs index d3d773ef40..e606b1e3e9 100644 --- a/Octokit/Exceptions/RepositoryExistsException.cs +++ b/Octokit/Exceptions/RepositoryExistsException.cs @@ -1,9 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Security; namespace Octokit @@ -11,9 +9,7 @@ namespace Octokit /// <summary> /// Exception thrown when creating a repository, but it already exists on the server. /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class RepositoryExistsException : ApiValidationException @@ -97,7 +93,6 @@ public override string Message /// </summary> public bool OwnerIsOrganization { get; private set; } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of RepositoryExistsException. /// </summary> @@ -130,6 +125,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("OwnerIsOrganization", OwnerIsOrganization); info.AddValue("ExistingRepositoryWebUrl", ExistingRepositoryWebUrl); } -#endif } } diff --git a/Octokit/Exceptions/RepositoryFormatException.cs b/Octokit/Exceptions/RepositoryFormatException.cs index c0ab53b515..60428fc3bf 100644 --- a/Octokit/Exceptions/RepositoryFormatException.cs +++ b/Octokit/Exceptions/RepositoryFormatException.cs @@ -2,16 +2,12 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Security; namespace Octokit { -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class RepositoryFormatException : Exception @@ -35,7 +31,6 @@ public override string Message } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of LoginAttemptsExceededException /// </summary> @@ -60,6 +55,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("Message", Message); } -#endif } } diff --git a/Octokit/Exceptions/SecondaryRateLimitExceededException.cs b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs index 48d264a751..dc0795b742 100644 --- a/Octokit/Exceptions/SecondaryRateLimitExceededException.cs +++ b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs @@ -1,8 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { @@ -16,9 +14,7 @@ namespace Octokit /// </para> /// <para>See https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits for more details.</para> /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class SecondaryRateLimitExceededException : ForbiddenException @@ -46,7 +42,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Secondary API Rate Limit exceeded"; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of <see cref="Octokit.SecondaryRateLimitExceededException"/>. /// </summary> @@ -62,6 +57,5 @@ protected SecondaryRateLimitExceededException(SerializationInfo info, StreamingC : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/TwoFactorAuthorizationException.cs b/Octokit/Exceptions/TwoFactorAuthorizationException.cs index b1ab087f10..1e107497b3 100644 --- a/Octokit/Exceptions/TwoFactorAuthorizationException.cs +++ b/Octokit/Exceptions/TwoFactorAuthorizationException.cs @@ -2,19 +2,15 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Security; namespace Octokit { -#if !NO_SERIALIZABLE /// <summary> /// Represents a failed 2FA challenge from the API /// </summary> [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public abstract class TwoFactorAuthorizationException : AuthorizationException @@ -64,7 +60,6 @@ protected TwoFactorAuthorizationException(IResponse response, TwoFactorType twoF /// </summary> public TwoFactorType TwoFactorType { get; private set; } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of TwoFactorRequiredException. /// </summary> @@ -89,8 +84,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("TwoFactorType", TwoFactorType); } -#endif - } /// <summary> diff --git a/Octokit/Exceptions/TwoFactorChallengeFailedException.cs b/Octokit/Exceptions/TwoFactorChallengeFailedException.cs index 3e1b799f54..a317e176eb 100644 --- a/Octokit/Exceptions/TwoFactorChallengeFailedException.cs +++ b/Octokit/Exceptions/TwoFactorChallengeFailedException.cs @@ -1,18 +1,14 @@ using System; using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Security; namespace Octokit { -#if !NO_SERIALIZABLE /// <summary> /// Represents a failed 2FA challenge from the API /// </summary> [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class TwoFactorChallengeFailedException : TwoFactorAuthorizationException @@ -49,7 +45,6 @@ static TwoFactorType ParseTwoFactorType(ApiException exception) return exception == null ? TwoFactorType.None : Connection.ParseTwoFactorType(exception.HttpResponse); } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of TwoFactorChallengeFailedException. /// </summary> @@ -73,6 +68,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("AuthorizationCode", AuthorizationCode); } -#endif } } diff --git a/Octokit/Exceptions/TwoFactorRequiredException.cs b/Octokit/Exceptions/TwoFactorRequiredException.cs index 22f4276d19..5cdf5dab6d 100644 --- a/Octokit/Exceptions/TwoFactorRequiredException.cs +++ b/Octokit/Exceptions/TwoFactorRequiredException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// <summary> /// /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class TwoFactorRequiredException : TwoFactorAuthorizationException @@ -50,7 +46,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Two-factor authentication code is required"; } } -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of TwoFactorRequiredException. /// </summary> @@ -66,6 +61,5 @@ protected TwoFactorRequiredException(SerializationInfo info, StreamingContext co : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs b/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs index 9435b21e8f..ec8478581d 100644 --- a/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs +++ b/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs @@ -2,9 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { @@ -12,9 +10,7 @@ namespace Octokit /// Represents an error that occurs when trying to convert the /// last owner of the organization to an outside collaborator /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class UserIsLastOwnerOfOrganizationException : ApiException @@ -42,7 +38,6 @@ public UserIsLastOwnerOfOrganizationException(IResponse response, ApiException i // https://developer.github.com/v3/orgs/outside_collaborators/#response-if-user-is-the-last-owner-of-the-organization public override string Message => ApiErrorMessageSafe ?? "User is the last owner of the organization."; -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of <see cref="UserIsLastOwnerOfOrganizationException"/>. /// </summary> @@ -58,6 +53,5 @@ protected UserIsLastOwnerOfOrganizationException(SerializationInfo info, Streami : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs b/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs index 05976c6260..257e96fc9d 100644 --- a/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs +++ b/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs @@ -2,9 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { @@ -12,9 +10,7 @@ namespace Octokit /// Represents an error that occurs when trying to convert a user /// that is not a member of the organization to an outside collaborator /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class UserIsNotMemberOfOrganizationException : ApiException @@ -42,7 +38,6 @@ public UserIsNotMemberOfOrganizationException(IResponse response, ApiException i // https://developer.github.com/v3/orgs/outside_collaborators/#response-if-user-is-not-a-member-of-the-organization public override string Message => ApiErrorMessageSafe ?? "User is not a member of the organization."; -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of ForbiddenException /// </summary> @@ -58,6 +53,5 @@ protected UserIsNotMemberOfOrganizationException(SerializationInfo info, Streami : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/UserIsOrganizationMemberException.cs b/Octokit/Exceptions/UserIsOrganizationMemberException.cs index 06120d9044..072a763ce2 100644 --- a/Octokit/Exceptions/UserIsOrganizationMemberException.cs +++ b/Octokit/Exceptions/UserIsOrganizationMemberException.cs @@ -2,9 +2,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { @@ -12,9 +10,7 @@ namespace Octokit /// Represents an error that occurs when trying to remove an /// outside collaborator that is a member of the organization /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class UserIsOrganizationMemberException : ApiException @@ -42,7 +38,6 @@ public UserIsOrganizationMemberException(IResponse response, ApiException innerE // https://developer.github.com/v3/orgs/outside_collaborators/#response-if-user-is-a-member-of-the-organization public override string Message => ApiErrorMessageSafe ?? "User could not be removed as an outside collaborator."; -#if !NO_SERIALIZABLE /// <summary> /// Constructs an instance of <see cref="UserIsOrganizationMemberException"/>. /// </summary> @@ -58,6 +53,5 @@ protected UserIsOrganizationMemberException(SerializationInfo info, StreamingCon : base(info, context) { } -#endif } } diff --git a/Octokit/Helpers/ReflectionExtensions.cs b/Octokit/Helpers/ReflectionExtensions.cs index 49265172a8..cc8f5a4d75 100644 --- a/Octokit/Helpers/ReflectionExtensions.cs +++ b/Octokit/Helpers/ReflectionExtensions.cs @@ -39,12 +39,6 @@ public static bool IsNullable(this Type type) return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); } -#if !HAS_TYPEINFO - public static Type GetTypeInfo(this Type type) - { - return type; - } -#else public static IEnumerable<MemberInfo> GetMember(this Type type, string name) { return type.GetTypeInfo().DeclaredMembers.Where(m => m.Name == name); @@ -59,19 +53,14 @@ public static bool IsAssignableFrom(this Type type, Type otherType) { return type.GetTypeInfo().IsAssignableFrom(otherType.GetTypeInfo()); } -#endif public static IEnumerable<PropertyInfo> GetAllProperties(this Type type) { -#if HAS_TYPEINFO var typeInfo = type.GetTypeInfo(); var properties = typeInfo.DeclaredProperties; var baseType = typeInfo.BaseType; return baseType == null ? properties : properties.Concat(baseType.GetAllProperties()); -#else - return type.GetProperties(BindingFlags.Instance | BindingFlags.Public); -#endif } public static bool IsEnumeration(this Type type) diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 17cfce19fb..bcace9f7ee 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -8,9 +8,6 @@ using System.Threading; using System.Threading.Tasks; using Octokit.Internal; -#if !HAS_ENVIRONMENT -using System.Runtime.InteropServices; -#endif namespace Octokit { @@ -790,17 +787,11 @@ static string GetPlatformInformation() try { _platformInformation = string.Format(CultureInfo.InvariantCulture, -#if !HAS_ENVIRONMENT - "{0}; {1}", - RuntimeInformation.OSDescription.Trim(), - RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant().Trim() -#else "{0} {1}; {2}", Environment.OSVersion.Platform, Environment.OSVersion.Version.ToString(3), Environment.Is64BitOperatingSystem ? "amd64" : "x86" -#endif - ); + ); } catch { diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index efe823dda5..eca20a7480 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -29,31 +29,6 @@ public HttpClientAdapter(Func<HttpMessageHandler> getHandler) { Ensure.ArgumentNotNull(getHandler, nameof(getHandler)); -#if HAS_SERVICEPOINTMANAGER - // GitHub API requires TLS1.2 as of February 2018 - // - // .NET Framework before 4.6 did not enable TLS1.2 by default - // - // Even though this is an AppDomain wide setting, the decision was made for Octokit to - // ensure that TLS1.2 is enabled so that existing applications using Octokit did not need to - // make changes outside Octokit to continue to work with GitHub API - // - // *Update* - // .NET Framework 4.7 introduced a new value (SecurityProtocolType.SystemDefault = 0) - // which defers enabled protocols to operating system defaults - // If this is the current value we shouldn't do anything, as that would cause TLS1.2 to be the ONLY enabled protocol! - // - // See https://docs.microsoft.com/en-us/dotnet/api/system.net.securityprotocoltype?view=netframework-4.7 - // See https://github.com/octokit/octokit.net/issues/1914 - - // Only apply when current setting is not SystemDefault (0) added in .NET 4.7 - if ((int)ServicePointManager.SecurityProtocol != 0) - { - // Add Tls1.2 to the existing enabled protocols - ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; - } -#endif - _http = new HttpClient(new RedirectHandler { InnerHandler = getHandler() }); } diff --git a/Octokit/Http/RateLimit.cs b/Octokit/Http/RateLimit.cs index 016ef4944a..0695726bd5 100644 --- a/Octokit/Http/RateLimit.cs +++ b/Octokit/Http/RateLimit.cs @@ -4,22 +4,15 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Security; using Octokit.Internal; namespace Octokit { -#if !NO_SERIALIZABLE [Serializable] -#endif [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class RateLimit -#if !NO_SERIALIZABLE - : ISerializable -#endif + public class RateLimit : ISerializable { public RateLimit() { } @@ -96,7 +89,6 @@ static long GetHeaderValueAsInt32Safe(IDictionary<string, string> responseHeader : result; } -#if !NO_SERIALIZABLE protected RateLimit(SerializationInfo info, StreamingContext context) { Ensure.ArgumentNotNull(info, nameof(info)); @@ -115,7 +107,6 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte info.AddValue("Remaining", Remaining); info.AddValue("ResetAsUtcEpochSeconds", ResetAsUtcEpochSeconds); } -#endif internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ApiError.cs b/Octokit/Models/Response/ApiError.cs index be5650c9f6..2317cdacab 100644 --- a/Octokit/Models/Response/ApiError.cs +++ b/Octokit/Models/Response/ApiError.cs @@ -8,9 +8,7 @@ namespace Octokit /// <summary> /// Error payload from the API response /// </summary> -#if !NO_SERIALIZABLE [Serializable] -#endif [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ApiError { diff --git a/Octokit/Models/Response/ApiErrorDetail.cs b/Octokit/Models/Response/ApiErrorDetail.cs index 9e9d9f76bc..391561e02e 100644 --- a/Octokit/Models/Response/ApiErrorDetail.cs +++ b/Octokit/Models/Response/ApiErrorDetail.cs @@ -4,9 +4,7 @@ namespace Octokit { -#if !NO_SERIALIZABLE [Serializable] -#endif [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ApiErrorDetail { diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 0148ebc3eb..33b13e2f7c 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -20,7 +20,7 @@ </PropertyGroup> <PropertyGroup> - <DefineConstants>$(DefineConstants);HAS_TYPEINFO;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> + <DefineConstants>$(DefineConstants);SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> <NoWarn>1591;1701;1702;1705</NoWarn> </PropertyGroup> diff --git a/Octokit/SimpleJson.cs b/Octokit/SimpleJson.cs index 5d5161c202..eab7a32a6f 100644 --- a/Octokit/SimpleJson.cs +++ b/Octokit/SimpleJson.cs @@ -59,9 +59,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif using System.Text; using Octokit.Reflection; #if !SIMPLE_JSON_NO_LINQ_EXPRESSION @@ -549,11 +547,7 @@ public static object DeserializeObject(string json) if (TryDeserializeObject(json, out obj)) return obj; -#if !NO_SERIALIZABLE throw new SerializationException("Invalid JSON string"); -#else - throw new Exception("Invalid JSON string"); -#endif } /// <summary> From b866d669d664e2726a5cd9e6ad985a382e800f64 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 12 Aug 2022 18:21:36 +0100 Subject: [PATCH 110/209] feat: Adding seats and filled seats to plan response. (#2539) --- .../Clients/OrganizationClientTests.cs | 46 ++++++++++++------- Octokit/Models/Response/Plan.cs | 31 ++++++++----- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/OrganizationClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationClientTests.cs index 1ca0e804c9..8faabf581d 100644 --- a/Octokit.Tests.Integration/Clients/OrganizationClientTests.cs +++ b/Octokit.Tests.Integration/Clients/OrganizationClientTests.cs @@ -8,19 +8,12 @@ public class OrganizationClientTests { public class TheGetAllMethod { - readonly IGitHubClient _github; - readonly IOrganizationsClient _organizationsClient; - - public TheGetAllMethod() - { - _github = EnterpriseHelper.GetAuthenticatedClient(); - - _organizationsClient = _github.Organization; - } - [GitHubEnterpriseTest] public async Task CanListAllOrganizations() { + var github = EnterpriseHelper.GetAuthenticatedClient(); + var organizationsClient = github.Organization; + string orgLogin1 = Helper.MakeNameWithTimestamp("MyOrganization1"); string orgName1 = string.Concat(orgLogin1, " Display Name 1"); string orgLogin2 = Helper.MakeNameWithTimestamp("MyOrganization2"); @@ -28,10 +21,10 @@ public async Task CanListAllOrganizations() var newOrganization1 = new NewOrganization(orgLogin1, EnterpriseHelper.UserName, orgName1); var newOrganization2 = new NewOrganization(orgLogin2, EnterpriseHelper.UserName, orgName2); - await _github.Enterprise.Organization.Create(newOrganization1); - await _github.Enterprise.Organization.Create(newOrganization2); + await github.Enterprise.Organization.Create(newOrganization1); + await github.Enterprise.Organization.Create(newOrganization2); - var organizations = await _organizationsClient.GetAll(); + var organizations = await organizationsClient.GetAll(); Assert.Contains(organizations, (org => org.Login == orgLogin1)); Assert.Contains(organizations, (org => org.Login == orgLogin2)); @@ -40,6 +33,9 @@ public async Task CanListAllOrganizations() [GitHubEnterpriseTest] public async Task ReturnsCorrectOrganizationsWithSince() { + var github = EnterpriseHelper.GetAuthenticatedClient(); + var organizationsClient = github.Organization; + string orgLogin1 = Helper.MakeNameWithTimestamp("MyOrganization1"); string orgName1 = string.Concat(orgLogin1, " Display Name 1"); string orgLogin2 = Helper.MakeNameWithTimestamp("MyOrganization2"); @@ -51,13 +47,13 @@ public async Task ReturnsCorrectOrganizationsWithSince() var newOrganization2 = new NewOrganization(orgLogin2, EnterpriseHelper.UserName, orgName2); var newOrganization3 = new NewOrganization(orgLogin3, EnterpriseHelper.UserName, orgName3); - var createdOrganization1 = await _github.Enterprise.Organization.Create(newOrganization1); - var createdOrganization2 = await _github.Enterprise.Organization.Create(newOrganization2); - var createdOrganization3 = await _github.Enterprise.Organization.Create(newOrganization3); + var createdOrganization1 = await github.Enterprise.Organization.Create(newOrganization1); + var createdOrganization2 = await github.Enterprise.Organization.Create(newOrganization2); + var createdOrganization3 = await github.Enterprise.Organization.Create(newOrganization3); var requestParameter = new OrganizationRequest(createdOrganization1.Id); - var organizations = await _organizationsClient.GetAll(requestParameter); + var organizations = await organizationsClient.GetAll(requestParameter); Assert.DoesNotContain(organizations, (org => org.Login == orgLogin1)); Assert.Contains(organizations, (org => org.Login == orgLogin2)); @@ -65,6 +61,22 @@ public async Task ReturnsCorrectOrganizationsWithSince() } } + public class TheGetMethod + { + [IntegrationTest] + [PotentiallyFlakyTest] + public async Task GetFreeOrganization() + { + var github = Helper.GetAuthenticatedClient(); + + var organization = await + github.Organization.Get("snyrting6orggithub"); + + Assert.Equal(0, organization.Plan.Seats); + Assert.Equal(1, organization.Plan.FilledSeats); + } + } + public class TheGetAllForCurrentMethod { readonly IGitHubClient _github; diff --git a/Octokit/Models/Response/Plan.cs b/Octokit/Models/Response/Plan.cs index f5de2a8b3b..336dc1baca 100644 --- a/Octokit/Models/Response/Plan.cs +++ b/Octokit/Models/Response/Plan.cs @@ -1,5 +1,5 @@ +using Octokit.Internal; using System.Diagnostics; -using System.Globalization; namespace Octokit { @@ -11,46 +11,55 @@ public class Plan { public Plan() { } - public Plan(long collaborators, string name, long privateRepos, long space, string billingEmail) + public Plan(long collaborators, string name, long privateRepos, long space, string billingEmail, int filledSeats, int seats) { Collaborators = collaborators; Name = name; PrivateRepos = privateRepos; Space = space; BillingEmail = billingEmail; + FilledSeats = filledSeats; + Seats = seats; } /// <summary> /// The number of collaborators allowed with this plan. /// </summary> /// <remarks>This returns <see cref="long"/> because GitHub Enterprise uses a sentinel value of 999999999999 to denote an "unlimited" number of collaborators.</remarks> - public long Collaborators { get; protected set; } + public long Collaborators { get; private set; } /// <summary> /// The name of the plan. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The number of private repositories allowed with this plan. /// </summary> /// <remarks>This returns <see cref="long"/> because GitHub Enterprise uses a sentinel value of 999999999999 to denote an "unlimited" number of plans.</remarks> - public long PrivateRepos { get; protected set; } + public long PrivateRepos { get; private set; } /// <summary> /// The amount of disk space allowed with this plan. /// </summary> /// <remarks>This returns <see cref="long"/> because GitHub Enterprise uses a sentinel value of 999999999999 to denote an "unlimited" amount of disk space.</remarks> - public long Space { get; protected set; } + public long Space { get; private set; } /// <summary> /// The billing email for the organization. Only has a value in response to editing an organization. /// </summary> - public string BillingEmail { get; protected set; } + public string BillingEmail { get; private set; } - internal string DebuggerDisplay - { - get { return string.Format(CultureInfo.InvariantCulture, "Name: {0}, Space: {1}, Private Repos: {2}, Collaborators: {3}", Name, Space, PrivateRepos, Collaborators); } - } + /// <summary> + /// The number of seats filled on this plan + /// </summary> + public int FilledSeats { get; private set; } + + /// <summary> + /// The number of seats available for this plan + /// </summary> + public int Seats { get; private set; } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); } } From 595e35d6419e444bbf20f9d02bab5a9749219e83 Mon Sep 17 00:00:00 2001 From: notauserx <82922717+notauserx@users.noreply.github.com> Date: Fri, 19 Aug 2022 23:36:47 +0600 Subject: [PATCH 111/209] add active lock reason to PR (#2543) * add active lock reason to PR * update docs * refactor: extract lock and unlock from IIssuesClient create ILockUnlockClient so both IIssuesClient and IPullRequestClient can access lock and unlock methods. * refactor LockUnlock for reactive clients * Update doc to include lock unlock sample code * Use Assert.Null to check null value in test Co-authored-by: notauserx <notauserx@users.noreply.github.com> --- .../Clients/IObservableIssuesClient.cs | 41 ++-------- .../Clients/IObservableLockUnlockClient.cs | 47 ++++++++++++ .../Clients/IObservablePullRequestsClient.cs | 5 ++ .../Clients/ObservableIssuesClient.cs | 60 ++------------- .../Clients/ObservableLockUnlockClient.cs | 75 ++++++++++++++++++ .../Clients/ObservablePullRequestsClient.cs | 6 ++ .../Clients/IssuesClientTests.cs | 10 +-- .../Clients/IssuesEventsClientTests.cs | 72 +++++++++--------- .../Clients/PullRequestsClientTests.cs | 19 +++++ .../Reactive/ObservableIssuesClientTests.cs | 4 +- Octokit.Tests/Clients/IssuesClientTests.cs | 24 +++--- .../Reactive/ObservableIssuesClientTests.cs | 32 ++++---- Octokit/Clients/IIssuesClient.cs | 37 +-------- Octokit/Clients/ILockUnlockClient.cs | 47 ++++++++++++ Octokit/Clients/IPullRequestsClient.cs | 5 ++ Octokit/Clients/IssuesClient.cs | 66 ++-------------- Octokit/Clients/LockUnlockClient.cs | 76 +++++++++++++++++++ Octokit/Clients/PullRequestsClient.cs | 6 ++ Octokit/Models/Response/PullRequest.cs | 8 +- docs/issues.md | 20 +++++ 20 files changed, 405 insertions(+), 255 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableLockUnlockClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableLockUnlockClient.cs create mode 100644 Octokit/Clients/ILockUnlockClient.cs create mode 100644 Octokit/Clients/LockUnlockClient.cs diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs index 3081488e98..8057f9e23e 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs @@ -44,6 +44,11 @@ public interface IObservableIssuesClient /// </summary> IObservableIssueTimelineClient Timeline { get; } + /// <summary> + /// Client for locking/unlocking conversation on an issue + /// </summary> + IObservableLockUnlockClient LockUnlock { get; } + /// <summary> /// Gets a single Issue by number. /// </summary> @@ -316,41 +321,5 @@ public interface IObservableIssuesClient /// <param name="issueUpdate">An <see cref="IssueUpdate"/> instance describing the changes to make to the issue /// </param> IObservable<Issue> Update(long repositoryId, int number, IssueUpdate issueUpdate); - - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null); - - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null); - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - IObservable<Unit> Unlock(string owner, string name, int number); - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - IObservable<Unit> Unlock(long repositoryId, int number); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableLockUnlockClient.cs b/Octokit.Reactive/Clients/IObservableLockUnlockClient.cs new file mode 100644 index 0000000000..b897141b59 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableLockUnlockClient.cs @@ -0,0 +1,47 @@ +using System; +using System.Reactive; + +namespace Octokit.Reactive +{ + /// <summary> + /// Client to manage locking/unlocking a conversation for an Issue or a Pull request + /// </summary> + public interface IObservableLockUnlockClient + { + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null); + + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null); + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + IObservable<Unit> Unlock(string owner, string name, int number); + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + IObservable<Unit> Unlock(long repositoryId, int number); + } +} diff --git a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs index 007886afcf..997d662212 100644 --- a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs @@ -26,6 +26,11 @@ public interface IObservablePullRequestsClient /// </summary> IObservablePullRequestReviewRequestsClient ReviewRequest { get; } + /// <summary> + /// Client for locking/unlocking a conversation on a pull request + /// </summary> + IObservableLockUnlockClient LockUnlock { get; } + /// <summary> /// Gets a single Pull Request by number. /// </summary> diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index 2f2df7c915..033408d31c 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -48,6 +48,11 @@ public class ObservableIssuesClient : IObservableIssuesClient /// </summary> public IObservableIssueTimelineClient Timeline { get; private set; } + /// <summary> + /// Client for locking/unlocking conversation on an issue + /// </summary> + public IObservableLockUnlockClient LockUnlock { get; protected set; } + public ObservableIssuesClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, nameof(client)); @@ -60,6 +65,7 @@ public ObservableIssuesClient(IGitHubClient client) Milestone = new ObservableMilestonesClient(client); Comment = new ObservableIssueCommentsClient(client); Timeline = new ObservableIssueTimelineClient(client); + LockUnlock = new ObservableLockUnlockClient(client); } /// <summary> @@ -473,58 +479,6 @@ public IObservable<Issue> Update(long repositoryId, int number, IssueUpdate issu return _client.Update(repositoryId, number, issueUpdate).ToObservable(); } - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - public IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return _client.Lock(owner, name, number, lockReason).ToObservable(); - } - - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - public IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null) - { - return _client.Lock(repositoryId, number, lockReason).ToObservable(); - } - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - public IObservable<Unit> Unlock(string owner, string name, int number) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return _client.Unlock(owner, name, number).ToObservable(); - } - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - public IObservable<Unit> Unlock(long repositoryId, int number) - { - return _client.Unlock(repositoryId, number).ToObservable(); - } + } } diff --git a/Octokit.Reactive/Clients/ObservableLockUnlockClient.cs b/Octokit.Reactive/Clients/ObservableLockUnlockClient.cs new file mode 100644 index 0000000000..3010741a8c --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableLockUnlockClient.cs @@ -0,0 +1,75 @@ +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// Client to manage locking/unlocking a conversation for an Issue or a Pull request + /// </summary> + public class ObservableLockUnlockClient : IObservableLockUnlockClient + { + readonly ILockUnlockClient _client; + + public ObservableLockUnlockClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Issue.LockUnlock; + } + + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + public IObservable<Unit> Lock(string owner, string name, int number, LockReason? lockReason = null) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Lock(owner, name, number, lockReason).ToObservable(); + } + + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + public IObservable<Unit> Lock(long repositoryId, int number, LockReason? lockReason = null) + { + return _client.Lock(repositoryId, number, lockReason).ToObservable(); + } + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + public IObservable<Unit> Unlock(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return _client.Unlock(owner, name, number).ToObservable(); + } + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + public IObservable<Unit> Unlock(long repositoryId, int number) + { + return _client.Unlock(repositoryId, number).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs index 9fbafba8ba..0f34376011 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs @@ -30,6 +30,11 @@ public class ObservablePullRequestsClient : IObservablePullRequestsClient /// </summary> public IObservablePullRequestReviewRequestsClient ReviewRequest { get; private set; } + /// <summary> + /// Client for locking/unlocking a conversation on a pull request + /// </summary> + public IObservableLockUnlockClient LockUnlock { get; private set; } + public ObservablePullRequestsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, nameof(client)); @@ -39,6 +44,7 @@ public ObservablePullRequestsClient(IGitHubClient client) Review = new ObservablePullRequestReviewsClient(client); ReviewComment = new ObservablePullRequestReviewCommentsClient(client); ReviewRequest = new ObservablePullRequestReviewRequestsClient(client); + LockUnlock = new ObservableLockUnlockClient(client); } /// <summary> diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 16bf28f76f..2a92b35b59 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -241,12 +241,12 @@ public async Task CanLockAndUnlockIssue() var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); Assert.False(issue.Locked); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.NotNull(retrieved); Assert.True(retrieved.Locked); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.NotNull(retrieved); Assert.False(retrieved.Locked); @@ -259,7 +259,7 @@ public async Task CanAccessActiveLockReason() var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); Assert.False(issue.Locked); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number, LockReason.OffTopic); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number, LockReason.OffTopic); var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.NotNull(retrieved); Assert.True(retrieved.Locked); @@ -273,12 +273,12 @@ public async Task CanLockAndUnlockIssueWithRepositoryId() var issue = await _issuesClient.Create(_context.Repository.Id, newIssue); Assert.False(issue.Locked); - await _issuesClient.Lock(_context.Repository.Id, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.Repository.Id, issue.Number); var retrieved = await _issuesClient.Get(_context.Repository.Id, issue.Number); Assert.NotNull(retrieved); Assert.True(retrieved.Locked); - await _issuesClient.Unlock(_context.Repository.Id, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.Repository.Id, issue.Number); retrieved = await _issuesClient.Get(_context.Repository.Id, issue.Number); Assert.NotNull(retrieved); Assert.False(retrieved.Locked); diff --git a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs index 9daa2834fd..a223d65e60 100644 --- a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs @@ -63,9 +63,9 @@ public async Task ReturnsCorrectCountOfEventInfosWithoutStart() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -83,9 +83,9 @@ public async Task ReturnsCorrectCountOfEventInfosWithoutStartWithRepositoryId() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -103,9 +103,9 @@ public async Task ReturnsCorrectCountOfEventInfosWithStart() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -124,9 +124,9 @@ public async Task ReturnsCorrectCountOfEventInfosWithStartWithRepositoryId() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -145,9 +145,9 @@ public async Task ReturnsDistinctEventInfosBasedOnStartPage() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var startOptions = new ApiOptions { @@ -174,9 +174,9 @@ public async Task ReturnsDistinctEventInfosBasedOnStartPageWithRepositoryId() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var startOptions = new ApiOptions { @@ -259,9 +259,9 @@ public async Task ReturnsCorrectCountOfIssueEventsWithoutStart() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -279,9 +279,9 @@ public async Task ReturnsCorrectCountOfIssueEventsWithoutStartWithRepositoryId() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -299,9 +299,9 @@ public async Task ReturnsCorrectCountOfIssueEventsWithStart() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -320,9 +320,9 @@ public async Task ReturnsCorrectCountOfIssueEventsWithStartWithRepositoryId() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var options = new ApiOptions { @@ -341,9 +341,9 @@ public async Task ReturnsDistinctIssueEventsBasedOnStartPage() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var startOptions = new ApiOptions { @@ -370,9 +370,9 @@ public async Task ReturnsDistinctIssueEventsBasedOnStartPageWithRepositoryId() { var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); var startOptions = new ApiOptions { diff --git a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs index 8985e28b32..d8c6cc410e 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs @@ -653,6 +653,25 @@ public async Task CanClose() Assert.Equal(pullRequest.Body, result.Body); } + [IntegrationTest] + public async Task CanLockAndUnlock() + { + await CreateTheWorld(); + + var newPullRequest = new NewPullRequest("a pull request to lock", branchName, "main"); + var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); + + await _fixture.LockUnlock.Lock(Helper.UserName, _context.RepositoryName, pullRequest.Number, LockReason.OffTopic); + var retrived = await _fixture.Get(Helper.UserName, _context.RepositoryName, pullRequest.Number); + + Assert.Equal(retrived.ActiveLockReason, LockReason.OffTopic); + + await _fixture.LockUnlock.Unlock(Helper.UserName, _context.RepositoryName, pullRequest.Number); + var unlocked = await _fixture.Get(Helper.UserName, _context.RepositoryName, pullRequest.Number); + + Assert.Null(unlocked.ActiveLockReason); + } + [IntegrationTest] public async Task CanFindClosedPullRequest() { diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs index bedb3d3791..146228e980 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs @@ -118,11 +118,11 @@ public async Task CanLockAndUnlockIssues() var createResult = await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); Assert.False(createResult.Locked); - await _client.Lock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + await _client.LockUnlock.Lock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); var lockResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); Assert.True(lockResult.Locked); - await _client.Unlock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + await _client.LockUnlock.Unlock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); var unlockIssueResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); Assert.False(unlockIssueResult.Locked); } diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index 5eaceb81d7..6cfc3e783f 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -478,7 +478,7 @@ public void PostsToCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new IssuesClient(connection); - client.Lock("fake", "repo", 42); + client.LockUnlock.Lock("fake", "repo", 42); connection.Received().Put<Issue>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Any<object>()); } @@ -489,7 +489,7 @@ public void PostsToCorrectUrlWithRepositoryId() var connection = Substitute.For<IApiConnection>(); var client = new IssuesClient(connection); - client.Lock(1, 42); + client.LockUnlock.Lock(1, 42); connection.Received().Put<Issue>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/lock"), Arg.Any<object>()); } @@ -500,11 +500,11 @@ public async Task EnsuresNonNullArguments() var connection = Substitute.For<IApiConnection>(); var client = new IssuesClient(connection); - await Assert.ThrowsAsync<ArgumentNullException>(() => client.Lock(null, "name", 1)); - await Assert.ThrowsAsync<ArgumentNullException>(() => client.Lock("owner", null, 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.LockUnlock.Lock(null, "name", 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.LockUnlock.Lock("owner", null, 1)); - await Assert.ThrowsAsync<ArgumentException>(() => client.Lock("", "name", 1)); - await Assert.ThrowsAsync<ArgumentException>(() => client.Lock("owner", "", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.LockUnlock.Lock("", "name", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.LockUnlock.Lock("owner", "", 1)); } } @@ -516,7 +516,7 @@ public void PostsToCorrectUrl() var connection = Substitute.For<IApiConnection>(); var client = new IssuesClient(connection); - client.Unlock("fake", "repo", 42); + client.LockUnlock.Unlock("fake", "repo", 42); connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/lock")); } @@ -527,7 +527,7 @@ public void PostsToCorrectUrlWithApiOptions() var connection = Substitute.For<IApiConnection>(); var client = new IssuesClient(connection); - client.Unlock(1, 42); + client.LockUnlock.Unlock(1, 42); connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/lock")); } @@ -538,11 +538,11 @@ public async Task EnsuresNonNullArguments() var connection = Substitute.For<IApiConnection>(); var client = new IssuesClient(connection); - await Assert.ThrowsAsync<ArgumentNullException>(() => client.Unlock(null, "name", 1)); - await Assert.ThrowsAsync<ArgumentNullException>(() => client.Unlock("owner", null, 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.LockUnlock.Unlock(null, "name", 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.LockUnlock.Unlock("owner", null, 1)); - await Assert.ThrowsAsync<ArgumentException>(() => client.Unlock("", "name", 1)); - await Assert.ThrowsAsync<ArgumentException>(() => client.Unlock("owner", "", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.LockUnlock.Unlock("", "name", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.LockUnlock.Unlock("owner", "", 1)); } } diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index 347f17ad9f..6245620aab 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -645,9 +645,9 @@ public void LocksIssue() var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssuesClient(gitHubClient); - client.Lock("fake", "repo", 42); + client.LockUnlock.Lock("fake", "repo", 42); - gitHubClient.Issue.Received().Lock("fake", "repo", 42); + gitHubClient.Issue.Received().LockUnlock.Lock("fake", "repo", 42); } [Fact] @@ -656,9 +656,9 @@ public void LocksIssueWithRepositoryId() var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssuesClient(gitHubClient); - client.Lock(1, 42); + client.LockUnlock.Lock(1, 42); - gitHubClient.Issue.Received().Lock(1, 42); + gitHubClient.Issue.Received().LockUnlock.Lock(1, 42); } [Fact] @@ -667,11 +667,11 @@ public void EnsuresNonNullArguments() var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssuesClient(gitHubClient); - Assert.Throws<ArgumentNullException>(() => client.Lock(null, "name", 42)); - Assert.Throws<ArgumentNullException>(() => client.Lock("owner", null, 42)); + Assert.Throws<ArgumentNullException>(() => client.LockUnlock.Lock(null, "name", 42)); + Assert.Throws<ArgumentNullException>(() => client.LockUnlock.Lock("owner", null, 42)); - Assert.Throws<ArgumentException>(() => client.Lock("", "name", 42)); - Assert.Throws<ArgumentException>(() => client.Lock("owner", "", 42)); + Assert.Throws<ArgumentException>(() => client.LockUnlock.Lock("", "name", 42)); + Assert.Throws<ArgumentException>(() => client.LockUnlock.Lock("owner", "", 42)); } } @@ -683,9 +683,9 @@ public void UnlocksIssue() var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssuesClient(gitHubClient); - client.Unlock("fake", "repo", 42); + client.LockUnlock.Unlock("fake", "repo", 42); - gitHubClient.Issue.Received().Unlock("fake", "repo", 42); + gitHubClient.Issue.Received().LockUnlock.Unlock("fake", "repo", 42); } [Fact] @@ -694,9 +694,9 @@ public void UnlocksIssueWithRepositoryId() var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssuesClient(gitHubClient); - client.Unlock(1, 42); + client.LockUnlock.Unlock(1, 42); - gitHubClient.Issue.Received().Unlock(1, 42); + gitHubClient.Issue.Received().LockUnlock.Unlock(1, 42); } [Fact] @@ -705,11 +705,11 @@ public void EnsuresNonNullArguments() var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservableIssuesClient(gitHubClient); - Assert.Throws<ArgumentNullException>(() => client.Unlock(null, "name", 42)); - Assert.Throws<ArgumentNullException>(() => client.Unlock("owner", null, 42)); + Assert.Throws<ArgumentNullException>(() => client.LockUnlock.Unlock(null, "name", 42)); + Assert.Throws<ArgumentNullException>(() => client.LockUnlock.Unlock("owner", null, 42)); - Assert.Throws<ArgumentException>(() => client.Unlock("", "name", 42)); - Assert.Throws<ArgumentException>(() => client.Unlock("owner", "", 42)); + Assert.Throws<ArgumentException>(() => client.LockUnlock.Unlock("", "name", 42)); + Assert.Throws<ArgumentException>(() => client.LockUnlock.Unlock("owner", "", 42)); } } diff --git a/Octokit/Clients/IIssuesClient.cs b/Octokit/Clients/IIssuesClient.cs index 63f5611d09..c8dc2c1acd 100644 --- a/Octokit/Clients/IIssuesClient.cs +++ b/Octokit/Clients/IIssuesClient.cs @@ -41,6 +41,8 @@ public interface IIssuesClient IIssueTimelineClient Timeline { get; } + ILockUnlockClient LockUnlock { get; } + /// <summary> /// Gets a single Issue by number. /// </summary> @@ -314,40 +316,5 @@ public interface IIssuesClient /// </param> Task<Issue> Update(long repositoryId, int number, IssueUpdate issueUpdate); - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - Task Lock(string owner, string name, int number, LockReason? lockReason = null); - - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - Task Lock(long repositoryId, int number, LockReason? lockReason = null); - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - Task Unlock(string owner, string name, int number); - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - Task Unlock(long repositoryId, int number); } } \ No newline at end of file diff --git a/Octokit/Clients/ILockUnlockClient.cs b/Octokit/Clients/ILockUnlockClient.cs new file mode 100644 index 0000000000..da5f6ff86c --- /dev/null +++ b/Octokit/Clients/ILockUnlockClient.cs @@ -0,0 +1,47 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// Client to manage locking/unlocking a conversation for an Issue or a Pull request + /// </summary> + public interface ILockUnlockClient + { + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + Task Lock(string owner, string name, int number, LockReason? lockReason = null); + + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + Task Lock(long repositoryId, int number, LockReason? lockReason = null); + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + Task Unlock(string owner, string name, int number); + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + Task Unlock(long repositoryId, int number); + + } +} diff --git a/Octokit/Clients/IPullRequestsClient.cs b/Octokit/Clients/IPullRequestsClient.cs index 639c9c4f7c..e35d22d6e7 100644 --- a/Octokit/Clients/IPullRequestsClient.cs +++ b/Octokit/Clients/IPullRequestsClient.cs @@ -28,6 +28,11 @@ public interface IPullRequestsClient /// </summary> IPullRequestReviewRequestsClient ReviewRequest { get; } + /// <summary> + /// Client for locking/unlocking a coversation on a pull request + /// </summary> + ILockUnlockClient LockUnlock { get; } + /// <summary> /// Get a pull request by number. /// </summary> diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 508e6c2180..01c8c4d5fc 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -23,6 +23,7 @@ public IssuesClient(IApiConnection apiConnection) : base(apiConnection) Milestone = new MilestonesClient(apiConnection); Comment = new IssueCommentsClient(apiConnection); Timeline = new IssueTimelineClient(apiConnection); + LockUnlock = new LockUnlockClient(apiConnection); } /// <summary> @@ -57,6 +58,11 @@ public IssuesClient(IApiConnection apiConnection) : base(apiConnection) /// </summary> public IIssueTimelineClient Timeline { get; private set; } + /// <summary> + /// Client for locking and unlocking a conversation on a Issue or Pull request + /// </summary> + public ILockUnlockClient LockUnlock { get; private set; } + /// <summary> /// Gets a single Issue by number. /// </summary> @@ -491,64 +497,6 @@ public Task<Issue> Update(long repositoryId, int number, IssueUpdate issueUpdate Ensure.ArgumentNotNull(issueUpdate, nameof(issueUpdate)); return ApiConnection.Patch<Issue>(ApiUrls.Issue(repositoryId, number), issueUpdate); - } - - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - [ManualRoute("PUT", "/repos/{owner}/{repo}/issues/{issue_number}/lock")] - public Task Lock(string owner, string name, int number, LockReason? lockReason = null) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return ApiConnection.Put<Issue>(ApiUrls.IssueLock(owner, name, number), lockReason.HasValue ? new { LockReason = lockReason } : new object()); - } - - /// <summary> - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - /// <param name="lockReason">The reason for locking the issue</param> - [ManualRoute("PUT", "/repositories/{id}/issues/{number}/lock")] - public Task Lock(long repositoryId, int number, LockReason? lockReason = null) - { - return ApiConnection.Put<Issue>(ApiUrls.IssueLock(repositoryId, number), lockReason.HasValue ? new { LockReaons = lockReason } : new object()); - } - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="owner">The owner of the repository</param> - /// <param name="name">The name of the repository</param> - /// <param name="number">The issue number</param> - [ManualRoute("DELETE", "/repos/{owner}/{repo}/issues/{issue_number}/lock")] - public Task Unlock(string owner, string name, int number) - { - Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); - Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - - return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number)); - } - - /// <summary> - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// </summary> - /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> - /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue number</param> - [ManualRoute("DELETE", "/repositories/{id}/issues/{number}/lock")] - public Task Unlock(long repositoryId, int number) - { - return ApiConnection.Delete(ApiUrls.IssueLock(repositoryId, number)); - } + } } } diff --git a/Octokit/Clients/LockUnlockClient.cs b/Octokit/Clients/LockUnlockClient.cs new file mode 100644 index 0000000000..4acf702da3 --- /dev/null +++ b/Octokit/Clients/LockUnlockClient.cs @@ -0,0 +1,76 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// Client to manage locking/unlocking a conversation for an Issue or a Pull request + /// </summary> + public class LockUnlockClient : ApiClient, ILockUnlockClient + { + /// <summary> + /// Instantiates a new GitHub Issue Lock API client. + /// </summary> + /// <param name="apiConnection">An API connection</param> + public LockUnlockClient(IApiConnection apiConnection) : base(apiConnection) + { + + } + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + [ManualRoute("PUT", "/repos/{owner}/{repo}/issues/{issue_number}/lock")] + public Task Lock(string owner, string name, int number, LockReason? lockReason = null) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Put<Issue>(ApiUrls.IssueLock(owner, name, number), lockReason.HasValue ? new { LockReason = lockReason } : new object()); + } + + /// <summary> + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + /// <param name="lockReason">The reason for locking the issue</param> + [ManualRoute("PUT", "/repositories/{id}/issues/{number}/lock")] + public Task Lock(long repositoryId, int number, LockReason? lockReason = null) + { + return ApiConnection.Put<Issue>(ApiUrls.IssueLock(repositoryId, number), lockReason.HasValue ? new { LockReaons = lockReason } : new object()); + } + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The issue number</param> + [ManualRoute("DELETE", "/repos/{owner}/{repo}/issues/{issue_number}/lock")] + public Task Unlock(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number)); + } + + /// <summary> + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue or pull request's conversation. + /// </summary> + /// <remarks>https://developer.github.com/v3/issues/#unlock-an-issue</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The issue number</param> + [ManualRoute("DELETE", "/repositories/{id}/issues/{number}/lock")] + public Task Unlock(long repositoryId, int number) + { + return ApiConnection.Delete(ApiUrls.IssueLock(repositoryId, number)); + } + } +} diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 07c63b9748..34bf1cda62 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -18,6 +18,7 @@ public PullRequestsClient(IApiConnection apiConnection) : base(apiConnection) Review = new PullRequestReviewsClient(apiConnection); ReviewComment = new PullRequestReviewCommentsClient(apiConnection); ReviewRequest = new PullRequestReviewRequestsClient(apiConnection); + LockUnlock = new LockUnlockClient(apiConnection); } /// <summary> @@ -35,6 +36,11 @@ public PullRequestsClient(IApiConnection apiConnection) : base(apiConnection) /// </summary> public IPullRequestReviewRequestsClient ReviewRequest { get; set; } + /// <summary> + /// Client for locking/unlocking a coversation on a pull request + /// </summary> + public ILockUnlockClient LockUnlock { get; set; } + /// <summary> /// Get a pull request by number. /// </summary> diff --git a/Octokit/Models/Response/PullRequest.cs b/Octokit/Models/Response/PullRequest.cs index 9ca99408ad..e7690c7d44 100644 --- a/Octokit/Models/Response/PullRequest.cs +++ b/Octokit/Models/Response/PullRequest.cs @@ -16,7 +16,7 @@ public PullRequest(int number) Number = number; } - public PullRequest(long id, string nodeId, string url, string htmlUrl, string diffUrl, string patchUrl, string issueUrl, string statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, IReadOnlyList<User> assignees, bool draft, bool? mergeable, MergeableState? mergeableState, User mergedBy, string mergeCommitSha, int comments, int commits, int additions, int deletions, int changedFiles, Milestone milestone, bool locked, bool? maintainerCanModify, IReadOnlyList<User> requestedReviewers, IReadOnlyList<Team> requestedTeams, IReadOnlyList<Label> labels) + public PullRequest(long id, string nodeId, string url, string htmlUrl, string diffUrl, string patchUrl, string issueUrl, string statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, IReadOnlyList<User> assignees, bool draft, bool? mergeable, MergeableState? mergeableState, User mergedBy, string mergeCommitSha, int comments, int commits, int additions, int deletions, int changedFiles, Milestone milestone, bool locked, bool? maintainerCanModify, IReadOnlyList<User> requestedReviewers, IReadOnlyList<Team> requestedTeams, IReadOnlyList<Label> labels, LockReason? activeLockReason) { Id = id; NodeId = nodeId; @@ -55,6 +55,7 @@ public PullRequest(long id, string nodeId, string url, string htmlUrl, string di RequestedReviewers = requestedReviewers; RequestedTeams = requestedTeams; Labels = labels; + ActiveLockReason = activeLockReason; } /// <summary> @@ -251,6 +252,11 @@ public bool Merged public IReadOnlyList<Label> Labels { get; protected set; } + /// <summary> + /// Reason that the conversation was locked + /// </summary> + public StringEnum<LockReason>? ActiveLockReason { get; protected set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Number: {0} State: {1}", Number, State); } diff --git a/docs/issues.md b/docs/issues.md index 65804a422c..07e23caba3 100644 --- a/docs/issues.md +++ b/docs/issues.md @@ -120,3 +120,23 @@ Label changes probably requires some explanation: If you're trying to populate the `Labels` collection by hand, you might hit some exceptional behaviour due to these rules. + +### Lock / Unlock + +The lock and unlock methods are available on the ILockUnlockClient on IIssuesClient. + +Heres a sample code for locking an issue: + +```csharp +var issue = await client.Issue.Get("octokit", "octokit.net", 405); +await client.LockUnlock.Lock("octokit", "octokit.net", 405, LockReason.OffTopic); +``` + +The active lock reason can be accessed via the LockReason property on Issues class. + +The code below demonstrates how to unlock an issue: + +```csharp +var issue = await client.Issue.Get("octokit", "octokit.net", 405); +await client.LockUnlock.Unlock("octokit", "octokit.net", 405); +``` From 3d53362bd7fec942e1eda31668cd2aeed5357c88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Aug 2022 18:39:23 +0100 Subject: [PATCH 112/209] build(deps): bump Microsoft.NET.Test.Sdk from 17.2.0 to 17.3.0 (#2548) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.2.0 to 17.3.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.2.0...v17.3.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 5bcbc497db..e102b94bcb 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index a99961f414..d7cca912e7 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -33,7 +33,7 @@ <ItemGroup> <PackageReference Include="GitHubJwt" Version="0.0.5" /> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 92ec09d1dc..605c0bdcbd 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> From 498c2aa0a5a4a06d05095303530f28c4f16a07cc Mon Sep 17 00:00:00 2001 From: Gamer025 <33846895+Gamer025@users.noreply.github.com> Date: Sun, 28 Aug 2022 16:12:27 +0200 Subject: [PATCH 113/209] Add ability to pass ApiOptions to PullRequestsClient.Files (#2553) * Add ability to pass ApiOptions to PullRequestsClient.Files * Change Reactive PullRequestClient + Fix Test Mocking --- .../Clients/IObservablePullRequestsClient.cs | 19 ++++++++++++ .../Clients/ObservablePullRequestsClient.cs | 31 +++++++++++++++++-- .../Clients/PullRequestsClientTests.cs | 4 +-- .../ObservablePullRequestsClientTests.cs | 8 ++--- Octokit/Clients/IPullRequestsClient.cs | 19 ++++++++++++ Octokit/Clients/PullRequestsClient.cs | 31 +++++++++++++++++-- 6 files changed, 101 insertions(+), 11 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs index 997d662212..510769f8da 100644 --- a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs @@ -231,6 +231,16 @@ public interface IObservablePullRequestsClient /// <param name="number">The pull request number</param> IObservable<PullRequestCommit> Commits(long repositoryId, int number); + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The pull request number</param> + /// <param name="options">Options for changing the API response</param> + IObservable<PullRequestFile> Files(string owner, string name, int number, ApiOptions options); + /// <summary> /// Get the list of files on a pull request. /// </summary> @@ -240,6 +250,15 @@ public interface IObservablePullRequestsClient /// <param name="number">The pull request number</param> IObservable<PullRequestFile> Files(string owner, string name, int number); + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The pull request number</param> + /// <param name="options">Options for changing the API response</param> + IObservable<PullRequestFile> Files(long repositoryId, int number, ApiOptions options); + /// <summary> /// Get the list of files on a pull request. /// </summary> diff --git a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs index 0f34376011..5b41a65aac 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs @@ -359,12 +359,37 @@ public IObservable<PullRequestCommit> Commits(long repositoryId, int number) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The pull request number</param> - public IObservable<PullRequestFile> Files(string owner, string name, int number) + /// <param name="options">Options for changing the API response</param> + public IObservable<PullRequestFile> Files(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return _connection.GetAndFlattenAllPages<PullRequestFile>(ApiUrls.PullRequestFiles(owner, name, number)); + return _connection.GetAndFlattenAllPages<PullRequestFile>(ApiUrls.PullRequestFiles(owner, name, number), options); + } + + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The pull request number</param> + public IObservable<PullRequestFile> Files(string owner, string name, int number) + { + return Files(owner, name, number, ApiOptions.None); + } + + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The pull request number</param> + /// <param name="options">Options for changing the API response</param> + public IObservable<PullRequestFile> Files(long repositoryId, int number, ApiOptions options) + { + return _connection.GetAndFlattenAllPages<PullRequestFile>(ApiUrls.PullRequestFiles(repositoryId, number), options); } /// <summary> @@ -375,7 +400,7 @@ public IObservable<PullRequestFile> Files(string owner, string name, int number) /// <param name="number">The pull request number</param> public IObservable<PullRequestFile> Files(long repositoryId, int number) { - return _connection.GetAndFlattenAllPages<PullRequestFile>(ApiUrls.PullRequestFiles(repositoryId, number)); + return Files(repositoryId, number, ApiOptions.None); } } } diff --git a/Octokit.Tests/Clients/PullRequestsClientTests.cs b/Octokit.Tests/Clients/PullRequestsClientTests.cs index 2f10009ad5..362ac6ae91 100644 --- a/Octokit.Tests/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestsClientTests.cs @@ -461,7 +461,7 @@ public async Task RequestsCorrectUrl() await client.Files("fake", "repo", 42); connection.Received() - .GetAll<PullRequestFile>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/files")); + .GetAll<PullRequestFile>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/files"), Args.ApiOptions); } [Fact] @@ -473,7 +473,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Files(1, 42); connection.Received() - .GetAll<PullRequestFile>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42/files")); + .GetAll<PullRequestFile>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/42/files"), Args.ApiOptions); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs index c48529d53c..c6b2932df6 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs @@ -704,7 +704,7 @@ public async Task FetchesAllFilesForPullRequest() CreateResponse(HttpStatusCode.OK), new List<PullRequestFile> { file } ); - connection.Get<List<PullRequestFile>>(Args.Uri, null) + connection.Get<List<PullRequestFile>>(Args.Uri, Arg.Any<IDictionary<string, string>>()) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -713,7 +713,7 @@ public async Task FetchesAllFilesForPullRequest() Assert.Equal(1, files.Count); Assert.Same(file, files[0]); - connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), null); + connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), Arg.Any<IDictionary<string, string>>()); } [Fact] @@ -728,7 +728,7 @@ public async Task FetchesAllFilesForPullRequestWithRepositoryId() CreateResponse(HttpStatusCode.OK), new List<PullRequestFile> { file } ); - connection.Get<List<PullRequestFile>>(Args.Uri, null) + connection.Get<List<PullRequestFile>>(Args.Uri, Arg.Any<IDictionary<string, string>>()) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -737,7 +737,7 @@ public async Task FetchesAllFilesForPullRequestWithRepositoryId() Assert.Equal(1, files.Count); Assert.Same(file, files[0]); - connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), null); + connection.Received().Get<List<PullRequestFile>>(new Uri(expectedUrl, UriKind.Relative), Arg.Any<IDictionary<string, string>>()); } [Fact] diff --git a/Octokit/Clients/IPullRequestsClient.cs b/Octokit/Clients/IPullRequestsClient.cs index e35d22d6e7..01e42c7ca2 100644 --- a/Octokit/Clients/IPullRequestsClient.cs +++ b/Octokit/Clients/IPullRequestsClient.cs @@ -228,6 +228,16 @@ public interface IPullRequestsClient /// <param name="number">The pull request number</param> Task<IReadOnlyList<PullRequestCommit>> Commits(long repositoryId, int number); + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The pull request number</param> + /// <param name="options">Options for changing the API response</param> + Task<IReadOnlyList<PullRequestFile>> Files(string owner, string name, int number, ApiOptions options); + /// <summary> /// Get the list of files on a pull request. /// </summary> @@ -237,6 +247,15 @@ public interface IPullRequestsClient /// <param name="number">The pull request number</param> Task<IReadOnlyList<PullRequestFile>> Files(string owner, string name, int number); + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The pull request number</param> + /// <param name="options">Options for changing the API response</param> + Task<IReadOnlyList<PullRequestFile>> Files(long repositoryId, int number, ApiOptions options); + /// <summary> /// Get the list of files on a pull request. /// </summary> diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 34bf1cda62..bcfcfe9a11 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -425,11 +425,25 @@ public Task<IReadOnlyList<PullRequestCommit>> Commits(long repositoryId, int num /// <param name="number">The pull request number</param> [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/{pull_number}/files")] public Task<IReadOnlyList<PullRequestFile>> Files(string owner, string name, int number) + { + return Files(owner, name, number, ApiOptions.None); + } + + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="number">The pull request number</param> + /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/{pull_number}/files")] + public Task<IReadOnlyList<PullRequestFile>> Files(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.GetAll<PullRequestFile>(ApiUrls.PullRequestFiles(owner, name, number)); + return ApiConnection.GetAll<PullRequestFile>(ApiUrls.PullRequestFiles(owner, name, number), options); } /// <summary> @@ -441,7 +455,20 @@ public Task<IReadOnlyList<PullRequestFile>> Files(string owner, string name, int [ManualRoute("GET", "/repositories/{id}/pulls/{number}/files")] public Task<IReadOnlyList<PullRequestFile>> Files(long repositoryId, int number) { - return ApiConnection.GetAll<PullRequestFile>(ApiUrls.PullRequestFiles(repositoryId, number)); + return Files(repositoryId, number, ApiOptions.None); + } + + /// <summary> + /// Get the list of files on a pull request. + /// </summary> + /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="number">The pull request number</param> + /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repositories/{id}/pulls/{number}/files")] + public Task<IReadOnlyList<PullRequestFile>> Files(long repositoryId, int number, ApiOptions options) + { + return ApiConnection.GetAll<PullRequestFile>(ApiUrls.PullRequestFiles(repositoryId, number), options); } } } From 269201cd964d0c31416cbf126596d4524bcc33af Mon Sep 17 00:00:00 2001 From: Randy Kreisel <randy@rkreisel.com> Date: Tue, 30 Aug 2022 06:36:02 -0500 Subject: [PATCH 114/209] Remove reference to Basic Authentication in the docs (#2555) * Update getting-started.md Edited the section on Authentication to remove Basic Auth, which GitHub no longer supports, with instructions for using a Personal Access Token. * Update getting-started.md Second commit: Removed "/en" from links. * Update docs/getting-started.md Co-authored-by: Tim Rogers <timrogers@github.com> * Update docs/getting-started.md Co-authored-by: Tim Rogers <timrogers@github.com> * Update getting-started.md Removed the two bullet pointed items because the sentence preceding them provided a clearer description of the options. Co-authored-by: Tim Rogers <timrogers@github.com> --- docs/getting-started.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index ae99a35ca4..1934e849dd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -6,25 +6,22 @@ The easiest way to get started with Octokit is to use a plain `GitHubClient`: var client = new GitHubClient(new ProductHeaderValue("my-cool-app")); ``` -This will let you access unauthenticated GitHub APIs, but you will be subject to rate limiting (you can read more about this [here](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting)). +This will let you access unauthenticated GitHub APIs, but you will be subject to rate limiting (you can read more about this [here](https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting)). But why do you need this `ProductHeaderValue` value? -The API will reject you if you don't provide a `User-Agent` header (more details [here](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required)). This is also to identify applications that are accessing the API and enable GitHub to contact the application author if there are problems. So pick a name that stands out! +The API will reject you if you don't provide a `User-Agent` header (more details [here](https://docs.github.com/rest/overview/resources-in-the-rest-api#user-agent-required)). This is also to identify applications that are accessing the API and enable GitHub to contact the application author if there are problems. So pick a name that stands out! ### Authenticated Access If you want to access private repositories or perform actions on behalf of a user, you need to pass credentials to the client. -There are two options supported by the API - basic and OAuth authentication. +You can authenticate by passing an access token, for example a personal access token (PAT), an OAuth access token or an installation token from a GitHub App. -```csharp -var basicAuth = new Credentials("username", "password"); // NOTE: not real credentials -client.Credentials = basicAuth; -``` +If you wish to use a PAT follow this [link](https://docs.github.com/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to generate one, then replace "token" in the snippet below with the text generated by GitHub. ```csharp -var tokenAuth = new Credentials("token"); // NOTE: not real token +var tokenAuth = new Credentials("token"); // This can be a PAT or an OAuth token. client.Credentials = tokenAuth; ``` @@ -71,6 +68,7 @@ var user = await client.User.Current(); ``` ### Too Much of a Good Thing: Dealing with API Rate Limits + Like any popular API, Github needs to throttle some requests. The OctoKit.NET client allows you to get some insight into how many requests you have left and when you can start making requests again. In fact, there are two ways to get the Rate Limits via OctoKit.NET. Calling `GitHubClient.GetLastApiInfo()` returns the Rate Limit status which has been returned with the last api call. So, calling `GitHubClient.GetLastApiInfo()` will not send any extra HTTP requests to GitHub's servers. From 9c3317f7114bda4eaa18f40a4e007082564c7fcd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Sep 2022 06:24:56 +0100 Subject: [PATCH 115/209] build(deps): bump Microsoft.NET.Test.Sdk from 17.3.0 to 17.3.1 (#2561) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.3.0 to 17.3.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.3.0...v17.3.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index e102b94bcb..46a164b525 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index d7cca912e7..d0d4d64164 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -33,7 +33,7 @@ <ItemGroup> <PackageReference Include="GitHubJwt" Version="0.0.5" /> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 605c0bdcbd..b02c7d730d 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> From 00692397746d9afa20aaf7895a719939fca68dcd Mon Sep 17 00:00:00 2001 From: Annchous <57408376+annchous@users.noreply.github.com> Date: Tue, 6 Sep 2022 09:36:48 +0400 Subject: [PATCH 116/209] Fix failure with 201 status code on adding a collaborator (#2559) * fix: return RepositoryInvitation instead of throwing an exception on 201 * fix: TheAddMethod test --- .../IObservableRepoCollaboratorsClient.cs | 4 +-- .../ObservableRepoCollaboratorsClient.cs | 4 +-- .../Clients/RepoCollaboratorsClientTests.cs | 2 +- Octokit/Clients/IRepoCollaboratorsClient.cs | 4 +-- Octokit/Clients/RepoCollaboratorsClient.cs | 26 ++++--------------- 5 files changed, 12 insertions(+), 28 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index be9e5a3687..6dc5561174 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -172,7 +172,7 @@ public interface IObservableRepoCollaboratorsClient /// <param name="user">Username of the new collaborator</param> /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - IObservable<bool> Add(string owner, string name, string user, CollaboratorRequest permission); + IObservable<RepositoryInvitation> Add(string owner, string name, string user, CollaboratorRequest permission); /// <summary> /// Adds a new collaborator to the repository. @@ -195,7 +195,7 @@ public interface IObservableRepoCollaboratorsClient /// <param name="user">Username of the new collaborator</param> /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - IObservable<bool> Add(long repositoryId, string user, CollaboratorRequest permission); + IObservable<RepositoryInvitation> Add(long repositoryId, string user, CollaboratorRequest permission); /// <summary> /// Invites a user as a collaborator to a repository. diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index 6bee5da362..38f8f710e3 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -267,7 +267,7 @@ public IObservable<Unit> Add(string owner, string name, string user) /// <param name="user">Username of the new collaborator</param> /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - public IObservable<bool> Add(string owner, string name, string user, CollaboratorRequest permission) + public IObservable<RepositoryInvitation> Add(string owner, string name, string user, CollaboratorRequest permission) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -303,7 +303,7 @@ public IObservable<Unit> Add(long repositoryId, string user) /// <param name="user">Username of the new collaborator</param> /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - public IObservable<bool> Add(long repositoryId, string user, CollaboratorRequest permission) + public IObservable<RepositoryInvitation> Add(long repositoryId, string user, CollaboratorRequest permission) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); Ensure.ArgumentNotNull(permission, nameof(permission)); diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index f255388a83..7e5f0d9084 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -391,7 +391,7 @@ public async Task SurfacesAuthorizationExceptionWhenSpecifyingCollaboratorReques var connection = Substitute.For<IApiConnection>(); var client = new RepoCollaboratorsClient(connection); - connection.Connection.Put<object>(Arg.Any<Uri>(), Arg.Any<object>()).ThrowsAsync(new AuthorizationException()); + connection.Put<RepositoryInvitation>(Arg.Any<Uri>(), Arg.Any<object>()).ThrowsAsync(new AuthorizationException()); await Assert.ThrowsAsync<AuthorizationException>(() => client.Add("owner", "test", "user1", new CollaboratorRequest(Permission.Pull))); await Assert.ThrowsAsync<AuthorizationException>(() => client.Add(1, "user1", new CollaboratorRequest(Permission.Pull))); diff --git a/Octokit/Clients/IRepoCollaboratorsClient.cs b/Octokit/Clients/IRepoCollaboratorsClient.cs index d117d414bd..1cc0593598 100644 --- a/Octokit/Clients/IRepoCollaboratorsClient.cs +++ b/Octokit/Clients/IRepoCollaboratorsClient.cs @@ -172,7 +172,7 @@ public interface IRepoCollaboratorsClient /// <param name="user">Username of the new collaborator</param> /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - Task<bool> Add(string owner, string name, string user, CollaboratorRequest permission); + Task<RepositoryInvitation> Add(string owner, string name, string user, CollaboratorRequest permission); /// <summary> /// Adds a new collaborator to the repository. @@ -195,7 +195,7 @@ public interface IRepoCollaboratorsClient /// <param name="user">Username of the new collaborator</param> /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - Task<bool> Add(long repositoryId, string user, CollaboratorRequest permission); + Task<RepositoryInvitation> Add(long repositoryId, string user, CollaboratorRequest permission); /// <summary> /// Invites a new collaborator to the repo diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index c91639d535..499ba4a23d 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -292,21 +292,13 @@ public Task Add(string owner, string name, string user) /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> [ManualRoute("PUT", "/repos/{owner}/{repo}/collaborators/{username}")] - public async Task<bool> Add(string owner, string name, string user, CollaboratorRequest permission) + public async Task<RepositoryInvitation> Add(string owner, string name, string user, CollaboratorRequest permission) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); - - try - { - var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(owner, name, user), permission).ConfigureAwait(false); - return response.HttpResponse.IsTrue(); - } - catch (NotFoundException) - { - return false; - } + + return await ApiConnection.Put<RepositoryInvitation>(ApiUrls.RepoCollaborator(owner, name, user), permission).ConfigureAwait(false); } /// <summary> @@ -337,19 +329,11 @@ public Task Add(long repositoryId, string user) /// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> [ManualRoute("PUT", "/repository/{id}/collaborators/{username}")] - public async Task<bool> Add(long repositoryId, string user, CollaboratorRequest permission) + public async Task<RepositoryInvitation> Add(long repositoryId, string user, CollaboratorRequest permission) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); - try - { - var response = await Connection.Put<object>(ApiUrls.RepoCollaborator(repositoryId, user), permission).ConfigureAwait(false); - return response.HttpResponse.IsTrue(); - } - catch (NotFoundException) - { - return false; - } + return await ApiConnection.Put<RepositoryInvitation>(ApiUrls.RepoCollaborator(repositoryId, user), permission).ConfigureAwait(false); } /// <summary> From d88a9071d89974af811bf540161ed5a0f4d0fa44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Sep 2022 14:42:37 -0500 Subject: [PATCH 117/209] build(deps): bump Microsoft.NETFramework.ReferenceAssemblies from 1.0.2 to 1.0.3 (#2549) build(deps): bump Microsoft.NETFramework.ReferenceAssemblies Bumps [Microsoft.NETFramework.ReferenceAssemblies](https://github.com/Microsoft/dotnet) from 1.0.2 to 1.0.3. - [Release notes](https://github.com/Microsoft/dotnet/releases) - [Commits](https://github.com/Microsoft/dotnet/commits) --- updated-dependencies: - dependency-name: Microsoft.NETFramework.ReferenceAssemblies dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../Octokit.AsyncPaginationExtension.csproj | 2 +- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj index 38c33b9357..9360717e9e 100644 --- a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj +++ b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj @@ -26,7 +26,7 @@ </PropertyGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net461' "> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" /> </ItemGroup> <ItemGroup> diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 46a164b525..45889e08bf 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -39,7 +39,7 @@ </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" /> </ItemGroup> <ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index d0d4d64164..ac2ff55db3 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -44,7 +44,7 @@ </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" /> </ItemGroup> </Project> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index b02c7d730d..9ec8a43959 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -42,7 +42,7 @@ <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> <Reference Include="System" /> <Reference Include="Microsoft.CSharp" /> - <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" /> + <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" /> </ItemGroup> <ItemGroup> From b3d20967667181662a987ac7a492d060fa8a799e Mon Sep 17 00:00:00 2001 From: Rares Iova <iovarares@gmail.com> Date: Wed, 7 Sep 2022 19:01:32 +0300 Subject: [PATCH 118/209] [Releases]Added support for generating release notes (#2563) --- .../Clients/IObservableReleasesClient.cs | 23 +++++++ .../Clients/ObservableReleasesClient.cs | 35 ++++++++++ Octokit.Tests/Clients/ReleasesClientTests.cs | 49 ++++++++++++++ Octokit/Clients/IReleasesClient.cs | 23 +++++++ Octokit/Clients/ReleasesClient.cs | 39 +++++++++++ .../Request/GenerateReleaseNotesRequest.cs | 66 +++++++++++++++++++ .../Models/Response/GeneratedReleaseNotes.cs | 47 +++++++++++++ docs/releases.md | 13 ++++ 8 files changed, 295 insertions(+) create mode 100644 Octokit/Models/Request/GenerateReleaseNotesRequest.cs create mode 100644 Octokit/Models/Response/GeneratedReleaseNotes.cs diff --git a/Octokit.Reactive/Clients/IObservableReleasesClient.cs b/Octokit.Reactive/Clients/IObservableReleasesClient.cs index 7320f5addd..072aba0ff2 100644 --- a/Octokit.Reactive/Clients/IObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/IObservableReleasesClient.cs @@ -13,6 +13,29 @@ namespace Octokit.Reactive /// </remarks> public interface IObservableReleasesClient { + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The repository's owner</param> + /// <param name="name">The repository's name</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, string name, GenerateReleaseNotesRequest data); + + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<GeneratedReleaseNotes> GenerateReleaseNotes(long repositoryId, GenerateReleaseNotesRequest data); + /// <summary> /// Gets all <see cref="Release"/>s for the specified repository. /// </summary> diff --git a/Octokit.Reactive/Clients/ObservableReleasesClient.cs b/Octokit.Reactive/Clients/ObservableReleasesClient.cs index 644269643b..dcab994bff 100644 --- a/Octokit.Reactive/Clients/ObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReleasesClient.cs @@ -25,6 +25,41 @@ public ObservableReleasesClient(IGitHubClient client) _connection = client.Connection; } + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The repository's owner</param> + /// <param name="name">The repository's name</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, string name, GenerateReleaseNotesRequest data) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(data, nameof(data)); + + return _client.GenerateReleaseNotes(owner, name, data).ToObservable(); + } + + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<GeneratedReleaseNotes> GenerateReleaseNotes(long repositoryId, GenerateReleaseNotesRequest data) + { + Ensure.ArgumentNotNull(data, nameof(data)); + + return _client.GenerateReleaseNotes(repositoryId, data).ToObservable(); + } + /// <summary> /// Gets all <see cref="Release"/>s for the specified repository. /// </summary> diff --git a/Octokit.Tests/Clients/ReleasesClientTests.cs b/Octokit.Tests/Clients/ReleasesClientTests.cs index 742c8e8912..903d8115e9 100644 --- a/Octokit.Tests/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests/Clients/ReleasesClientTests.cs @@ -20,6 +20,55 @@ public void EnsuresNonNullArguments() } } + public class TheGenerateReleaseNotesMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var client = Substitute.For<IApiConnection>(); + var releasesClient = new ReleasesClient(client); + var data = new GenerateReleaseNotesRequest("fake-tag"); + + await releasesClient.GenerateReleaseNotes("fake", "repo", data); + + client.Received().Post<GeneratedReleaseNotes>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases"), + data, + "application/vnd.github.v3"); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var client = Substitute.For<IApiConnection>(); + var releasesClient = new ReleasesClient(client); + var data = new GenerateReleaseNotesRequest("fake-tag"); + + await releasesClient.GenerateReleaseNotes(1, data); + + client.Received().Post<GeneratedReleaseNotes>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases"), + data, + "application/vnd.github.v3"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); + Assert.Throws<ArgumentNullException>(() => new GenerateReleaseNotesRequest(null)); + + var data = new GenerateReleaseNotesRequest("fake-tag"); + + await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GenerateReleaseNotes(null, "name", data)); + await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GenerateReleaseNotes("owner", null, data)); + await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GenerateReleaseNotes("owner", "name", null)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GenerateReleaseNotes(1, null)); + + await Assert.ThrowsAsync<ArgumentException>(() => releasesClient.GenerateReleaseNotes("", "name", data)); + await Assert.ThrowsAsync<ArgumentException>(() => releasesClient.GenerateReleaseNotes("owner", "", data)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit/Clients/IReleasesClient.cs b/Octokit/Clients/IReleasesClient.cs index d8ef30bb33..0af33be082 100644 --- a/Octokit/Clients/IReleasesClient.cs +++ b/Octokit/Clients/IReleasesClient.cs @@ -13,6 +13,29 @@ namespace Octokit /// </remarks> public interface IReleasesClient { + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The repository's owner</param> + /// <param name="name">The repository's name</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, string name, GenerateReleaseNotesRequest data); + + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<GeneratedReleaseNotes> GenerateReleaseNotes(long repositoryId, GenerateReleaseNotesRequest data); + /// <summary> /// Gets all <see cref="Release"/>s for the specified repository. /// </summary> diff --git a/Octokit/Clients/ReleasesClient.cs b/Octokit/Clients/ReleasesClient.cs index dd1b360eb6..bc988dd876 100644 --- a/Octokit/Clients/ReleasesClient.cs +++ b/Octokit/Clients/ReleasesClient.cs @@ -20,6 +20,45 @@ public ReleasesClient(IApiConnection apiConnection) : base(apiConnection) { } + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The repository's owner</param> + /// <param name="name">The repository's name</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("GET", "/repos/{owner}/{repo}/releases")] + public Task<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, string name, GenerateReleaseNotesRequest data) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(data, nameof(data)); + + var endpoint = ApiUrls.Releases(owner, name); + return ApiConnection.Post<GeneratedReleaseNotes>(endpoint, data, AcceptHeaders.StableVersion); + } + + /// <summary> + /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// </remarks> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="data">The request for generating release notes</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("GET", "/repos/{owner}/{repo}/releases")] + public Task<GeneratedReleaseNotes> GenerateReleaseNotes(long repositoryId, GenerateReleaseNotesRequest data) + { + Ensure.ArgumentNotNull(data, nameof(data)); + + var endpoint = ApiUrls.Releases(repositoryId); + return ApiConnection.Post<GeneratedReleaseNotes>(endpoint, data, AcceptHeaders.StableVersion); + } + /// <summary> /// Gets all <see cref="Release"/>s for the specified repository. /// </summary> diff --git a/Octokit/Models/Request/GenerateReleaseNotesRequest.cs b/Octokit/Models/Request/GenerateReleaseNotesRequest.cs new file mode 100644 index 0000000000..f3aef13039 --- /dev/null +++ b/Octokit/Models/Request/GenerateReleaseNotesRequest.cs @@ -0,0 +1,66 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Used to generate release notes for a given tag. + /// </summary> + /// <remarks> + /// API: https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release + /// </remarks> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class GenerateReleaseNotesRequest + { + /// <summary> + /// Initializes a new instance of the <see cref="GenerateReleaseNotesRequest"/> class. + /// </summary> + /// <param name="tagName">Name of the tag to create in the repository for this release.</param> + public GenerateReleaseNotesRequest(string tagName) + { + Ensure.ArgumentNotNullOrEmptyString(tagName, nameof(tagName)); + TagName = tagName; + } + + /// <summary> + /// Gets the name of the tag. + /// </summary> + /// <value> + /// The name of the tag. + /// </value> + public string TagName { get; private set; } + + /// <summary> + /// The name of the previous tag to use as the starting point for the release notes. + /// Use to manually specify the range for the set of changes considered as part this release. + /// </summary> + /// <value> + /// The target commitish. + /// </value> + public string TargetCommitish { get; set; } + + /// <summary> + /// Gets the name of the tag. + /// </summary> + /// <value> + /// The name of the previous tag. + /// </value> + public string PreviousTagName { get; set; } + + /// <summary> + /// Specifies a path to a file in the repository containing configuration settings used for generating the + /// release notes. If unspecified, the configuration file located in the repository at '.github/release.yml' or + /// '.github/release.yaml' will be used. If that is not present, the default configuration will be used. + /// </summary> + /// <value> + /// The path to the configuration file. + /// </value> + public string ConfigurationFilePath { get; set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "TagName: {0} PreviousTagName: {1}", TagName, PreviousTagName); } + } + + } +} diff --git a/Octokit/Models/Response/GeneratedReleaseNotes.cs b/Octokit/Models/Response/GeneratedReleaseNotes.cs new file mode 100644 index 0000000000..009e3dcf9a --- /dev/null +++ b/Octokit/Models/Response/GeneratedReleaseNotes.cs @@ -0,0 +1,47 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Used to retrieve generated release notes. + /// </summary> + /// <remarks> + /// API: https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release + /// The generated release notes are not saved anywhere. + /// They are intended to be generated and used when creating a new release. + /// </remarks> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class GeneratedReleaseNotes + { + public GeneratedReleaseNotes() { } + + public GeneratedReleaseNotes(string name, string body) + { + Name = name; + Body = body; + } + + /// <summary> + /// Gets the name of the release. + /// </summary> + /// <value> + /// The name of the relaese. + /// </value> + public string Name { get; private set; } + + /// <summary> + /// Gets the body of the release. + /// </summary> + /// <value> + /// The body of the release. + /// </value> + public string Body { get; private set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} Body: {1}", Name, Body); } + } + + } +} diff --git a/docs/releases.md b/docs/releases.md index 950c5b6ed0..3f9e9582c3 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -30,6 +30,19 @@ Console.WriteLine("Created release id {0}", result.Id); Note that the `Draft` flag is used to indicate when a release should be published to the world, whereas the `PreRelease` flag is used to indicate whether a release is unofficial or preview release. +#### Generate release notes + +Additionally, you can ask GitHub to generate a name and body before creating a new release. + +```csharp +var generationRequest = new GenerateReleaseNotesRequest("v2.0.0"); +var releaseNotes = await client.Repository.Release.GenerateReleaseNotes("octokit", "octokit.net", generationRequest); + +var newRelease = new NewRelease("v1.0.0"); +newRelease.Name = releaseNotes.Name; +newRelease.Body = releaseNotes.Body; +``` + ### Update Once the release is ready for the public, you can apply an update to the release: From 958f71b7f868eed7734d99e0e6b59598ab82e050 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Thu, 8 Sep 2022 16:05:45 +0300 Subject: [PATCH 119/209] fix acitivy payload debugger display --- Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs | 2 +- Octokit/Octokit.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs index ea89c33195..aec80af469 100644 --- a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs @@ -21,7 +21,7 @@ public ActivityPayload(Repository repository, User sender, InstallationId instal internal string DebuggerDisplay { - get { return Repository.FullName; } + get { return Repository?.FullName; } } } } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 3d7159cb59..a1699dacc8 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.6</Version> + <Version>1.0.7</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 19ea38062acc1cd8899878fbeb40a5096a50d725 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Thu, 8 Sep 2022 17:20:05 +0300 Subject: [PATCH 120/209] fix support of installation events + fix tests --- .../Clients/IObservableGitHubAppsClient.cs | 8 + .../Clients/ObservableGitHubAppsClient.cs | 6 + Octokit.Tests/Models/InstallationEventTest.cs | 146 ++++++++++++++++++ Octokit.Tests/Models/InstallationTest.cs | 1 - Octokit/Clients/GitHubAppsClient.cs | 2 + .../InstallationEventPayload.cs | 8 +- Octokit/Models/Response/Plan.cs | 4 +- Octokit/Octokit.csproj | 2 +- 8 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 Octokit.Tests/Models/InstallationEventTest.cs diff --git a/Octokit.Reactive/Clients/IObservableGitHubAppsClient.cs b/Octokit.Reactive/Clients/IObservableGitHubAppsClient.cs index 30a7e70d3f..b431630e08 100644 --- a/Octokit.Reactive/Clients/IObservableGitHubAppsClient.cs +++ b/Octokit.Reactive/Clients/IObservableGitHubAppsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; namespace Octokit.Reactive { @@ -110,5 +111,12 @@ public interface IObservableGitHubAppsClient /// <remarks>https://developer.github.com/v3/apps/#find-user-installation</remarks> /// <param name="user">The name of the user</param> IObservable<Installation> GetUserInstallationForCurrent(string user); + + /// <summary> + /// Uninstalls a GitHub App on a user, organization, or business account (requires GitHubApp auth). + /// </summary> + /// <remarks>https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app</remarks> + /// <param name="installationId">The Id of the GitHub App Installation</param> + IObservable<Unit> DeleteInstallationForCurrent(long installationId); } } diff --git a/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs b/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs index 5adc03aebe..c14960ce9a 100644 --- a/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs +++ b/Octokit.Reactive/Clients/ObservableGitHubAppsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -175,5 +176,10 @@ public IObservable<Installation> GetUserInstallationForCurrent(string user) return _client.GetUserInstallationForCurrent(user).ToObservable(); } + + public IObservable<Unit> DeleteInstallationForCurrent(long installationId) + { + return _client.DeleteInstallationForCurrent(installationId).ToObservable(); + } } } diff --git a/Octokit.Tests/Models/InstallationEventTest.cs b/Octokit.Tests/Models/InstallationEventTest.cs new file mode 100644 index 0000000000..c66c046eb0 --- /dev/null +++ b/Octokit.Tests/Models/InstallationEventTest.cs @@ -0,0 +1,146 @@ +using Octokit.Internal; +using Xunit; + +namespace Octokit.Tests.Models; + +public class InstallationEventTest +{ + [Fact] + public void CanBeDeserialized() + { + const string json = @"{ + ""action"": ""deleted"", + ""installation"": { + ""id"": 29024610, + ""account"": { + ""login"": ""tomer-apiiro-test"", + ""id"": 64733398, + ""node_id"": ""MDEyOk9yZ2FuaXphdGlvbjY0NzMzMzk4"", + ""avatar_url"": ""https://avatars.githubusercontent.com/u/64733398?v=4"", + ""gravatar_id"": """", + ""url"": ""https://api.github.com/users/tomer-apiiro-test"", + ""html_url"": ""https://github.com/tomer-apiiro-test"", + ""followers_url"": ""https://api.github.com/users/tomer-apiiro-test/followers"", + ""following_url"": ""https://api.github.com/users/tomer-apiiro-test/following{/other_user}"", + ""gists_url"": ""https://api.github.com/users/tomer-apiiro-test/gists{/gist_id}"", + ""starred_url"": ""https://api.github.com/users/tomer-apiiro-test/starred{/owner}{/repo}"", + ""subscriptions_url"": ""https://api.github.com/users/tomer-apiiro-test/subscriptions"", + ""organizations_url"": ""https://api.github.com/users/tomer-apiiro-test/orgs"", + ""repos_url"": ""https://api.github.com/users/tomer-apiiro-test/repos"", + ""events_url"": ""https://api.github.com/users/tomer-apiiro-test/events{/privacy}"", + ""received_events_url"": ""https://api.github.com/users/tomer-apiiro-test/received_events"", + ""type"": ""Organization"", + ""site_admin"": false + }, + ""repository_selection"": ""all"", + ""access_tokens_url"": ""https://api.github.com/app/installations/29024610/access_tokens"", + ""repositories_url"": ""https://api.github.com/installation/repositories"", + ""html_url"": ""https://github.com/organizations/tomer-apiiro-test/settings/installations/29024610"", + ""app_id"": 111651, + ""app_slug"": ""apiiro"", + ""target_id"": 64733398, + ""target_type"": ""Organization"", + ""permissions"": { + ""checks"": ""write"", + ""issues"": ""read"", + ""contents"": ""read"", + ""metadata"": ""read"", + ""packages"": ""read"", + ""deployments"": ""read"", + ""pull_requests"": ""write"", + ""administration"": ""read"", + ""security_events"": ""read"", + ""vulnerability_alerts"": ""read"", + ""secret_scanning_alerts"": ""read"", + ""organization_user_blocking"": ""read"", + ""organization_administration"": ""read"" + }, + ""events"": [ + ""check_run"", + ""check_suite"", + ""pull_request"" + ], + ""created_at"": ""2022-09-08T13:16:41.000Z"", + ""updated_at"": ""2022-09-08T13:16:41.000Z"", + ""single_file_name"": null, + ""has_multiple_single_files"": false, + ""single_file_paths"": [ + + ], + ""suspended_by"": null, + ""suspended_at"": null + }, + ""repositories"": [ + { + ""id"": 260900357, + ""node_id"": ""MDEwOlJlcG9zaXRvcnkyNjA5MDAzNTc="", + ""name"": ""test"", + ""full_name"": ""tomer-apiiro-test/test"", + ""private"": true + }, + { + ""id"": 277490362, + ""node_id"": ""MDEwOlJlcG9zaXRvcnkyNzc0OTAzNjI="", + ""name"": ""Apiiro_test"", + ""full_name"": ""tomer-apiiro-test/Apiiro_test"", + ""private"": true + }, + { + ""id"": 279815866, + ""node_id"": ""MDEwOlJlcG9zaXRvcnkyNzk4MTU4NjY="", + ""name"": ""lic"", + ""full_name"": ""tomer-apiiro-test/lic"", + ""private"": false + }, + { + ""id"": 294123711, + ""node_id"": ""MDEwOlJlcG9zaXRvcnkyOTQxMjM3MTE="", + ""name"": ""empty-repo"", + ""full_name"": ""tomer-apiiro-test/empty-repo"", + ""private"": true + }, + { + ""id"": 397634362, + ""node_id"": ""MDEwOlJlcG9zaXRvcnkzOTc2MzQzNjI="", + ""name"": ""dotnet-test"", + ""full_name"": ""tomer-apiiro-test/dotnet-test"", + ""private"": false + }, + { + ""id"": 418169292, + ""node_id"": ""R_kgDOGOzBzA"", + ""name"": ""node-test"", + ""full_name"": ""tomer-apiiro-test/node-test"", + ""private"": true + } + ], + ""sender"": { + ""login"": ""tomer-amir"", + ""id"": 63953532, + ""node_id"": ""MDQ6VXNlcjYzOTUzNTMy"", + ""avatar_url"": ""https://avatars.githubusercontent.com/u/63953532?v=4"", + ""gravatar_id"": """", + ""url"": ""https://api.github.com/users/tomer-amir"", + ""html_url"": ""https://github.com/tomer-amir"", + ""followers_url"": ""https://api.github.com/users/tomer-amir/followers"", + ""following_url"": ""https://api.github.com/users/tomer-amir/following{/other_user}"", + ""gists_url"": ""https://api.github.com/users/tomer-amir/gists{/gist_id}"", + ""starred_url"": ""https://api.github.com/users/tomer-amir/starred{/owner}{/repo}"", + ""subscriptions_url"": ""https://api.github.com/users/tomer-amir/subscriptions"", + ""organizations_url"": ""https://api.github.com/users/tomer-amir/orgs"", + ""repos_url"": ""https://api.github.com/users/tomer-amir/repos"", + ""events_url"": ""https://api.github.com/users/tomer-amir/events{/privacy}"", + ""received_events_url"": ""https://api.github.com/users/tomer-amir/received_events"", + ""type"": ""User"", + ""site_admin"": false + } +}"; + var serializer = new SimpleJsonSerializer(); + + var installationEvent = serializer.Deserialize<InstallationEventPayload>(json); + + Assert.Equal("deleted", installationEvent.Action); + Assert.Equal("https://github.com/tomer-apiiro-test", installationEvent.Installation.Account?.HtmlUrl); + Assert.Equal(6, installationEvent.Repositories.Count); + } +} diff --git a/Octokit.Tests/Models/InstallationTest.cs b/Octokit.Tests/Models/InstallationTest.cs index 5d47740086..3505c360f0 100644 --- a/Octokit.Tests/Models/InstallationTest.cs +++ b/Octokit.Tests/Models/InstallationTest.cs @@ -1,4 +1,3 @@ -using System.Linq; using Octokit.Internal; using Xunit; diff --git a/Octokit/Clients/GitHubAppsClient.cs b/Octokit/Clients/GitHubAppsClient.cs index ac1e1120c6..a94528b91a 100644 --- a/Octokit/Clients/GitHubAppsClient.cs +++ b/Octokit/Clients/GitHubAppsClient.cs @@ -209,6 +209,8 @@ public Task<Installation> GetUserInstallationForCurrent(string user) /// </summary> /// <remarks>https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app</remarks> /// <param name="installationId">The Id of the GitHub App Installation</param> + [Preview("machine-man")] + [ManualRoute("DELETE", "/app/installations/{installationId}")] public Task DeleteInstallationForCurrent(long installationId) { return ApiConnection.Delete(ApiUrls.Installation(installationId)); diff --git a/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs index bfea8006fd..f83cad256b 100644 --- a/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs @@ -4,8 +4,14 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class InstallationEventPayload : ActivityWithActionPayload + public class InstallationEventPayload { + public string Action { get; set; } + + public User Sender { get; set; } + public IReadOnlyCollection<Repository> Repositories { get; set; } + + public Installation Installation { get; set; } } } diff --git a/Octokit/Models/Response/Plan.cs b/Octokit/Models/Response/Plan.cs index 3995980e20..83b977b234 100644 --- a/Octokit/Models/Response/Plan.cs +++ b/Octokit/Models/Response/Plan.cs @@ -13,13 +13,15 @@ public Plan() { } - public Plan(long collaborators, string name, long privateRepos, long space, string billingEmail) + public Plan(long collaborators, string name, long privateRepos, long space, string billingEmail, long seats, long filledSeats) { Collaborators = collaborators; Name = name; PrivateRepos = privateRepos; Space = space; BillingEmail = billingEmail; + Seats = seats; + FilledSeats = filledSeats; } /// <summary> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a1699dacc8..cbec786141 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.7</Version> + <Version>1.0.8</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From cf9db5fc46daa903abecf1fec0025837343cd3d6 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Thu, 8 Sep 2022 15:59:46 +0100 Subject: [PATCH 121/209] feat: Adds Packages and Package versions APIs (#2551) --- .../IObservablePackageVersionsClient.cs | 152 +++++++ .../Clients/IObservablePackagesClient.cs | 138 ++++++ .../ObservablePackageVersionsClient.cs | 253 +++++++++++ .../Clients/ObservablePackagesClient.cs | 235 +++++++++++ Octokit.Reactive/IObservableGitHubClient.cs | 1 + Octokit.Reactive/ObservableGitHubClient.cs | 2 + .../Clients/PackageVersionsClientTests.cs | 34 ++ .../Clients/PackagesClientTests.cs | 34 ++ .../Clients/PackageVersionsClientTests.cs | 395 ++++++++++++++++++ Octokit.Tests/Clients/PackagesClientTests.cs | 344 +++++++++++++++ .../ObservablePackageVersionsTests.cs | 146 +++++++ .../Reactive/ObservablePackagesTests.cs | 350 ++++++++++++++++ Octokit/Clients/IPackageVersionsClient.cs | 151 +++++++ Octokit/Clients/IPackagesClient.cs | 141 +++++++ Octokit/Clients/PackageVersionsClient.cs | 283 +++++++++++++ Octokit/Clients/PackagesClient.cs | 258 ++++++++++++ Octokit/GitHubClient.cs | 9 + Octokit/Helpers/ApiUrls.cs | 162 +++++++ Octokit/Helpers/Ensure.cs | 19 + Octokit/Helpers/EnumExtensions.cs | 16 + Octokit/Helpers/ParameterBuilder.cs | 91 ++++ Octokit/IGitHubClient.cs | 8 + Octokit/Models/Common/PackageType.cs | 43 ++ Octokit/Models/Common/PackageVersionState.cs | 19 + Octokit/Models/Common/PackageVisibility.cs | 25 ++ Octokit/Models/Response/Package.cs | 78 ++++ Octokit/Models/Response/PackageVersion.cs | 73 ++++ 27 files changed, 3460 insertions(+) create mode 100644 Octokit.Reactive/Clients/IObservablePackageVersionsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservablePackagesClient.cs create mode 100644 Octokit.Reactive/Clients/ObservablePackageVersionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservablePackagesClient.cs create mode 100644 Octokit.Tests.Integration/Clients/PackageVersionsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/PackagesClientTests.cs create mode 100644 Octokit.Tests/Clients/PackageVersionsClientTests.cs create mode 100644 Octokit.Tests/Clients/PackagesClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs create mode 100644 Octokit.Tests/Reactive/ObservablePackagesTests.cs create mode 100644 Octokit/Clients/IPackageVersionsClient.cs create mode 100644 Octokit/Clients/IPackagesClient.cs create mode 100644 Octokit/Clients/PackageVersionsClient.cs create mode 100644 Octokit/Clients/PackagesClient.cs create mode 100644 Octokit/Helpers/ParameterBuilder.cs create mode 100644 Octokit/Models/Common/PackageType.cs create mode 100644 Octokit/Models/Common/PackageVersionState.cs create mode 100644 Octokit/Models/Common/PackageVisibility.cs create mode 100644 Octokit/Models/Response/Package.cs create mode 100644 Octokit/Models/Response/PackageVersion.cs diff --git a/Octokit.Reactive/Clients/IObservablePackageVersionsClient.cs b/Octokit.Reactive/Clients/IObservablePackageVersionsClient.cs new file mode 100644 index 0000000000..5d2f0045ca --- /dev/null +++ b/Octokit.Reactive/Clients/IObservablePackageVersionsClient.cs @@ -0,0 +1,152 @@ +using System; +using System.Reactive; + +namespace Octokit.Reactive +{ + public interface IObservablePackageVersionsClient + { + /// <summary> + /// List all versions of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + IObservable<PackageVersion> GetAllForOrg(string org, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null); + + /// <summary> + /// Get a specific version of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + + IObservable<PackageVersion> GetForOrg(string org, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Deletes a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<Unit> DeleteForOrg(string org, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Restores a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<Unit> RestoreForOrg(string org, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Returns all package versions for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + IObservable<PackageVersion> GetAllForActiveUser(PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null); + + /// <summary> + /// Gets a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<PackageVersion> GetForActiveUser(PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Deletes a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<Unit> DeleteForActiveUser(PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Restores a package version owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<Unit> RestoreForActiveUser(PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Returns all package versions for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + IObservable<PackageVersion> GetAllForUser(string username, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null); + + /// <summary> + /// Gets a specific package version for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<PackageVersion> GetForUser(string username, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Deletes a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<Unit> DeleteForUser(string username, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Restores a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + IObservable<Unit> RestoreForUser(string username, PackageType packageType, string packageName, int packageVersionId); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservablePackagesClient.cs b/Octokit.Reactive/Clients/IObservablePackagesClient.cs new file mode 100644 index 0000000000..6814cad88d --- /dev/null +++ b/Octokit.Reactive/Clients/IObservablePackagesClient.cs @@ -0,0 +1,138 @@ +using System; +using System.Reactive; + +namespace Octokit.Reactive +{ + public interface IObservablePackagesClient + { + IObservablePackageVersionsClient PackageVersions { get; } + + /// <summary> + /// List all packages for an organisations, readable by the current user + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + IObservable<Package> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null); + + /// <summary> + /// Get a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Package> GetForOrg(string org, PackageType packageType, string packageName); + + /// <summary> + /// Delete a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Unit> DeleteForOrg(string org, PackageType packageType, string packageName); + + /// <summary> + /// Restore a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Unit> RestoreForOrg(string org, PackageType packageType, string packageName); + + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + IObservable<Package> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null); + + /// <summary> + /// Gets a specific package for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Package> GetForActiveUser(PackageType packageType, string packageName); + + /// <summary> + /// Deletes a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Unit> DeleteForActiveUser(PackageType packageType, string packageName); + + /// <summary> + /// Restores a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Unit> RestoreForActiveUser(PackageType packageType, string packageName); + + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + IObservable<Package> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null); + + /// <summary> + /// Gets a specific package metadata for a public package owned by a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Package> GetForUser(string username, PackageType packageType, string packageName); + + /// <summary> + /// Deletes an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Unit> DeleteForUser(string username, PackageType packageType, string packageName); + + /// <summary> + /// Restores an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + IObservable<Unit> RestoreForUser(string username, PackageType packageType, string packageName); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservablePackageVersionsClient.cs b/Octokit.Reactive/Clients/ObservablePackageVersionsClient.cs new file mode 100644 index 0000000000..f6ad28d7a4 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservablePackageVersionsClient.cs @@ -0,0 +1,253 @@ +using Octokit.Reactive.Internal; +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + public class ObservablePackageVersionsClient : IObservablePackageVersionsClient + { + readonly IPackageVersionsClient _client; + readonly IConnection _connection; + + public ObservablePackageVersionsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Packages.PackageVersions; + _connection = client.Connection; + } + + /// <summary> + /// List all versions of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + public IObservable<PackageVersion> GetAllForOrg(string org, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.ApiOptionsNotNull(ref options); + + var route = ApiUrls.PackageVersionsOrg(org, packageType, packageName); + var parameters = ParameterBuilder.AddParameter("state", state); + + return _connection.GetAndFlattenAllPages<PackageVersion>(route, parameters); + } + + /// <summary> + /// Get a specific version of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<PackageVersion> GetForOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.GetForOrg(org, packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Deletes a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<Unit> DeleteForOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.DeleteForOrg(org, packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Restores a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<Unit> RestoreForOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.RestoreForOrg(org, packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Returns all package versions for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + public IObservable<PackageVersion> GetAllForActiveUser(PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.ApiOptionsNotNull(ref options); + + var route = ApiUrls.PackageVersionsActiveUser(packageType, packageName); + var parameters = ParameterBuilder.AddParameter("state", state); + + return _connection.GetAndFlattenAllPages<PackageVersion>(route, parameters); + } + + /// <summary> + /// Gets a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<PackageVersion> GetForActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.GetForActiveUser(packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Deletes a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<Unit> DeleteForActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.DeleteForActiveUser(packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Restores a package version owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<Unit> RestoreForActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.RestoreForActiveUser(packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Returns all package versions for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + public IObservable<PackageVersion> GetAllForUser(string username, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.ApiOptionsNotNull(ref options); + + var route = ApiUrls.PackageVersionsUser(username, packageType, packageName); + var parameters = ParameterBuilder.AddParameter("state", state); + + return _connection.GetAndFlattenAllPages<PackageVersion>(route, parameters); + } + + /// <summary> + /// Gets a specific package version for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<PackageVersion> GetForUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.GetForUser(username, packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Deletes a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<Unit> DeleteForUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.DeleteForUser(username, packageType, packageName, packageVersionId).ToObservable(); + } + + /// <summary> + /// Restores a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + public IObservable<Unit> RestoreForUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + return _client.RestoreForUser(username, packageType, packageName, packageVersionId).ToObservable(); + } + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservablePackagesClient.cs b/Octokit.Reactive/Clients/ObservablePackagesClient.cs new file mode 100644 index 0000000000..662efb556b --- /dev/null +++ b/Octokit.Reactive/Clients/ObservablePackagesClient.cs @@ -0,0 +1,235 @@ +using Octokit.Reactive.Internal; +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + public class ObservablePackagesClient : IObservablePackagesClient + { + readonly IPackagesClient _client; + readonly IConnection _connection; + + public ObservablePackagesClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Packages; + _connection = client.Connection; + } + + public IObservablePackageVersionsClient PackageVersions { get; private set; } + + /// <summary> + /// List all packages for an organisations, readable by the current user + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + public IObservable<Package> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + var route = ApiUrls.PackagesOrg(org); + var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); + + return _connection.GetAndFlattenAllPages<Package>(route, parameters); + } + + /// <summary> + /// Get a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Package> GetForOrg(string org, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.GetForOrg(org, packageType, packageName).ToObservable(); + } + + /// <summary> + /// Delete a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Unit> DeleteForOrg(string org, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.DeleteForOrg(org, packageType, packageName).ToObservable(); + } + + /// <summary> + /// Restore a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Unit> RestoreForOrg(string org, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.RestoreForOrg(org, packageType, packageName).ToObservable(); + } + + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + public IObservable<Package> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null) + { + var route = ApiUrls.PackagesActiveUser(); + var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); + + return _connection.GetAndFlattenAllPages<Package>(route, parameters); + } + + /// <summary> + /// Gets a specific package for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Package> GetForActiveUser(PackageType packageType, string packageName) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.GetForActiveUser(packageType, packageName).ToObservable(); + } + + /// <summary> + /// Deletes a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Unit> DeleteForActiveUser(PackageType packageType, string packageName) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.DeleteForActiveUser(packageType, packageName).ToObservable(); + } + + /// <summary> + /// Restores a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Unit> RestoreForActiveUser(PackageType packageType, string packageName) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.RestoreForActiveUser(packageType, packageName).ToObservable(); + } + + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + public IObservable<Package> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + + var route = ApiUrls.PackagesUser(username); + var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); + + return _connection.GetAndFlattenAllPages<Package>(route, parameters); + } + + /// <summary> + /// Gets a specific package metadata for a public package owned by a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Package> GetForUser(string username, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.GetForUser(username, packageType, packageName).ToObservable(); + } + + /// <summary> + /// Deletes an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Unit> DeleteForUser(string username, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.DeleteForUser(username, packageType, packageName).ToObservable(); + } + + /// <summary> + /// Restores an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + public IObservable<Unit> RestoreForUser(string username, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + return _client.RestoreForUser(username, packageType, packageName).ToObservable(); + } + } +} \ No newline at end of file diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index e4f91ec061..5563afe5c2 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -34,5 +34,6 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableMigrationClient Migration { get; } IObservableReactionsClient Reaction { get; } IObservableChecksClient Check { get; } + IObservablePackagesClient Packages{ get; } } } \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index a063faae62..e84e191b1f 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -49,6 +49,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Migration = new ObservableMigrationClient(gitHubClient); Reaction = new ObservableReactionsClient(gitHubClient); Check = new ObservableChecksClient(gitHubClient); + Packages = new ObservablePackagesClient(gitHubClient); } public IConnection Connection @@ -88,6 +89,7 @@ public void SetRequestTimeout(TimeSpan timeout) public IObservableMigrationClient Migration { get; private set; } public IObservableReactionsClient Reaction { get; private set; } public IObservableChecksClient Check { get; private set; } + public IObservablePackagesClient Packages { get; private set; } /// <summary> /// Gets the latest API Info - this will be null if no API calls have been made diff --git a/Octokit.Tests.Integration/Clients/PackageVersionsClientTests.cs b/Octokit.Tests.Integration/Clients/PackageVersionsClientTests.cs new file mode 100644 index 0000000000..2571500d4a --- /dev/null +++ b/Octokit.Tests.Integration/Clients/PackageVersionsClientTests.cs @@ -0,0 +1,34 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class PackageVersionsClientTests + { + public class TheGetAllMethod + { + [IntegrationTest(Skip = "Cannot create packages as part of this test, so can never succeed")] + public async Task ReturnsAllPackageVersions() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.Packages.PackageVersions.GetAllForOrg(Helper.Organization, PackageType.Container, "asd"); + + Assert.NotEmpty(result); + } + } + + public class TheGetMethod + { + [IntegrationTest(Skip = "Cannot create packages as part of this test, so can never succeed")] + public async Task ReturnsAPackages() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.Packages.PackageVersions.GetForOrg(Helper.Organization, PackageType.Container, "asd", 1); + + Assert.NotNull(result); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/PackagesClientTests.cs b/Octokit.Tests.Integration/Clients/PackagesClientTests.cs new file mode 100644 index 0000000000..f1e2ab0031 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/PackagesClientTests.cs @@ -0,0 +1,34 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class PackagesClientTests + { + public class TheGetAllMethod + { + [IntegrationTest(Skip = "Cannot create packages as part of this test, so can never succeed")] + public async Task ReturnsAllPackages() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.Packages.GetAllForOrg(Helper.Organization, PackageType.Container); + + Assert.NotEmpty(result); + } + } + + public class TheGetMethod + { + [IntegrationTest(Skip = "Cannot create packages as part of this test, so can never succeed")] + public async Task ReturnsAPackages() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.Packages.GetForOrg(Helper.Organization, PackageType.Container, "asd"); + + Assert.NotNull(result); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/PackageVersionsClientTests.cs b/Octokit.Tests/Clients/PackageVersionsClientTests.cs new file mode 100644 index 0000000000..2e75aa3325 --- /dev/null +++ b/Octokit.Tests/Clients/PackageVersionsClientTests.cs @@ -0,0 +1,395 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class PackageVersionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new PackageVersionsClient(null)); + } + } + + public class TheGetAllForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetAllForOrg("fake", PackageType.RubyGems, "name"); + + connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => + u.ToString() == "/orgs/fake/packages/rubygems/name/versions"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithOptionalParameter() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetAllForOrg("fake", PackageType.RubyGems, "name", PackageVersionState.Deleted); + + var calls = connection.ReceivedCalls(); + connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => + u.ToString() == "/orgs/fake/packages/rubygems/name/versions"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted"), + Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrg(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrg("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrg("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrg("owner", PackageType.Npm, "")); + } + } + + public class TheGetForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetForOrg("fake", PackageType.Npm, "name", 5); + + connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/versions/5")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForOrg(null, PackageType.Npm, "asd", 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForOrg("", PackageType.Npm, "asd", 5)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForOrg("owner", PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForOrg("owner", PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForOrg("owner", PackageType.Npm, "", 0)); + } + } + + public class TheDeleteForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.DeleteForOrg("fake", PackageType.Npm, "name", 5); + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/versions/5")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForOrg(null, PackageType.Npm, "asd", 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForOrg("", PackageType.Npm, "asd", 5)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForOrg("owner", PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForOrg("owner", PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForOrg("owner", PackageType.Npm, "", 0)); + } + } + + public class TheRestoreForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.RestoreForOrg("fake", PackageType.Npm, "name", 5); + + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/versions/5/restore")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForOrg(null, PackageType.Npm, "asd", 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForOrg("", PackageType.Npm, "asd", 5)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForOrg("owner", PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForOrg("owner", PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForOrg("owner", PackageType.Npm, "", 0)); + } + } + + public class TheGetAllForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetAllForActiveUser(PackageType.RubyGems, "name"); + + connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => + u.ToString() == "/user/packages/rubygems/name/versions"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithOptionalParameter() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetAllForActiveUser(PackageType.RubyGems, "name", PackageVersionState.Deleted); + + var calls = connection.ReceivedCalls(); + connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => + u.ToString() == "/user/packages/rubygems/name/versions"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted"), + Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForActiveUser(PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForActiveUser(PackageType.Npm, "")); + } + } + + public class TheGetForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetForActiveUser(PackageType.Npm, "name", 5); + + connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/versions/5")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForActiveUser(PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForActiveUser(PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForActiveUser(PackageType.Npm, "", 0)); + } + } + + public class TheDeleteForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.DeleteForActiveUser(PackageType.Npm, "name", 5); + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/versions/5")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForActiveUser(PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForActiveUser(PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForActiveUser(PackageType.Npm, "", 0)); + } + } + + public class TheRestoreForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.RestoreForActiveUser(PackageType.Npm, "name", 5); + + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/versions/5/restore")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForActiveUser(PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForActiveUser(PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForActiveUser(PackageType.Npm, "", 0)); + } + } + + public class TheGetAllForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetAllForUser("fake", PackageType.RubyGems, "name"); + + connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => + u.ToString() == "/users/fake/packages/rubygems/name/versions"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), + Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithOptionalParameter() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetAllForUser("fake", PackageType.RubyGems, "name", PackageVersionState.Deleted); + + var calls = connection.ReceivedCalls(); + connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => + u.ToString() == "/users/fake/packages/rubygems/name/versions"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted"), + Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("owner", PackageType.Npm, "")); + } + } + + public class TheGetForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.GetForUser("fake", PackageType.Npm, "name", 5); + + connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/versions/5")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForUser(null, PackageType.Npm, "asd", 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForUser("", PackageType.Npm, "asd", 5)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForUser("owner", PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForUser("owner", PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForUser("owner", PackageType.Npm, "", 0)); + } + } + + public class TheDeleteForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.DeleteForUser("fake", PackageType.Npm, "name", 5); + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/versions/5")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForUser(null, PackageType.Npm, "asd", 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForUser("", PackageType.Npm, "asd", 5)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForUser("owner", PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForUser("owner", PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForUser("owner", PackageType.Npm, "", 0)); + } + } + + public class TheRestoreForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackageVersionsClient(connection); + + await client.RestoreForUser("fake", PackageType.Npm, "name", 5); + + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/versions/5/restore")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackageVersionsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForUser(null, PackageType.Npm, "asd", 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForUser("", PackageType.Npm, "asd", 5)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForUser("owner", PackageType.Npm, null, 5)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForUser("owner", PackageType.Npm, "", 5)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForUser("owner", PackageType.Npm, "", 0)); + } + } + } +} diff --git a/Octokit.Tests/Clients/PackagesClientTests.cs b/Octokit.Tests/Clients/PackagesClientTests.cs new file mode 100644 index 0000000000..1b056c30a4 --- /dev/null +++ b/Octokit.Tests/Clients/PackagesClientTests.cs @@ -0,0 +1,344 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class PackagesClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new PackagesClient(null)); + } + } + + public class TheGetAllForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetAllForOrg("fake", PackageType.RubyGems); + + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + } + + [Fact] + public async Task RequestsCorrectUrlWithOptionalParameter() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetAllForOrg("fake", PackageType.RubyGems, PackageVisibility.Public); + + var calls = connection.ReceivedCalls(); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrg(null, PackageType.Nuget)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrg("", PackageType.Nuget)); + } + } + + public class TheGetForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetForOrg("fake", PackageType.Npm, "name"); + + connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForOrg(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForOrg("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForOrg("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForOrg("owner", PackageType.Npm, "")); + } + } + + public class TheDeleteForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.DeleteForOrg("fake", PackageType.Npm, "name"); + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForOrg(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForOrg("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForOrg("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForOrg("owner", PackageType.Npm, "")); + } + } + + public class TheRestoreForOrgMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.RestoreForOrg("fake", PackageType.Npm, "name"); + + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/restore")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForOrg(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForOrg("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForOrg("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForOrg("owner", PackageType.Npm, "")); + } + } + + public class TheGetAllForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetAllForActiveUser(PackageType.RubyGems); + + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/user/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + } + + [Fact] + public async Task RequestsCorrectUrlWithOptionalParameter() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetAllForActiveUser(PackageType.RubyGems, PackageVisibility.Public); + + var calls = connection.ReceivedCalls(); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/user/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + } + } + + public class TheGetForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetForActiveUser(PackageType.Npm, "name"); + + connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForActiveUser(PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForActiveUser(PackageType.Npm, "")); + } + } + + public class TheDeleteForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.DeleteForActiveUser(PackageType.Npm, "name"); + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForActiveUser(PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForActiveUser(PackageType.Npm, "")); + } + } + + public class TheRestoreForActiveUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.RestoreForActiveUser(PackageType.Npm, "name"); + + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/restore")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForActiveUser(PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForActiveUser(PackageType.Npm, "")); + } + } + + public class TheGetAllForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetAllForUser("fake", PackageType.RubyGems); + + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + } + + [Fact] + public async Task RequestsCorrectUrlWithOptionalParameter() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetAllForUser("fake", PackageType.RubyGems, PackageVisibility.Public); + + var calls = connection.ReceivedCalls(); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForUser(null, PackageType.Nuget)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", PackageType.Nuget)); + } + } + + public class TheGetForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.GetForUser("fake", PackageType.Npm, "name"); + + connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForUser(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForUser("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetForUser("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetForUser("owner", PackageType.Npm, "")); + } + } + + public class TheDeleteForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.DeleteForUser("fake", PackageType.Npm, "name"); + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForUser(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForUser("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteForUser("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteForUser("owner", PackageType.Npm, "")); + } + } + + public class TheRestoreForUserMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new PackagesClient(connection); + + await client.RestoreForUser("fake", PackageType.Npm, "name"); + + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/restore")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new PackagesClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForUser(null, PackageType.Npm, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForUser("", PackageType.Npm, "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RestoreForUser("owner", PackageType.Npm, null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RestoreForUser("owner", PackageType.Npm, "")); + } + } + + } +} diff --git a/Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs b/Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs new file mode 100644 index 0000000000..0ba5cc3332 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservablePackageVersionsTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservablePackageVersionsClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackageVersionsClient(gitHubClient); + + client.GetAllForOrg("fake", PackageType.RubyGems, "name"); + + gitHubClient.Connection.Received().Get<List<PackageVersion>>( + new Uri("/orgs/fake/packages/rubygems/name/versions", UriKind.Relative), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state"))); + } + + [Fact] + public void RequestsCorrectUrlWithOptionalParameter() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackageVersionsClient(gitHubClient); + + client.GetAllForOrg("fake", PackageType.RubyGems, "name", PackageVersionState.Deleted); + + gitHubClient.Connection.Received().Get<List<PackageVersion>>( + Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/rubygems/name/versions"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted")); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackageVersionsClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetAllForOrg(null, PackageType.Nuget, "name")); + Assert.Throws<ArgumentException>(() => client.GetAllForOrg("", PackageType.Nuget, "name")); + + Assert.Throws<ArgumentNullException>(() => client.GetAllForOrg("fake", PackageType.Nuget, null)); + Assert.Throws<ArgumentException>(() => client.GetAllForOrg("fake", PackageType.Nuget, "")); + } + } + + public class TheGetMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackageVersionsClient(gitHubClient); + + client.GetForOrg("fake", PackageType.Npm, "name", 5); + + gitHubClient.Packages.PackageVersions.Received().GetForOrg("fake", PackageType.Npm, "name", 5); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackageVersionsClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetForOrg(null, PackageType.Npm, "asd", 5)); + Assert.Throws<ArgumentException>(() => client.GetForOrg("", PackageType.Npm, "asd", 5)); + + Assert.Throws<ArgumentNullException>(() => client.GetForOrg("owner", PackageType.Npm, null, 5)); + Assert.Throws<ArgumentException>(() => client.GetForOrg("owner", PackageType.Npm, "", 5)); + + Assert.Throws<ArgumentException>(() => client.GetForOrg("owner", PackageType.Npm, "asd", 0)); + } + } + + public class TheDeleteMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackageVersionsClient(gitHubClient); + + client.DeleteForOrg("fake", PackageType.Npm, "name", 5); + + gitHubClient.Packages.PackageVersions.Received(1).DeleteForOrg("fake", PackageType.Npm, "name", 5); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackageVersionsClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.DeleteForOrg(null, PackageType.Npm, "asd", 5)); + Assert.Throws<ArgumentException>(() => client.DeleteForOrg("", PackageType.Npm, "asd", 5)); + + Assert.Throws<ArgumentNullException>(() => client.DeleteForOrg("owner", PackageType.Npm, null, 5)); + Assert.Throws<ArgumentException>(() => client.DeleteForOrg("owner", PackageType.Npm, "", 5)); + + Assert.Throws<ArgumentException>(() => client.DeleteForOrg("owner", PackageType.Npm, "asd", 0)); + } + } + + public class TheRestoreMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackageVersionsClient(gitHubClient); + + client.RestoreForOrg("fake", PackageType.Npm, "name", 5); + + gitHubClient.Packages.PackageVersions.Received(1).RestoreForOrg("fake", PackageType.Npm, "name", 5); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackageVersionsClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.RestoreForOrg(null, PackageType.Npm, "asd", 5)); + Assert.Throws<ArgumentException>(() => client.RestoreForOrg("", PackageType.Npm, "asd", 5)); + + Assert.Throws<ArgumentNullException>(() => client.RestoreForOrg("owner", PackageType.Npm, null, 5)); + Assert.Throws<ArgumentException>(() => client.RestoreForOrg("owner", PackageType.Npm, "", 5)); + + Assert.Throws<ArgumentException>(() => client.RestoreForOrg("owner", PackageType.Npm, "asd", 0)); + } + } + } + +} diff --git a/Octokit.Tests/Reactive/ObservablePackagesTests.cs b/Octokit.Tests/Reactive/ObservablePackagesTests.cs new file mode 100644 index 0000000000..996da9b7bd --- /dev/null +++ b/Octokit.Tests/Reactive/ObservablePackagesTests.cs @@ -0,0 +1,350 @@ +using System; +using System.Collections.Generic; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservablePackagesTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservablePackagesClient(null)); + } + } + + public class TheGetAllForOrgMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetAllForOrg("fake", PackageType.RubyGems); + + gitHubClient.Connection.Received(1).Get<List<Package>>( + new Uri("/orgs/fake/packages", UriKind.Relative), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + } + + [Fact] + public void RequestsCorrectUrlWithOptionalParameter() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetAllForOrg("fake", PackageType.RubyGems, PackageVisibility.Public); + + gitHubClient.Connection.Received().Get<List<Package>>( + Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetAllForOrg(null, PackageType.Nuget)); + Assert.Throws<ArgumentException>(() => client.GetAllForOrg("", PackageType.Nuget)); + } + } + + public class TheGetForOrgMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetForOrg("fake", PackageType.Npm, "name"); + + gitHubClient.Packages.Received().GetForOrg("fake", PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetForOrg(null, PackageType.Npm, "asd")); + Assert.Throws<ArgumentException>(() => client.GetForOrg("", PackageType.Npm, "asd")); + + Assert.Throws<ArgumentNullException>(() => client.GetForOrg("owner", PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.GetForOrg("owner", PackageType.Npm, "")); + } + } + + public class TheDeleteForOrgMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.DeleteForOrg("fake", PackageType.Npm, "name"); + + gitHubClient.Packages.Received(1).DeleteForOrg("fake", PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.DeleteForOrg(null, PackageType.Npm, "asd")); + Assert.Throws<ArgumentException>(() => client.DeleteForOrg("", PackageType.Npm, "asd")); + + Assert.Throws<ArgumentNullException>(() => client.DeleteForOrg("owner", PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.DeleteForOrg("owner", PackageType.Npm, "")); + } + } + + public class TheRestoreForOrgMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.RestoreForOrg("fake", PackageType.Npm, "name"); + + gitHubClient.Packages.Received(1).RestoreForOrg("fake", PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.RestoreForOrg(null, PackageType.Npm, "asd")); + Assert.Throws<ArgumentException>(() => client.RestoreForOrg("", PackageType.Npm, "asd")); + + Assert.Throws<ArgumentNullException>(() => client.RestoreForOrg("owner", PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.RestoreForOrg("owner", PackageType.Npm, "")); + } + + public class TheGetAllForActiveUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetAllForActiveUser(PackageType.RubyGems); + + gitHubClient.Connection.Received(1).Get<List<Package>>( + new Uri("/user/packages", UriKind.Relative), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + } + + [Fact] + public void RequestsCorrectUrlWithOptionalParameter() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetAllForActiveUser(PackageType.RubyGems, PackageVisibility.Public); + + gitHubClient.Connection.Received().Get<List<Package>>( + Arg.Is<Uri>(u => u.ToString() == "/user/packages"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + } + } + + public class TheGetForActiveUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetForActiveUser(PackageType.Npm, "name"); + + gitHubClient.Packages.Received().GetForActiveUser(PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetForActiveUser(PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.GetForActiveUser(PackageType.Npm, "")); + } + } + + public class TheDeleteForActiveUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.DeleteForActiveUser(PackageType.Npm, "name"); + + gitHubClient.Packages.Received(1).DeleteForActiveUser(PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.DeleteForActiveUser(PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.DeleteForActiveUser(PackageType.Npm, "")); + } + } + + public class TheRestoreForActiveUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.RestoreForActiveUser(PackageType.Npm, "name"); + + gitHubClient.Packages.Received(1).RestoreForActiveUser(PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.RestoreForActiveUser(PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.RestoreForActiveUser(PackageType.Npm, "")); + } + } + + public class TheGetAllForUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetAllForUser("fake", PackageType.RubyGems); + + gitHubClient.Connection.Received(1).Get<List<Package>>( + new Uri("/users/fake/packages", UriKind.Relative), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + } + + [Fact] + public void RequestsCorrectUrlWithOptionalParameter() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetAllForUser("fake", PackageType.RubyGems, PackageVisibility.Public); + + gitHubClient.Connection.Received().Get<List<Package>>( + Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages"), + Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetAllForUser(null, PackageType.Nuget)); + Assert.Throws<ArgumentException>(() => client.GetAllForUser("", PackageType.Nuget)); + } + } + + public class TheGetForUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.GetForUser("fake", PackageType.Npm, "name"); + + gitHubClient.Packages.Received().GetForUser("fake", PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.GetForUser(null, PackageType.Npm, "asd")); + Assert.Throws<ArgumentException>(() => client.GetForUser("", PackageType.Npm, "asd")); + + Assert.Throws<ArgumentNullException>(() => client.GetForUser("owner", PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.GetForUser("owner", PackageType.Npm, "")); + } + } + + public class TheDeleteForUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.DeleteForUser("fake", PackageType.Npm, "name"); + + gitHubClient.Packages.Received(1).DeleteForUser("fake", PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.DeleteForUser(null, PackageType.Npm, "asd")); + Assert.Throws<ArgumentException>(() => client.DeleteForUser("", PackageType.Npm, "asd")); + + Assert.Throws<ArgumentNullException>(() => client.DeleteForUser("owner", PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.DeleteForUser("owner", PackageType.Npm, "")); + } + } + + public class TheRestoreForUserMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservablePackagesClient(gitHubClient); + + client.RestoreForUser("fake", PackageType.Npm, "name"); + + gitHubClient.Packages.Received(1).RestoreForUser("fake", PackageType.Npm, "name"); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservablePackagesClient(Substitute.For<IGitHubClient>()); + + Assert.Throws<ArgumentNullException>(() => client.RestoreForUser(null, PackageType.Npm, "asd")); + Assert.Throws<ArgumentException>(() => client.RestoreForUser("", PackageType.Npm, "asd")); + + Assert.Throws<ArgumentNullException>(() => client.RestoreForUser("owner", PackageType.Npm, null)); + Assert.Throws<ArgumentException>(() => client.RestoreForUser("owner", PackageType.Npm, "")); + } + } + } + } +} diff --git a/Octokit/Clients/IPackageVersionsClient.cs b/Octokit/Clients/IPackageVersionsClient.cs new file mode 100644 index 0000000000..dd877f7868 --- /dev/null +++ b/Octokit/Clients/IPackageVersionsClient.cs @@ -0,0 +1,151 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IPackageVersionsClient + { + /// <summary> + /// List all versions of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + Task<IReadOnlyList<PackageVersion>> GetAllForOrg(string org, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null); + + /// <summary> + /// Get a specific version of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task<PackageVersion> GetForOrg(string org, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Deletes a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task DeleteForOrg(string org, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Restores a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task RestoreForOrg(string org, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Returns all package versions for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + Task<IReadOnlyList<PackageVersion>> GetAllForActiveUser(PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null); + + /// <summary> + /// Gets a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task<PackageVersion> GetForActiveUser(PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Deletes a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task DeleteForActiveUser(PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Restores a package version owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task RestoreForActiveUser(PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Returns all package versions for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + Task<IReadOnlyList<PackageVersion>> GetAllForUser(string username, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null); + + /// <summary> + /// Gets a specific package version for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task<PackageVersion> GetForUser(string username, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Deletes a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task DeleteForUser(string username, PackageType packageType, string packageName, int packageVersionId); + + /// <summary> + /// Restores a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + Task RestoreForUser(string username, PackageType packageType, string packageName, int packageVersionId); + } +} \ No newline at end of file diff --git a/Octokit/Clients/IPackagesClient.cs b/Octokit/Clients/IPackagesClient.cs new file mode 100644 index 0000000000..25dac896d0 --- /dev/null +++ b/Octokit/Clients/IPackagesClient.cs @@ -0,0 +1,141 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IPackagesClient + { + IPackageVersionsClient PackageVersions { get; } + + /// <summary> + /// List all packages for an organisations, readable by the current user + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + [ExcludeFromPaginationApiOptionsConventionTest("No api options available according to the documentation")] + Task<IReadOnlyList<Package>> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null); + + /// <summary> + /// Get a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task<Package> GetForOrg(string org, PackageType packageType, string packageName); + + /// <summary> + /// Delete a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task DeleteForOrg(string org, PackageType packageType, string packageName); + + /// <summary> + /// Restore a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task RestoreForOrg(string org, PackageType packageType, string packageName); + + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + [ExcludeFromPaginationApiOptionsConventionTest("No api options available according to the documentation")] + Task<IReadOnlyList<Package>> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null); + + /// <summary> + /// Gets a specific package for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task<Package> GetForActiveUser(PackageType packageType, string packageName); + + /// <summary> + /// Deletes a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task DeleteForActiveUser(PackageType packageType, string packageName); + + /// <summary> + /// Restores a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task RestoreForActiveUser(PackageType packageType, string packageName); + + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + [ExcludeFromPaginationApiOptionsConventionTest("No api options available according to the documentation")] + Task<IReadOnlyList<Package>> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null); + + /// <summary> + /// Gets a specific package metadata for a public package owned by a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task<Package> GetForUser(string username, PackageType packageType, string packageName); + + /// <summary> + /// Deletes an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task DeleteForUser(string username, PackageType packageType, string packageName); + + /// <summary> + /// Restores an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + Task RestoreForUser(string username, PackageType packageType, string packageName); + } +} \ No newline at end of file diff --git a/Octokit/Clients/PackageVersionsClient.cs b/Octokit/Clients/PackageVersionsClient.cs new file mode 100644 index 0000000000..023cb18fb2 --- /dev/null +++ b/Octokit/Clients/PackageVersionsClient.cs @@ -0,0 +1,283 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public class PackageVersionsClient : ApiClient, IPackageVersionsClient + { + public PackageVersionsClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + #region Organization + /// <summary> + /// List all versions of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + [ManualRoute("GET", "/orgs/{org}/packages/{package_type}/{package_name}/versions")] + public Task<IReadOnlyList<PackageVersion>> GetAllForOrg(string org, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.ApiOptionsNotNull(ref options); + + var route = ApiUrls.PackageVersionsOrg(org, packageType, packageName); + var parameters = ParameterBuilder.AddParameter("state", state); + + return ApiConnection.GetAll<PackageVersion>(route, parameters, options); + } + + /// <summary> + /// Get a specific version of a package. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("GET", "/orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}")] + public Task<PackageVersion> GetForOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionOrg(org, packageType, packageName, packageVersionId); + + return ApiConnection.Get<PackageVersion>(route); + } + + /// <summary> + /// Deletes a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("DELETE", "/orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}")] + public Task DeleteForOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionOrg(org, packageType, packageName, packageVersionId); + return ApiConnection.Delete(route); + } + + /// <summary> + /// Restores a specific package version in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("POST", "/orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore")] + public Task RestoreForOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionRestoreOrg(org, packageType, packageName, packageVersionId); + + return ApiConnection.Post(route); + } + #endregion + + #region Active User + /// <summary> + /// Returns all package versions for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + [ManualRoute("GET", "/user/packages/{package_type}/{package_name}/versions")] + public Task<IReadOnlyList<PackageVersion>> GetAllForActiveUser(PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.ApiOptionsNotNull(ref options); + + var route = ApiUrls.PackageVersionsActiveUser(packageType, packageName); + var parameters = ParameterBuilder.AddParameter("state", state); + + return ApiConnection.GetAll<PackageVersion>(route, parameters, options); + } + + /// <summary> + /// Gets a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("GET", "/user/packages/{package_type}/{package_name}/versions/{package_version_id}")] + public Task<PackageVersion> GetForActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionActiveUser( packageType, packageName, packageVersionId); + + return ApiConnection.Get<PackageVersion>(route); + } + + /// <summary> + /// Deletes a specific package version for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("DELETE", "/user/packages/{package_type}/{package_name}/versions/{package_version_id}")] + public Task DeleteForActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionActiveUser(packageType, packageName, packageVersionId); + return ApiConnection.Delete(route); + } + + /// <summary> + /// Restores a package version owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-version-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("POST", "/user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore")] + public Task RestoreForActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionRestoreActiveUser(packageType, packageName, packageVersionId); + + return ApiConnection.Post(route); + } + #endregion + + #region Specific User + /// <summary> + /// Returns all package versions for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-all-package-versions-for-a-package-owned-by-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="state">Optional: Return packages with a state. Defaults to Active</param> + /// <param name="options">Optional: Paging options</param> + [ManualRoute("GET", "/users/{username}/packages/{package_type}/{package_name}/versions")] + public Task<IReadOnlyList<PackageVersion>> GetAllForUser(string username, PackageType packageType, string packageName, PackageVersionState state = PackageVersionState.Active, ApiOptions options = null) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.ApiOptionsNotNull(ref options); + + var route = ApiUrls.PackageVersionsUser(username, packageType, packageName); + var parameters = ParameterBuilder.AddParameter("state", state); + + return ApiConnection.GetAll<PackageVersion>(route, parameters, options); + } + + /// <summary> + /// Gets a specific package version for a public package owned by a specified user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("GET", "/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}")] + public Task<PackageVersion> GetForUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionUser(username, packageType, packageName, packageVersionId); + + return ApiConnection.Get<PackageVersion>(route); + } + + /// <summary> + /// Deletes a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("DELETE", "/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}")] + public Task DeleteForUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNull(packageType, nameof(packageType)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionUser(username, packageType, packageName, packageVersionId); + return ApiConnection.Delete(route); + } + + /// <summary> + /// Restores a specific package version for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-package-version-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + /// <param name="packageVersionId">Required: The id of the package version</param> + [ManualRoute("POST", "/users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore")] + public Task RestoreForUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + Ensure.GreaterThanZero(packageVersionId, nameof(packageVersionId)); + + var route = ApiUrls.PackageVersionRestoreUser(username, packageType, packageName, packageVersionId); + + return ApiConnection.Post(route); + } + #endregion + } +} diff --git a/Octokit/Clients/PackagesClient.cs b/Octokit/Clients/PackagesClient.cs new file mode 100644 index 0000000000..d5de960fb0 --- /dev/null +++ b/Octokit/Clients/PackagesClient.cs @@ -0,0 +1,258 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Packages API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/packages">Packages API documentation</a> for more details. + /// </remarks> + public class PackagesClient : ApiClient, IPackagesClient + { + public PackagesClient(IApiConnection apiConnection) : base(apiConnection) + { + PackageVersions = new PackageVersionsClient(apiConnection); + } + + public IPackageVersionsClient PackageVersions { get; private set; } + + #region Organization + /// <summary> + /// List all packages for an organisations, readable by the current user + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + [ManualRoute("GET", "/orgs/{org}/packages")] + public Task<IReadOnlyList<Package>> GetAllForOrg(string org, PackageType packageType, PackageVisibility? packageVisibility = null) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + var route = ApiUrls.PackagesOrg(org); + var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); + + return ApiConnection.GetAll<Package>(route, parameters); + } + + /// <summary> + /// Get a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("GET", "/orgs/{org}/packages/{package_type}/{package_name}")] + public Task<Package> GetForOrg(string org, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageOrg(org, packageType, packageName); + + return ApiConnection.Get<Package>(route); + } + + /// <summary> + /// Delete a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("DELETE", "/orgs/{org}/packages/{package_type}/{package_name}")] + public Task DeleteForOrg(string org, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageOrg(org, packageType, packageName); + + return ApiConnection.Delete(route); + } + + /// <summary> + /// Restore a specific package for an Organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-an-organization">API documentation</a> for more details + /// </remarks> + /// <param name="org">Required: Organisation Name</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("POST", "/orgs/{org}/packages/{package_type}/{package_name}/restore")] + public Task RestoreForOrg(string org, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageRestoreOrg(org, packageType, packageName); + + return ApiConnection.Post(route); + } + #endregion + + #region Active User + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + [ManualRoute("GET", "/user/packages")] + public Task<IReadOnlyList<Package>> GetAllForActiveUser(PackageType packageType, PackageVisibility? packageVisibility = null) + { + var route = ApiUrls.PackagesActiveUser(); + var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); + + return ApiConnection.GetAll<Package>(route, parameters); + } + + /// <summary> + /// Gets a specific package for a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("GET", "/user/packages/{package_type}/{package_name}")] + public Task<Package> GetForActiveUser(PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageActiveUser(packageType, packageName); + + return ApiConnection.Get<Package>(route); + } + + /// <summary> + /// Deletes a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("DELETE", "/user/packages/{package_type}/{package_name}")] + public Task DeleteForActiveUser(PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageActiveUser(packageType, packageName); + + return ApiConnection.Delete(route); + } + + /// <summary> + /// Restores a package owned by the authenticated user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-the-authenticated-user">API documentation</a> for more details + /// </remarks> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("POST", "/user/packages/{package_type}/{package_name}/restore")] + public Task RestoreForActiveUser(PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageRestoreActiveUser(packageType, packageName); + + return ApiConnection.Post(route); + } + #endregion + + #region Specific User + /// <summary> + /// Lists packages owned by the authenticated user within the user's namespace + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#list-packages-for-the-authenticated-users-namespace">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageVisibility">Optional: The visibility of the package</param> + [ManualRoute("GET", "/users/{username}/packages")] + public Task<IReadOnlyList<Package>> GetAllForUser(string username, PackageType packageType, PackageVisibility? packageVisibility = null) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + + var route = ApiUrls.PackagesUser(username); + var parameters = ParameterBuilder.AddParameter("package_type", packageType).AddOptionalParameter("visibility", packageVisibility); + + return ApiConnection.GetAll<Package>(route, parameters); + } + + /// <summary> + /// Gets a specific package metadata for a public package owned by a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#get-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("GET", "/users/{username}/packages/{package_type}/{package_name}")] + public Task<Package> GetForUser(string username, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageUser(username, packageType, packageName); + + return ApiConnection.Get<Package>(route); + } + + /// <summary> + /// Deletes an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#delete-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("DELETE", "/users/{username}/packages/{package_type}/{package_name}")] + public Task DeleteForUser(string username, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageUser(username, packageType, packageName); + + return ApiConnection.Delete(route); + } + + /// <summary> + /// Restores an entire package for a user. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/packages#restore-a-package-for-a-user">API documentation</a> for more details + /// </remarks> + /// <param name="username">Required: Username</param> + /// <param name="packageType">Required: The type of package</param> + /// <param name="packageName">Required: The name of the package</param> + [ManualRoute("POST", "/users/{username}/packages/{package_type}/{package_name}/restore")] + public Task RestoreForUser(string username, PackageType packageType, string packageName) + { + Ensure.ArgumentNotNullOrEmptyString(username, nameof(username)); + Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); + + var route = ApiUrls.PackageRestoreUser(username, packageType, packageName); + + return ApiConnection.Post(route); + } + #endregion + } +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index f030540853..f3b2f0c0ca 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -111,6 +111,7 @@ public GitHubClient(IConnection connection) User = new UsersClient(apiConnection); Reaction = new ReactionsClient(apiConnection); Check = new ChecksClient(apiConnection); + Packages = new PackagesClient(apiConnection); } /// <summary> @@ -225,6 +226,14 @@ public Uri BaseAddress /// </remarks> public IOrganizationsClient Organization { get; private set; } + /// <summary> + /// Access GitHub's Pacakges API. + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/en/rest/packages + /// </remarks> + public IPackagesClient Packages { get; private set; } + /// <summary> /// Access GitHub's Pull Requests API. /// </summary> diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index de890c6247..86679989c4 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -4457,5 +4457,167 @@ public static Uri Meta() { return "meta".FormatUri(); } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Packages request + /// </summary> + /// <returns>The <see cref="Uri"/> Packages endpoint.</returns> + public static Uri PackagesOrg(string org) + { + return "/orgs/{0}/packages".FormatUri(org); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageOrg(string org, PackageType packageType, string packageName) + { + return "/orgs/{0}/packages/{1}/{2}".FormatUri(org, packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Restore request + /// </summary> + /// <returns>The <see cref="Uri"/> Package Restore endpoint.</returns> + public static Uri PackageRestoreOrg(string org, PackageType packageType, string packageName) + { + return "/orgs/{0}/packages/{1}/{2}/restore".FormatUri(org, packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Versions request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionsOrg(string org, PackageType packageType, string packageName) + { + return "/orgs/{0}/packages/{1}/{2}/versions".FormatUri(org, packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Version request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + return "/orgs/{0}/packages/{1}/{2}/versions/{3}".FormatUri(org, packageType.ToParameter(), packageName, packageVersionId); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Version request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionRestoreOrg(string org, PackageType packageType, string packageName, int packageVersionId) + { + return "/orgs/{0}/packages/{1}/{2}/versions/{3}/restore".FormatUri(org, packageType.ToParameter(), packageName, packageVersionId); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Packages request + /// </summary> + /// <returns>The <see cref="Uri"/> Packages endpoint.</returns> + public static Uri PackagesActiveUser() + { + return "/user/packages".FormatUri(); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageActiveUser(PackageType packageType, string packageName) + { + return "/user/packages/{0}/{1}".FormatUri(packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Restore request + /// </summary> + /// <returns>The <see cref="Uri"/> Package Restore endpoint.</returns> + public static Uri PackageRestoreActiveUser(PackageType packageType, string packageName) + { + return "/user/packages/{0}/{1}/restore".FormatUri(packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Versions request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionsActiveUser(PackageType packageType, string packageName) + { + return "/user/packages/{0}/{1}/versions".FormatUri(packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Version request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + return "/user/packages/{0}/{1}/versions/{2}".FormatUri(packageType.ToParameter(), packageName, packageVersionId); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Version request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionRestoreActiveUser(PackageType packageType, string packageName, int packageVersionId) + { + return "/user/packages/{0}/{1}/versions/{2}/restore".FormatUri(packageType.ToParameter(), packageName, packageVersionId); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Packages request + /// </summary> + /// <returns>The <see cref="Uri"/> Packages endpoint.</returns> + public static Uri PackagesUser(string username) + { + return "/users/{0}/packages".FormatUri(username); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageUser(string username, PackageType packageType, string packageName) + { + return "/users/{0}/packages/{1}/{2}".FormatUri(username, packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Restore request + /// </summary> + /// <returns>The <see cref="Uri"/> Package Restore endpoint.</returns> + public static Uri PackageRestoreUser(string username, PackageType packageType, string packageName) + { + return "/users/{0}/packages/{1}/{2}/restore".FormatUri(username, packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Versions request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionsUser(string username, PackageType packageType, string packageName) + { + return "/users/{0}/packages/{1}/{2}/versions".FormatUri(username, packageType.ToParameter(), packageName); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Version request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + return "/users/{0}/packages/{1}/{2}/versions/{3}".FormatUri(username, packageType.ToParameter(), packageName, packageVersionId); + } + + /// <summary> + /// Returns the <see cref="Uri"/> for the Package Version request + /// </summary> + /// <returns>The <see cref="Uri"/> Package endpoint.</returns> + public static Uri PackageVersionRestoreUser(string username, PackageType packageType, string packageName, int packageVersionId) + { + return "/users/{0}/packages/{1}/{2}/versions/{3}/restore".FormatUri(username, packageType.ToParameter(), packageName, packageVersionId); + } } } diff --git a/Octokit/Helpers/Ensure.cs b/Octokit/Helpers/Ensure.cs index 727c5422c5..77204d9531 100644 --- a/Octokit/Helpers/Ensure.cs +++ b/Octokit/Helpers/Ensure.cs @@ -50,6 +50,20 @@ public static void GreaterThanZero([ValidatedNotNull]TimeSpan value, string name throw new ArgumentException("Timespan must be greater than zero", name); } + /// <summary> + /// Checks an integer argument to ensure it is a positive value. + /// </summary> + /// <param name = "value">The argument value to check</param> + /// <param name = "name">The name of the argument</param> + public static void GreaterThanZero([ValidatedNotNull] int value, string name) + { + ArgumentNotNull(value, name); + + if (value > 0) return; + + throw new ArgumentException("Value must be greater than zero", name); + } + /// <summary> /// Checks an enumerable argument to ensure it isn't null or empty. /// </summary> @@ -62,6 +76,11 @@ public static void ArgumentNotNullOrEmptyEnumerable<T>([ValidatedNotNull]IEnumer throw new ArgumentException("List cannot be empty", name); } + + public static void ApiOptionsNotNull(ref ApiOptions options) + { + options = options ?? ApiOptions.None; + } } [AttributeUsage(AttributeTargets.Parameter)] diff --git a/Octokit/Helpers/EnumExtensions.cs b/Octokit/Helpers/EnumExtensions.cs index 83bb3fae76..3eae11a8c0 100644 --- a/Octokit/Helpers/EnumExtensions.cs +++ b/Octokit/Helpers/EnumExtensions.cs @@ -24,5 +24,21 @@ internal static string ToParameter(this Enum prop) return attribute != null ? attribute.Value : propString.ToLowerInvariant(); } + + internal static bool HasParameter(this Enum prop) + { + if (prop == null) return false; + + var propString = prop.ToString(); + var member = prop.GetType().GetMember(propString).FirstOrDefault(); + + if (member == null) return false; + + var attribute = member.GetCustomAttributes(typeof(ParameterAttribute), false) + .Cast<ParameterAttribute>() + .FirstOrDefault(); + + return attribute != null; + } } } diff --git a/Octokit/Helpers/ParameterBuilder.cs b/Octokit/Helpers/ParameterBuilder.cs new file mode 100644 index 0000000000..56bb07456f --- /dev/null +++ b/Octokit/Helpers/ParameterBuilder.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; + +namespace Octokit +{ + public static class ParameterBuilder + { + public static Dictionary<string, string> AddParameter(string key, string value) + { + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); + Ensure.ArgumentNotNullOrEmptyString(value, nameof(value)); + + return new Dictionary<string, string> { { key, value } }; + } + + public static Dictionary<string, string> AddParameter(string key, Enum value) + { + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); + Ensure.ArgumentNotNull(value, nameof(value)); + + if (value.HasParameter()) + { + return new Dictionary<string, string> { { key, value.ToParameter() } }; + } + + return new Dictionary<string, string> { { key, value.ToString() } }; + + } + + public static Dictionary<string, string> AddParameter(this Dictionary<string, string> data, string key, string value) + { + Ensure.ArgumentNotNull(data, nameof(data)); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); + Ensure.ArgumentNotNullOrEmptyString(value, nameof(value)); + + data.Add(key, value); + return data; + } + + public static Dictionary<string, string> AddParameter(this Dictionary<string, string> data, string key, Enum value) + { + Ensure.ArgumentNotNull(data, nameof(data)); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); + Ensure.ArgumentNotNull(value, nameof(value)); + + if (value.HasParameter()) + { + data.Add(key, value.ToParameter()); + } + else + { + data.Add(key, value.ToString()); + } + + return data; + } + + + public static Dictionary<string, string> AddOptionalParameter(this Dictionary<string, string> data, string key, string value) + { + Ensure.ArgumentNotNull(data, nameof(data)); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); + + if (value != null) + { + data.Add(key, value); + } + return data; + } + + public static Dictionary<string, string> AddOptionalParameter(this Dictionary<string, string> data, string key, Enum value) + { + Ensure.ArgumentNotNull(data, nameof(data)); + Ensure.ArgumentNotNullOrEmptyString(key, nameof(key)); + + if (value != null) + { + if (value.HasParameter()) + { + data.Add(key, value.ToParameter()); + } + else + { + data.Add(key, value.ToString()); + } + } + + return data; + } + } +} diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 43b0179335..0d2ee9523f 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -87,6 +87,14 @@ public interface IGitHubClient : IApiInfoProvider /// </remarks> IOrganizationsClient Organization { get; } + /// <summary> + /// Access GitHub's Pacakges API. + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/en/rest/packages + /// </remarks> + IPackagesClient Packages { get; } + /// <summary> /// Access GitHub's Pull Requests API. /// </summary> diff --git a/Octokit/Models/Common/PackageType.cs b/Octokit/Models/Common/PackageType.cs new file mode 100644 index 0000000000..7d9201dc24 --- /dev/null +++ b/Octokit/Models/Common/PackageType.cs @@ -0,0 +1,43 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum PackageType + { + /// <summary> + /// Npm repository packages + /// </summary> + [Parameter(Value = "npm")] + Npm, + + /// <summary> + /// Gradle registry packages + /// </summary> + [Parameter(Value = "maven")] + Maven, + + /// <summary> + /// RubyGems packages + /// </summary> + [Parameter(Value = "rubygems")] + RubyGems, + + /// <summary> + /// Docker container registry packages + /// </summary> + [Parameter(Value = "docker")] + Docker, + + /// <summary> + /// Nuget registry packages + /// </summary> + [Parameter(Value = "nuget")] + Nuget, + + /// <summary> + /// Container registry packages + /// </summary> + [Parameter(Value = "container")] + Container, + } +} diff --git a/Octokit/Models/Common/PackageVersionState.cs b/Octokit/Models/Common/PackageVersionState.cs new file mode 100644 index 0000000000..fc90f32c30 --- /dev/null +++ b/Octokit/Models/Common/PackageVersionState.cs @@ -0,0 +1,19 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum PackageVersionState + { + /// <summary> + /// Package version which is active + /// </summary> + [Parameter(Value = "active")] + Active, + + /// <summary> + /// Package version whic is deleted + /// </summary> + [Parameter(Value = "deleted")] + Deleted + } +} diff --git a/Octokit/Models/Common/PackageVisibility.cs b/Octokit/Models/Common/PackageVisibility.cs new file mode 100644 index 0000000000..360d49397d --- /dev/null +++ b/Octokit/Models/Common/PackageVisibility.cs @@ -0,0 +1,25 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum PackageVisibility + { + /// <summary> + /// Only public packages + /// </summary> + [Parameter(Value = "public")] + Public, + + /// <summary> + /// Only private packages + /// </summary> + [Parameter(Value = "private")] + Private, + + /// <summary> + /// Only supported by container package types, otherwise the same as private + /// </summary> + [Parameter(Value = "internal")] + Internal + } +} diff --git a/Octokit/Models/Response/Package.cs b/Octokit/Models/Response/Package.cs new file mode 100644 index 0000000000..b8adedf2b7 --- /dev/null +++ b/Octokit/Models/Response/Package.cs @@ -0,0 +1,78 @@ +using Octokit.Internal; +using System; +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class Package + { + public Package() { } + + public Package(long id, string name, PackageType packageType, Author owner, int versionCount, PackageVisibility visibility, string url, DateTime createdAt, DateTime updatedAt, string htmlUrl) + { + Id = id; + Name = name; + PackageType = packageType; + Owner = owner; + VersionCount = versionCount; + Visibility = visibility; + Url = url; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + HtmlUrl = htmlUrl; + } + + /// <summary> + /// The Id of the package + /// </summary> + public long Id { get; private set; } + + /// <summary> + /// The Name of the package + /// </summary> + public string Name { get; private set; } + + /// <summary> + /// The Type of the package + /// </summary> + public StringEnum<PackageType> PackageType { get; private set; } + + /// <summary> + /// The Owner of the package + /// </summary> + public Author Owner { get; private set; } + + /// <summary> + /// The Version Count of the package + /// </summary> + public int VersionCount { get; private set; } + + /// <summary> + /// The Visibility of the package + /// </summary> + public StringEnum<PackageVisibility> Visibility { get; private set; } + + /// <summary> + /// The Url of the package + /// </summary> + public string Url { get; private set; } + + /// <summary> + /// The Date the package was first created + /// </summary> + public DateTime CreatedAt { get; private set; } + + /// <summary> + /// The Date the package was last updated + /// </summary> + public DateTime UpdatedAt { get; private set; } + + /// <summary> + /// The Url of the package + /// </summary> + public string HtmlUrl { get; private set; } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/PackageVersion.cs b/Octokit/Models/Response/PackageVersion.cs new file mode 100644 index 0000000000..b1c918d0b4 --- /dev/null +++ b/Octokit/Models/Response/PackageVersion.cs @@ -0,0 +1,73 @@ +using Octokit.Internal; +using System; +using System.Collections.Generic; +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PackageVersion + { + public PackageVersion() { } + + public PackageVersion(long id, string name, string url, string packageHtmlUrl, DateTime createdAt, DateTime updatedAt, string htmlUrl, PackageVersionMetadata metadata) + { + Id = id; + Name = name; + Url = url; + PackageHtmlUrl = packageHtmlUrl; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + HtmlUrl = htmlUrl; + Metadata = metadata; + } + + public long Id { get; private set; } + + public string Name { get; private set; } + + public string Url { get; private set; } + + public string PackageHtmlUrl { get; private set; } + + public DateTime CreatedAt { get; private set; } + + public DateTime UpdatedAt { get; private set; } + + public string HtmlUrl { get; private set; } + + public PackageVersionMetadata Metadata { get; private set; } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); + } + + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PackageVersionMetadata + { + public PackageVersionMetadata() { } + + public PackageVersionMetadata(string packageType) + { + PackageType = packageType; + } + + public string PackageType { get; private set; } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); + } + + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PackageVersionMetadataContainer + { + public PackageVersionMetadataContainer() { } + + public PackageVersionMetadataContainer(IReadOnlyList<string> tags) + { + Tags = tags; + } + + public IReadOnlyList<string> Tags { get; private set; } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); + } +} \ No newline at end of file From 38b24d5878b1ed082f9f4d465ebb988d3bd98a55 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Sun, 11 Sep 2022 13:47:10 +0300 Subject: [PATCH 122/209] fix polymorphism of event payloads --- Octokit.Tests/Models/CheckRunEventTests.cs | 1 + Octokit.Tests/Models/CheckSuiteEventTests.cs | 1 + .../Response/ActivityPayloads/ActivityPayload.cs | 4 +--- .../ActivityWithInstallationIdPayload.cs | 10 ++++++++++ .../Response/ActivityPayloads/CheckRunEventPayload.cs | 2 +- .../ActivityPayloads/CheckSuiteEventPayload.cs | 2 +- .../ActivityPayloads/InstallationEventPayload.cs | 6 +----- .../Response/ActivityPayloads/IssueCommentPayload.cs | 2 +- .../Response/ActivityPayloads/IssueEventPayload.cs | 2 +- .../ActivityPayloads/PullRequestCommentPayload.cs | 2 +- .../ActivityPayloads/PullRequestEventPayload.cs | 2 +- .../ActivityPayloads/PullRequestReviewEventPayload.cs | 2 +- .../Response/ActivityPayloads/ReleaseEventPayload.cs | 2 +- .../Response/ActivityPayloads/StarredEventPayload.cs | 2 +- Octokit/Octokit.csproj | 2 +- 15 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs diff --git a/Octokit.Tests/Models/CheckRunEventTests.cs b/Octokit.Tests/Models/CheckRunEventTests.cs index 360a72382a..94fec972da 100644 --- a/Octokit.Tests/Models/CheckRunEventTests.cs +++ b/Octokit.Tests/Models/CheckRunEventTests.cs @@ -246,6 +246,7 @@ public void CanBeDeserialized() var payload = serializer.Deserialize<CheckRunEventPayload>(json); + Assert.Equal(1, payload.Installation.Id); Assert.Equal("rerequested", payload.Action); Assert.Equal("d6fde92930d4715a2b49857d24b940956b26d2d3", payload.CheckRun.HeadSha); Assert.Equal(4, payload.CheckRun.Id); diff --git a/Octokit.Tests/Models/CheckSuiteEventTests.cs b/Octokit.Tests/Models/CheckSuiteEventTests.cs index cccfa91454..cc4efc65d0 100644 --- a/Octokit.Tests/Models/CheckSuiteEventTests.cs +++ b/Octokit.Tests/Models/CheckSuiteEventTests.cs @@ -15,6 +15,7 @@ public void CanBeDeserialized() var payload = serializer.Deserialize<CheckSuiteEventPayload>(json); + Assert.Equal(103621, payload.Installation.Id); Assert.Equal("rerequested", payload.Action); Assert.Equal("73955d02043135d48809add98052c2170522158f", payload.CheckSuite.HeadSha); Assert.Equal(CheckStatus.Queued, payload.CheckSuite.Status.Value); diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs index aec80af469..a86f45c401 100644 --- a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs @@ -8,16 +8,14 @@ public class ActivityPayload public ActivityPayload() { } - public ActivityPayload(Repository repository, User sender, InstallationId installation) + public ActivityPayload(Repository repository, User sender) { Repository = repository; Sender = sender; - Installation = installation; } public Repository Repository { get; protected set; } public User Sender { get; protected set; } - public InstallationId Installation { get; protected set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs new file mode 100644 index 0000000000..2e80057fd7 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs @@ -0,0 +1,10 @@ +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class ActivityWithInstallationIdPayload : ActivityWithActionPayload + { + public InstallationId Installation { get; set; } + } +} diff --git a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs index b610d549da..d560ca4b29 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunEventPayload : ActivityWithActionPayload + public class CheckRunEventPayload : ActivityWithInstallationIdPayload { public CheckRun CheckRun { get; protected set; } public CheckRunRequestedAction RequestedAction { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs index c922e6b3f6..32c57942ee 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuiteEventPayload : ActivityWithActionPayload + public class CheckSuiteEventPayload : ActivityWithInstallationIdPayload { public CheckSuite CheckSuite { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs index f83cad256b..8d1374e6e3 100644 --- a/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs @@ -4,12 +4,8 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class InstallationEventPayload + public class InstallationEventPayload : ActivityWithActionPayload { - public string Action { get; set; } - - public User Sender { get; set; } - public IReadOnlyCollection<Repository> Repositories { get; set; } public Installation Installation { get; set; } diff --git a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs index 935fcff071..dae932a1dd 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class IssueCommentPayload : ActivityWithActionPayload + public class IssueCommentPayload : ActivityWithInstallationIdPayload { // should always be "created" according to github api docs public Issue Issue { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs index f22693389a..fddd414fec 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class IssueEventPayload : ActivityWithActionPayload + public class IssueEventPayload : ActivityWithInstallationIdPayload { public Issue Issue { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs index df8a4c620e..ca3a1b1219 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestCommentPayload : ActivityWithActionPayload + public class PullRequestCommentPayload : ActivityWithInstallationIdPayload { public PullRequest PullRequest { get; protected set; } public PullRequestReviewComment Comment { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs index 73a1f326d7..5f41945409 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestEventPayload : ActivityWithActionPayload + public class PullRequestEventPayload : ActivityWithInstallationIdPayload { public int Number { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs index 80693881f8..683baa0f85 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestReviewEventPayload : ActivityWithActionPayload + public class PullRequestReviewEventPayload : ActivityWithInstallationIdPayload { public PullRequest PullRequest { get; protected set; } public PullRequestReview Review { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs index a6903e3802..ebd272ae12 100644 --- a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class ReleaseEventPayload : ActivityWithActionPayload + public class ReleaseEventPayload : ActivityWithInstallationIdPayload { public Release Release { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs index ab55890c9d..bd44c75b48 100644 --- a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class StarredEventPayload : ActivityWithActionPayload + public class StarredEventPayload : ActivityWithInstallationIdPayload { } } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index cbec786141..83d48a58b8 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.8</Version> + <Version>1.0.9</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 033e2a95f8c3fb4c8e7da1c171b3a97f465fc514 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Sun, 11 Sep 2022 13:49:05 +0300 Subject: [PATCH 123/209] improve test --- Octokit.Tests/Models/InstallationEventTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Octokit.Tests/Models/InstallationEventTest.cs b/Octokit.Tests/Models/InstallationEventTest.cs index c66c046eb0..38a7899934 100644 --- a/Octokit.Tests/Models/InstallationEventTest.cs +++ b/Octokit.Tests/Models/InstallationEventTest.cs @@ -139,6 +139,7 @@ public void CanBeDeserialized() var installationEvent = serializer.Deserialize<InstallationEventPayload>(json); + Assert.Equal(29024610, installationEvent.Installation.Id); Assert.Equal("deleted", installationEvent.Action); Assert.Equal("https://github.com/tomer-apiiro-test", installationEvent.Installation.Account?.HtmlUrl); Assert.Equal(6, installationEvent.Repositories.Count); From 1dcc87b90d713ce731a234f79f6d7328b5e001e1 Mon Sep 17 00:00:00 2001 From: Tomer Amir <tomer@apiiro.com> Date: Sun, 11 Sep 2022 16:12:55 +0300 Subject: [PATCH 124/209] improve polymorphism again --- .../Response/ActivityPayloads/ActivityPayload.cs | 4 +++- .../ActivityWithInstallationIdPayload.cs | 10 ---------- .../Response/ActivityPayloads/CheckRunEventPayload.cs | 2 +- .../ActivityPayloads/CheckSuiteEventPayload.cs | 2 +- .../ActivityPayloads/InstallationEventPayload.cs | 2 -- .../Response/ActivityPayloads/IssueCommentPayload.cs | 2 +- .../Response/ActivityPayloads/IssueEventPayload.cs | 2 +- .../ActivityPayloads/PullRequestCommentPayload.cs | 2 +- .../ActivityPayloads/PullRequestEventPayload.cs | 2 +- .../ActivityPayloads/PullRequestReviewEventPayload.cs | 2 +- .../Response/ActivityPayloads/ReleaseEventPayload.cs | 2 +- .../Response/ActivityPayloads/StarredEventPayload.cs | 2 +- Octokit/Octokit.csproj | 2 +- 13 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs index a86f45c401..e3ecfa8337 100644 --- a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs @@ -8,14 +8,16 @@ public class ActivityPayload public ActivityPayload() { } - public ActivityPayload(Repository repository, User sender) + public ActivityPayload(Repository repository, User sender, Installation installation) { Repository = repository; Sender = sender; + Installation = installation; } public Repository Repository { get; protected set; } public User Sender { get; protected set; } + public Installation Installation { get; protected set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs deleted file mode 100644 index 2e80057fd7..0000000000 --- a/Octokit/Models/Response/ActivityPayloads/ActivityWithInstallationIdPayload.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Diagnostics; - -namespace Octokit -{ - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class ActivityWithInstallationIdPayload : ActivityWithActionPayload - { - public InstallationId Installation { get; set; } - } -} diff --git a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs index d560ca4b29..b610d549da 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckRunEventPayload : ActivityWithInstallationIdPayload + public class CheckRunEventPayload : ActivityWithActionPayload { public CheckRun CheckRun { get; protected set; } public CheckRunRequestedAction RequestedAction { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs index 32c57942ee..c922e6b3f6 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CheckSuiteEventPayload : ActivityWithInstallationIdPayload + public class CheckSuiteEventPayload : ActivityWithActionPayload { public CheckSuite CheckSuite { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs index 8d1374e6e3..bfea8006fd 100644 --- a/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/InstallationEventPayload.cs @@ -7,7 +7,5 @@ namespace Octokit public class InstallationEventPayload : ActivityWithActionPayload { public IReadOnlyCollection<Repository> Repositories { get; set; } - - public Installation Installation { get; set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs index dae932a1dd..935fcff071 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class IssueCommentPayload : ActivityWithInstallationIdPayload + public class IssueCommentPayload : ActivityWithActionPayload { // should always be "created" according to github api docs public Issue Issue { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs index fddd414fec..f22693389a 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class IssueEventPayload : ActivityWithInstallationIdPayload + public class IssueEventPayload : ActivityWithActionPayload { public Issue Issue { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs index ca3a1b1219..df8a4c620e 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestCommentPayload : ActivityWithInstallationIdPayload + public class PullRequestCommentPayload : ActivityWithActionPayload { public PullRequest PullRequest { get; protected set; } public PullRequestReviewComment Comment { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs index 5f41945409..73a1f326d7 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestEventPayload : ActivityWithInstallationIdPayload + public class PullRequestEventPayload : ActivityWithActionPayload { public int Number { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs index 683baa0f85..80693881f8 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class PullRequestReviewEventPayload : ActivityWithInstallationIdPayload + public class PullRequestReviewEventPayload : ActivityWithActionPayload { public PullRequest PullRequest { get; protected set; } public PullRequestReview Review { get; protected set; } diff --git a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs index ebd272ae12..a6903e3802 100644 --- a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class ReleaseEventPayload : ActivityWithInstallationIdPayload + public class ReleaseEventPayload : ActivityWithActionPayload { public Release Release { get; protected set; } } diff --git a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs index bd44c75b48..ab55890c9d 100644 --- a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs @@ -3,7 +3,7 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class StarredEventPayload : ActivityWithInstallationIdPayload + public class StarredEventPayload : ActivityWithActionPayload { } } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 83d48a58b8..6626938264 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.9</Version> + <Version>1.0.10</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 9ceb1885dc5eb9d6a11988d2318976ef41184dff Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:24:21 -0500 Subject: [PATCH 125/209] Convert response model property accessors from protected to the more appropriate private for consistency (#2565) --- Octokit/Models/Response/AccessToken.cs | 4 +- Octokit/Models/Response/Activity.cs | 18 ++-- .../ActivityPayloads/ActivityPayload.cs | 6 +- .../ActivityPayloads/CheckRunEventPayload.cs | 6 +- .../CheckSuiteEventPayload.cs | 4 +- .../ActivityPayloads/CommitCommentPayload.cs | 2 +- .../ActivityPayloads/CreateEventPayload.cs | 8 +- .../ActivityPayloads/DeleteEventPayload.cs | 4 +- .../ActivityPayloads/ForkEventPayload.cs | 2 +- .../ActivityPayloads/IssueCommentPayload.cs | 6 +- .../ActivityPayloads/IssueEventPayload.cs | 4 +- .../PullRequestCommentPayload.cs | 6 +- .../PullRequestEventPayload.cs | 6 +- .../PullRequestReviewEventPayload.cs | 6 +- .../ActivityPayloads/PushEventPayload.cs | 8 +- .../ActivityPayloads/PushWebhookCommit.cs | 22 ++--- .../ActivityPayloads/PushWebhookCommitter.cs | 6 +- .../ActivityPayloads/PushWebhookPayload.cs | 24 ++--- .../ActivityPayloads/ReleaseEventPayload.cs | 4 +- .../ActivityPayloads/StarredEventPayload.cs | 2 +- .../ActivityPayloads/StatusEventPayload.cs | 24 ++--- Octokit/Models/Response/ApiError.cs | 8 +- Octokit/Models/Response/ApiErrorDetail.cs | 10 +-- Octokit/Models/Response/Application.cs | 4 +- Octokit/Models/Response/Blob.cs | 12 +-- Octokit/Models/Response/BlobReference.cs | 4 +- Octokit/Models/Response/Branch.cs | 8 +- Octokit/Models/Response/BranchProtection.cs | 14 +-- Octokit/Models/Response/CheckRun.cs | 30 +++---- Octokit/Models/Response/CheckRunAnnotation.cs | 26 +++--- .../Models/Response/CheckRunOutputResponse.cs | 10 +-- .../Response/CheckRunRequestedAction.cs | 2 +- Octokit/Models/Response/CheckRunsResponse.cs | 4 +- Octokit/Models/Response/CheckSuite.cs | 22 ++--- .../Response/CheckSuitePreferencesResponse.cs | 4 +- .../Models/Response/CheckSuitesResponse.cs | 4 +- .../Models/Response/CollaboratorPermission.cs | 4 +- .../Models/Response/CombinedCommitStatus.cs | 12 +-- Octokit/Models/Response/Commit.cs | 14 +-- Octokit/Models/Response/CommitComment.cs | 28 +++--- Octokit/Models/Response/CommitStatus.cs | 20 ++--- Octokit/Models/Response/CompareResult.cs | 26 +++--- Octokit/Models/Response/Contributor.cs | 8 +- Octokit/Models/Response/DeployKey.cs | 8 +- Octokit/Models/Response/Deployment.cs | 30 +++---- Octokit/Models/Response/DeploymentStatus.cs | 26 +++--- Octokit/Models/Response/EmailAddress.cs | 14 +-- .../MaintenanceModeActiveProcesses.cs | 4 +- .../Enterprise/PreReceiveEnvironment.cs | 18 ++-- .../PreReceiveEnvironmentDownload.cs | 8 +- .../Response/Enterprise/PreReceiveHook.cs | 14 +-- Octokit/Models/Response/EventInfo.cs | 30 +++---- Octokit/Models/Response/Feed.cs | 16 ++-- Octokit/Models/Response/FeedLink.cs | 18 ++-- Octokit/Models/Response/Gist.cs | 34 +++---- Octokit/Models/Response/GistChangeStatus.cs | 8 +- Octokit/Models/Response/GistComment.cs | 16 ++-- Octokit/Models/Response/GistFile.cs | 14 +-- Octokit/Models/Response/GistFork.cs | 10 +-- Octokit/Models/Response/GistHistory.cs | 12 +-- Octokit/Models/Response/GitHubApp.cs | 18 ++-- Octokit/Models/Response/GitHubCommit.cs | 16 ++-- Octokit/Models/Response/GitHubCommitFile.cs | 22 ++--- Octokit/Models/Response/GitHubCommitStats.cs | 6 +- Octokit/Models/Response/GitIgnoreTemplate.cs | 4 +- Octokit/Models/Response/GitTag.cs | 10 +-- Octokit/Models/Response/GpgKey.cs | 24 ++--- Octokit/Models/Response/Installation.cs | 14 +-- .../Response/InstallationPermissions.cs | 30 +++---- .../Models/Response/InstallationsResponse.cs | 6 +- Octokit/Models/Response/Issue.cs | 52 +++++------ Octokit/Models/Response/IssueComment.cs | 20 ++--- Octokit/Models/Response/IssueEvent.cs | 26 +++--- .../Models/Response/IssueEventProjectCard.cs | 12 +-- Octokit/Models/Response/Label.cs | 14 +-- Octokit/Models/Response/License.cs | 16 ++-- Octokit/Models/Response/LicenseMetadata.cs | 2 +- Octokit/Models/Response/Merge.cs | 16 ++-- Octokit/Models/Response/Migration.cs | 4 +- Octokit/Models/Response/Milestone.cs | 30 +++---- Octokit/Models/Response/Notification.cs | 16 ++-- Octokit/Models/Response/NotificationInfo.cs | 8 +- Octokit/Models/Response/Organization.cs | 28 +++--- .../Models/Response/OrganizationMembership.cs | 12 +-- .../OrganizationMembershipInvitation.cs | 14 +-- Octokit/Models/Response/Page.cs | 10 +-- Octokit/Models/Response/PagesBuild.cs | 16 ++-- Octokit/Models/Response/Participation.cs | 4 +- Octokit/Models/Response/Project.cs | 24 ++--- Octokit/Models/Response/ProjectCard.cs | 18 ++-- Octokit/Models/Response/ProjectColumn.cs | 12 +-- Octokit/Models/Response/PublicKey.cs | 8 +- Octokit/Models/Response/PullRequest.cs | 76 ++++++++-------- Octokit/Models/Response/PullRequestCommit.cs | 18 ++-- Octokit/Models/Response/PullRequestFile.cs | 22 ++--- Octokit/Models/Response/PullRequestMerge.cs | 6 +- Octokit/Models/Response/PullRequestReview.cs | 20 ++--- .../Response/PullRequestReviewComment.cs | 38 ++++---- Octokit/Models/Response/Reaction.cs | 9 +- Octokit/Models/Response/ReactionSummary.cs | 18 ++-- Octokit/Models/Response/ReadmeResponse.cs | 12 +-- Octokit/Models/Response/Reference.cs | 8 +- Octokit/Models/Response/Release.cs | 36 ++++---- Octokit/Models/Response/ReleaseAsset.cs | 26 +++--- Octokit/Models/Response/RenameInfo.cs | 4 +- .../Models/Response/RepositoriesResponse.cs | 6 +- Octokit/Models/Response/Repository.cs | 88 +++++++++---------- Octokit/Models/Response/RepositoryContent.cs | 6 +- .../Response/RepositoryContentChangeSet.cs | 6 +- .../Response/RepositoryContentLicense.cs | 2 +- .../Models/Response/RepositoryContributor.cs | 4 +- .../Models/Response/RepositoryInvitation.cs | 18 ++-- Octokit/Models/Response/RepositoryLanguage.cs | 4 +- Octokit/Models/Response/RepositoryStar.cs | 6 +- Octokit/Models/Response/RepositoryTag.cs | 10 +-- Octokit/Models/Response/RepositoryTopics.cs | 2 +- .../Models/Response/RepositoryTrafficClone.cs | 12 +-- .../Models/Response/RepositoryTrafficPath.cs | 8 +- .../Response/RepositoryTrafficReferrer.cs | 6 +- .../Models/Response/RepositoryTrafficView.cs | 12 +-- Octokit/Models/Response/RequestedReviews.cs | 4 +- Octokit/Models/Response/SearchCode.cs | 14 +-- Octokit/Models/Response/SourceInfo.cs | 8 +- Octokit/Models/Response/Subscription.cs | 12 +-- Octokit/Models/Response/TagObject.cs | 4 +- Octokit/Models/Response/Team.cs | 28 +++--- .../Models/Response/TeamMembershipDetails.cs | 4 +- Octokit/Models/Response/ThreadSubscription.cs | 12 +-- Octokit/Models/Response/TimelineEventInfo.cs | 26 +++--- Octokit/Models/Response/TreeItem.cs | 14 +-- Octokit/Models/Response/TreeResponse.cs | 10 +-- Octokit/Models/Response/User.cs | 10 +-- Octokit/Models/Response/UserRenameResponse.cs | 4 +- Octokit/Models/Response/UserStar.cs | 6 +- Octokit/Models/Response/Verification.cs | 8 +- .../Models/Response/WeeklyCommitActivity.cs | 6 +- Octokit/Models/Response/WeeklyHash.cs | 8 +- 137 files changed, 949 insertions(+), 950 deletions(-) diff --git a/Octokit/Models/Response/AccessToken.cs b/Octokit/Models/Response/AccessToken.cs index 182a555322..bc198de96b 100644 --- a/Octokit/Models/Response/AccessToken.cs +++ b/Octokit/Models/Response/AccessToken.cs @@ -18,12 +18,12 @@ public AccessToken(string token, DateTimeOffset expiresAt) /// <summary> /// The access token /// </summary> - public string Token { get; protected set; } + public string Token { get; private set; } /// <summary> /// The expiration date /// </summary> - public DateTimeOffset ExpiresAt { get; protected set; } + public DateTimeOffset ExpiresAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Activity.cs b/Octokit/Models/Response/Activity.cs index 5a453ef91d..c14501efe2 100644 --- a/Octokit/Models/Response/Activity.cs +++ b/Octokit/Models/Response/Activity.cs @@ -29,42 +29,42 @@ public Activity(string type, bool @public, Repository repo, User actor, Organiza /// The type of the activity. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] - public string Type { get; protected set; } + public string Type { get; private set; } /// <summary> /// Whether the activity event is public or not. /// </summary> - public bool Public { get; protected set; } + public bool Public { get; private set; } /// <summary> /// The repository associated with the activity event. /// </summary> - public Repository Repo { get; protected set; } + public Repository Repo { get; private set; } /// <summary> /// The user associated with the activity event. /// </summary> - public User Actor { get; protected set; } + public User Actor { get; private set; } /// <summary> /// The organization associated with the activity event. /// </summary> - public Organization Org { get; protected set; } + public Organization Org { get; private set; } /// <summary> /// The date the activity event was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The activity event Id. /// </summary> - public string Id { get; protected set; } + public string Id { get; private set; } /// <summary> /// The payload associated with the activity event. /// </summary> - public ActivityPayload Payload { get; protected set; } + public ActivityPayload Payload { get; private set; } internal string DebuggerDisplay { @@ -74,4 +74,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs index ea89c33195..0e0ec2a074 100644 --- a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs @@ -15,9 +15,9 @@ public ActivityPayload(Repository repository, User sender, InstallationId instal Installation = installation; } - public Repository Repository { get; protected set; } - public User Sender { get; protected set; } - public InstallationId Installation { get; protected set; } + public Repository Repository { get; private set; } + public User Sender { get; private set; } + public InstallationId Installation { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs index 9bc83e6f84..345a8bd541 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckRunEventPayload.cs @@ -5,8 +5,8 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckRunEventPayload : ActivityPayload { - public string Action { get; protected set; } - public CheckRun CheckRun { get; protected set; } - public CheckRunRequestedAction RequestedAction { get; protected set; } + public string Action { get; private set; } + public CheckRun CheckRun { get; private set; } + public CheckRunRequestedAction RequestedAction { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs index 3a0d324d8a..41693e37d0 100644 --- a/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CheckSuiteEventPayload.cs @@ -5,7 +5,7 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CheckSuiteEventPayload : ActivityPayload { - public string Action { get; protected set; } - public CheckSuite CheckSuite { get; protected set; } + public string Action { get; private set; } + public CheckSuite CheckSuite { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/CommitCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/CommitCommentPayload.cs index 9e35c99420..ef33d4fadb 100644 --- a/Octokit/Models/Response/ActivityPayloads/CommitCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CommitCommentPayload.cs @@ -5,6 +5,6 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CommitCommentPayload : ActivityPayload { - public CommitComment Comment { get; protected set; } + public CommitComment Comment { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/CreateEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/CreateEventPayload.cs index 4abae7b97c..58d4a8960e 100644 --- a/Octokit/Models/Response/ActivityPayloads/CreateEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/CreateEventPayload.cs @@ -6,12 +6,12 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CreateEventPayload : ActivityPayload { - public string Ref { get; protected set; } + public string Ref { get; private set; } - public StringEnum<RefType> RefType { get; protected set; } + public StringEnum<RefType> RefType { get; private set; } - public string MasterBranch { get; protected set; } + public string MasterBranch { get; private set; } - public string Description { get; protected set; } + public string Description { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/DeleteEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/DeleteEventPayload.cs index 6abd970c01..e28b37aed6 100644 --- a/Octokit/Models/Response/ActivityPayloads/DeleteEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/DeleteEventPayload.cs @@ -6,8 +6,8 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class DeleteEventPayload : ActivityPayload { - public string Ref { get; protected set; } + public string Ref { get; private set; } - public StringEnum<RefType> RefType { get; protected set; } + public StringEnum<RefType> RefType { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/ForkEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/ForkEventPayload.cs index f48d01c094..4b02eedb4e 100644 --- a/Octokit/Models/Response/ActivityPayloads/ForkEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ForkEventPayload.cs @@ -5,6 +5,6 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ForkEventPayload : ActivityPayload { - public Repository Forkee { get; protected set; } + public Repository Forkee { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs index 0b2989df36..f9fb1068f3 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueCommentPayload.cs @@ -6,8 +6,8 @@ namespace Octokit public class IssueCommentPayload : ActivityPayload { // should always be "created" according to github api docs - public string Action { get; protected set; } - public Issue Issue { get; protected set; } - public IssueComment Comment { get; protected set; } + public string Action { get; private set; } + public Issue Issue { get; private set; } + public IssueComment Comment { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs index 1f40a122df..6b9713e6cc 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs @@ -5,7 +5,7 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class IssueEventPayload : ActivityPayload { - public string Action { get; protected set; } - public Issue Issue { get; protected set; } + public string Action { get; private set; } + public Issue Issue { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs index 026935e018..f0e3906a3f 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestCommentPayload.cs @@ -5,8 +5,8 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PullRequestCommentPayload : ActivityPayload { - public string Action { get; protected set; } - public PullRequest PullRequest { get; protected set; } - public PullRequestReviewComment Comment { get; protected set; } + public string Action { get; private set; } + public PullRequest PullRequest { get; private set; } + public PullRequestReviewComment Comment { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs index ebaf48de57..c06efc77c1 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestEventPayload.cs @@ -5,9 +5,9 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PullRequestEventPayload : ActivityPayload { - public string Action { get; protected set; } - public int Number { get; protected set; } + public string Action { get; private set; } + public int Number { get; private set; } - public PullRequest PullRequest { get; protected set; } + public PullRequest PullRequest { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs index c0a7b10b5d..0df70b22a5 100644 --- a/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PullRequestReviewEventPayload.cs @@ -5,8 +5,8 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PullRequestReviewEventPayload : ActivityPayload { - public string Action { get; protected set; } - public PullRequest PullRequest { get; protected set; } - public PullRequestReview Review { get; protected set; } + public string Action { get; private set; } + public PullRequest PullRequest { get; private set; } + public PullRequestReview Review { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/PushEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/PushEventPayload.cs index f1ebefd70b..b007526896 100644 --- a/Octokit/Models/Response/ActivityPayloads/PushEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PushEventPayload.cs @@ -6,9 +6,9 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PushEventPayload : ActivityPayload { - public string Head { get; protected set; } - public string Ref { get; protected set; } - public int Size { get; protected set; } - public IReadOnlyList<Commit> Commits { get; protected set; } + public string Head { get; private set; } + public string Ref { get; private set; } + public int Size { get; private set; } + public IReadOnlyList<Commit> Commits { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs index 6ce11053c8..d04d897501 100644 --- a/Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs +++ b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs @@ -8,27 +8,27 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PushWebhookCommit { - public string Id { get; protected set; } + public string Id { get; private set; } - public string TreeId { get; protected set; } + public string TreeId { get; private set; } - public bool Distinct { get; protected set; } + public bool Distinct { get; private set; } - public string Message { get; protected set; } + public string Message { get; private set; } - public DateTimeOffset Timestamp { get; protected set; } + public DateTimeOffset Timestamp { get; private set; } - public Uri Url { get; protected set; } + public Uri Url { get; private set; } - public Committer Author { get; protected set; } + public Committer Author { get; private set; } - public Committer Committer { get; protected set; } + public Committer Committer { get; private set; } - public IReadOnlyList<string> Added { get; protected set; } + public IReadOnlyList<string> Added { get; private set; } - public IReadOnlyList<string> Removed { get; protected set; } + public IReadOnlyList<string> Removed { get; private set; } - public IReadOnlyList<string> Modified { get; protected set; } + public IReadOnlyList<string> Modified { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs index fb7cb4941c..2932166178 100644 --- a/Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs +++ b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs @@ -35,7 +35,7 @@ public PushWebhookCommitter(string name, string email, string username) /// <value> /// The name. /// </value> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// Gets the email of the author or committer. @@ -43,7 +43,7 @@ public PushWebhookCommitter(string name, string email, string username) /// <value> /// The email. /// </value> - public string Email { get; protected set; } + public string Email { get; private set; } /// <summary> /// Gets the GitHub username associated with the commit @@ -51,7 +51,7 @@ public PushWebhookCommitter(string name, string email, string username) /// <value> /// The username. /// </value> - public string Username { get; protected set; } + public string Username { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs b/Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs index 159282de67..6075313b0e 100644 --- a/Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs @@ -6,17 +6,17 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PushWebhookPayload : ActivityPayload { - public string Head { get; protected set; } - public string Before { get; protected set; } - public string After { get; protected set; } - public string Ref { get; protected set; } - public string BaseRef { get; protected set; } - public bool Created { get; protected set; } - public bool Deleted { get; protected set; } - public bool Forced { get; protected set; } - public string Compare { get; protected set; } - public int Size { get; protected set; } - public IReadOnlyList<PushWebhookCommit> Commits { get; protected set; } - public PushWebhookCommit HeadCommit { get; protected set; } + public string Head { get; private set; } + public string Before { get; private set; } + public string After { get; private set; } + public string Ref { get; private set; } + public string BaseRef { get; private set; } + public bool Created { get; private set; } + public bool Deleted { get; private set; } + public bool Forced { get; private set; } + public string Compare { get; private set; } + public int Size { get; private set; } + public IReadOnlyList<PushWebhookCommit> Commits { get; private set; } + public PushWebhookCommit HeadCommit { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs index ffaac4cc76..7f6eb87f45 100644 --- a/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ReleaseEventPayload.cs @@ -5,8 +5,8 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ReleaseEventPayload : ActivityPayload { - public string Action { get; protected set; } + public string Action { get; private set; } - public Release Release { get; protected set; } + public Release Release { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs index 7bc43a2aac..5e40c57dd3 100644 --- a/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/StarredEventPayload.cs @@ -5,6 +5,6 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class StarredEventPayload : ActivityPayload { - public string Action { get; protected set; } + public string Action { get; private set; } } } diff --git a/Octokit/Models/Response/ActivityPayloads/StatusEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/StatusEventPayload.cs index 1c8d3db1a6..cf53cf6c75 100644 --- a/Octokit/Models/Response/ActivityPayloads/StatusEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/StatusEventPayload.cs @@ -10,62 +10,62 @@ public class StatusEventPayload : ActivityPayload /// <summary> /// The name of the repository. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The SHA of the reference. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// The date the commit status was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date the commit status was updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// The state of the commit /// </summary> - public StringEnum<CommitState> State { get; protected set; } + public StringEnum<CommitState> State { get; private set; } /// <summary> /// URL associated with this status. GitHub.com displays this URL as a link to allow users to easily see the /// ‘source’ of the Status. /// </summary> - public string TargetUrl { get; protected set; } + public string TargetUrl { get; private set; } /// <summary> /// Short description of the status. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// A string label to differentiate this status from the status of other systems. /// </summary> - public string Context { get; protected set; } + public string Context { get; private set; } /// <summary> /// The unique identifier of the status. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// The relevant commit. /// </summary> - public GitHubCommit Commit { get; protected set; } + public GitHubCommit Commit { get; private set; } /// <summary> /// The organization associated with the event. /// </summary> - public Organization Organization { get; protected set; } + public Organization Organization { get; private set; } /// <summary> /// The branches involved. /// </summary> - public IReadOnlyList<Branch> Branches { get; protected set; } + public IReadOnlyList<Branch> Branches { get; private set; } } } diff --git a/Octokit/Models/Response/ApiError.cs b/Octokit/Models/Response/ApiError.cs index 2317cdacab..7847e60e9e 100644 --- a/Octokit/Models/Response/ApiError.cs +++ b/Octokit/Models/Response/ApiError.cs @@ -29,17 +29,17 @@ public ApiError(string message, string documentationUrl, IReadOnlyList<ApiErrorD /// <summary> /// The error message /// </summary> - public string Message { get; protected set; } + public string Message { get; private set; } /// <summary> /// URL to the documentation for this error. /// </summary> - public string DocumentationUrl { get; protected set; } + public string DocumentationUrl { get; private set; } /// <summary> /// Additional details about the error /// </summary> - public IReadOnlyList<ApiErrorDetail> Errors { get; protected set; } + public IReadOnlyList<ApiErrorDetail> Errors { get; private set; } internal string DebuggerDisplay { @@ -49,4 +49,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/ApiErrorDetail.cs b/Octokit/Models/Response/ApiErrorDetail.cs index 391561e02e..cea59aa760 100644 --- a/Octokit/Models/Response/ApiErrorDetail.cs +++ b/Octokit/Models/Response/ApiErrorDetail.cs @@ -18,13 +18,13 @@ public ApiErrorDetail(string message, string code, string field, string resource Resource = resource; } - public string Message { get; protected set; } + public string Message { get; private set; } - public string Code { get; protected set; } + public string Code { get; private set; } - public string Field { get; protected set; } + public string Field { get; private set; } - public string Resource { get; protected set; } + public string Resource { get; private set; } internal string DebuggerDisplay { @@ -34,4 +34,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Application.cs b/Octokit/Models/Response/Application.cs index 3321d748e2..a2574bdd74 100644 --- a/Octokit/Models/Response/Application.cs +++ b/Octokit/Models/Response/Application.cs @@ -20,12 +20,12 @@ public Application(string name, string url) /// <summary> /// <see cref="Application"/> Name. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The Url of this <see cref="Application"/>. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Blob.cs b/Octokit/Models/Response/Blob.cs index b4df6a4f36..786806fd14 100644 --- a/Octokit/Models/Response/Blob.cs +++ b/Octokit/Models/Response/Blob.cs @@ -21,27 +21,27 @@ public Blob(string nodeId, string content, EncodingType encoding, string sha, in /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The content of the blob. /// </summary> - public string Content { get; protected set; } + public string Content { get; private set; } /// <summary> /// The encoding of the blob. /// </summary> - public StringEnum<EncodingType> Encoding { get; protected set; } + public StringEnum<EncodingType> Encoding { get; private set; } /// <summary> /// The SHA of the blob. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// The size of the blob. /// </summary> - public int Size { get; protected set; } + public int Size { get; private set; } internal string DebuggerDisplay { @@ -60,4 +60,4 @@ public enum EncodingType [Parameter(Value = "base64")] Base64 } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/BlobReference.cs b/Octokit/Models/Response/BlobReference.cs index fbba72dbfe..c4ba3fe039 100644 --- a/Octokit/Models/Response/BlobReference.cs +++ b/Octokit/Models/Response/BlobReference.cs @@ -16,7 +16,7 @@ public BlobReference(string sha) /// <summary> /// The SHA of the blob. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } internal string DebuggerDisplay { @@ -26,4 +26,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Branch.cs b/Octokit/Models/Response/Branch.cs index 78c8a76b96..fadb905e95 100644 --- a/Octokit/Models/Response/Branch.cs +++ b/Octokit/Models/Response/Branch.cs @@ -19,17 +19,17 @@ public Branch(string name, GitReference commit, bool @protected) /// <summary> /// Name of this <see cref="Branch"/>. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> - /// Whether this <see cref="Branch"/> is protected. + /// Whether this <see cref="Branch"/> is protected. /// </summary> - public bool Protected { get; protected set; } + public bool Protected { get; private set; } /// <summary> /// The <see cref="GitReference"/> history for this <see cref="Branch"/>. /// </summary> - public GitReference Commit { get; protected set; } + public GitReference Commit { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index 2c1703d164..cc73b69e3e 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -116,7 +116,7 @@ public EnforceAdmins(bool enabled) Enabled = enabled; } - public bool Enabled { get; protected set; } + public bool Enabled { get; private set; } internal string DebuggerDisplay { @@ -144,7 +144,7 @@ public BranchProtectionRequiredStatusChecks(bool strict, IReadOnlyList<string> c /// <summary> /// Require branches to be up to date before merging /// </summary> - public bool Strict { get; protected set; } + public bool Strict { get; private set; } /// <summary> /// Require status checks to pass before merging @@ -218,22 +218,22 @@ public BranchProtectionRequiredReviews(BranchProtectionRequiredReviewsDismissalR /// <summary> /// Specify which users and teams can dismiss pull request reviews. /// </summary> - public BranchProtectionRequiredReviewsDismissalRestrictions DismissalRestrictions { get; protected set; } + public BranchProtectionRequiredReviewsDismissalRestrictions DismissalRestrictions { get; private set; } /// <summary> /// Dismiss approved reviews automatically when a new commit is pushed. /// </summary> - public bool DismissStaleReviews { get; protected set; } + public bool DismissStaleReviews { get; private set; } /// <summary> /// Blocks merge until code owners have reviewed. /// </summary> - public bool RequireCodeOwnerReviews { get; protected set; } + public bool RequireCodeOwnerReviews { get; private set; } /// <summary> /// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6. /// </summary> - public int RequiredApprovingReviewCount { get; protected set; } + public int RequiredApprovingReviewCount { get; private set; } internal string DebuggerDisplay { @@ -294,7 +294,7 @@ public BranchProtectionEnabledCommon(bool enabled) Enabled = enabled; } - public bool Enabled { get; protected set; } + public bool Enabled { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/CheckRun.cs b/Octokit/Models/Response/CheckRun.cs index 3482a5bcea..8408d616ec 100644 --- a/Octokit/Models/Response/CheckRun.cs +++ b/Octokit/Models/Response/CheckRun.cs @@ -34,77 +34,77 @@ public CheckRun(long id, string headSha, string externalId, string url, string h /// <summary> /// The Id of the check run /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// The SHA of the commit the check run is associated with /// </summary> - public string HeadSha { get; protected set; } + public string HeadSha { get; private set; } /// <summary> /// A reference for the run on the integrator's system /// </summary> - public string ExternalId { get; protected set; } + public string ExternalId { get; private set; } /// <summary> /// The GitHub API URL of the check run /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The GitHub.com URL of the check run /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The URL of the integrator's site that has the full details of the check. /// </summary> - public string DetailsUrl { get; protected set; } + public string DetailsUrl { get; private set; } /// <summary> /// The check run status /// </summary> - public StringEnum<CheckStatus> Status { get; protected set; } + public StringEnum<CheckStatus> Status { get; private set; } /// <summary> /// The final conclusion of the check /// </summary> - public StringEnum<CheckConclusion>? Conclusion { get; protected set; } + public StringEnum<CheckConclusion>? Conclusion { get; private set; } /// <summary> /// The time that the check run began /// </summary> - public DateTimeOffset StartedAt { get; protected set; } + public DateTimeOffset StartedAt { get; private set; } /// <summary> /// The time the check run completed /// </summary> - public DateTimeOffset? CompletedAt { get; protected set; } + public DateTimeOffset? CompletedAt { get; private set; } /// <summary> /// Descriptive details about the run /// </summary> - public CheckRunOutputResponse Output { get; protected set; } + public CheckRunOutputResponse Output { get; private set; } /// <summary> /// The name of the check /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The check suite that is associated with this check run /// </summary> - public CheckSuite CheckSuite { get; protected set; } + public CheckSuite CheckSuite { get; private set; } /// <summary> /// The GitHub App that is associated with this check run /// </summary> - public GitHubApp App { get; protected set; } + public GitHubApp App { get; private set; } /// <summary> /// The pull requests that are associated with this check run /// </summary> - public IReadOnlyList<PullRequest> PullRequests { get; protected set; } + public IReadOnlyList<PullRequest> PullRequests { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0}, HeadSha: {1}, Conclusion: {2}", Id, HeadSha, Conclusion); } diff --git a/Octokit/Models/Response/CheckRunAnnotation.cs b/Octokit/Models/Response/CheckRunAnnotation.cs index 7437e59c54..601ce84903 100644 --- a/Octokit/Models/Response/CheckRunAnnotation.cs +++ b/Octokit/Models/Response/CheckRunAnnotation.cs @@ -52,66 +52,66 @@ public CheckRunAnnotation(string filename, string path, string blobHref, int sta /// The path of the file the annotation refers to /// </summary> [Obsolete("This property is replaced with Path but may still be required on GitHub Enterprise 2.14")] - public string Filename { get; protected set; } + public string Filename { get; private set; } /// <summary> /// The path of the file the annotation refers to /// </summary> - public string Path { get; protected set; } + public string Path { get; private set; } /// <summary> /// The file's full blob URL /// </summary> - public string BlobHref { get; protected set; } + public string BlobHref { get; private set; } /// <summary> /// The start line of the annotation /// </summary> - public int StartLine { get; protected set; } + public int StartLine { get; private set; } /// <summary> /// The end line of the annotation /// </summary> - public int EndLine { get; protected set; } + public int EndLine { get; private set; } /// <summary> /// The start line of the annotation /// </summary> - public int? StartColumn { get; protected set; } + public int? StartColumn { get; private set; } /// <summary> /// The end line of the annotation /// </summary> - public int? EndColumn { get; protected set; } + public int? EndColumn { get; private set; } /// <summary> /// The warning level of the annotation. Can be one of notice, warning, or failure /// </summary> [Obsolete("This property is replaced with AnnotationLevel but may still be required on GitHub Enterprise 2.14")] - public StringEnum<CheckWarningLevel>? WarningLevel { get; protected set; } + public StringEnum<CheckWarningLevel>? WarningLevel { get; private set; } /// <summary> /// The level of the annotation. Can be one of notice, warning, or failure /// </summary> - public StringEnum<CheckAnnotationLevel>? AnnotationLevel { get; protected set; } + public StringEnum<CheckAnnotationLevel>? AnnotationLevel { get; private set; } /// <summary> /// A short description of the feedback for these lines of code /// </summary> - public string Message { get; protected set; } + public string Message { get; private set; } /// <summary> /// The title that represents the annotation /// </summary> - public string Title { get; protected set; } + public string Title { get; private set; } /// <summary> /// Details about this annotation /// </summary> - public string RawDetails { get; protected set; } + public string RawDetails { get; private set; } #pragma warning disable CS0618 // Type or member is obsolete internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Path: {0}, StartLine: {1}, WarningLevel: {2}", Path ?? Filename, StartLine, AnnotationLevel?.DebuggerDisplay ?? WarningLevel?.DebuggerDisplay); #pragma warning restore CS0618 // Type or member is obsolete } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/CheckRunOutputResponse.cs b/Octokit/Models/Response/CheckRunOutputResponse.cs index 2aade56f4f..8b0f2da6b9 100644 --- a/Octokit/Models/Response/CheckRunOutputResponse.cs +++ b/Octokit/Models/Response/CheckRunOutputResponse.cs @@ -22,23 +22,23 @@ public CheckRunOutputResponse(string title, string summary, string text, long an /// <summary> /// The title of the check run /// </summary> - public string Title { get; protected set; } + public string Title { get; private set; } /// <summary> /// The summary of the check run /// </summary> - public string Summary { get; protected set; } + public string Summary { get; private set; } /// <summary> /// The details of the check run /// </summary> - public string Text { get; protected set; } + public string Text { get; private set; } /// <summary> /// The number of annotation entries for the check run (use <see cref="ICheckRunsClient.GetAllAnnotations(string, string, long)"/> to get annotation details) /// </summary> - public long AnnotationsCount { get; protected set; } + public long AnnotationsCount { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "Title: {0}", Title); } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/CheckRunRequestedAction.cs b/Octokit/Models/Response/CheckRunRequestedAction.cs index 05468942cc..346d43c25b 100644 --- a/Octokit/Models/Response/CheckRunRequestedAction.cs +++ b/Octokit/Models/Response/CheckRunRequestedAction.cs @@ -20,7 +20,7 @@ public CheckRunRequestedAction(string identifier) /// <summary> /// The Identifier of the check run requested action. /// </summary> - public string Identifier { get; protected set; } + public string Identifier { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Identifier: {0}", Identifier); } diff --git a/Octokit/Models/Response/CheckRunsResponse.cs b/Octokit/Models/Response/CheckRunsResponse.cs index ffdc26e116..30a9981abc 100644 --- a/Octokit/Models/Response/CheckRunsResponse.cs +++ b/Octokit/Models/Response/CheckRunsResponse.cs @@ -20,12 +20,12 @@ public CheckRunsResponse(int totalCount, IReadOnlyList<CheckRun> checkRuns) /// <summary> /// The total number of check runs that match the request filter /// </summary> - public int TotalCount { get; protected set; } + public int TotalCount { get; private set; } /// <summary> /// The retrieved check runs /// </summary> - public IReadOnlyList<CheckRun> CheckRuns { get; protected set; } + public IReadOnlyList<CheckRun> CheckRuns { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, CheckRuns: {1}", TotalCount, CheckRuns.Count); } diff --git a/Octokit/Models/Response/CheckSuite.cs b/Octokit/Models/Response/CheckSuite.cs index 8c7350c5da..569ffb59a3 100644 --- a/Octokit/Models/Response/CheckSuite.cs +++ b/Octokit/Models/Response/CheckSuite.cs @@ -29,57 +29,57 @@ public CheckSuite(long id, string headBranch, string headSha, CheckStatus status /// <summary> /// The Id of the check suite /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// The branch the check suite is associated with /// </summary> - public string HeadBranch { get; protected set; } + public string HeadBranch { get; private set; } /// <summary> /// The SHA of the head commit in the push that created the check suite /// </summary> - public string HeadSha { get; protected set; } + public string HeadSha { get; private set; } /// <summary> /// The summarized status of the check runs included in the check suite /// </summary> - public StringEnum<CheckStatus> Status { get; protected set; } + public StringEnum<CheckStatus> Status { get; private set; } /// <summary> /// The summarized conclusion of the check runs included in the check suite /// </summary> - public StringEnum<CheckConclusion>? Conclusion { get; protected set; } + public StringEnum<CheckConclusion>? Conclusion { get; private set; } /// <summary> /// The GitHub API URL of the check suite /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The hash of the commit prior to the push that created the check suite /// </summary> - public string Before { get; protected set; } + public string Before { get; private set; } /// <summary> /// The hash of the commit after the push that created the check suite (or HeadSha if no later commits exist) /// </summary> - public string After { get; protected set; } + public string After { get; private set; } /// <summary> /// The pull requests that are associated with the check suite /// </summary> - public IReadOnlyList<PullRequest> PullRequests { get; protected set; } + public IReadOnlyList<PullRequest> PullRequests { get; private set; } /// <summary> /// The GitHub App for the check suite /// </summary> - public GitHubApp App { get; protected set; } + public GitHubApp App { get; private set; } /// <summary> /// The repository for the check suite /// </summary> - public Repository Repository { get; protected set; } + public Repository Repository { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0}, HeadBranch: {1}, HeadSha: {2}, Conclusion: {3}", Id, HeadBranch, HeadSha, Conclusion); } diff --git a/Octokit/Models/Response/CheckSuitePreferencesResponse.cs b/Octokit/Models/Response/CheckSuitePreferencesResponse.cs index ca1a1d6688..ac83622206 100644 --- a/Octokit/Models/Response/CheckSuitePreferencesResponse.cs +++ b/Octokit/Models/Response/CheckSuitePreferencesResponse.cs @@ -19,12 +19,12 @@ public CheckSuitePreferencesResponse(CheckSuitePreferences preferences, Reposito /// <summary> /// The check suite preferences /// </summary> - public CheckSuitePreferences Preferences { get; protected set; } + public CheckSuitePreferences Preferences { get; private set; } /// <summary> /// The repository the check suite preferences are related to /// </summary> - public Repository Repository { get; protected set; } + public Repository Repository { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Preferences: {0}, Repository: {1}", Preferences.DebuggerDisplay, Repository.DebuggerDisplay); } diff --git a/Octokit/Models/Response/CheckSuitesResponse.cs b/Octokit/Models/Response/CheckSuitesResponse.cs index b41d8ddae6..a18be37a7e 100644 --- a/Octokit/Models/Response/CheckSuitesResponse.cs +++ b/Octokit/Models/Response/CheckSuitesResponse.cs @@ -20,12 +20,12 @@ public CheckSuitesResponse(int totalCount, IReadOnlyList<CheckSuite> checkSuites /// <summary> /// The total number of check suites that match the request filter /// </summary> - public int TotalCount { get; protected set; } + public int TotalCount { get; private set; } /// <summary> /// The retrieved check suites /// </summary> - public IReadOnlyList<CheckSuite> CheckSuites { get; protected set; } + public IReadOnlyList<CheckSuite> CheckSuites { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, CheckSuites: {1}", TotalCount, CheckSuites.Count); } diff --git a/Octokit/Models/Response/CollaboratorPermission.cs b/Octokit/Models/Response/CollaboratorPermission.cs index 4a9b29b102..7e2ed0a577 100644 --- a/Octokit/Models/Response/CollaboratorPermission.cs +++ b/Octokit/Models/Response/CollaboratorPermission.cs @@ -13,8 +13,8 @@ public CollaboratorPermission(PermissionLevel permission, User user) User = user; } - public StringEnum<PermissionLevel> Permission { get; protected set; } - public User User { get; protected set; } + public StringEnum<PermissionLevel> Permission { get; private set; } + public User User { get; private set; } internal string DebuggerDisplay => $"User: {User.Id} Permission: {Permission}"; } diff --git a/Octokit/Models/Response/CombinedCommitStatus.cs b/Octokit/Models/Response/CombinedCommitStatus.cs index db2c2caebe..37224d0deb 100644 --- a/Octokit/Models/Response/CombinedCommitStatus.cs +++ b/Octokit/Models/Response/CombinedCommitStatus.cs @@ -21,27 +21,27 @@ public CombinedCommitStatus(CommitState state, string sha, int totalCount, IRead /// <summary> /// The combined state of the commits. /// </summary> - public StringEnum<CommitState> State { get; protected set; } + public StringEnum<CommitState> State { get; private set; } /// <summary> /// The SHA of the reference. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// The total number of statuses. /// </summary> - public int TotalCount { get; protected set; } + public int TotalCount { get; private set; } /// <summary> /// The statuses. /// </summary> - public IReadOnlyList<CommitStatus> Statuses { get; protected set; } + public IReadOnlyList<CommitStatus> Statuses { get; private set; } /// <summary> /// The repository of the reference. /// </summary> - public Repository Repository { get; protected set; } + public Repository Repository { get; private set; } internal string DebuggerDisplay { @@ -51,4 +51,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Commit.cs b/Octokit/Models/Response/Commit.cs index e72abbf649..af11cde87f 100644 --- a/Octokit/Models/Response/Commit.cs +++ b/Octokit/Models/Response/Commit.cs @@ -24,18 +24,18 @@ public Commit(string nodeId, string url, string label, string @ref, string sha, Verification = verification; } - public string Message { get; protected set; } + public string Message { get; private set; } - public Committer Author { get; protected set; } + public Committer Author { get; private set; } - public Committer Committer { get; protected set; } + public Committer Committer { get; private set; } - public GitReference Tree { get; protected set; } + public GitReference Tree { get; private set; } - public IReadOnlyList<GitReference> Parents { get; protected set; } + public IReadOnlyList<GitReference> Parents { get; private set; } - public int CommentCount { get; protected set; } + public int CommentCount { get; private set; } - public Verification Verification { get; protected set; } + public Verification Verification { get; private set; } } } diff --git a/Octokit/Models/Response/CommitComment.cs b/Octokit/Models/Response/CommitComment.cs index 531423a103..07b0d4bc1c 100644 --- a/Octokit/Models/Response/CommitComment.cs +++ b/Octokit/Models/Response/CommitComment.cs @@ -29,67 +29,67 @@ public CommitComment(int id, string nodeId, string url, string htmlUrl, string b /// <summary> /// The issue comment Id. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL for this repository comment. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The html URL for this repository comment. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// Details about the repository comment. /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// Relative path of the file that was commented on. /// </summary> - public string Path { get; protected set; } + public string Path { get; private set; } /// <summary> /// Line index in the diff that was commented on. /// </summary> - public int? Position { get; protected set; } + public int? Position { get; private set; } /// <summary> /// The line number in the file that was commented on. /// </summary> - public int? Line { get; protected set; } + public int? Line { get; private set; } /// <summary> - /// The commit + /// The commit /// </summary> - public string CommitId { get; protected set; } + public string CommitId { get; private set; } /// <summary> /// The user that created the repository comment. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The date the repository comment was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date the repository comment was last updated. /// </summary> - public DateTimeOffset? UpdatedAt { get; protected set; } + public DateTimeOffset? UpdatedAt { get; private set; } /// <summary> /// The reaction summary for this comment. /// </summary> - public ReactionSummary Reactions { get; protected set; } + public ReactionSummary Reactions { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/CommitStatus.cs b/Octokit/Models/Response/CommitStatus.cs index d5660f21da..4f92096f35 100644 --- a/Octokit/Models/Response/CommitStatus.cs +++ b/Octokit/Models/Response/CommitStatus.cs @@ -27,53 +27,53 @@ public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitSt /// <summary> /// The date the commit status was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date the commit status was updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// The state of the commit /// </summary> - public StringEnum<CommitState> State { get; protected set; } + public StringEnum<CommitState> State { get; private set; } /// <summary> /// URL associated with this status. GitHub.com displays this URL as a link to allow users to easily see the /// ‘source’ of the Status. /// </summary> - public string TargetUrl { get; protected set; } + public string TargetUrl { get; private set; } /// <summary> /// Short description of the status. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// A string label to differentiate this status from the status of other systems. /// </summary> - public string Context { get; protected set; } + public string Context { get; private set; } /// <summary> /// The unique identifier of the status. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL of the status. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The user that created the status. /// </summary> - public User Creator { get; protected set; } + public User Creator { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/CompareResult.cs b/Octokit/Models/Response/CompareResult.cs index 6d02119b23..99bbf540ad 100644 --- a/Octokit/Models/Response/CompareResult.cs +++ b/Octokit/Models/Response/CompareResult.cs @@ -26,19 +26,19 @@ public CompareResult(string url, string htmlUrl, string permalinkUrl, string dif Files = files; } - public string Url { get; protected set; } - public string HtmlUrl { get; protected set; } - public string PermalinkUrl { get; protected set; } - public string DiffUrl { get; protected set; } - public string PatchUrl { get; protected set; } - public GitHubCommit BaseCommit { get; protected set; } - public GitHubCommit MergeBaseCommit { get; protected set; } - public string Status { get; protected set; } - public int AheadBy { get; protected set; } - public int BehindBy { get; protected set; } - public int TotalCommits { get; protected set; } - public IReadOnlyList<GitHubCommit> Commits { get; protected set; } - public IReadOnlyList<GitHubCommitFile> Files { get; protected set; } + public string Url { get; private set; } + public string HtmlUrl { get; private set; } + public string PermalinkUrl { get; private set; } + public string DiffUrl { get; private set; } + public string PatchUrl { get; private set; } + public GitHubCommit BaseCommit { get; private set; } + public GitHubCommit MergeBaseCommit { get; private set; } + public string Status { get; private set; } + public int AheadBy { get; private set; } + public int BehindBy { get; private set; } + public int TotalCommits { get; private set; } + public IReadOnlyList<GitHubCommit> Commits { get; private set; } + public IReadOnlyList<GitHubCommitFile> Files { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Contributor.cs b/Octokit/Models/Response/Contributor.cs index 4c35c334d6..2bf5a57e65 100644 --- a/Octokit/Models/Response/Contributor.cs +++ b/Octokit/Models/Response/Contributor.cs @@ -19,11 +19,11 @@ public Contributor(Author author, int total, IReadOnlyList<WeeklyHash> weeks) Weeks = weeks; } - public Author Author { get; protected set; } + public Author Author { get; private set; } - public int Total { get; protected set; } + public int Total { get; private set; } - public IReadOnlyList<WeeklyHash> Weeks { get; protected set; } + public IReadOnlyList<WeeklyHash> Weeks { get; private set; } internal string DebuggerDisplay { @@ -34,4 +34,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/DeployKey.cs b/Octokit/Models/Response/DeployKey.cs index 464e0b8384..0f9771158c 100644 --- a/Octokit/Models/Response/DeployKey.cs +++ b/Octokit/Models/Response/DeployKey.cs @@ -16,10 +16,10 @@ public DeployKey(int id, string key, string url, string title) Title = title; } - public int Id { get; protected set; } - public string Key { get; protected set; } - public string Url { get; protected set; } - public string Title { get; protected set; } + public int Id { get; private set; } + public string Key { get; private set; } + public string Url { get; private set; } + public string Title { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Deployment.cs b/Octokit/Models/Response/Deployment.cs index ba3016a295..f8dbb4cce3 100644 --- a/Octokit/Models/Response/Deployment.cs +++ b/Octokit/Models/Response/Deployment.cs @@ -33,67 +33,67 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I /// <summary> /// Id of this deployment. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> - /// + /// /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// The API URL for this deployment. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The <seealso cref="User"/> that created the deployment. /// </summary> - public User Creator { get; protected set; } + public User Creator { get; private set; } /// <summary> /// JSON payload with extra information about the deployment. /// </summary> - public IReadOnlyDictionary<string, string> Payload { get; protected set; } + public IReadOnlyDictionary<string, string> Payload { get; private set; } /// <summary> /// Date and time that the deployment was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// Date and time that the deployment was updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// A short description of the deployment. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// The API URL for the <seealso cref="DeploymentStatus"/>es of this deployment. /// </summary> - public string StatusesUrl { get; protected set; } + public string StatusesUrl { get; private set; } /// <summary> /// Indicates if the environment is specific to a deployment and will no longer exist at some point in the future. /// </summary> - public bool TransientEnvironment { get; protected set; } + public bool TransientEnvironment { get; private set; } /// <summary> /// Indicates if the environment is one with which end users directly interact. /// </summary> - public bool ProductionEnvironment { get; protected set; } + public bool ProductionEnvironment { get; private set; } /// <summary> /// Specifies a task to execute (e.g., deploy or deploy:migrations) /// </summary> - public string Task { get; protected set; } + public string Task { get; private set; } internal string DebuggerDisplay { @@ -103,4 +103,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/DeploymentStatus.cs b/Octokit/Models/Response/DeploymentStatus.cs index cd46e7339e..1936e63c35 100644 --- a/Octokit/Models/Response/DeploymentStatus.cs +++ b/Octokit/Models/Response/DeploymentStatus.cs @@ -30,66 +30,66 @@ public DeploymentStatus(int id, string nodeId, string url, DeploymentState state /// <summary> /// Id of this deployment status. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The API URL for this deployment status. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The state of this deployment status. /// </summary> - public StringEnum<DeploymentState> State { get; protected set; } + public StringEnum<DeploymentState> State { get; private set; } /// <summary> /// The <seealso cref="User"/> that created this deployment status. /// </summary> - public User Creator { get; protected set; } + public User Creator { get; private set; } /// <summary> /// JSON payload with extra information about the deployment. /// </summary> - public IReadOnlyDictionary<string, string> Payload { get; protected set; } + public IReadOnlyDictionary<string, string> Payload { get; private set; } /// <summary> /// The target URL of this deployment status. This URL should contain /// output to keep the user updated while the task is running or serve /// as historical information for what happened in the deployment /// </summary> - public string TargetUrl { get; protected set; } + public string TargetUrl { get; private set; } /// <summary> /// The target URL of this deployment status. This URL should contain /// output to keep the user updated while the task is running or serve as /// historical information for what happened in the deployment /// </summary> - public string LogUrl { get; protected set; } + public string LogUrl { get; private set; } /// <summary> /// The URL for accessing your environment. /// </summary> - public string EnvironmentUrl { get; protected set; } + public string EnvironmentUrl { get; private set; } /// <summary> /// The date and time that the status was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date and time that the status was updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// A short description of the status. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } internal string DebuggerDisplay { @@ -123,4 +123,4 @@ public enum DeploymentState [Parameter(Value = "queued")] Queued } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/EmailAddress.cs b/Octokit/Models/Response/EmailAddress.cs index 0ae7e3cbb4..355cbf31ee 100644 --- a/Octokit/Models/Response/EmailAddress.cs +++ b/Octokit/Models/Response/EmailAddress.cs @@ -24,23 +24,23 @@ public EmailAddress(string email, bool verified, bool primary, EmailVisibility v /// <summary> /// The email address /// </summary> - public string Email { get; protected set; } + public string Email { get; private set; } /// <summary> /// True if the email is verified; otherwise false /// </summary> - public bool Verified { get; protected set; } + public bool Verified { get; private set; } /// <summary> /// True if this is the users primary email; otherwise false /// </summary> - public bool Primary { get; protected set; } + public bool Primary { get; private set; } /// <summary> /// "private" or "public" if the email address is the primary; /// otherwise null /// </summary> - public StringEnum<EmailVisibility>? Visibility { get; protected set; } + public StringEnum<EmailVisibility>? Visibility { get; private set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by DebuggerDisplayAttribute")] @@ -61,14 +61,14 @@ public enum EmailVisibility { /// <summary> /// Primary email address and is public - /// </summary> + /// </summary> [Parameter(Value = "public")] Public, /// <summary> /// Primary email address and is private - /// </summary> + /// </summary> [Parameter(Value = "private")] Private } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Enterprise/MaintenanceModeActiveProcesses.cs b/Octokit/Models/Response/Enterprise/MaintenanceModeActiveProcesses.cs index 57b475c87f..81898a755a 100644 --- a/Octokit/Models/Response/Enterprise/MaintenanceModeActiveProcesses.cs +++ b/Octokit/Models/Response/Enterprise/MaintenanceModeActiveProcesses.cs @@ -14,9 +14,9 @@ public MaintenanceModeActiveProcesses(string name, int number) Number = number; } - public string Name { get; protected set; } + public string Name { get; private set; } - public int Number { get; protected set; } + public int Number { get; private set; } public override string ToString() { diff --git a/Octokit/Models/Response/Enterprise/PreReceiveEnvironment.cs b/Octokit/Models/Response/Enterprise/PreReceiveEnvironment.cs index cf2c2ce646..2a5a84ff1a 100644 --- a/Octokit/Models/Response/Enterprise/PreReceiveEnvironment.cs +++ b/Octokit/Models/Response/Enterprise/PreReceiveEnvironment.cs @@ -29,47 +29,47 @@ public PreReceiveEnvironment(long id, string name, string url, string imageUrl, /// <summary> /// Identifier for the pre-receive environment. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// The name of the environment as displayed in the UI. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// URL to the pre-receive environment. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// URL to the tarball that will be downloaded and extracted. /// </summary> - public string ImageUrl { get; protected set; } + public string ImageUrl { get; private set; } /// <summary> /// UI URL to the pre-receive environment. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// Whether this is the default environment that ships with GitHub Enterprise. /// </summary> - public bool DefaultEnvironment { get; protected set; } + public bool DefaultEnvironment { get; private set; } /// <summary> /// The time when the pre-receive environment was created. /// </summary> - public DateTimeOffset? CreatedAt { get; protected set; } + public DateTimeOffset? CreatedAt { get; private set; } /// <summary> /// The number of pre-receive hooks that use this environment. /// </summary> - public int HooksCount { get; protected set; } + public int HooksCount { get; private set; } /// <summary> /// This environment's download status. /// </summary> - public PreReceiveEnvironmentDownload Download { get; protected set; } + public PreReceiveEnvironmentDownload Download { get; private set; } /// <summary> /// Prepares an <see cref="UpdatePreReceiveEnvironment"/> for use when updating a pre-receive environment. diff --git a/Octokit/Models/Response/Enterprise/PreReceiveEnvironmentDownload.cs b/Octokit/Models/Response/Enterprise/PreReceiveEnvironmentDownload.cs index 05200a1ff4..cef9f73c96 100644 --- a/Octokit/Models/Response/Enterprise/PreReceiveEnvironmentDownload.cs +++ b/Octokit/Models/Response/Enterprise/PreReceiveEnvironmentDownload.cs @@ -24,22 +24,22 @@ public PreReceiveEnvironmentDownload(string url, PreReceiveEnvironmentDownloadSt /// <summary> /// URL to the download status for a pre-receive environment. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The state of the most recent download. /// </summary> - public StringEnum<PreReceiveEnvironmentDownloadState> State { get; protected set; } + public StringEnum<PreReceiveEnvironmentDownloadState> State { get; private set; } /// <summary> /// On failure, this will have any error messages produced. /// </summary> - public string Message { get; protected set; } + public string Message { get; private set; } /// <summary> /// The time when the most recent download started. /// </summary> - public DateTimeOffset? DownloadedAt { get; protected set; } + public DateTimeOffset? DownloadedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Enterprise/PreReceiveHook.cs b/Octokit/Models/Response/Enterprise/PreReceiveHook.cs index af9d5c7c51..a63bdde68c 100644 --- a/Octokit/Models/Response/Enterprise/PreReceiveHook.cs +++ b/Octokit/Models/Response/Enterprise/PreReceiveHook.cs @@ -26,37 +26,37 @@ public PreReceiveHook(int id, string name, StringEnum<PreReceiveHookEnforcement> /// <summary> /// The identifier for the pre-receive hook. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// The name of the hook. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The state of enforcement for this hook. /// </summary> - public StringEnum<PreReceiveHookEnforcement> Enforcement { get; protected set; } + public StringEnum<PreReceiveHookEnforcement> Enforcement { get; private set; } /// <summary> /// The script that the hook runs. /// </summary> - public string Script { get; protected set; } + public string Script { get; private set; } /// <summary> /// The GitHub repository where the script is kept. /// </summary> - public Repository ScriptRepository { get; protected set; } + public Repository ScriptRepository { get; private set; } /// <summary> /// The pre-receive environment where the script is executed. /// </summary> - public PreReceiveEnvironment Environment { get; protected set; } + public PreReceiveEnvironment Environment { get; private set; } /// <summary> /// Whether enforcement can be overridden at the org or repo level. /// </summary> - public bool AllowDownstreamConfiguration { get; protected set; } + public bool AllowDownstreamConfiguration { get; private set; } public UpdatePreReceiveHook ToUpdate() { diff --git a/Octokit/Models/Response/EventInfo.cs b/Octokit/Models/Response/EventInfo.cs index 16ebc58148..d2a0238ad7 100644 --- a/Octokit/Models/Response/EventInfo.cs +++ b/Octokit/Models/Response/EventInfo.cs @@ -27,47 +27,47 @@ public EventInfo(long id, string nodeId, string url, User actor, User assignee, /// <summary> /// The id of the issue/pull request event. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL for this event. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// Always the User that generated the event. /// </summary> - public User Actor { get; protected set; } + public User Actor { get; private set; } /// <summary> /// The user that was assigned, if the event was 'Assigned'. /// </summary> - public User Assignee { get; protected set; } + public User Assignee { get; private set; } /// <summary> /// The label that was assigned, if the event was 'Labeled' /// </summary> - public Label Label { get; protected set; } + public Label Label { get; private set; } /// <summary> /// Identifies the actual type of Event that occurred. /// </summary> - public StringEnum<EventInfoState> Event { get; protected set; } + public StringEnum<EventInfoState> Event { get; private set; } /// <summary> /// The String SHA of a commit that referenced this Issue. /// </summary> - public string CommitId { get; protected set; } + public string CommitId { get; private set; } /// <summary> /// Date the event occurred for the issue/pull request. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } internal string DebuggerDisplay { @@ -111,7 +111,7 @@ public enum EventInfoState BaseRefChanged, /// <summary> - /// The issue was closed by the actor. When the commit_id is present, it identifies the commit that + /// The issue was closed by the actor. When the commit_id is present, it identifies the commit that /// closed the issue using “closes / fixes #NN” syntax. /// </summary> [Parameter(Value = "closed")] @@ -195,7 +195,7 @@ public enum EventInfoState HeadRefRestored, /// <summary> - /// The pull request’s branch was force pushed to. + /// The pull request’s branch was force pushed to. /// </summary> [Parameter(Value = "head_ref_force_pushed")] HeadRefForcePushed, @@ -256,7 +256,7 @@ public enum EventInfoState ReadyForReview, /// <summary> - /// The issue was referenced from a commit message. The commit_id attribute is the commit SHA1 of where + /// The issue was referenced from a commit message. The commit_id attribute is the commit SHA1 of where /// that happened. /// </summary> [Parameter(Value = "referenced")] @@ -309,7 +309,7 @@ public enum EventInfoState /// </summary> [Parameter(Value = "subscribed")] Subscribed, - + /// <summary> /// An issue was transferred. /// </summary> @@ -321,7 +321,7 @@ public enum EventInfoState /// </summary> [Parameter(Value = "unassigned")] Unassigned, - + /// <summary> /// A label was removed from the issue. /// </summary> @@ -339,7 +339,7 @@ public enum EventInfoState /// </summary> [Parameter(Value = "unmarked_as_duplicate")] UnmarkedAsDuplicate, - + /// <summary> /// An issue was unpinned. /// </summary> diff --git a/Octokit/Models/Response/Feed.cs b/Octokit/Models/Response/Feed.cs index f699881668..1252402873 100644 --- a/Octokit/Models/Response/Feed.cs +++ b/Octokit/Models/Response/Feed.cs @@ -26,38 +26,38 @@ public Feed(string timelineUrl, string userUrl, string currentUserPublicUrl, str /// <summary> /// The GitHub global public timeline /// </summary> - public string TimelineUrl { get; protected set; } + public string TimelineUrl { get; private set; } /// <summary> /// The public timeline for any user, using URI template /// </summary> - public string UserUrl { get; protected set; } + public string UserUrl { get; private set; } /// <summary> /// The public timeline for the authenticated user /// </summary> - public string CurrentUserPublicUrl { get; protected set; } + public string CurrentUserPublicUrl { get; private set; } /// <summary> /// The private timeline for the authenticated user /// </summary> - public string CurrentUserUrl { get; protected set; } + public string CurrentUserUrl { get; private set; } /// <summary> /// The private timeline for activity created by the authenticated user /// </summary> - public string CurrentUserActorUrl { get; protected set; } + public string CurrentUserActorUrl { get; private set; } /// <summary> /// The private timeline for the authenticated user for a given organization, using URI template /// </summary> - public string CurrentUserOrganizationUrl { get; protected set; } + public string CurrentUserOrganizationUrl { get; private set; } /// <summary> /// List of feed urls including feed url and feed type, e.g. application/atom+xml /// </summary> [Parameter(Key = "_links")] - public FeedLinks Links { get; protected set; } + public FeedLinks Links { get; private set; } internal string DebuggerDisplay { @@ -67,4 +67,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/FeedLink.cs b/Octokit/Models/Response/FeedLink.cs index d0cdc7bf1c..518d4f3055 100644 --- a/Octokit/Models/Response/FeedLink.cs +++ b/Octokit/Models/Response/FeedLink.cs @@ -24,32 +24,32 @@ public FeedLinks(FeedLink timeline, FeedLink user, FeedLink currentUserPublic, F /// <summary> /// The GitHub global public timeline /// </summary> - public FeedLink Timeline { get; protected set; } + public FeedLink Timeline { get; private set; } /// <summary> /// The public timeline for any user, using URI template /// </summary> - public FeedLink User { get; protected set; } + public FeedLink User { get; private set; } /// <summary> /// The public timeline for the authenticated user /// </summary> - public FeedLink CurrentUserPublic { get; protected set; } + public FeedLink CurrentUserPublic { get; private set; } /// <summary> /// The private timeline for the authenticated user /// </summary> - public FeedLink CurrentUser { get; protected set; } + public FeedLink CurrentUser { get; private set; } /// <summary> /// The private timeline for activity created by the authenticated user /// </summary> - public FeedLink CurrentUserActor { get; protected set; } + public FeedLink CurrentUserActor { get; private set; } /// <summary> /// The private timeline for the authenticated user for a given organization, using URI template /// </summary> - public FeedLink CurrentUserOrganization { get; protected set; } + public FeedLink CurrentUserOrganization { get; private set; } internal string DebuggerDisplay { @@ -74,17 +74,17 @@ public FeedLink(string href, string type) /// <summary> /// Link to feed /// </summary> - public string Href { get; protected set; } + public string Href { get; private set; } /// <summary> /// Feed type, e.g. application/atom+xml /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] - public string Type { get; protected set; } + public string Type { get; private set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Type: {0}, Href: {1}", Type, Href); } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Gist.cs b/Octokit/Models/Response/Gist.cs index 2ec6ffdc52..d209c4abbc 100644 --- a/Octokit/Models/Response/Gist.cs +++ b/Octokit/Models/Response/Gist.cs @@ -33,7 +33,7 @@ public Gist(string url, string id, string nodeId, string description, bool @publ /// <summary> /// The API URL for this <see cref="Gist"/>. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The Id of this <see cref="Gist"/>. @@ -41,22 +41,22 @@ public Gist(string url, string id, string nodeId, string description, bool @publ /// <remarks> /// Given a gist url of https://gist.github.com/UserName/1234 the Id would be '1234'. /// </remarks> - public string Id { get; protected set; } + public string Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// A description of the <see cref="Gist"/>. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// Indicates if the <see cref="Gist"/> is private or public. /// </summary> - public bool Public { get; protected set; } + public bool Public { get; private set; } /// <summary> /// The <see cref="User"/> who owns this <see cref="Gist"/>. @@ -64,57 +64,57 @@ public Gist(string url, string id, string nodeId, string description, bool @publ /// <remarks> /// Given a gist url of https://gist.github.com/UserName/1234 the Owner would be 'UserName'. /// </remarks> - public User Owner { get; protected set; } + public User Owner { get; private set; } /// <summary> /// A <see cref="IDictionary{TKey,TValue}"/> containing all <see cref="GistFile"/>s in this <see cref="Gist"/>. /// </summary> - public IReadOnlyDictionary<string, GistFile> Files { get; protected set; } + public IReadOnlyDictionary<string, GistFile> Files { get; private set; } /// <summary> /// The number of comments on this <see cref="Gist"/>. /// </summary> - public int Comments { get; protected set; } + public int Comments { get; private set; } /// <summary> /// A url to retrieve the comments for this <see cref="Gist"/>. /// </summary> - public string CommentsUrl { get; protected set; } + public string CommentsUrl { get; private set; } /// <summary> /// URL to view the gist on gist.github.com. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The git url to pull from to retrieve the contents for this <see cref="Gist"/>. /// </summary> - public string GitPullUrl { get; protected set; } + public string GitPullUrl { get; private set; } /// <summary> /// The git url to push to when changing this <see cref="Gist"/>. /// </summary> - public string GitPushUrl { get; protected set; } + public string GitPushUrl { get; private set; } /// <summary> /// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was last updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// A <see cref="IList{T}"/> of all <see cref="GistFork"/> that exist for this <see cref="Gist"/>. /// </summary> - public IReadOnlyList<GistFork> Forks { get; protected set; } + public IReadOnlyList<GistFork> Forks { get; private set; } /// <summary> /// A <see cref="IList{T}"/> of all <see cref="GistHistory"/> containing the full history for this <see cref="Gist"/>. /// </summary> - public IReadOnlyList<GistHistory> History { get; protected set; } + public IReadOnlyList<GistHistory> History { get; private set; } internal string DebuggerDisplay { @@ -124,4 +124,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/GistChangeStatus.cs b/Octokit/Models/Response/GistChangeStatus.cs index f892fcb8cf..ac5f4a1d26 100644 --- a/Octokit/Models/Response/GistChangeStatus.cs +++ b/Octokit/Models/Response/GistChangeStatus.cs @@ -21,21 +21,21 @@ public GistChangeStatus(int deletions, int additions, int total) /// <summary> /// The number of deletions that occurred as part of this change. /// </summary> - public int Deletions { get; protected set; } + public int Deletions { get; private set; } /// <summary> /// The number of additions that occurred as part of this change. /// </summary> - public int Additions { get; protected set; } + public int Additions { get; private set; } /// <summary> /// The total number of changes. /// </summary> - public int Total { get; protected set; } + public int Total { get; private set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Deletions: {0}, Additions: {1}, Total: {2}", Deletions, Additions, Total); } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/GistComment.cs b/Octokit/Models/Response/GistComment.cs index 9a9b773c18..f432398de2 100644 --- a/Octokit/Models/Response/GistComment.cs +++ b/Octokit/Models/Response/GistComment.cs @@ -23,37 +23,37 @@ public GistComment(int id, string nodeId, string url, string body, User user, Da /// <summary> /// The gist comment id. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL for this gist comment. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The body of this gist comment. /// </summary>t - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// The user that created this gist comment. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The date this comment was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date this comment was last updated. /// </summary> - public DateTimeOffset? UpdatedAt { get; protected set; } + public DateTimeOffset? UpdatedAt { get; private set; } internal string DebuggerDisplay { @@ -63,4 +63,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/GistFile.cs b/Octokit/Models/Response/GistFile.cs index 0fd53f6d95..d02d1f4055 100644 --- a/Octokit/Models/Response/GistFile.cs +++ b/Octokit/Models/Response/GistFile.cs @@ -23,38 +23,38 @@ public GistFile(int size, string filename, string type, string language, string /// <summary> /// The size in bytes of the file. /// </summary> - public int Size { get; protected set; } + public int Size { get; private set; } /// <summary> /// The name of the file /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")] - public string Filename { get; protected set; } + public string Filename { get; private set; } /// <summary> /// The mime type of the file /// </summary> [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] - public string Type { get; protected set; } + public string Type { get; private set; } /// <summary> /// The programming language of the file, if any. /// </summary> - public string Language { get; protected set; } + public string Language { get; private set; } /// <summary> /// The text content of the file. /// </summary> - public string Content { get; protected set; } + public string Content { get; private set; } /// <summary> /// The url to download the file. /// </summary> - public string RawUrl { get; protected set; } + public string RawUrl { get; private set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Filename: {0}, Size: {1}, Type: {2}, Language: {3}", Filename, Size, Type, Language); } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/GistFork.cs b/Octokit/Models/Response/GistFork.cs index 888b81cb8c..9fc8ac5e1c 100644 --- a/Octokit/Models/Response/GistFork.cs +++ b/Octokit/Models/Response/GistFork.cs @@ -20,26 +20,26 @@ public GistFork(string nodeId, User user, string url, DateTimeOffset createdAt) /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The <see cref="User"/> that created this <see cref="GistFork"/> /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The API URL for this <see cref="GistFork"/>. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "User: {0}, Url: {1}", User.DebuggerDisplay, Url); } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/GistHistory.cs b/Octokit/Models/Response/GistHistory.cs index e7d06fcbb4..bc6f9bceb0 100644 --- a/Octokit/Models/Response/GistHistory.cs +++ b/Octokit/Models/Response/GistHistory.cs @@ -24,31 +24,31 @@ public GistHistory(string url, string version, User user, GistChangeStatus chang /// <summary> /// The url that can be used by the API to retrieve this version of the <see cref="Gist"/>. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// A git sha representing the version. /// </summary> - public string Version { get; protected set; } + public string Version { get; private set; } /// <summary> /// The <see cref="User"/> who create this version. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// A <see cref="GistHistory"/> that represents the level of change for this <see cref="GistHistory"/>. /// </summary> - public GistChangeStatus ChangeStatus { get; protected set; } + public GistChangeStatus ChangeStatus { get; private set; } /// <summary> /// The <see cref="DateTimeOffset"/> the version was created. /// </summary> - public DateTimeOffset CommittedAt { get; protected set; } + public DateTimeOffset CommittedAt { get; private set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "User: {0}, Url: {1}, Version: {2}, ChangeStatus: {3}", User.DebuggerDisplay, Url, Version, ChangeStatus); } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/GitHubApp.cs b/Octokit/Models/Response/GitHubApp.cs index 1f233e05a2..d511450340 100644 --- a/Octokit/Models/Response/GitHubApp.cs +++ b/Octokit/Models/Response/GitHubApp.cs @@ -28,47 +28,47 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti /// <summary> /// The Id of the GitHub App. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// The url-friendly version of the GitHub App name. /// </summary> - public string Slug { get; protected set; } + public string Slug { get; private set; } /// <summary> /// The Name of the GitHub App. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The Owner of the GitHub App. /// </summary> - public User Owner { get; protected set; } + public User Owner { get; private set; } /// <summary> /// The Description of the GitHub App. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// The URL to the GitHub App's external website. /// </summary> - public string ExternalUrl { get; protected set; } + public string ExternalUrl { get; private set; } /// <summary> /// The URL to view the GitHub App on GitHub. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// Date the GitHub App was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// Date the GitHub App was last updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/GitHubCommit.cs b/Octokit/Models/Response/GitHubCommit.cs index 34f4a35606..cc5eaec7ae 100644 --- a/Octokit/Models/Response/GitHubCommit.cs +++ b/Octokit/Models/Response/GitHubCommit.cs @@ -29,25 +29,25 @@ public GitHubCommit(string nodeId, string url, string label, string @ref, string /// address used in the commit with the email addresses registered with the GitHub account. /// If no account corresponds to the commit email, then this property is null. /// </summary> - public Author Author { get; protected set; } + public Author Author { get; private set; } - public string CommentsUrl { get; protected set; } + public string CommentsUrl { get; private set; } - public Commit Commit { get; protected set; } + public Commit Commit { get; private set; } /// <summary> /// Gets the GitHub account information for the commit committer. It attempts to match the email /// address used in the commit with the email addresses registered with the GitHub account. /// If no account corresponds to the commit email, then this property is null. /// </summary> - public Author Committer { get; protected set; } + public Author Committer { get; private set; } - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } - public GitHubCommitStats Stats { get; protected set; } + public GitHubCommitStats Stats { get; private set; } - public IReadOnlyList<GitReference> Parents { get; protected set; } + public IReadOnlyList<GitReference> Parents { get; private set; } - public IReadOnlyList<GitHubCommitFile> Files { get; protected set; } + public IReadOnlyList<GitHubCommitFile> Files { get; private set; } } } diff --git a/Octokit/Models/Response/GitHubCommitFile.cs b/Octokit/Models/Response/GitHubCommitFile.cs index d144ee760a..52eb91bf92 100644 --- a/Octokit/Models/Response/GitHubCommitFile.cs +++ b/Octokit/Models/Response/GitHubCommitFile.cs @@ -33,58 +33,58 @@ public GitHubCommitFile(string filename, int additions, int deletions, int chang /// The name of the file /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")] - public string Filename { get; protected set; } + public string Filename { get; private set; } /// <summary> /// Number of additions performed on the file. /// </summary> - public int Additions { get; protected set; } + public int Additions { get; private set; } /// <summary> /// Number of deletions performed on the file. /// </summary> - public int Deletions { get; protected set; } + public int Deletions { get; private set; } /// <summary> /// Number of changes performed on the file. /// </summary> - public int Changes { get; protected set; } + public int Changes { get; private set; } /// <summary> /// File status, like modified, added, deleted. /// </summary> - public string Status { get; protected set; } + public string Status { get; private set; } /// <summary> /// The url to the file blob. /// </summary> - public string BlobUrl { get; protected set; } + public string BlobUrl { get; private set; } /// <summary> /// The url to file contents API. /// </summary> - public string ContentsUrl { get; protected set; } + public string ContentsUrl { get; private set; } /// <summary> /// The raw url to download the file. /// </summary> - public string RawUrl { get; protected set; } + public string RawUrl { get; private set; } /// <summary> /// The SHA of the file. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// The patch associated with the commit /// </summary> - public string Patch { get; protected set; } + public string Patch { get; private set; } /// <summary> /// The previous filename for a renamed file. /// </summary> [Parameter(Key = "previous_filename")] - public string PreviousFileName { get; protected set; } + public string PreviousFileName { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/GitHubCommitStats.cs b/Octokit/Models/Response/GitHubCommitStats.cs index cf4eb44029..ef6bc083a4 100644 --- a/Octokit/Models/Response/GitHubCommitStats.cs +++ b/Octokit/Models/Response/GitHubCommitStats.cs @@ -21,17 +21,17 @@ public GitHubCommitStats(int additions, int deletions, int total) /// <summary> /// The number of additions made within the commit /// </summary> - public int Additions { get; protected set; } + public int Additions { get; private set; } /// <summary> /// The number of deletions made within the commit /// </summary> - public int Deletions { get; protected set; } + public int Deletions { get; private set; } /// <summary> /// The total number of modifications within the commit /// </summary> - public int Total { get; protected set; } + public int Total { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/GitIgnoreTemplate.cs b/Octokit/Models/Response/GitIgnoreTemplate.cs index 3a517df135..491769fbe5 100644 --- a/Octokit/Models/Response/GitIgnoreTemplate.cs +++ b/Octokit/Models/Response/GitIgnoreTemplate.cs @@ -19,8 +19,8 @@ public GitIgnoreTemplate() { } - public string Name { get; protected set; } - public string Source { get; protected set; } + public string Name { get; private set; } + public string Source { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/GitTag.cs b/Octokit/Models/Response/GitTag.cs index 6db53711d7..a03a2d507b 100644 --- a/Octokit/Models/Response/GitTag.cs +++ b/Octokit/Models/Response/GitTag.cs @@ -18,14 +18,14 @@ public GitTag(string nodeId, string url, string label, string @ref, string sha, } - public string Tag { get; protected set; } + public string Tag { get; private set; } - public string Message { get; protected set; } + public string Message { get; private set; } - public Committer Tagger { get; protected set; } + public Committer Tagger { get; private set; } - public TagObject Object { get; protected set; } + public TagObject Object { get; private set; } - public Verification Verification { get; protected set; } + public Verification Verification { get; private set; } } } diff --git a/Octokit/Models/Response/GpgKey.cs b/Octokit/Models/Response/GpgKey.cs index 311393b4ea..48296bc8d6 100644 --- a/Octokit/Models/Response/GpgKey.cs +++ b/Octokit/Models/Response/GpgKey.cs @@ -28,19 +28,19 @@ public GpgKey(int id, int? primaryKeyId, string keyId, string publicKey, IReadOn ExpiresAt = expiresAt; } - public int Id { get; protected set; } - public int? PrimaryKeyId { get; protected set; } - public string KeyId { get; protected set; } - public string PublicKey { get; protected set; } - public IReadOnlyList<EmailAddress> Emails { get; protected set; } - public IReadOnlyList<GpgKey> Subkeys { get; protected set; } - public bool CanSign { get; protected set; } + public int Id { get; private set; } + public int? PrimaryKeyId { get; private set; } + public string KeyId { get; private set; } + public string PublicKey { get; private set; } + public IReadOnlyList<EmailAddress> Emails { get; private set; } + public IReadOnlyList<GpgKey> Subkeys { get; private set; } + public bool CanSign { get; private set; } [Parameter(Key = "can_encrypt_comms")] - public bool CanEncryptCommunications { get; protected set; } - public bool CanEncryptStorage { get; protected set; } - public bool CanCertify { get; protected set; } - public DateTimeOffset CreatedAt { get; protected set; } - public DateTimeOffset? ExpiresAt { get; protected set; } + public bool CanEncryptCommunications { get; private set; } + public bool CanEncryptStorage { get; private set; } + public bool CanCertify { get; private set; } + public DateTimeOffset CreatedAt { get; private set; } + public DateTimeOffset? ExpiresAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Installation.cs b/Octokit/Models/Response/Installation.cs index 83a7817a0c..98e002630d 100644 --- a/Octokit/Models/Response/Installation.cs +++ b/Octokit/Models/Response/Installation.cs @@ -32,27 +32,27 @@ public Installation(long id, User account, string accessTokenUrl, string reposit /// <summary> /// The user who owns the Installation. /// </summary> - public User Account { get; protected set; } + public User Account { get; private set; } /// <summary> /// The URL to view the Installation on GitHub. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The Id of the associated GitHub App. /// </summary> - public long AppId { get; protected set; } + public long AppId { get; private set; } /// <summary> /// The Id of the User/Organization the Installation is installed in /// </summary> - public long TargetId { get; protected set; } + public long TargetId { get; private set; } /// <summary> /// The type of the target (User or Organization) /// </summary> - public StringEnum<AccountType> TargetType { get; protected set; } + public StringEnum<AccountType> TargetType { get; private set; } /// <summary> /// The Permissions granted to the Installation @@ -67,12 +67,12 @@ public Installation(long id, User account, string accessTokenUrl, string reposit /// <summary> /// The single file the GitHub App can manage (when Permissions.SingleFile is set to read or write) /// </summary> - public string SingleFileName { get; protected set; } + public string SingleFileName { get; private set; } /// <summary> /// The choice of repositories the installation is on. Can be either "selected" or "all". /// </summary> - public StringEnum<InstallationRepositorySelection> RepositorySelection { get; protected set; } + public StringEnum<InstallationRepositorySelection> RepositorySelection { get; private set; } internal new string DebuggerDisplay { diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index 1b01d031fc..fb407f4943 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -31,85 +31,85 @@ public InstallationPermissions(InstallationPermissionLevel? metadata, Installati /// Repository metadata /// Search repositories, list collaborators, and access repository metadata. /// </summary> - public StringEnum<InstallationPermissionLevel>? Metadata { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Metadata { get; private set; } /// <summary> /// Repository administration /// Repository creation, deletion, settings, teams, and collaborators. /// </summary> - public StringEnum<InstallationPermissionLevel>? Administration { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Administration { get; private set; } /// <summary> /// Commit statuses /// Commit statuses. /// </summary> - public StringEnum<InstallationPermissionLevel>? Statuses { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Statuses { get; private set; } /// <summary> /// Deployments /// Deployments and deployment statuses. /// </summary> - public StringEnum<InstallationPermissionLevel>? Deployments { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Deployments { get; private set; } /// <summary> /// Issues /// Issues and related comments, assignees, labels, and milestones. /// </summary> - public StringEnum<InstallationPermissionLevel>? Issues { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Issues { get; private set; } /// <summary> /// Pages /// Retrieve Pages statuses, configuration, and builds, as well as create new builds. /// </summary> - public StringEnum<InstallationPermissionLevel>? Pages { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Pages { get; private set; } /// <summary> /// Pull requests /// Pull requests and related comments, assignees, labels, milestones, and merges. /// </summary> - public StringEnum<InstallationPermissionLevel>? PullRequests { get; protected set; } + public StringEnum<InstallationPermissionLevel>? PullRequests { get; private set; } /// <summary> /// Repository contents /// Repository contents, commits, branches, downloads, releases, and merges. /// </summary> - public StringEnum<InstallationPermissionLevel>? Contents { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Contents { get; private set; } /// <summary> /// Single file /// Manage just a single file. /// </summary> - public StringEnum<InstallationPermissionLevel>? SingleFile { get; protected set; } + public StringEnum<InstallationPermissionLevel>? SingleFile { get; private set; } /// <summary> /// Repository projects /// Manage repository projects, columns, and cards. /// </summary> - public StringEnum<InstallationPermissionLevel>? RepositoryProjects { get; protected set; } + public StringEnum<InstallationPermissionLevel>? RepositoryProjects { get; private set; } /// <summary> /// Checks /// Detailed information about CI checks /// </summary> - public StringEnum<InstallationPermissionLevel>? Checks { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Checks { get; private set; } /// <summary> /// Organization members (only applicable when installed for an Organization ) /// Organization members and teams. /// </summary> - public StringEnum<InstallationPermissionLevel>? Members { get; protected set; } + public StringEnum<InstallationPermissionLevel>? Members { get; private set; } /// <summary> /// Organization projects (only applicable when installed for an Organization ) /// Manage organization projects, columns, and cards. /// </summary> - public StringEnum<InstallationPermissionLevel>? OrganizationProjects { get; protected set; } + public StringEnum<InstallationPermissionLevel>? OrganizationProjects { get; private set; } /// <summary> /// Team discussions (only applicable when installed for an Organization ) /// Team discussions. /// </summary> - public StringEnum<InstallationPermissionLevel>? TeamDiscussions { get; protected set; } + public StringEnum<InstallationPermissionLevel>? TeamDiscussions { get; private set; } internal string DebuggerDisplay { @@ -125,4 +125,4 @@ public enum InstallationPermissionLevel [Parameter(Value = "write")] Write } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/InstallationsResponse.cs b/Octokit/Models/Response/InstallationsResponse.cs index acea8ec7f0..5348fbcd5f 100644 --- a/Octokit/Models/Response/InstallationsResponse.cs +++ b/Octokit/Models/Response/InstallationsResponse.cs @@ -20,13 +20,13 @@ public InstallationsResponse(int totalCount, IReadOnlyList<Installation> install /// <summary> /// The total number of check suites that match the request filter /// </summary> - public int TotalCount { get; protected set; } + public int TotalCount { get; private set; } /// <summary> /// The retrieved check suites /// </summary> - public IReadOnlyList<Installation> Installations { get; protected set; } + public IReadOnlyList<Installation> Installations { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, Installations: {1}", TotalCount, Installations.Count); } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index 0a33673c56..ef25f3c26f 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -44,124 +44,124 @@ public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, i /// <summary> /// The internal Id for this issue (not the issue number) /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL for this issue. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The URL for the HTML view of this issue. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The Comments URL of this issue. /// </summary> - public string CommentsUrl { get; protected set; } + public string CommentsUrl { get; private set; } /// <summary> /// The Events URL of this issue. /// </summary> - public string EventsUrl { get; protected set; } + public string EventsUrl { get; private set; } /// <summary> /// The issue number. /// </summary> - public int Number { get; protected set; } + public int Number { get; private set; } /// <summary> /// Whether the issue is open or closed. /// </summary> - public StringEnum<ItemState> State { get; protected set; } + public StringEnum<ItemState> State { get; private set; } /// <summary> /// Title of the issue /// </summary> - public string Title { get; protected set; } + public string Title { get; private set; } /// <summary> /// Details about the issue. /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// Details about the user who has closed this issue. /// </summary> - public User ClosedBy { get; protected set; } + public User ClosedBy { get; private set; } /// <summary> /// The user that created the issue. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The set of labels applied to the issue /// </summary> - public IReadOnlyList<Label> Labels { get; protected set; } + public IReadOnlyList<Label> Labels { get; private set; } /// <summary> /// The user this issue is assigned to. /// </summary> - public User Assignee { get; protected set; } + public User Assignee { get; private set; } /// <summary> ///The multiple users this issue is assigned to. /// </summary> - public IReadOnlyList<User> Assignees { get; protected set; } + public IReadOnlyList<User> Assignees { get; private set; } /// <summary> /// The milestone, if any, that this issue is assigned to. /// </summary> - public Milestone Milestone { get; protected set; } + public Milestone Milestone { get; private set; } /// <summary> /// The number of comments on the issue. /// </summary> - public int Comments { get; protected set; } + public int Comments { get; private set; } - public PullRequest PullRequest { get; protected set; } + public PullRequest PullRequest { get; private set; } /// <summary> /// The date the issue was closed if closed. /// </summary> - public DateTimeOffset? ClosedAt { get; protected set; } + public DateTimeOffset? ClosedAt { get; private set; } /// <summary> /// The date the issue was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date the issue was last updated. /// </summary> - public DateTimeOffset? UpdatedAt { get; protected set; } + public DateTimeOffset? UpdatedAt { get; private set; } /// <summary> /// If the issue is locked or not. /// </summary> - public bool Locked { get; protected set; } + public bool Locked { get; private set; } /// <summary> /// The repository the issue comes from. /// </summary> - public Repository Repository { get; protected set; } + public Repository Repository { get; private set; } /// <summary> /// The reaction summary for this issue. /// </summary> - public ReactionSummary Reactions { get; protected set; } + public ReactionSummary Reactions { get; private set; } /// <summary> /// Reason that the conversation was locked. /// </summary> - public StringEnum<LockReason>? ActiveLockReason { get; protected set; } + public StringEnum<LockReason>? ActiveLockReason { get; private set; } internal string DebuggerDisplay { @@ -213,4 +213,4 @@ public IssueUpdate ToUpdate() return issueUpdate; } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/IssueComment.cs b/Octokit/Models/Response/IssueComment.cs index 9ef576f89d..0d7d3da7b7 100644 --- a/Octokit/Models/Response/IssueComment.cs +++ b/Octokit/Models/Response/IssueComment.cs @@ -27,52 +27,52 @@ public IssueComment(int id, string nodeId, string url, string htmlUrl, string bo /// <summary> /// The issue comment Id. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL for this issue comment. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The html URL for this issue comment. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// Details about the issue comment. /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// The date the issue comment was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date the issue comment was last updated. /// </summary> - public DateTimeOffset? UpdatedAt { get; protected set; } + public DateTimeOffset? UpdatedAt { get; private set; } /// <summary> /// The user that created the issue comment. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The comment author association with repository. /// </summary> - public StringEnum<AuthorAssociation> AuthorAssociation { get; protected set; } + public StringEnum<AuthorAssociation> AuthorAssociation { get; private set; } /// <summary> /// The reaction summary for this comment. /// </summary> - public ReactionSummary Reactions { get; protected set; } + public ReactionSummary Reactions { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/IssueEvent.cs b/Octokit/Models/Response/IssueEvent.cs index be5b79f7ba..a32d2864e3 100644 --- a/Octokit/Models/Response/IssueEvent.cs +++ b/Octokit/Models/Response/IssueEvent.cs @@ -29,69 +29,69 @@ public IssueEvent(long id, string nodeId, string url, User actor, User assignee, /// <summary> /// The id of the issue/pull request event. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL for this issue/pull request event. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// Always the User that generated the event. /// </summary> - public User Actor { get; protected set; } + public User Actor { get; private set; } /// <summary> /// The user that was assigned, if the event was 'Assigned'. /// </summary> - public User Assignee { get; protected set; } + public User Assignee { get; private set; } /// <summary> /// The label that was assigned, if the event was 'Labeled' /// </summary> - public Label Label { get; protected set; } + public Label Label { get; private set; } /// <summary> /// Identifies the actual type of Event that occurred. /// </summary> - public StringEnum<EventInfoState> Event { get; protected set; } + public StringEnum<EventInfoState> Event { get; private set; } /// <summary> /// The String SHA of a commit that referenced this Issue. /// </summary> - public string CommitId { get; protected set; } + public string CommitId { get; private set; } /// <summary> /// The commit URL of a commit that referenced this issue. /// </summary> - public string CommitUrl { get; protected set; } + public string CommitUrl { get; private set; } /// <summary> /// Date the event occurred for the issue/pull request. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The issue associated to this event. /// </summary> - public Issue Issue { get; protected set; } + public Issue Issue { get; private set; } /// <summary> /// An object containing rename details /// Only provided for renamed events /// </summary> - public RenameInfo Rename { get; protected set; } + public RenameInfo Rename { get; private set; } /// <summary> /// Information about the project card that triggered the event. /// The project_card attribute is not returned if someone deletes the project board, or if you do not have permission to view it. /// </summary> - public IssueEventProjectCard ProjectCard { get; protected set; } + public IssueEventProjectCard ProjectCard { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/IssueEventProjectCard.cs b/Octokit/Models/Response/IssueEventProjectCard.cs index f2cf797d1b..7a3ac91593 100644 --- a/Octokit/Models/Response/IssueEventProjectCard.cs +++ b/Octokit/Models/Response/IssueEventProjectCard.cs @@ -21,34 +21,34 @@ public IssueEventProjectCard(long id, string url, long projectId, string project /// <summary> /// The identification number of the project card. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// The API URL of the project card, if the card still exists. /// Not included for removed_from_project events. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The identification number of the project. /// </summary> - public long ProjectId { get; protected set; } + public long ProjectId { get; private set; } /// <summary> /// The API URL of the project. /// </summary> - public string ProjectUrl { get; protected set; } + public string ProjectUrl { get; private set; } /// <summary> /// The name of the column that the card is listed in. /// </summary> - public string ColumnName { get; protected set; } + public string ColumnName { get; private set; } /// <summary> /// The name of the column that the card was listed in prior to column_name /// Only returned for moved_columns_in_project events. /// </summary> - public string PreviousColumnName { get; protected set; } + public string PreviousColumnName { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Label.cs b/Octokit/Models/Response/Label.cs index af23eda7e0..2ae1260b6f 100644 --- a/Octokit/Models/Response/Label.cs +++ b/Octokit/Models/Response/Label.cs @@ -22,37 +22,37 @@ public Label(long id, string url, string name, string nodeId, string color, stri /// <summary> /// Id of the label /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// Url of the label /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// Name of the label /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// Color of the label /// </summary> - public string Color { get; protected set; } + public string Color { get; private set; } /// <summary> /// Description of the label /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// Is default label /// </summary> - public bool Default { get; protected set; } + public bool Default { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/License.cs b/Octokit/Models/Response/License.cs index 0bd31205bd..616e765d0c 100644 --- a/Octokit/Models/Response/License.cs +++ b/Octokit/Models/Response/License.cs @@ -42,42 +42,42 @@ public License() /// <summary> /// Url to the license on https://choosealicense.com /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// A description of the license. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// A group or family that the license belongs to such as the GPL family of licenses. /// </summary> - public string Category { get; protected set; } + public string Category { get; private set; } /// <summary> /// Notes on how to properly apply the license. /// </summary> - public string Implementation { get; protected set; } + public string Implementation { get; private set; } /// <summary> /// Set of codes for what is required under the terms of the license. For example, "include-copyright" /// </summary> - public IReadOnlyList<string> Required { get; protected set; } + public IReadOnlyList<string> Required { get; private set; } /// <summary> /// Set of codes for what is permitted under the terms of the license. For example, "commercial-use" /// </summary> - public IReadOnlyList<string> Permitted { get; protected set; } + public IReadOnlyList<string> Permitted { get; private set; } /// <summary> /// Set of codes for what is forbidden under the terms of the license. For example, "no-liability" /// </summary> - public IReadOnlyList<string> Forbidden { get; protected set; } + public IReadOnlyList<string> Forbidden { get; private set; } /// <summary> /// The text of the license /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } internal override string DebuggerDisplay { diff --git a/Octokit/Models/Response/LicenseMetadata.cs b/Octokit/Models/Response/LicenseMetadata.cs index d00c075088..cad52d65a9 100644 --- a/Octokit/Models/Response/LicenseMetadata.cs +++ b/Octokit/Models/Response/LicenseMetadata.cs @@ -21,7 +21,7 @@ public LicenseMetadata() } /// <summary> - /// The + /// Keyword for the given license (i.e. mit, gpl, cc) /// </summary> public string Key { get; protected set; } diff --git a/Octokit/Models/Response/Merge.cs b/Octokit/Models/Response/Merge.cs index 8af031a08b..f74992b48a 100644 --- a/Octokit/Models/Response/Merge.cs +++ b/Octokit/Models/Response/Merge.cs @@ -24,12 +24,12 @@ public Merge(string nodeId, string url, string label, string @ref, string sha, U HtmlUrl = htmlUrl; } - public Author Author { get; protected set; } - public Author Committer { get; protected set; } - public Commit Commit { get; protected set; } - public IReadOnlyList<GitReference> Parents { get; protected set; } - public string CommentsUrl { get; protected set; } - public int CommentCount { get; protected set; } - public string HtmlUrl { get; protected set; } + public Author Author { get; private set; } + public Author Committer { get; private set; } + public Commit Commit { get; private set; } + public IReadOnlyList<GitReference> Parents { get; private set; } + public string CommentsUrl { get; private set; } + public int CommentCount { get; private set; } + public string HtmlUrl { get; private set; } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Migration.cs b/Octokit/Models/Response/Migration.cs index f56213b1ac..92fd527c17 100644 --- a/Octokit/Models/Response/Migration.cs +++ b/Octokit/Models/Response/Migration.cs @@ -53,7 +53,7 @@ public Migration( /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// Guid of migration. @@ -136,4 +136,4 @@ public enum MigrationState Failed } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Milestone.cs b/Octokit/Models/Response/Milestone.cs index aa67e362f8..002d22755d 100644 --- a/Octokit/Models/Response/Milestone.cs +++ b/Octokit/Models/Response/Milestone.cs @@ -36,77 +36,77 @@ public Milestone(string url, string htmlUrl, long id, int number, string nodeId, /// <summary> /// The URL for this milestone. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The Html page for this milestone. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The ID for this milestone. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// The milestone number. /// </summary> - public int Number { get; protected set; } + public int Number { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// Whether the milestone is open or closed. /// </summary> - public StringEnum<ItemState> State { get; protected set; } + public StringEnum<ItemState> State { get; private set; } /// <summary> /// Title of the milestone. /// </summary> - public string Title { get; protected set; } + public string Title { get; private set; } /// <summary> /// Optional description for the milestone. /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// The user that created this milestone. /// </summary> - public User Creator { get; protected set; } + public User Creator { get; private set; } /// <summary> /// The number of open issues in this milestone. /// </summary> - public int OpenIssues { get; protected set; } + public int OpenIssues { get; private set; } /// <summary> /// The number of closed issues in this milestone. /// </summary> - public int ClosedIssues { get; protected set; } + public int ClosedIssues { get; private set; } /// <summary> /// The date this milestone was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date, if any, when this milestone is due. /// </summary> - public DateTimeOffset? DueOn { get; protected set; } + public DateTimeOffset? DueOn { get; private set; } /// <summary> /// The date, if any, when this milestone was closed. /// </summary> - public DateTimeOffset? ClosedAt { get; protected set; } + public DateTimeOffset? ClosedAt { get; private set; } /// <summary> /// The date, if any, when this milestone was updated. /// </summary> - public DateTimeOffset? UpdatedAt { get; protected set; } + public DateTimeOffset? UpdatedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Notification.cs b/Octokit/Models/Response/Notification.cs index 964c41b815..c743c6563b 100644 --- a/Octokit/Models/Response/Notification.cs +++ b/Octokit/Models/Response/Notification.cs @@ -20,21 +20,21 @@ public Notification(string id, Repository repository, NotificationInfo subject, Url = url; } - public string Id { get; protected set; } // NB: API currently returns this as string which is Weird + public string Id { get; private set; } // NB: API currently returns this as string which is Weird - public Repository Repository { get; protected set; } + public Repository Repository { get; private set; } - public NotificationInfo Subject { get; protected set; } + public NotificationInfo Subject { get; private set; } - public string Reason { get; protected set; } + public string Reason { get; private set; } - public bool Unread { get; protected set; } + public bool Unread { get; private set; } - public string UpdatedAt { get; protected set; } + public string UpdatedAt { get; private set; } - public string LastReadAt { get; protected set; } + public string LastReadAt { get; private set; } - public string Url { get; protected set; } + public string Url { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/NotificationInfo.cs b/Octokit/Models/Response/NotificationInfo.cs index a0c8fefa83..a668eafe80 100644 --- a/Octokit/Models/Response/NotificationInfo.cs +++ b/Octokit/Models/Response/NotificationInfo.cs @@ -17,15 +17,15 @@ public NotificationInfo(string title, string url, string latestCommentUrl, strin Type = type; } - public string Title { get; protected set; } + public string Title { get; private set; } - public string Url { get; protected set; } + public string Url { get; private set; } - public string LatestCommentUrl { get; protected set; } + public string LatestCommentUrl { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "Matches the property name used by the API")] - public string Type { get; protected set; } + public string Type { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Organization.cs b/Octokit/Models/Response/Organization.cs index 06de89cf86..c56242ea9c 100644 --- a/Octokit/Models/Response/Organization.cs +++ b/Octokit/Models/Response/Organization.cs @@ -28,21 +28,21 @@ public Organization(string avatarUrl, string bio, string blog, int collaborators } /// <summary> - /// The billing address for an organization. This is only returned when updating + /// The billing address for an organization. This is only returned when updating /// an organization. /// </summary> - public string BillingAddress { get; protected set; } - public string ReposUrl { get; protected set; } - public string EventsUrl { get; protected set; } - public string HooksUrl { get; protected set; } - public string IssuesUrl { get; protected set; } - public string MembersUrl { get; protected set; } - public string PublicMembersUrl { get; protected set; } - public string Description { get; protected set; } - public bool IsVerified { get; protected set; } - public bool HasOrganizationProjects { get; protected set; } - public bool HasRepositoryProjects { get; protected set; } - public DateTimeOffset UpdatedAt { get; protected set; } + public string BillingAddress { get; private set; } + public string ReposUrl { get; private set; } + public string EventsUrl { get; private set; } + public string HooksUrl { get; private set; } + public string IssuesUrl { get; private set; } + public string MembersUrl { get; private set; } + public string PublicMembersUrl { get; private set; } + public string Description { get; private set; } + public bool IsVerified { get; private set; } + public bool HasOrganizationProjects { get; private set; } + public bool HasRepositoryProjects { get; private set; } + public DateTimeOffset UpdatedAt { get; private set; } internal string DebuggerDisplay @@ -54,4 +54,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/OrganizationMembership.cs b/Octokit/Models/Response/OrganizationMembership.cs index 3ecc185eb7..c63fcda5e2 100644 --- a/Octokit/Models/Response/OrganizationMembership.cs +++ b/Octokit/Models/Response/OrganizationMembership.cs @@ -20,12 +20,12 @@ public OrganizationMembership(string url, StringEnum<MembershipState> state, Str User = user; } - public string Url { get; protected set; } - public StringEnum<MembershipState> State { get; protected set; } - public StringEnum<MembershipRole> Role { get; protected set; } - public string OrganizationUrl { get; protected set; } - public Organization Organization { get; protected set; } - public User User { get; protected set; } + public string Url { get; private set; } + public StringEnum<MembershipState> State { get; private set; } + public StringEnum<MembershipRole> Role { get; private set; } + public string OrganizationUrl { get; private set; } + public Organization Organization { get; private set; } + public User User { get; private set; } internal string DebuggerDisplay => $"{nameof(OrganizationMembership)}: User: {User.Login}; Organization: {Organization.Login}; State: {State}; Role: {Role}"; } diff --git a/Octokit/Models/Response/OrganizationMembershipInvitation.cs b/Octokit/Models/Response/OrganizationMembershipInvitation.cs index 5413cbe024..3a22389fdd 100644 --- a/Octokit/Models/Response/OrganizationMembershipInvitation.cs +++ b/Octokit/Models/Response/OrganizationMembershipInvitation.cs @@ -23,18 +23,18 @@ public OrganizationMembershipInvitation(int id, string nodeId, string login, str Inviter = inviter; } - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public string Login { get; protected set; } - public string Email { get; protected set; } - public StringEnum<OrganizationMembershipRole> Role { get; protected set; } - public DateTimeOffset CreatedAt { get; protected set; } - public User Inviter { get; protected set; } + public string Login { get; private set; } + public string Email { get; private set; } + public StringEnum<OrganizationMembershipRole> Role { get; private set; } + public DateTimeOffset CreatedAt { get; private set; } + public User Inviter { get; private set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Used by DebuggerDisplayAttribute")] diff --git a/Octokit/Models/Response/Page.cs b/Octokit/Models/Response/Page.cs index 2ef718e380..21abe3dfd5 100644 --- a/Octokit/Models/Response/Page.cs +++ b/Octokit/Models/Response/Page.cs @@ -60,28 +60,28 @@ public Page(string url, string htmlUrl, PagesBuildStatus status, string cname, b /// <summary> /// The pages's API URL. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// Absolute URL to the rendered site. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// Build status of the pages site. /// </summary> - public StringEnum<PagesBuildStatus> Status { get; protected set; } + public StringEnum<PagesBuildStatus> Status { get; private set; } /// <summary> /// CName of the pages site. Will be null if no CName was provided by the user. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "CName")] - public string CName { get; protected set; } + public string CName { get; private set; } /// <summary> /// Is a custom 404 page provided. /// </summary> - public bool Custom404 { get; protected set; } + public bool Custom404 { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PagesBuild.cs b/Octokit/Models/Response/PagesBuild.cs index 46c8fd0054..087f0de045 100644 --- a/Octokit/Models/Response/PagesBuild.cs +++ b/Octokit/Models/Response/PagesBuild.cs @@ -27,29 +27,29 @@ public PagesBuild(string url, PagesBuildStatus status, ApiError error, User push /// <summary> /// The pages's API URL. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The status of the build. /// </summary> - public StringEnum<PagesBuildStatus> Status { get; protected set; } + public StringEnum<PagesBuildStatus> Status { get; private set; } /// <summary> /// Error details - if there was one. /// </summary> - public ApiError Error { get; protected set; } + public ApiError Error { get; private set; } /// <summary> /// The user whose commit initiated the build. /// </summary> - public User Pusher { get; protected set; } + public User Pusher { get; private set; } /// <summary> /// Commit SHA. /// </summary> - public Commit Commit { get; protected set; } + public Commit Commit { get; private set; } /// <summary> /// Duration of the build /// </summary> - public TimeSpan Duration { get; protected set; } - public DateTime CreatedAt { get; protected set; } - public DateTime UpdatedAt { get; protected set; } + public TimeSpan Duration { get; private set; } + public DateTime CreatedAt { get; private set; } + public DateTime UpdatedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Participation.cs b/Octokit/Models/Response/Participation.cs index 0c384e25bf..490f985370 100644 --- a/Octokit/Models/Response/Participation.cs +++ b/Octokit/Models/Response/Participation.cs @@ -26,12 +26,12 @@ public Participation(IEnumerable<int> all, IEnumerable<int> owner) /// <summary> /// Returns the commit counts made each week, for the last 52 weeks /// </summary> - public IReadOnlyList<int> All { get; protected set; } + public IReadOnlyList<int> All { get; private set; } /// <summary> /// Returns the commit counts made by the owner each week, for the last 52 weeks /// </summary> - public IReadOnlyList<int> Owner { get; protected set; } + public IReadOnlyList<int> Owner { get; private set; } /// <summary> /// The total number of commits made by the owner in the last 52 weeks. diff --git a/Octokit/Models/Response/Project.cs b/Octokit/Models/Response/Project.cs index 575e885269..baf763d12e 100644 --- a/Octokit/Models/Response/Project.cs +++ b/Octokit/Models/Response/Project.cs @@ -28,62 +28,62 @@ public Project(string ownerUrl, string url, string htmlUrl, int id, string nodeI /// <summary> /// The URL for this projects repository. /// </summary> - public string OwnerUrl { get; protected set; } + public string OwnerUrl { get; private set; } /// <summary> /// The HTML URL for this project. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The URL for this project. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The Id for this project. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The name for this project. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The body for this project. /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// The number for this project. /// </summary> - public int Number { get; protected set; } + public int Number { get; private set; } /// <summary> /// The current state of this project. /// </summary> - public StringEnum<ItemState> State { get; protected set; } + public StringEnum<ItemState> State { get; private set; } /// <summary> /// The user associated with this project. /// </summary> - public User Creator { get; protected set; } + public User Creator { get; private set; } /// <summary> /// When this project was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// When this project was last updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ProjectCard.cs b/Octokit/Models/Response/ProjectCard.cs index c8128e1436..471903a6af 100644 --- a/Octokit/Models/Response/ProjectCard.cs +++ b/Octokit/Models/Response/ProjectCard.cs @@ -25,47 +25,47 @@ public ProjectCard(string columnUrl, string contentUrl, int id, string nodeId, s /// <summary> /// The URL for this cards column. /// </summary> - public string ColumnUrl { get; protected set; } + public string ColumnUrl { get; private set; } /// <summary> /// The URL for this cards content. /// </summary> - public string ContentUrl { get; protected set; } + public string ContentUrl { get; private set; } /// <summary> /// The Id for this card. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The note for this card. /// </summary> - public string Note { get; protected set; } + public string Note { get; private set; } /// <summary> /// The user associated with this card. /// </summary> - public User Creator { get; protected set; } + public User Creator { get; private set; } /// <summary> /// When this card was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// When this card was last updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// Whether this card is archived. /// </summary> - public bool Archived { get; protected set; } + public bool Archived { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ProjectColumn.cs b/Octokit/Models/Response/ProjectColumn.cs index 98da4696c1..6ab1c3078d 100644 --- a/Octokit/Models/Response/ProjectColumn.cs +++ b/Octokit/Models/Response/ProjectColumn.cs @@ -22,32 +22,32 @@ public ProjectColumn(int id, string nodeId, string name, string projectUrl, Date /// <summary> /// The Id for this column. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The name for this column. /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// The URL for this columns project. /// </summary> - public string ProjectUrl { get; protected set; } + public string ProjectUrl { get; private set; } /// <summary> /// When this column was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// When this column was last updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PublicKey.cs b/Octokit/Models/Response/PublicKey.cs index fc47e6c27c..cc91194df3 100644 --- a/Octokit/Models/Response/PublicKey.cs +++ b/Octokit/Models/Response/PublicKey.cs @@ -16,19 +16,19 @@ public PublicKey(int id, string key, string url, string title) Title = title; } - public int Id { get; protected set; } + public int Id { get; private set; } - public string Key { get; protected set; } + public string Key { get; private set; } /// <remarks> /// Only visible for the current user, or with the correct OAuth scope /// </remarks> - public string Url { get; protected set; } + public string Url { get; private set; } /// <remarks> /// Only visible for the current user, or with the correct OAuth scope /// </remarks> - public string Title { get; protected set; } + public string Title { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PullRequest.cs b/Octokit/Models/Response/PullRequest.cs index e7690c7d44..82f7a005e2 100644 --- a/Octokit/Models/Response/PullRequest.cs +++ b/Octokit/Models/Response/PullRequest.cs @@ -61,117 +61,117 @@ public PullRequest(long id, string nodeId, string url, string htmlUrl, string di /// <summary> /// The internal Id for this pull request (not the pull request number) /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The URL for this pull request. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The URL for the pull request page. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The URL for the pull request's diff (.diff) file. /// </summary> - public string DiffUrl { get; protected set; } + public string DiffUrl { get; private set; } /// <summary> /// The URL for the pull request's patch (.patch) file. /// </summary> - public string PatchUrl { get; protected set; } + public string PatchUrl { get; private set; } /// <summary> /// The URL for the specific pull request issue. /// </summary> - public string IssueUrl { get; protected set; } + public string IssueUrl { get; private set; } /// <summary> /// The URL for the pull request statuses. /// </summary> - public string StatusesUrl { get; protected set; } + public string StatusesUrl { get; private set; } /// <summary> /// The pull request number. /// </summary> - public int Number { get; protected set; } + public int Number { get; private set; } /// <summary> /// Whether the pull request is open or closed. The default is <see cref="ItemState.Open"/>. /// </summary> - public StringEnum<ItemState> State { get; protected set; } + public StringEnum<ItemState> State { get; private set; } /// <summary> /// Title of the pull request. /// </summary> - public string Title { get; protected set; } + public string Title { get; private set; } /// <summary> /// The body (content) contained within the pull request. /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// When the pull request was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// When the pull request was last updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// When the pull request was closed. /// </summary> - public DateTimeOffset? ClosedAt { get; protected set; } + public DateTimeOffset? ClosedAt { get; private set; } /// <summary> /// When the pull request was merged. /// </summary> - public DateTimeOffset? MergedAt { get; protected set; } + public DateTimeOffset? MergedAt { get; private set; } /// <summary> /// The HEAD reference for the pull request. /// </summary> - public GitReference Head { get; protected set; } + public GitReference Head { get; private set; } /// <summary> /// The BASE reference for the pull request. /// </summary> - public GitReference Base { get; protected set; } + public GitReference Base { get; private set; } /// <summary> /// The user who created the pull request. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The user who is assigned the pull request. /// </summary> - public User Assignee { get; protected set; } + public User Assignee { get; private set; } /// <summary> ///The multiple users this pull request is assigned to. /// </summary> - public IReadOnlyList<User> Assignees { get; protected set; } + public IReadOnlyList<User> Assignees { get; private set; } /// <summary> /// The milestone, if any, that this pull request is assigned to. /// </summary> - public Milestone Milestone { get; protected set; } + public Milestone Milestone { get; private set; } /// <summary> /// Whether or not the pull request is in a draft state, and cannot be merged. /// </summary> - public bool Draft { get; protected set; } + public bool Draft { get; private set; } /// <summary> /// Whether or not the pull request has been merged. @@ -184,17 +184,17 @@ public bool Merged /// <summary> /// Whether or not the pull request can be merged. /// </summary> - public bool? Mergeable { get; protected set; } + public bool? Mergeable { get; private set; } /// <summary> /// Provides extra information regarding the mergeability of the pull request. /// </summary> - public StringEnum<MergeableState>? MergeableState { get; protected set; } + public StringEnum<MergeableState>? MergeableState { get; private set; } /// <summary> /// The user who merged the pull request. /// </summary> - public User MergedBy { get; protected set; } + public User MergedBy { get; private set; } /// <summary> /// The value of this field changes depending on the state of the pull request. @@ -203,59 +203,59 @@ public bool Merged /// Merged via squashing - the hash of the squashed commit added to the base branch. /// Merged via rebase - the hash of the commit that the base branch was updated to. /// </summary> - public string MergeCommitSha { get; protected set; } + public string MergeCommitSha { get; private set; } /// <summary> /// Total number of comments contained in the pull request. /// </summary> - public int Comments { get; protected set; } + public int Comments { get; private set; } /// <summary> /// Total number of commits contained in the pull request. /// </summary> - public int Commits { get; protected set; } + public int Commits { get; private set; } /// <summary> /// Total number of additions contained in the pull request. /// </summary> - public int Additions { get; protected set; } + public int Additions { get; private set; } /// <summary> /// Total number of deletions contained in the pull request. /// </summary> - public int Deletions { get; protected set; } + public int Deletions { get; private set; } /// <summary> /// Total number of files changed in the pull request. /// </summary> - public int ChangedFiles { get; protected set; } + public int ChangedFiles { get; private set; } /// <summary> /// If the issue is locked or not /// </summary> - public bool Locked { get; protected set; } + public bool Locked { get; private set; } /// <summary> /// Whether maintainers of the base repository can push to the HEAD branch /// </summary> - public bool? MaintainerCanModify { get; protected set; } + public bool? MaintainerCanModify { get; private set; } /// <summary> /// Users requested for review /// </summary> - public IReadOnlyList<User> RequestedReviewers { get; protected set; } + public IReadOnlyList<User> RequestedReviewers { get; private set; } /// <summary> /// Teams requested for review /// </summary> - public IReadOnlyList<Team> RequestedTeams { get; protected set; } + public IReadOnlyList<Team> RequestedTeams { get; private set; } - public IReadOnlyList<Label> Labels { get; protected set; } + public IReadOnlyList<Label> Labels { get; private set; } /// <summary> /// Reason that the conversation was locked /// </summary> - public StringEnum<LockReason>? ActiveLockReason { get; protected set; } + public StringEnum<LockReason>? ActiveLockReason { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PullRequestCommit.cs b/Octokit/Models/Response/PullRequestCommit.cs index e032c309e3..94e1cbe1e7 100644 --- a/Octokit/Models/Response/PullRequestCommit.cs +++ b/Octokit/Models/Response/PullRequestCommit.cs @@ -29,23 +29,23 @@ public PullRequestCommit(string nodeId, User author, string commentsUrl, Commit /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public User Author { get; protected set; } + public User Author { get; private set; } - public string CommentsUrl { get; protected set; } + public string CommentsUrl { get; private set; } - public Commit Commit { get; protected set; } + public Commit Commit { get; private set; } - public User Committer { get; protected set; } + public User Committer { get; private set; } - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } - public IReadOnlyList<GitReference> Parents { get; protected set; } + public IReadOnlyList<GitReference> Parents { get; private set; } - public string Sha { get; protected set; } + public string Sha { get; private set; } - public string Url { get; protected set; } + public string Url { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PullRequestFile.cs b/Octokit/Models/Response/PullRequestFile.cs index 362dfe0adf..9e65a50849 100644 --- a/Octokit/Models/Response/PullRequestFile.cs +++ b/Octokit/Models/Response/PullRequestFile.cs @@ -24,19 +24,19 @@ public PullRequestFile(string sha, string fileName, string status, int additions PreviousFileName = previousFileName; } - public string Sha { get; protected set; } + public string Sha { get; private set; } [Parameter(Key = "filename")] - public string FileName { get; protected set; } - public string Status { get; protected set; } - public int Additions { get; protected set; } - public int Deletions { get; protected set; } - public int Changes { get; protected set; } - public string BlobUrl { get; protected set; } - public string RawUrl { get; protected set; } - public string ContentsUrl { get; protected set; } - public string Patch { get; protected set; } + public string FileName { get; private set; } + public string Status { get; private set; } + public int Additions { get; private set; } + public int Deletions { get; private set; } + public int Changes { get; private set; } + public string BlobUrl { get; private set; } + public string RawUrl { get; private set; } + public string ContentsUrl { get; private set; } + public string Patch { get; private set; } [Parameter(Key = "previous_filename")] - public string PreviousFileName { get; protected set; } + public string PreviousFileName { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PullRequestMerge.cs b/Octokit/Models/Response/PullRequestMerge.cs index 7a1d5d21d1..6669a0cc94 100644 --- a/Octokit/Models/Response/PullRequestMerge.cs +++ b/Octokit/Models/Response/PullRequestMerge.cs @@ -28,17 +28,17 @@ public PullRequestMerge(string sha, bool merged, string message) /// <summary> /// The sha reference of the commit. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// True if merged successfully, otherwise false. /// </summary> - public bool Merged { get; protected set; } + public bool Merged { get; private set; } /// <summary> /// The message that will be used for the merge commit. /// </summary> - public string Message { get; protected set; } + public string Message { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PullRequestReview.cs b/Octokit/Models/Response/PullRequestReview.cs index 2b46cb8bbb..c90cc2ca89 100644 --- a/Octokit/Models/Response/PullRequestReview.cs +++ b/Octokit/Models/Response/PullRequestReview.cs @@ -32,52 +32,52 @@ public PullRequestReview(long id, string nodeId, string commitId, User user, str /// <summary> /// The review Id. /// </summary> - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The state of the review /// </summary> - public StringEnum<PullRequestReviewState> State { get; protected set; } + public StringEnum<PullRequestReviewState> State { get; private set; } /// <summary> /// The commit Id the review is associated with. /// </summary> - public string CommitId { get; protected set; } + public string CommitId { get; private set; } /// <summary> /// The user that created the review. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The text of the review. /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// The URL for this review on Github.com /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The URL for the pull request via the API. /// </summary> - public string PullRequestUrl { get; protected set; } + public string PullRequestUrl { get; private set; } /// <summary> /// The comment author association with repository. /// </summary> - public StringEnum<AuthorAssociation> AuthorAssociation { get; protected set; } + public StringEnum<AuthorAssociation> AuthorAssociation { get; private set; } /// <summary> /// The time the review was submitted /// </summary> - public DateTimeOffset SubmittedAt { get; protected set; } + public DateTimeOffset SubmittedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/PullRequestReviewComment.cs b/Octokit/Models/Response/PullRequestReviewComment.cs index 6f2a96734b..44dbf519e3 100644 --- a/Octokit/Models/Response/PullRequestReviewComment.cs +++ b/Octokit/Models/Response/PullRequestReviewComment.cs @@ -41,97 +41,97 @@ public PullRequestReviewComment(string url, int id, string nodeId, string diffHu /// <summary> /// URL of the comment via the API. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The comment Id. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// The diff hunk the comment is about. /// </summary> - public string DiffHunk { get; protected set; } + public string DiffHunk { get; private set; } /// <summary> /// The relative path of the file the comment is about. /// </summary> - public string Path { get; protected set; } + public string Path { get; private set; } /// <summary> /// The line index in the diff. /// </summary> - public int? Position { get; protected set; } + public int? Position { get; private set; } /// <summary> /// The comment original position. /// </summary> - public int? OriginalPosition { get; protected set; } + public int? OriginalPosition { get; private set; } /// <summary> /// The commit Id the comment is associated with. /// </summary> - public string CommitId { get; protected set; } + public string CommitId { get; private set; } /// <summary> /// The original commit Id the comment is associated with. /// </summary> - public string OriginalCommitId { get; protected set; } + public string OriginalCommitId { get; private set; } /// <summary> /// The user that created the comment. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The text of the comment. /// </summary> - public string Body { get; protected set; } + public string Body { get; private set; } /// <summary> /// The date the comment was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The date the comment was last updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } /// <summary> /// The URL for this comment on Github.com /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// The URL for the pull request via the API. /// </summary> - public string PullRequestUrl { get; protected set; } + public string PullRequestUrl { get; private set; } /// <summary> /// The reaction summary for this comment. /// </summary> - public ReactionSummary Reactions { get; protected set; } + public ReactionSummary Reactions { get; private set; } /// <summary> /// The Id of the comment this comment replys to. /// </summary> - public int? InReplyToId { get; protected set; } + public int? InReplyToId { get; private set; } /// <summary> /// The Id of the pull request this comment belongs to. /// </summary> - public int? PullRequestReviewId { get; protected set; } + public int? PullRequestReviewId { get; private set; } /// <summary> /// The comment author association with repository. /// </summary> - public StringEnum<AuthorAssociation> AuthorAssociation { get; protected set; } + public StringEnum<AuthorAssociation> AuthorAssociation { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Reaction.cs b/Octokit/Models/Response/Reaction.cs index 41a171a350..3b6ba7f44d 100644 --- a/Octokit/Models/Response/Reaction.cs +++ b/Octokit/Models/Response/Reaction.cs @@ -47,23 +47,23 @@ public Reaction(int id, string nodeId, User user, ReactionType content) /// <summary> /// The Id for this reaction. /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// Information about the user. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } /// <summary> /// The reaction type for this commit comment. /// </summary> [Parameter(Key = "content")] - public StringEnum<ReactionType> Content { get; protected set; } + public StringEnum<ReactionType> Content { get; private set; } internal string DebuggerDisplay { @@ -74,4 +74,3 @@ internal string DebuggerDisplay } } } - diff --git a/Octokit/Models/Response/ReactionSummary.cs b/Octokit/Models/Response/ReactionSummary.cs index 96ef77a8de..59dd350754 100644 --- a/Octokit/Models/Response/ReactionSummary.cs +++ b/Octokit/Models/Response/ReactionSummary.cs @@ -21,16 +21,16 @@ public ReactionSummary(int totalCount, int plus1, int minus1, int laugh, int con Url = url; } - public int TotalCount { get; protected set; } + public int TotalCount { get; private set; } [Parameter(Key = "+1")] - public int Plus1 { get; protected set; } + public int Plus1 { get; private set; } [Parameter(Key = "-1")] - public int Minus1 { get; protected set; } - public int Laugh { get; protected set; } - public int Confused { get; protected set; } - public int Heart { get; protected set; } - public int Hooray { get; protected set; } - public string Url { get; protected set; } + public int Minus1 { get; private set; } + public int Laugh { get; private set; } + public int Confused { get; private set; } + public int Heart { get; private set; } + public int Hooray { get; private set; } + public string Url { get; private set; } internal string DebuggerDisplay { @@ -49,4 +49,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/ReadmeResponse.cs b/Octokit/Models/Response/ReadmeResponse.cs index 082565216d..dbb3383228 100644 --- a/Octokit/Models/Response/ReadmeResponse.cs +++ b/Octokit/Models/Response/ReadmeResponse.cs @@ -13,10 +13,10 @@ public ReadmeResponse(string content, string name, string htmlUrl, string url, s Encoding = encoding; } - public string Content { get; protected set; } - public string Name { get; protected set; } - public string HtmlUrl { get; protected set; } - public string Url { get; protected set; } - public string Encoding { get; protected set; } + public string Content { get; private set; } + public string Name { get; private set; } + public string HtmlUrl { get; private set; } + public string Url { get; private set; } + public string Encoding { get; private set; } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Reference.cs b/Octokit/Models/Response/Reference.cs index 9cde85b692..f3b52611dc 100644 --- a/Octokit/Models/Response/Reference.cs +++ b/Octokit/Models/Response/Reference.cs @@ -16,16 +16,16 @@ public Reference(string @ref, string nodeId, string url, TagObject @object) Object = @object; } - public string Ref { get; protected set; } + public string Ref { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public string Url { get; protected set; } + public string Url { get; private set; } - public TagObject Object { get; protected set; } + public TagObject Object { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Release.cs b/Octokit/Models/Response/Release.cs index 008a752e6c..b2335262b5 100644 --- a/Octokit/Models/Response/Release.cs +++ b/Octokit/Models/Response/Release.cs @@ -39,44 +39,44 @@ public Release(string uploadUrl) UploadUrl = uploadUrl; } - public string Url { get; protected set; } + public string Url { get; private set; } - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } - public string AssetsUrl { get; protected set; } + public string AssetsUrl { get; private set; } - public string UploadUrl { get; protected set; } + public string UploadUrl { get; private set; } - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public string TagName { get; protected set; } + public string TagName { get; private set; } - public string TargetCommitish { get; protected set; } + public string TargetCommitish { get; private set; } - public string Name { get; protected set; } + public string Name { get; private set; } - public string Body { get; protected set; } + public string Body { get; private set; } - public bool Draft { get; protected set; } + public bool Draft { get; private set; } - public bool Prerelease { get; protected set; } + public bool Prerelease { get; private set; } - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } - public DateTimeOffset? PublishedAt { get; protected set; } + public DateTimeOffset? PublishedAt { get; private set; } - public Author Author { get; protected set; } + public Author Author { get; private set; } - public string TarballUrl { get; protected set; } + public string TarballUrl { get; private set; } - public string ZipballUrl { get; protected set; } + public string ZipballUrl { get; private set; } - public IReadOnlyList<ReleaseAsset> Assets { get; protected set; } + public IReadOnlyList<ReleaseAsset> Assets { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ReleaseAsset.cs b/Octokit/Models/Response/ReleaseAsset.cs index 13b33a3955..bec638a4b0 100644 --- a/Octokit/Models/Response/ReleaseAsset.cs +++ b/Octokit/Models/Response/ReleaseAsset.cs @@ -26,34 +26,34 @@ public ReleaseAsset(string url, int id, string nodeId, string name, string label Uploader = uploader; } - public string Url { get; protected set; } + public string Url { get; private set; } - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public string Name { get; protected set; } + public string Name { get; private set; } - public string Label { get; protected set; } + public string Label { get; private set; } - public string State { get; protected set; } + public string State { get; private set; } - public string ContentType { get; protected set; } + public string ContentType { get; private set; } - public int Size { get; protected set; } + public int Size { get; private set; } - public int DownloadCount { get; protected set; } + public int DownloadCount { get; private set; } - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } - public string BrowserDownloadUrl { get; protected set; } + public string BrowserDownloadUrl { get; private set; } - public Author Uploader { get; protected set; } + public Author Uploader { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RenameInfo.cs b/Octokit/Models/Response/RenameInfo.cs index baf3bc8b35..1fb7332595 100644 --- a/Octokit/Models/Response/RenameInfo.cs +++ b/Octokit/Models/Response/RenameInfo.cs @@ -14,8 +14,8 @@ public RenameInfo(string from, string to) To = to; } - public string From { get; protected set; } - public string To { get; protected set; } + public string From { get; private set; } + public string To { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RepositoriesResponse.cs b/Octokit/Models/Response/RepositoriesResponse.cs index dd1f783372..cf17e710b2 100644 --- a/Octokit/Models/Response/RepositoriesResponse.cs +++ b/Octokit/Models/Response/RepositoriesResponse.cs @@ -20,13 +20,13 @@ public RepositoriesResponse(int totalCount, IReadOnlyList<Repository> repositori /// <summary> /// The total number of check suites that match the request filter /// </summary> - public int TotalCount { get; protected set; } + public int TotalCount { get; private set; } /// <summary> /// The retrieved check suites /// </summary> - public IReadOnlyList<Repository> Repositories { get; protected set; } + public IReadOnlyList<Repository> Repositories { get; private set; } internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, Repositories: {1}", TotalCount, Repositories.Count); } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 33e53e1a56..ba7b2c697f 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -67,97 +67,97 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st AllowAutoMerge = allowAutoMerge; } - public string Url { get; protected set; } + public string Url { get; private set; } - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } - public string CloneUrl { get; protected set; } + public string CloneUrl { get; private set; } - public string GitUrl { get; protected set; } + public string GitUrl { get; private set; } - public string SshUrl { get; protected set; } + public string SshUrl { get; private set; } - public string SvnUrl { get; protected set; } + public string SvnUrl { get; private set; } - public string MirrorUrl { get; protected set; } + public string MirrorUrl { get; private set; } - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public User Owner { get; protected set; } + public User Owner { get; private set; } - public string Name { get; protected set; } + public string Name { get; private set; } - public string FullName { get; protected set; } + public string FullName { get; private set; } - public bool IsTemplate { get; protected set; } + public bool IsTemplate { get; private set; } - public string Description { get; protected set; } + public string Description { get; private set; } - public string Homepage { get; protected set; } + public string Homepage { get; private set; } - public string Language { get; protected set; } + public string Language { get; private set; } - public bool Private { get; protected set; } + public bool Private { get; private set; } - public bool Fork { get; protected set; } + public bool Fork { get; private set; } - public int ForksCount { get; protected set; } + public int ForksCount { get; private set; } - public int StargazersCount { get; protected set; } + public int StargazersCount { get; private set; } [Obsolete("WatchersCount returns the same data as StargazersCount. You are likely looking to use SubscribersCount. Update your code to use SubscribersCount, as this field will stop containing data in the future")] - public int WatchersCount { get; protected set; } + public int WatchersCount { get; private set; } - public string DefaultBranch { get; protected set; } + public string DefaultBranch { get; private set; } - public int OpenIssuesCount { get; protected set; } + public int OpenIssuesCount { get; private set; } - public DateTimeOffset? PushedAt { get; protected set; } + public DateTimeOffset? PushedAt { get; private set; } - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } - public RepositoryPermissions Permissions { get; protected set; } + public RepositoryPermissions Permissions { get; private set; } - public Repository Parent { get; protected set; } + public Repository Parent { get; private set; } - public Repository Source { get; protected set; } + public Repository Source { get; private set; } - public LicenseMetadata License { get; protected set; } + public LicenseMetadata License { get; private set; } - public bool HasIssues { get; protected set; } + public bool HasIssues { get; private set; } - public bool HasWiki { get; protected set; } + public bool HasWiki { get; private set; } - public bool HasDownloads { get; protected set; } + public bool HasDownloads { get; private set; } - public bool? AllowRebaseMerge { get; protected set; } + public bool? AllowRebaseMerge { get; private set; } - public bool? AllowSquashMerge { get; protected set; } + public bool? AllowSquashMerge { get; private set; } - public bool? AllowMergeCommit { get; protected set; } + public bool? AllowMergeCommit { get; private set; } - public bool HasPages { get; protected set; } + public bool HasPages { get; private set; } - public int SubscribersCount { get; protected set; } + public int SubscribersCount { get; private set; } - public long Size { get; protected set; } + public long Size { get; private set; } - public bool Archived { get; protected set; } + public bool Archived { get; private set; } - public IReadOnlyList<string> Topics { get; protected set; } + public IReadOnlyList<string> Topics { get; private set; } - public bool? DeleteBranchOnMerge { get; protected set; } + public bool? DeleteBranchOnMerge { get; private set; } - public RepositoryVisibility? Visibility { get; protected set; } + public RepositoryVisibility? Visibility { get; private set; } - public bool? AllowAutoMerge { get; protected set; } + public bool? AllowAutoMerge { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RepositoryContent.cs b/Octokit/Models/Response/RepositoryContent.cs index e75875368a..a0f3637b58 100644 --- a/Octokit/Models/Response/RepositoryContent.cs +++ b/Octokit/Models/Response/RepositoryContent.cs @@ -24,7 +24,7 @@ public RepositoryContent(string name, string path, string sha, int size, Content /// <summary> /// The encoding of the content if this is a file. Typically "base64". Otherwise it's null. /// </summary> - public string Encoding { get; protected set; } + public string Encoding { get; private set; } /// <summary> /// The Base64 encoded content if this is a file. Otherwise it's null. @@ -48,11 +48,11 @@ public string Content /// <summary> /// Path to the target file in the repository if this is a symlink. Otherwise it's null. /// </summary> - public string Target { get; protected set; } + public string Target { get; private set; } /// <summary> /// The location of the submodule repository if this is a submodule. Otherwise it's null. /// </summary> - public string SubmoduleGitUrl { get; protected set; } + public string SubmoduleGitUrl { get; private set; } } } diff --git a/Octokit/Models/Response/RepositoryContentChangeSet.cs b/Octokit/Models/Response/RepositoryContentChangeSet.cs index 29e3dd4012..647219662a 100644 --- a/Octokit/Models/Response/RepositoryContentChangeSet.cs +++ b/Octokit/Models/Response/RepositoryContentChangeSet.cs @@ -21,16 +21,16 @@ public RepositoryContentChangeSet(RepositoryContentInfo content, Commit commit) /// <summary> /// The content of the response. /// </summary> - public RepositoryContentInfo Content { get; protected set; } + public RepositoryContentInfo Content { get; private set; } /// <summary> /// The commit information for the content change. /// </summary> - public Commit Commit { get; protected set; } + public Commit Commit { get; private set; } internal string DebuggerDisplay { get { return Content.DebuggerDisplay; } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/RepositoryContentLicense.cs b/Octokit/Models/Response/RepositoryContentLicense.cs index 65a9515859..12b96d0fae 100644 --- a/Octokit/Models/Response/RepositoryContentLicense.cs +++ b/Octokit/Models/Response/RepositoryContentLicense.cs @@ -21,7 +21,7 @@ public RepositoryContentLicense() /// <summary> /// License information /// </summary> - public LicenseMetadata License { get; protected set; } + public LicenseMetadata License { get; private set; } internal new string DebuggerDisplay { diff --git a/Octokit/Models/Response/RepositoryContributor.cs b/Octokit/Models/Response/RepositoryContributor.cs index 2c3d0e3262..17f864f003 100644 --- a/Octokit/Models/Response/RepositoryContributor.cs +++ b/Octokit/Models/Response/RepositoryContributor.cs @@ -16,6 +16,6 @@ public RepositoryContributor(string login, int id, string nodeId, string avatarU Contributions = contributions; } - public int Contributions { get; protected set; } + public int Contributions { get; private set; } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/RepositoryInvitation.cs b/Octokit/Models/Response/RepositoryInvitation.cs index fe5a86fcda..98b027e553 100644 --- a/Octokit/Models/Response/RepositoryInvitation.cs +++ b/Octokit/Models/Response/RepositoryInvitation.cs @@ -35,26 +35,26 @@ public RepositoryInvitation(int id, string nodeId, Repository repository, User i HtmlUrl = htmlUrl; } - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public Repository Repository { get; protected set; } + public Repository Repository { get; private set; } - public User Invitee { get; protected set; } + public User Invitee { get; private set; } - public User Inviter { get; protected set; } + public User Inviter { get; private set; } - public StringEnum<InvitationPermissionType> Permissions { get; protected set; } + public StringEnum<InvitationPermissionType> Permissions { get; private set; } - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } - public string Url { get; protected set; } + public string Url { get; private set; } - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RepositoryLanguage.cs b/Octokit/Models/Response/RepositoryLanguage.cs index 6a63120b5d..ac5055de4d 100644 --- a/Octokit/Models/Response/RepositoryLanguage.cs +++ b/Octokit/Models/Response/RepositoryLanguage.cs @@ -15,9 +15,9 @@ public RepositoryLanguage(string name, long numberOfBytes) NumberOfBytes = numberOfBytes; } - public string Name { get; protected set; } + public string Name { get; private set; } - public long NumberOfBytes { get; protected set; } + public long NumberOfBytes { get; private set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal string DebuggerDisplay diff --git a/Octokit/Models/Response/RepositoryStar.cs b/Octokit/Models/Response/RepositoryStar.cs index dd51445dd5..4f7961c9e3 100644 --- a/Octokit/Models/Response/RepositoryStar.cs +++ b/Octokit/Models/Response/RepositoryStar.cs @@ -21,12 +21,12 @@ public RepositoryStar(DateTimeOffset starredAt, Repository repo) /// <summary> /// The date the star was created. /// </summary> - public DateTimeOffset StarredAt { get; protected set; } + public DateTimeOffset StarredAt { get; private set; } /// <summary> /// The repository associated with the star. /// </summary> - public Repository Repo { get; protected set; } + public Repository Repo { get; private set; } internal string DebuggerDisplay { @@ -36,4 +36,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/RepositoryTag.cs b/Octokit/Models/Response/RepositoryTag.cs index 74c0769246..baaef2f2a5 100644 --- a/Octokit/Models/Response/RepositoryTag.cs +++ b/Octokit/Models/Response/RepositoryTag.cs @@ -21,20 +21,20 @@ public RepositoryTag(string name, string nodeId, GitReference commit, string zip TarballUrl = tarballUrl; } - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public GitReference Commit { get; protected set; } + public GitReference Commit { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Zipball")] - public string ZipballUrl { get; protected set; } + public string ZipballUrl { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Tarball")] - public string TarballUrl { get; protected set; } + public string TarballUrl { get; private set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal string DebuggerDisplay diff --git a/Octokit/Models/Response/RepositoryTopics.cs b/Octokit/Models/Response/RepositoryTopics.cs index 93af0fd073..4281d355bb 100644 --- a/Octokit/Models/Response/RepositoryTopics.cs +++ b/Octokit/Models/Response/RepositoryTopics.cs @@ -18,7 +18,7 @@ public RepositoryTopics(IEnumerable<string> names) Names = new ReadOnlyCollection<string>(initialItems); } - public IReadOnlyList<string> Names { get; protected set; } + public IReadOnlyList<string> Names { get; private set; } [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal string DebuggerDisplay diff --git a/Octokit/Models/Response/RepositoryTrafficClone.cs b/Octokit/Models/Response/RepositoryTrafficClone.cs index 9d96eb280e..d0fc1cb5d7 100644 --- a/Octokit/Models/Response/RepositoryTrafficClone.cs +++ b/Octokit/Models/Response/RepositoryTrafficClone.cs @@ -20,12 +20,12 @@ public RepositoryTrafficCloneSummary(int count, int uniques, IReadOnlyList<Repos Clones = clones; } - public int Count { get; protected set; } + public int Count { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")] - public int Uniques { get; protected set; } + public int Uniques { get; private set; } - public IReadOnlyList<RepositoryTrafficClone> Clones { get; protected set; } + public IReadOnlyList<RepositoryTrafficClone> Clones { get; private set; } internal string DebuggerDisplay { @@ -46,12 +46,12 @@ public RepositoryTrafficClone(DateTimeOffset timestamp, int count, int uniques) Uniques = uniques; } - public DateTimeOffset Timestamp { get; protected set; } + public DateTimeOffset Timestamp { get; private set; } - public int Count { get; protected set; } + public int Count { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")] - public int Uniques { get; protected set; } + public int Uniques { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RepositoryTrafficPath.cs b/Octokit/Models/Response/RepositoryTrafficPath.cs index fcac8cccc7..5adf2086b9 100644 --- a/Octokit/Models/Response/RepositoryTrafficPath.cs +++ b/Octokit/Models/Response/RepositoryTrafficPath.cs @@ -18,14 +18,14 @@ public RepositoryTrafficPath(string path, string title, int count, int uniques) Uniques = uniques; } - public string Path { get; protected set; } + public string Path { get; private set; } - public string Title { get; protected set; } + public string Title { get; private set; } - public int Count { get; protected set; } + public int Count { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")] - public int Uniques { get; protected set; } + public int Uniques { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RepositoryTrafficReferrer.cs b/Octokit/Models/Response/RepositoryTrafficReferrer.cs index cc4d893234..d94f45cfea 100644 --- a/Octokit/Models/Response/RepositoryTrafficReferrer.cs +++ b/Octokit/Models/Response/RepositoryTrafficReferrer.cs @@ -17,12 +17,12 @@ public RepositoryTrafficReferrer(string referrer, int count, int uniques) Uniques = uniques; } - public string Referrer { get; protected set; } + public string Referrer { get; private set; } - public int Count { get; protected set; } + public int Count { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")] - public int Uniques { get; protected set; } + public int Uniques { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RepositoryTrafficView.cs b/Octokit/Models/Response/RepositoryTrafficView.cs index 259ec6c715..6b19cd7ceb 100644 --- a/Octokit/Models/Response/RepositoryTrafficView.cs +++ b/Octokit/Models/Response/RepositoryTrafficView.cs @@ -19,12 +19,12 @@ public RepositoryTrafficViewSummary(int count, int uniques, IReadOnlyList<Reposi Views = views; } - public int Count { get; protected set; } + public int Count { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")] - public int Uniques { get; protected set; } + public int Uniques { get; private set; } - public IReadOnlyList<RepositoryTrafficView> Views { get; protected set; } + public IReadOnlyList<RepositoryTrafficView> Views { get; private set; } internal string DebuggerDisplay { @@ -45,12 +45,12 @@ public RepositoryTrafficView(DateTimeOffset timestamp, int count, int uniques) Uniques = uniques; } - public DateTimeOffset Timestamp { get; protected set; } + public DateTimeOffset Timestamp { get; private set; } - public int Count { get; protected set; } + public int Count { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Justification = "It's a property from the api.")] - public int Uniques { get; protected set; } + public int Uniques { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/RequestedReviews.cs b/Octokit/Models/Response/RequestedReviews.cs index cbceff3469..31229264f2 100644 --- a/Octokit/Models/Response/RequestedReviews.cs +++ b/Octokit/Models/Response/RequestedReviews.cs @@ -22,8 +22,8 @@ public RequestedReviews(IReadOnlyList<User> users, IReadOnlyList<Team> teams) Users = users; Teams = teams; } - public IReadOnlyList<User> Users { get; protected set; } - public IReadOnlyList<Team> Teams { get; protected set; } + public IReadOnlyList<User> Users { get; private set; } + public IReadOnlyList<Team> Teams { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/SearchCode.cs b/Octokit/Models/Response/SearchCode.cs index e1d242392a..b1e28bee1b 100644 --- a/Octokit/Models/Response/SearchCode.cs +++ b/Octokit/Models/Response/SearchCode.cs @@ -22,37 +22,37 @@ public SearchCode(string name, string path, string sha, string url, string gitUr /// <summary> /// file name /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// path to file /// </summary> - public string Path { get; protected set; } + public string Path { get; private set; } /// <summary> /// Sha for file /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// api-url to file /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// git-url to file /// </summary> - public string GitUrl { get; protected set; } + public string GitUrl { get; private set; } /// <summary> /// html-url to file /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// Repo where this file belongs to /// </summary> - public Repository Repository { get; protected set; } + public Repository Repository { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/SourceInfo.cs b/Octokit/Models/Response/SourceInfo.cs index 06cb292e3b..cc3efc1f70 100644 --- a/Octokit/Models/Response/SourceInfo.cs +++ b/Octokit/Models/Response/SourceInfo.cs @@ -16,10 +16,10 @@ public SourceInfo(User actor, int id, Issue issue, string url) Url = url; } - public User Actor { get; protected set; } - public int Id { get; protected set; } - public Issue Issue { get; protected set; } - public string Url { get; protected set; } + public User Actor { get; private set; } + public int Id { get; private set; } + public Issue Issue { get; private set; } + public string Url { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Subscription.cs b/Octokit/Models/Response/Subscription.cs index 7dacae0aa4..7ef1334e8e 100644 --- a/Octokit/Models/Response/Subscription.cs +++ b/Octokit/Models/Response/Subscription.cs @@ -22,32 +22,32 @@ public Subscription(bool subscribed, bool ignored, string reason, DateTimeOffset /// <summary> /// Determines if notifications should be received from this repository. /// </summary> - public bool Subscribed { get; protected set; } + public bool Subscribed { get; private set; } /// <summary> /// Determines if all notifications should be blocked from this repository. /// </summary> - public bool Ignored { get; protected set; } + public bool Ignored { get; private set; } /// <summary> /// Url of the label /// </summary> - public string Reason { get; protected set; } + public string Reason { get; private set; } /// <summary> /// The <see cref="DateTimeOffset"/> for when this <see cref="Subscription"/> was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The API URL for this <see cref="Subscription"/>. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The API URL for this <see cref="Repository"/>. /// </summary> - public string RepositoryUrl { get; protected set; } + public string RepositoryUrl { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/TagObject.cs b/Octokit/Models/Response/TagObject.cs index 0ffa976dfe..ba6213b447 100644 --- a/Octokit/Models/Response/TagObject.cs +++ b/Octokit/Models/Response/TagObject.cs @@ -17,7 +17,7 @@ public TagObject(string nodeId, string url, string label, string @ref, string sh [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "Name defined by web api and required for deserialization")] - public StringEnum<TaggedType> Type { get; protected set; } + public StringEnum<TaggedType> Type { get; private set; } } /// <summary> @@ -37,4 +37,4 @@ public enum TaggedType [Parameter(Value = "tag")] Tag } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Team.cs b/Octokit/Models/Response/Team.cs index 99aaedd4d3..99fba9ecca 100644 --- a/Octokit/Models/Response/Team.cs +++ b/Octokit/Models/Response/Team.cs @@ -33,73 +33,73 @@ public Team(string url, string htmlUrl, int id, string nodeId, string slug, stri /// <summary> /// url for this team /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The HTML URL for this team. /// </summary> - public string HtmlUrl { get; protected set; } + public string HtmlUrl { get; private set; } /// <summary> /// team id /// </summary> - public int Id { get; protected set; } + public int Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } /// <summary> /// team slug /// </summary> - public string Slug { get; protected set; } + public string Slug { get; private set; } /// <summary> /// team name /// </summary> - public string Name { get; protected set; } + public string Name { get; private set; } /// <summary> /// team description /// </summary> - public string Description { get; protected set; } + public string Description { get; private set; } /// <summary> /// team privacy /// </summary> - public StringEnum<TeamPrivacy> Privacy { get; protected set; } + public StringEnum<TeamPrivacy> Privacy { get; private set; } /// <summary> /// permission attached to this team /// </summary> - public StringEnum<PermissionLevel> Permission { get; protected set; } + public StringEnum<PermissionLevel> Permission { get; private set; } /// <summary> /// how many members in this team /// </summary> - public int MembersCount { get; protected set; } + public int MembersCount { get; private set; } /// <summary> /// how many repo this team has access to /// </summary> - public int ReposCount { get; protected set; } + public int ReposCount { get; private set; } /// <summary> /// who this team belongs to /// </summary> - public Organization Organization { get; protected set; } + public Organization Organization { get; private set; } /// <summary> /// The parent team /// </summary> - public Team Parent { get; protected set; } + public Team Parent { get; private set; } /// <summary> /// LDAP Binding (GitHub Enterprise only) /// </summary> [Parameter(Key = "ldap_dn")] - public string LdapDistinguishedName { get; protected set; } + public string LdapDistinguishedName { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/TeamMembershipDetails.cs b/Octokit/Models/Response/TeamMembershipDetails.cs index dbc1c75de8..d032249c24 100644 --- a/Octokit/Models/Response/TeamMembershipDetails.cs +++ b/Octokit/Models/Response/TeamMembershipDetails.cs @@ -15,9 +15,9 @@ public TeamMembershipDetails(TeamRole role, MembershipState state) State = state; } - public StringEnum<TeamRole> Role { get; protected set; } + public StringEnum<TeamRole> Role { get; private set; } - public StringEnum<MembershipState> State { get; protected set; } + public StringEnum<MembershipState> State { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ThreadSubscription.cs b/Octokit/Models/Response/ThreadSubscription.cs index 2a8688827a..533e2847a3 100644 --- a/Octokit/Models/Response/ThreadSubscription.cs +++ b/Octokit/Models/Response/ThreadSubscription.cs @@ -22,32 +22,32 @@ public ThreadSubscription(bool subscribed, bool ignored, string reason, DateTime /// <summary> /// Determines if notifications should be received from this repository. /// </summary> - public bool Subscribed { get; protected set; } + public bool Subscribed { get; private set; } /// <summary> /// Determines if all notifications should be blocked from this repository. /// </summary> - public bool Ignored { get; protected set; } + public bool Ignored { get; private set; } /// <summary> /// Url of the label /// </summary> - public string Reason { get; protected set; } + public string Reason { get; private set; } /// <summary> /// The <see cref="DateTimeOffset"/> for when this <see cref="Subscription"/> was created. /// </summary> - public DateTimeOffset CreatedAt { get; protected set; } + public DateTimeOffset CreatedAt { get; private set; } /// <summary> /// The API URL for this <see cref="Subscription"/>. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The API URL for this thread. /// </summary> - public string ThreadUrl { get; protected set; } + public string ThreadUrl { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/TimelineEventInfo.cs b/Octokit/Models/Response/TimelineEventInfo.cs index f9fb50f328..cefc1771ac 100644 --- a/Octokit/Models/Response/TimelineEventInfo.cs +++ b/Octokit/Models/Response/TimelineEventInfo.cs @@ -26,39 +26,39 @@ public TimelineEventInfo(long id, string nodeId, string url, User actor, string ProjectCard = projectCard; } - public long Id { get; protected set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id /// </summary> - public string NodeId { get; protected set; } + public string NodeId { get; private set; } - public string Url { get; protected set; } - public User Actor { get; protected set; } - public string CommitId { get; protected set; } - public StringEnum<EventInfoState> Event { get; protected set; } - public DateTimeOffset CreatedAt { get; protected set; } - public Label Label { get; protected set; } - public User Assignee { get; protected set; } - public Milestone Milestone { get; protected set; } + public string Url { get; private set; } + public User Actor { get; private set; } + public string CommitId { get; private set; } + public StringEnum<EventInfoState> Event { get; private set; } + public DateTimeOffset CreatedAt { get; private set; } + public Label Label { get; private set; } + public User Assignee { get; private set; } + public Milestone Milestone { get; private set; } /// <summary> /// The source of reference from another issue /// Only provided for cross-referenced events /// </summary> - public SourceInfo Source { get; protected set; } + public SourceInfo Source { get; private set; } /// <summary> /// An object containing rename details /// Only provided for renamed events /// </summary> - public RenameInfo Rename { get; protected set; } + public RenameInfo Rename { get; private set; } /// <summary> /// The name of the column that the card was listed in prior to column_name. /// Only returned for moved_columns_in_project events /// </summary> - public IssueEventProjectCard ProjectCard { get; protected set; } + public IssueEventProjectCard ProjectCard { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/TreeItem.cs b/Octokit/Models/Response/TreeItem.cs index eb4a326239..60612e8d8f 100644 --- a/Octokit/Models/Response/TreeItem.cs +++ b/Octokit/Models/Response/TreeItem.cs @@ -23,33 +23,33 @@ public TreeItem(string path, string mode, TreeType type, int size, string sha, s /// <summary> /// The path for this Tree Item. /// </summary> - public string Path { get; protected set; } + public string Path { get; private set; } /// <summary> /// The mode of this Tree Item. /// </summary> - public string Mode { get; protected set; } + public string Mode { get; private set; } /// <summary> /// The type of this Tree Item. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] - public StringEnum<TreeType> Type { get; protected set; } + public StringEnum<TreeType> Type { get; private set; } /// <summary> /// The size of this Tree Item. /// </summary> - public int Size { get; protected set; } + public int Size { get; private set; } /// <summary> /// The SHA of this Tree Item. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// The URL of this Tree Item. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } internal string DebuggerDisplay { @@ -97,4 +97,4 @@ public static class FileMode [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Symlink")] public const string Symlink = "120000"; } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/TreeResponse.cs b/Octokit/Models/Response/TreeResponse.cs index 60051af7cc..ae4dd23b66 100644 --- a/Octokit/Models/Response/TreeResponse.cs +++ b/Octokit/Models/Response/TreeResponse.cs @@ -20,22 +20,22 @@ public TreeResponse(string sha, string url, IReadOnlyList<TreeItem> tree, bool t /// <summary> /// The SHA for this Tree response. /// </summary> - public string Sha { get; protected set; } + public string Sha { get; private set; } /// <summary> /// The URL for this Tree response. /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } /// <summary> /// The list of Tree Items for this Tree response. /// </summary> - public IReadOnlyList<TreeItem> Tree { get; protected set; } + public IReadOnlyList<TreeItem> Tree { get; private set; } /// <summary> /// Whether the response was truncated due to GitHub API limits. /// </summary> - public bool Truncated { get; protected set; } + public bool Truncated { get; private set; } internal string DebuggerDisplay { @@ -45,4 +45,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/User.cs b/Octokit/Models/Response/User.cs index 96a2c611a1..363f1d80a2 100644 --- a/Octokit/Models/Response/User.cs +++ b/Octokit/Models/Response/User.cs @@ -24,17 +24,17 @@ public User(string avatarUrl, string bio, string blog, int collaborators, string UpdatedAt = updatedAt; } - public RepositoryPermissions Permissions { get; protected set; } + public RepositoryPermissions Permissions { get; private set; } /// <summary> /// Whether or not the user is an administrator of the site /// </summary> - public bool SiteAdmin { get; protected set; } + public bool SiteAdmin { get; private set; } /// <summary> /// When the user was suspended, if at all (GitHub Enterprise) /// </summary> - public DateTimeOffset? SuspendedAt { get; protected set; } + public DateTimeOffset? SuspendedAt { get; private set; } /// <summary> /// Whether or not the user is currently suspended @@ -45,12 +45,12 @@ public User(string avatarUrl, string bio, string blog, int collaborators, string /// LDAP Binding (GitHub Enterprise only) /// </summary> [Parameter(Key = "ldap_dn")] - public string LdapDistinguishedName { get; protected set; } + public string LdapDistinguishedName { get; private set; } /// <summary> /// Date the user account was updated. /// </summary> - public DateTimeOffset UpdatedAt { get; protected set; } + public DateTimeOffset UpdatedAt { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/UserRenameResponse.cs b/Octokit/Models/Response/UserRenameResponse.cs index d416adbae5..91b5f9e4a1 100644 --- a/Octokit/Models/Response/UserRenameResponse.cs +++ b/Octokit/Models/Response/UserRenameResponse.cs @@ -20,12 +20,12 @@ public UserRenameResponse(string message, string url) /// <summary> /// Message indicating if the Rename request was queued /// </summary> - public string Message { get; protected set; } + public string Message { get; private set; } /// <summary> /// Url to the user that will be renamed /// </summary> - public string Url { get; protected set; } + public string Url { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/UserStar.cs b/Octokit/Models/Response/UserStar.cs index 0e4e498b83..566bbe4b7a 100644 --- a/Octokit/Models/Response/UserStar.cs +++ b/Octokit/Models/Response/UserStar.cs @@ -21,12 +21,12 @@ public UserStar(DateTimeOffset starredAt, User user) /// <summary> /// The date the star was created. /// </summary> - public DateTimeOffset StarredAt { get; protected set; } + public DateTimeOffset StarredAt { get; private set; } /// <summary> /// The user associated with the star. /// </summary> - public User User { get; protected set; } + public User User { get; private set; } internal string DebuggerDisplay { @@ -36,4 +36,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Verification.cs b/Octokit/Models/Response/Verification.cs index 03695fba5a..6349d6c20a 100644 --- a/Octokit/Models/Response/Verification.cs +++ b/Octokit/Models/Response/Verification.cs @@ -23,23 +23,23 @@ public Verification(bool verified, VerificationReason reason, string signature, /// <summary> /// Does GitHub consider the signature in this commit to be verified? /// </summary> - public bool Verified { get; protected set; } + public bool Verified { get; private set; } /// <summary> /// The reason for verified value. /// </summary> [Parameter(Key = "reason")] - public StringEnum<VerificationReason> Reason { get; protected set; } + public StringEnum<VerificationReason> Reason { get; private set; } /// <summary> /// The signature that was extracted from the commit. /// </summary> - public string Signature { get; protected set; } + public string Signature { get; private set; } /// <summary> /// The value that was signed. /// </summary> - public string Payload { get; protected set; } + public string Payload { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/WeeklyCommitActivity.cs b/Octokit/Models/Response/WeeklyCommitActivity.cs index 1b7112206d..5752da135c 100644 --- a/Octokit/Models/Response/WeeklyCommitActivity.cs +++ b/Octokit/Models/Response/WeeklyCommitActivity.cs @@ -24,17 +24,17 @@ public WeeklyCommitActivity(IEnumerable<int> days, int total, long week) /// <summary> /// The days array is a group of commits per day, starting on Sunday. /// </summary> - public IReadOnlyList<int> Days { get; protected set; } + public IReadOnlyList<int> Days { get; private set; } /// <summary> /// Totally number of commits made this week. /// </summary> - public int Total { get; protected set; } + public int Total { get; private set; } /// <summary> /// The week of commits /// </summary> - public long Week { get; protected set; } + public long Week { get; private set; } public DateTimeOffset WeekTimestamp => DateTimeOffset.FromUnixTimeSeconds(Week); diff --git a/Octokit/Models/Response/WeeklyHash.cs b/Octokit/Models/Response/WeeklyHash.cs index 8e06d0b320..4aaa081db5 100644 --- a/Octokit/Models/Response/WeeklyHash.cs +++ b/Octokit/Models/Response/WeeklyHash.cs @@ -23,16 +23,16 @@ public WeeklyHash(long w, int a, int d, int c) } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "W")] - public long W { get; protected set; } + public long W { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "A")] - public int A { get; protected set; } + public int A { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "D")] - public int D { get; protected set; } + public int D { get; private set; } [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "C")] - public int C { get; protected set; } + public int C { get; private set; } public DateTimeOffset Week { From 098557b767dcb7529772908b78be87db2ef5be96 Mon Sep 17 00:00:00 2001 From: Hans Bakker <hansmbakker+github@gmail.com> Date: Mon, 12 Sep 2022 20:37:54 +0200 Subject: [PATCH 126/209] Adds missing fields for deployments API (#2560) --- .../Octokit.Tests.Conventions.csproj | 2 +- .../Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Models/DeploymentTests.cs | 32 +++++++++++++------ Octokit.Tests/Octokit.Tests.csproj | 2 +- Octokit/Models/Response/Deployment.cs | 28 ++++++++++++++-- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 45889e08bf..7b0589b97c 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -4,7 +4,7 @@ <Description>Convention-based tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Conventions</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks> + <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Conventions</AssemblyName> <PackageId>Octokit.Tests.Conventions</PackageId> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index ac2ff55db3..ae37077f7a 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -4,7 +4,7 @@ <Description>Integration tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Integration</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks> + <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Integration</AssemblyName> <PackageId>Octokit.Tests.Integration</PackageId> diff --git a/Octokit.Tests/Models/DeploymentTests.cs b/Octokit.Tests/Models/DeploymentTests.cs index b1630152de..152bb8d2a5 100644 --- a/Octokit.Tests/Models/DeploymentTests.cs +++ b/Octokit.Tests/Models/DeploymentTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Security.Policy; using Octokit.Internal; using Xunit; @@ -13,10 +14,10 @@ public void CanSerialize() { var deployment = new NewDeployment("ref") { - Payload = new Dictionary<string, string> {{"environment", "production"}} + Payload = new Dictionary<string, string> { { "environment", "production" } } }; var deserialized = new SimpleJsonSerializer().Serialize(deployment); - + Assert.Equal(@"{""ref"":""ref"",""payload"":{""environment"":""production""}}", deserialized); } @@ -24,14 +25,22 @@ public void CanSerialize() public void CanDeserialize() { const string json = @"{ - ""id"": 1, - ""sha"": ""topic-branch"", ""url"": ""https://api.github.com/repos/octocat/example/deployments/1"", + ""id"": 1, + ""node_id"": ""MDEwOkRlcGxveW1lbnQx"", + ""sha"": ""a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d"", + ""ref"": ""topic-branch"", + ""task"": ""deploy"", + ""payload"": {}, + ""original_environment"": ""staging"", + ""environment"": ""production"", + ""description"": ""Deploy request from hubot"", ""creator"": { ""login"": ""octocat"", ""id"": 1, + ""node_id"": ""MDQ6VXNlcjE="", ""avatar_url"": ""https://github.com/images/error/octocat_happy.gif"", - ""gravatar_id"": ""somehexcode"", + ""gravatar_id"": """", ""url"": ""https://api.github.com/users/octocat"", ""html_url"": ""https://github.com/octocat"", ""followers_url"": ""https://api.github.com/users/octocat/followers"", @@ -46,24 +55,27 @@ public void CanDeserialize() ""type"": ""User"", ""site_admin"": false }, - ""payload"": { ""environment"":""production""}, ""created_at"": ""2012-07-20T01:19:13Z"", ""updated_at"": ""2012-07-20T01:19:13Z"", - ""description"": ""Deploy request from hubot"", ""statuses_url"": ""https://api.github.com/repos/octocat/example/deployments/1/statuses"", - ""task"": ""deploy"" + ""repository_url"": ""https://api.github.com/repos/octocat/example"", + ""transient_environment"": false, + ""production_environment"": true }"; var actual = new SimpleJsonSerializer().Deserialize<Deployment>(json); Assert.Equal(1, actual.Id); - Assert.Equal("topic-branch", actual.Sha); + Assert.Equal("a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d", actual.Sha); + Assert.Equal("topic-branch", actual.Ref); Assert.Equal("https://api.github.com/repos/octocat/example/deployments/1", actual.Url); - Assert.Equal(new ReadOnlyDictionary<string, string>(new Dictionary<string, string> { { "environment", "production" } }), actual.Payload); + Assert.Equal("production", actual.Environment); + Assert.Equal("staging", actual.OriginalEnvironment); Assert.Equal(DateTimeOffset.Parse("2012-07-20T01:19:13Z"), actual.CreatedAt); Assert.Equal(DateTimeOffset.Parse("2012-07-20T01:19:13Z"), actual.UpdatedAt); Assert.Equal("Deploy request from hubot", actual.Description); Assert.Equal("https://api.github.com/repos/octocat/example/deployments/1/statuses", actual.StatusesUrl); + Assert.Equal("https://api.github.com/repos/octocat/example", actual.RepositoryUrl); Assert.Equal("deploy", actual.Task); } } diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 9ec8a43959..30f7d910f7 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -4,7 +4,7 @@ <Description>Tests for Octokit</Description> <AssemblyTitle>Octokit.Tests</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks> + <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests</AssemblyName> <PackageId>Octokit.Tests</PackageId> diff --git a/Octokit/Models/Response/Deployment.cs b/Octokit/Models/Response/Deployment.cs index f8dbb4cce3..00774d4abe 100644 --- a/Octokit/Models/Response/Deployment.cs +++ b/Octokit/Models/Response/Deployment.cs @@ -13,11 +13,12 @@ public class Deployment { public Deployment() { } - public Deployment(int id, string nodeId, string sha, string url, User creator, IReadOnlyDictionary<string, string> payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, bool transientEnvironment, bool productionEnvironment, string task) + public Deployment(int id, string nodeId, string sha, string @ref, string url, User creator, IReadOnlyDictionary<string, string> payload, DateTimeOffset createdAt, DateTimeOffset updatedAt, string description, string statusesUrl, string repositoryUrl, string environment, string originalEnvironment, bool transientEnvironment, bool productionEnvironment, string task) { Id = id; NodeId = nodeId; Sha = sha; + Ref = @ref; Url = url; Creator = creator; Payload = payload; @@ -25,6 +26,9 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I UpdatedAt = updatedAt; Description = description; StatusesUrl = statusesUrl; + RepositoryUrl = repositoryUrl; + Environment = environment; + OriginalEnvironment = originalEnvironment; TransientEnvironment = transientEnvironment; ProductionEnvironment = productionEnvironment; Task = task; @@ -41,10 +45,15 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I public string NodeId { get; private set; } /// <summary> - /// + /// The SHA recorded at creation time. /// </summary> public string Sha { get; private set; } + /// <summary> + /// The name of the ref. This can be a branch, tag, or SHA. + /// </summary> + public string Ref { get; private set; } + /// <summary> /// The API URL for this deployment. /// </summary> @@ -80,6 +89,21 @@ public Deployment(int id, string nodeId, string sha, string url, User creator, I /// </summary> public string StatusesUrl { get; private set; } + /// <summary> + /// The API URL for the <seealso cref="Repository"/> of this deployment. + /// </summary> + public string RepositoryUrl { get; private set; } + + /// <summary> + /// The name of the <seealso cref="Environment"/> that was deployed to (e.g., staging or production). + /// </summary> + public string Environment { get; private set; } + + /// <summary> + /// The name of the that was originally deployed to (e.g., staging or production). + /// </summary> + public string OriginalEnvironment { get; private set; } + /// <summary> /// Indicates if the environment is specific to a deployment and will no longer exist at some point in the future. /// </summary> From 063e85e4db5ad54ba4b121fb63ee86502247afee Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Mon, 12 Sep 2022 21:08:59 +0200 Subject: [PATCH 127/209] Adding credential-authorization get endpoints (#2556) --- .../Extensions.cs | 986 +++++++++--------- .../Clients/IObservableOrganizationsClient.cs | 32 + .../Clients/ObservableOrganizationsClient.cs | 63 ++ .../Clients/OrganizationsClientTests.cs | 97 ++ .../ObservableOrganizationsClientTests.cs | 76 ++ Octokit/Clients/IOrganizationsClient.cs | 32 + Octokit/Clients/OrganizationsClient.cs | 68 ++ Octokit/Helpers/ApiUrls.cs | 23 + .../Models/Response/OrganizationCredential.cs | 101 ++ 9 files changed, 989 insertions(+), 489 deletions(-) create mode 100644 Octokit/Models/Response/OrganizationCredential.cs diff --git a/Octokit.AsyncPaginationExtension/Extensions.cs b/Octokit.AsyncPaginationExtension/Extensions.cs index a9009f3b76..c541ac0bd8 100644 --- a/Octokit.AsyncPaginationExtension/Extensions.cs +++ b/Octokit.AsyncPaginationExtension/Extensions.cs @@ -14,57 +14,33 @@ public static class Extensions { private const int DEFAULT_PAGE_SIZE = 30; - /// <inheritdoc cref="IIssueReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<Team> GetAllAsync(this ITeamsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Team> GetAllForCurrentAsync(this ITeamsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllChildTeams(int, ApiOptions)"/> - public static IPaginatedList<Team> GetAllChildTeamsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllChildTeams(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, ApiOptions)"/> - public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, TeamMembersRequest, ApiOptions)"/> - public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, TeamMembersRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="ITeamsClient.GetAllRepositories(int, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllRepositoriesAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllRepositories(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="ITeamsClient.GetAllPendingInvitations(int, ApiOptions)"/> - public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IAuthorizationsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Authorization> GetAllAsync(this IAuthorizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Authorization>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(string, string, long, ApiOptions)"/> + public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, string owner, string name, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(owner, name, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(long, long, ApiOptions)"/> + public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, long repositoryId, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(repositoryId, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, RepositoryCollaboratorListRequest, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, RepositoryCollaboratorListRequest, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="ICommitStatusClient.GetAll(string, string, string, ApiOptions)"/> public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, string owner, string name, string reference, int pageSize = DEFAULT_PAGE_SIZE) @@ -74,145 +50,89 @@ public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient public static IPaginatedList<CommitStatus> GetAllAsync(this ICommitStatusClient t, long repositoryId, string reference, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<CommitStatus>(options => t.GetAll(repositoryId, reference, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, MilestoneRequest, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, MilestoneRequest, ApiOptions)"/> - public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IAuthorizationsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<Authorization> GetAllAsync(this IAuthorizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Authorization>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(RepositoryRequest, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, RepositoryRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForUserAsync(this IRepositoriesClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllForOrg(string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForOrgAsync(this IRepositoriesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForOrg(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IDeploymentsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, bool, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IDeploymentsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, bool, ApiOptions)"/> - public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IDeploymentStatusClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, string owner, string name, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(owner, name, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(string, string, ApiOptions)"/> - public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IDeploymentStatusClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, long repositoryId, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(repositoryId, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(long, ApiOptions)"/> - public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<Activity> GetAllAsync(this IEventsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoriesClient.GetAllTags(string, string, ApiOptions)"/> - public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoriesClient.GetAllTags(long, ApiOptions)"/> - public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IReferencesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IReferencesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(string, string, string, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, string owner, string name, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(owner, name, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllForRepositoryNetwork(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForRepositoryNetworkAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepositoryNetwork(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(long, string, ApiOptions)"/> - public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, long repositoryId, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(repositoryId, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForOrganizationAsync(this IEventsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationHooksClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<OrganizationHook> GetAllAsync(this IOrganizationHooksClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<OrganizationHook>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllUserReceived(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserReceivedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceived(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllUserReceivedPublic(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserReceivedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceivedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllUserPerformed(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserPerformedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformed(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersRole, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllUserPerformedPublic(string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllUserPerformedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, OrganizationMembersRole, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IEventsClient.GetAllForAnOrganization(string, string, ApiOptions)"/> + public static IPaginatedList<Activity> GetAllForAnOrganizationAsync(this IEventsClient t, string user, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForAnOrganization(user, organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationMembersClient.GetAllPublic(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllPublicAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllPublic(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IFollowersClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<User> GetAllForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationMembersClient.GetAllPendingInvitations(string, ApiOptions)"/> - public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IFollowersClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationMembersClient.GetAllFailedInvitations(string, ApiOptions)"/> - public static IPaginatedList<OrganizationMembershipInvitation> GetAllFailedInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllFailedInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IFollowersClient.GetAllFollowingForCurrent(ApiOptions)"/> + public static IPaginatedList<User> GetAllFollowingForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(t.GetAllFollowingForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IFollowersClient.GetAllFollowing(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllFollowingAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllFollowing(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IGistCommentsClient.GetAllForGist(string, ApiOptions)"/> + public static IPaginatedList<GistComment> GetAllForGistAsync(this IGistCommentsClient t, string gistId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GistComment>(options => t.GetAllForGist(gistId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="IGistsClient.GetAll(ApiOptions)"/> public static IPaginatedList<Gist> GetAllAsync(this IGistsClient t, int pageSize = DEFAULT_PAGE_SIZE) @@ -254,121 +174,17 @@ public static IPaginatedList<GistHistory> GetAllCommitsAsync(this IGistsClient t public static IPaginatedList<GistFork> GetAllForksAsync(this IGistsClient t, string id, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<GistFork>(options => t.GetAllForks(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<RepositoryInvitation> GetAllForCurrentAsync(this IRepositoryInvitationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IGitHubAppsClient.GetAllInstallationsForCurrent(ApiOptions)"/> + public static IPaginatedList<Installation> GetAllInstallationsForCurrentAsync(this IGitHubAppsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Installation>(t.GetAllInstallationsForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<RepositoryInvitation> GetAllForRepositoryAsync(this IRepositoryInvitationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReleasesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReleasesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReleasesClient.GetAllAssets(string, string, int, ApiOptions)"/> - public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, string owner, string name, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(owner, name, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IReleasesClient.GetAllAssets(long, int, ApiOptions)"/> - public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, long repositoryId, int id, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(repositoryId, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(string, string, int, long, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, string owner, string name, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(owner, name, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(long, int, long, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, long repositoryId, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(repositoryId, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IDeploymentsClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IDeploymentsClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<Deployment> GetAllAsync(this IDeploymentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Deployment>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(NotificationsRequest, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, NotificationsRequest, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, NotificationsRequest, ApiOptions)"/> - public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IUserEmailsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<EmailAddress> GetAllAsync(this IUserEmailsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<EmailAddress>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, PullRequestReviewCommentRequest, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, PullRequestReviewCommentRequest, ApiOptions)"/> - public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IUserKeysClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<PublicKey> GetAllAsync(this IUserKeysClient t, string userName, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PublicKey>(options => t.GetAll(userName, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IUserKeysClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<PublicKey> GetAllForCurrentAsync(this IUserKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PublicKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IIssueCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="IIssueCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> public static IPaginatedList<IssueComment> GetAllForRepositoryAsync(this IIssueCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) @@ -402,6 +218,70 @@ public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommen public static IPaginatedList<IssueComment> GetAllForIssueAsync(this IIssueCommentsClient t, long repositoryId, int number, IssueCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<IssueComment>(options => t.GetAllForIssue(repositoryId, number, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IIssueReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IIssueReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForOwnedAndMemberRepositories, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOwnedAndMemberRepositories(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, IssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, RepositoryIssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, RepositoryIssueRequest, ApiOptions)"/> + public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IIssuesLabelsClient.GetAllForIssue(string, string, int, ApiOptions)"/> public static IPaginatedList<Label> GetAllForIssueAsync(this IIssuesLabelsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); @@ -426,9 +306,113 @@ public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsCl public static IPaginatedList<Label> GetAllForMilestoneAsync(this IIssuesLabelsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<Label>(options => t.GetAllForMilestone(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IGistCommentsClient.GetAllForGist(string, ApiOptions)"/> - public static IPaginatedList<GistComment> GetAllForGistAsync(this IGistCommentsClient t, string gistId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GistComment>(options => t.GetAllForGist(gistId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(string, string, int, ApiOptions)"/> + public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, string owner, string repo, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(owner, repo, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(long, int, ApiOptions)"/> + public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(string, string, MilestoneRequest, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, string owner, string name, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMilestonesClient.GetAllForRepository(long, MilestoneRequest, ApiOptions)"/> + public static IPaginatedList<Milestone> GetAllForRepositoryAsync(this IMilestonesClient t, long repositoryId, MilestoneRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Milestone>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IMiscellaneousClient.GetAllLicenses(ApiOptions)"/> + public static IPaginatedList<LicenseMetadata> GetAllLicensesAsync(this IMiscellaneousClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<LicenseMetadata>(t.GetAllLicenses, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForCurrent(NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForCurrentAsync(this INotificationsClient t, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(string, string, NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, string owner, string name, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="INotificationsClient.GetAllForRepository(long, NotificationsRequest, ApiOptions)"/> + public static IPaginatedList<Notification> GetAllForRepositoryAsync(this INotificationsClient t, long repositoryId, NotificationsRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Notification>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationHooksClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<OrganizationHook> GetAllAsync(this IOrganizationHooksClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationHook>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersRole, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAll(string, OrganizationMembersFilter, OrganizationMembersRole, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationMembersClient t, string org, OrganizationMembersFilter filter, OrganizationMembersRole role, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, role, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllPublic(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllPublicAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllPublic(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllPendingInvitations(string, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationMembersClient.GetAllFailedInvitations(string, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllFailedInvitationsAsync(this IOrganizationMembersClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllFailedInvitations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationOutsideCollaboratorsClient.GetAll(string, OrganizationMembersFilter, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IOrganizationOutsideCollaboratorsClient t, string org, OrganizationMembersFilter filter, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(org, filter, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Organization> GetAllForCurrentAsync(this IOrganizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Organization>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationsClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Organization> GetAllForUserAsync(this IOrganizationsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Organization>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationsClient.GetAllAuthorizations(string, ApiOptions)"/> + public static IPaginatedList<OrganizationCredential> GetAllAuthorizationsAsync(this IOrganizationsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationCredential>(options => t.GetAllAuthorizations(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IOrganizationsClient.GetAllAuthorizations(string, string, ApiOptions)"/> + public static IPaginatedList<OrganizationCredential> GetAllAuthorizationsAsync(this IOrganizationsClient t, string org, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationCredential>(options => t.GetAllAuthorizations(org, login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="IProjectCardsClient.GetAll(int, ApiOptions)"/> public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, int pageSize = DEFAULT_PAGE_SIZE) @@ -438,17 +422,9 @@ public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t public static IPaginatedList<ProjectCard> GetAllAsync(this IProjectCardsClient t, int columnId, ProjectCardRequest request, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<ProjectCard>(options => t.GetAll(columnId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IMiscellaneousClient.GetAllLicenses(ApiOptions)"/> - public static IPaginatedList<LicenseMetadata> GetAllLicensesAsync(this IMiscellaneousClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<LicenseMetadata>(t.GetAllLicenses, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IProjectColumnsClient.GetAll(int, ApiOptions)"/> + public static IPaginatedList<ProjectColumn> GetAllAsync(this IProjectColumnsClient t, int projectId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ProjectColumn>(options => t.GetAll(projectId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="IProjectsClient.GetAllForRepository(string, string, ApiOptions)"/> public static IPaginatedList<Project> GetAllForRepositoryAsync(this IProjectsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) @@ -474,181 +450,213 @@ public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsC public static IPaginatedList<Project> GetAllForOrganizationAsync(this IProjectsClient t, string organization, ProjectRequest request, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<Project>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentReactionsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<Reaction> GetAllAsync(this IPullRequestReviewCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(string, string, string, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, string owner, string name, string sha, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(owner, name, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(long, string, ApiOptions)"/> - public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, long repositoryId, string sha, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(repositoryId, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IDeploymentStatusClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, string owner, string name, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(owner, name, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IDeploymentStatusClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<DeploymentStatus> GetAllAsync(this IDeploymentStatusClient t, long repositoryId, int deploymentId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<DeploymentStatus>(options => t.GetAll(repositoryId, deploymentId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(string, string, PullRequestReviewCommentRequest, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, string owner, string name, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewCommentsClient.GetAllForRepository(long, PullRequestReviewCommentRequest, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllForRepositoryAsync(this IPullRequestReviewCommentsClient t, long repositoryId, PullRequestReviewCommentRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, CommitRequest, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(string, string, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, CommitRequest, ApiOptions)"/> - public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewsClient.GetAll(long, int, ApiOptions)"/> + public static IPaginatedList<PullRequestReview> GetAllAsync(this IPullRequestReviewsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReview>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(string, string, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(string, string, int, long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, string owner, string name, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(owner, name, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="ICommitCommentReactionsClient.GetAll(long, int, ApiOptions)"/> - public static IPaginatedList<Reaction> GetAllAsync(this ICommitCommentReactionsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Reaction>(options => t.GetAll(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestReviewsClient.GetAllComments(long, int, long, ApiOptions)"/> + public static IPaginatedList<PullRequestReviewComment> GetAllCommentsAsync(this IPullRequestReviewsClient t, long repositoryId, int number, long reviewId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequestReviewComment>(options => t.GetAllComments(repositoryId, number, reviewId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryPagesClient.GetAll(string, string, ApiOptions)"/> - public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryPagesClient.GetAll(long, ApiOptions)"/> - public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IProjectColumnsClient.GetAll(int, ApiOptions)"/> - public static IPaginatedList<ProjectColumn> GetAllAsync(this IProjectColumnsClient t, int projectId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<ProjectColumn>(options => t.GetAll(projectId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, PullRequestRequest, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAll(ApiOptions)"/> - public static IPaginatedList<Activity> GetAllAsync(this IEventsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, PullRequestRequest, ApiOptions)"/> + public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReferencesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReferencesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllAsync(this IReferencesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(string, string, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, string owner, string name, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(owner, name, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllIssuesForRepository(long, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllIssuesForRepositoryAsync(this IEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllIssuesForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReferencesClient.GetAllForSubNamespace(long, string, ApiOptions)"/> + public static IPaginatedList<Reference> GetAllForSubNamespaceAsync(this IReferencesClient t, long repositoryId, string subNamespace, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Reference>(options => t.GetAllForSubNamespace(repositoryId, subNamespace, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllForRepositoryNetwork(string, string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForRepositoryNetworkAsync(this IEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForRepositoryNetwork(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReleasesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllForOrganization(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForOrganizationAsync(this IEventsClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReleasesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Release> GetAllAsync(this IReleasesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Release>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllUserReceived(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserReceivedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceived(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReleasesClient.GetAllAssets(string, string, int, ApiOptions)"/> + public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, string owner, string name, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(owner, name, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllUserReceivedPublic(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserReceivedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserReceivedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IReleasesClient.GetAllAssets(long, int, ApiOptions)"/> + public static IPaginatedList<ReleaseAsset> GetAllAssetsAsync(this IReleasesClient t, long repositoryId, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<ReleaseAsset>(options => t.GetAllAssets(repositoryId, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(string, string, RepositoryCollaboratorListRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepoCollaboratorsClient.GetAll(long, RepositoryCollaboratorListRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForCurrent(RepositoryRequest, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IRepositoriesClient t, RepositoryRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoriesClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IRepositoriesClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllUserPerformed(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserPerformedAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformed(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllForOrg(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForOrgAsync(this IRepositoriesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForOrg(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllUserPerformedPublic(string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllUserPerformedPublicAsync(this IEventsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllUserPerformedPublic(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IEventsClient.GetAllForAnOrganization(string, string, ApiOptions)"/> - public static IPaginatedList<Activity> GetAllForAnOrganizationAsync(this IEventsClient t, string user, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Activity>(options => t.GetAllForAnOrganization(user, organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(string, string, bool, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, string owner, string name, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(owner, name, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllContributors(long, bool, ApiOptions)"/> + public static IPaginatedList<RepositoryContributor> GetAllContributorsAsync(this IRepositoriesClient t, long repositoryId, bool includeAnonymous, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryContributor>(options => t.GetAllContributors(repositoryId, includeAnonymous, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(string, string, PullRequestRequest, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, string owner, string name, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(string, string, ApiOptions)"/> + public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IPullRequestsClient.GetAllForRepository(long, PullRequestRequest, ApiOptions)"/> - public static IPaginatedList<PullRequest> GetAllForRepositoryAsync(this IPullRequestsClient t, long repositoryId, PullRequestRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<PullRequest>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllTeams(long, ApiOptions)"/> + public static IPaginatedList<Team> GetAllTeamsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllTeams(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllTags(string, string, ApiOptions)"/> + public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForCurrent(IssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForCurrentAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForCurrent(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoriesClient.GetAllTags(long, ApiOptions)"/> + public static IPaginatedList<RepositoryTag> GetAllTagsAsync(this IRepositoriesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryTag>(options => t.GetAllTags(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(t.GetAllForOwnedAndMemberRepositories, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForOwnedAndMemberRepositories(IssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOwnedAndMemberRepositoriesAsync(this IIssuesClient t, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOwnedAndMemberRepositories(request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryBranchesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<Branch> GetAllAsync(this IRepositoryBranchesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Branch>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(string, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForOrganization(string, IssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForOrganizationAsync(this IIssuesClient t, string organization, IssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForOrganization(organization, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForRepositoryAsync(this IRepositoryCommentsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(string, string, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, string owner, string name, string sha, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(owner, name, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommentsClient.GetAllForCommit(long, string, ApiOptions)"/> + public static IPaginatedList<CommitComment> GetAllForCommitAsync(this IRepositoryCommentsClient t, long repositoryId, string sha, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<CommitComment>(options => t.GetAllForCommit(repositoryId, sha, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(string, string, RepositoryIssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, string owner, string name, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssuesClient.GetAllForRepository(long, RepositoryIssueRequest, ApiOptions)"/> - public static IPaginatedList<Issue> GetAllForRepositoryAsync(this IIssuesClient t, long repositoryId, RepositoryIssueRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Issue>(options => t.GetAllForRepository(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationsClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Organization> GetAllForCurrentAsync(this IOrganizationsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Organization>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(string, string, CommitRequest, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, string owner, string name, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IOrganizationsClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Organization> GetAllForUserAsync(this IOrganizationsClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Organization>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryCommitsClient.GetAll(long, CommitRequest, ApiOptions)"/> + public static IPaginatedList<GitHubCommit> GetAllAsync(this IRepositoryCommitsClient t, long repositoryId, CommitRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GitHubCommit>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IUserGpgKeysClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<GpgKey> GetAllForCurrentAsync(this IUserGpgKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<GpgKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IRepositoryDeployKeysClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<DeployKey> GetAllAsync(this IRepositoryDeployKeysClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<DeployKey>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="IRepositoryForksClient.GetAll(string, string, ApiOptions)"/> public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) @@ -666,42 +674,6 @@ public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient public static IPaginatedList<Repository> GetAllAsync(this IRepositoryForksClient t, long repositoryId, RepositoryForksListRequest request, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IGitHubAppsClient.GetAllInstallationsForCurrent(ApiOptions)"/> - public static IPaginatedList<Installation> GetAllInstallationsForCurrentAsync(this IGitHubAppsClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Installation>(t.GetAllInstallationsForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(string, string, int, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, string owner, string name, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(owner, name, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForIssue(long, int, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForIssueAsync(this IIssuesEventsClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IIssuesEventsClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<IssueEvent> GetAllForRepositoryAsync(this IIssuesEventsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<IssueEvent>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(string, string, ApiOptions)"/> - public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="IAssigneesClient.GetAllForRepository(long, ApiOptions)"/> - public static IPaginatedList<User> GetAllForRepositoryAsync(this IAssigneesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(string, string, long, ApiOptions)"/> - public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, string owner, string name, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(owner, name, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - - /// <inheritdoc cref="ICheckRunsClient.GetAllAnnotations(long, long, ApiOptions)"/> - public static IPaginatedList<CheckRunAnnotation> GetAllAnnotationsAsync(this ICheckRunsClient t, long repositoryId, long checkRunId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<CheckRunAnnotation>(options => t.GetAllAnnotations(repositoryId, checkRunId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IRepositoryHooksClient.GetAll(string, string, ApiOptions)"/> public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); @@ -710,21 +682,21 @@ public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksCl public static IPaginatedList<RepositoryHook> GetAllAsync(this IRepositoryHooksClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<RepositoryHook>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IWatchedClient.GetAllWatchers(string, string, ApiOptions)"/> - public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<RepositoryInvitation> GetAllForCurrentAsync(this IRepositoryInvitationsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IWatchedClient.GetAllWatchers(long, ApiOptions)"/> - public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryInvitationsClient.GetAllForRepository(long, ApiOptions)"/> + public static IPaginatedList<RepositoryInvitation> GetAllForRepositoryAsync(this IRepositoryInvitationsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<RepositoryInvitation>(options => t.GetAllForRepository(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IWatchedClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForCurrentAsync(this IWatchedClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryPagesClient.GetAll(string, string, ApiOptions)"/> + public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IWatchedClient.GetAllForUser(string, ApiOptions)"/> - public static IPaginatedList<Repository> GetAllForUserAsync(this IWatchedClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="IRepositoryPagesClient.GetAll(long, ApiOptions)"/> + public static IPaginatedList<PagesBuild> GetAllAsync(this IRepositoryPagesClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PagesBuild>(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="IStarredClient.GetAllStargazers(string, string, ApiOptions)"/> public static IPaginatedList<User> GetAllStargazersAsync(this IStarredClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) @@ -774,29 +746,65 @@ public static IPaginatedList<Repository> GetAllForUserAsync(this IStarredClient public static IPaginatedList<RepositoryStar> GetAllForUserWithTimestampsAsync(this IStarredClient t, string user, StarredRequest request, int pageSize = DEFAULT_PAGE_SIZE) => pageSize > 0 ? new PaginatedList<RepositoryStar>(options => t.GetAllForUserWithTimestamps(user, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IFollowersClient.GetAllForCurrent(ApiOptions)"/> - public static IPaginatedList<User> GetAllForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ITeamsClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<Team> GetAllAsync(this ITeamsClient t, string org, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAll(org, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IFollowersClient.GetAll(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAll(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ITeamsClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Team> GetAllForCurrentAsync(this ITeamsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IFollowersClient.GetAllFollowingForCurrent(ApiOptions)"/> - public static IPaginatedList<User> GetAllFollowingForCurrentAsync(this IFollowersClient t, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(t.GetAllFollowingForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ITeamsClient.GetAllChildTeams(int, ApiOptions)"/> + public static IPaginatedList<Team> GetAllChildTeamsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Team>(options => t.GetAllChildTeams(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IFollowersClient.GetAllFollowing(string, ApiOptions)"/> - public static IPaginatedList<User> GetAllFollowingAsync(this IFollowersClient t, string login, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllFollowing(login, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, ApiOptions)"/> + public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(string, string, int, ApiOptions)"/> - public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, string owner, string repo, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(owner, repo, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ITeamsClient.GetAllMembers(int, TeamMembersRequest, ApiOptions)"/> + public static IPaginatedList<User> GetAllMembersAsync(this ITeamsClient t, int id, TeamMembersRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllMembers(id, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); - /// <inheritdoc cref="IIssueTimelineClient.GetAllForIssue(long, int, ApiOptions)"/> - public static IPaginatedList<TimelineEventInfo> GetAllForIssueAsync(this IIssueTimelineClient t, long repositoryId, int number, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList<TimelineEventInfo>(options => t.GetAllForIssue(repositoryId, number, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + /// <inheritdoc cref="ITeamsClient.GetAllRepositories(int, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllRepositoriesAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllRepositories(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="ITeamsClient.GetAllPendingInvitations(int, ApiOptions)"/> + public static IPaginatedList<OrganizationMembershipInvitation> GetAllPendingInvitationsAsync(this ITeamsClient t, int id, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<OrganizationMembershipInvitation>(options => t.GetAllPendingInvitations(id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserEmailsClient.GetAll(ApiOptions)"/> + public static IPaginatedList<EmailAddress> GetAllAsync(this IUserEmailsClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<EmailAddress>(t.GetAll, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserGpgKeysClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<GpgKey> GetAllForCurrentAsync(this IUserGpgKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<GpgKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserKeysClient.GetAll(string, ApiOptions)"/> + public static IPaginatedList<PublicKey> GetAllAsync(this IUserKeysClient t, string userName, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PublicKey>(options => t.GetAll(userName, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IUserKeysClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<PublicKey> GetAllForCurrentAsync(this IUserKeysClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<PublicKey>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllWatchers(string, string, ApiOptions)"/> + public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllWatchers(long, ApiOptions)"/> + public static IPaginatedList<User> GetAllWatchersAsync(this IWatchedClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<User>(options => t.GetAllWatchers(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllForCurrent(ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForCurrentAsync(this IWatchedClient t, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(t.GetAllForCurrent, pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + + /// <inheritdoc cref="IWatchedClient.GetAllForUser(string, ApiOptions)"/> + public static IPaginatedList<Repository> GetAllForUserAsync(this IWatchedClient t, string user, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList<Repository>(options => t.GetAllForUser(user, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// <inheritdoc cref="IApiConnection.GetAll(Uri, ApiOptions)"/> public static IPaginatedList<T> GetAllAsync<T>(this IApiConnection t, Uri uri, int pageSize = DEFAULT_PAGE_SIZE) diff --git a/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs index 793b17846e..8e7596c7c5 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs @@ -88,5 +88,37 @@ public interface IObservableOrganizationsClient /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="Organization"/></returns> IObservable<Organization> Update(string org, OrganizationUpdate updateRequest); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + IObservable<OrganizationCredential> GetAllAuthorizations(string org); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + IObservable<OrganizationCredential> GetAllAuthorizations(string org, ApiOptions options); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + IObservable<OrganizationCredential> GetAllAuthorizations(string org, string login); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + IObservable<OrganizationCredential> GetAllAuthorizations(string org, string login, ApiOptions options); } } diff --git a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs index ec816645e8..348dc49e83 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs @@ -144,5 +144,68 @@ public IObservable<Organization> Update(string org, OrganizationUpdate updateReq return _client.Update(org, updateRequest).ToObservable(); } + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + public IObservable<OrganizationCredential> GetAllAuthorizations(string org) + { + Ensure.ArgumentNotNull(org, nameof(org)); + + var url = ApiUrls.AllOrganizationCredentials(org); + + return _connection.GetAndFlattenAllPages<OrganizationCredential>(url); + } + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + public IObservable<OrganizationCredential> GetAllAuthorizations(string org, ApiOptions options) + { + Ensure.ArgumentNotNull(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + var url = ApiUrls.AllOrganizationCredentials(org); + + return _connection.GetAndFlattenAllPages<OrganizationCredential>(url, options); + } + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + public IObservable<OrganizationCredential> GetAllAuthorizations(string org, string login) + { + Ensure.ArgumentNotNull(org, nameof(org)); + Ensure.ArgumentNotNull(login, nameof(login)); + + var url = ApiUrls.AllOrganizationCredentials(org, login); + + return _connection.GetAndFlattenAllPages<OrganizationCredential>(url); + } + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + public IObservable<OrganizationCredential> GetAllAuthorizations(string org, string login, ApiOptions options) + { + Ensure.ArgumentNotNull(org, nameof(org)); + Ensure.ArgumentNotNull(login, nameof(login)); + Ensure.ArgumentNotNull(options, nameof(options)); + + var url = ApiUrls.AllOrganizationCredentials(org, login); + + return _connection.GetAndFlattenAllPages<OrganizationCredential>(url, options); + } } } diff --git a/Octokit.Tests/Clients/OrganizationsClientTests.cs b/Octokit.Tests/Clients/OrganizationsClientTests.cs index 2dbf0a2a73..2e2df91586 100644 --- a/Octokit.Tests/Clients/OrganizationsClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationsClientTests.cs @@ -192,5 +192,102 @@ public async Task EnsuresNonNullArguments() await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", new OrganizationUpdate())); } } + + public class TheGetAllAuthorizationsMethod + { + [Fact] + public async Task RequestTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await client.GetAllAuthorizations("fake"); + + connection.Received().GetAll<OrganizationCredential>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/credential-authorizations")); + } + + [Fact] + public async Task RequestTheCorrectUrlWithOptions() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await client.GetAllAuthorizations("fake", new ApiOptions() { PageCount = 1, PageSize = 1, StartPage = 1}); + + connection.Received().GetAll<OrganizationCredential>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/credential-authorizations"), Args.ApiOptions); + } + + [Fact] + public async Task RequestTheCorrectUrlWithLogin() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await client.GetAllAuthorizations("fake", "login"); + + connection.Received().GetAll<OrganizationCredential>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/credential-authorizations?login=login")); + } + + [Fact] + public async Task RequestTheCorrectUrlWithLoginAndUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await client.GetAllAuthorizations("fake", "login", new ApiOptions() { PageCount = 1, PageSize = 1, StartPage = 1 }); + + connection.Received().GetAll<OrganizationCredential>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/credential-authorizations?login=login"), Args.ApiOptions); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations(null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAuthorizations("")); + } + + [Fact] + public async Task EnsuresNonNullArgumentsWithOptions() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations(null, new ApiOptions())); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAuthorizations("", new ApiOptions())); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations("asd", (ApiOptions)null)); + } + + [Fact] + public async Task EnsuresNonNullArgumentsWithLogin() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations(null, "asd")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAuthorizations("", "asd")); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations("asd", (string)null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAuthorizations("asd", "")); + } + + [Fact] + public async Task EnsuresNonNullArgumentsWithLoginAndOptions() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations(null, "asd", new ApiOptions())); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAuthorizations("", "asd", new ApiOptions())); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations("asd", (string)null, new ApiOptions())); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllAuthorizations("asd", "", new ApiOptions())); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllAuthorizations("asd", "asd", null)); + } + } } } diff --git a/Octokit.Tests/Reactive/ObservableOrganizationsClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationsClientTests.cs index 21eda991c2..7c7160e018 100644 --- a/Octokit.Tests/Reactive/ObservableOrganizationsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableOrganizationsClientTests.cs @@ -153,5 +153,81 @@ public void EnsuresNonNullArguments() Assert.Throws<ArgumentException>(() => client.Update("", new OrganizationUpdate())); } } + + public class TheGetAllAuthorizationsMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationsClient(gitHubClient); + + client.GetAllAuthorizations("org"); + + gitHubClient.Received().Organization.GetAllAuthorizations("org"); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationsClient(gitHubClient); + + var options = new ApiOptions + { + StartPage = 1, + PageCount = 1, + PageSize = 1 + }; + + client.GetAllAuthorizations("org", options); + + gitHubClient.Received().Organization.GetAllAuthorizations("org", options); + } + + [Fact] + public void RequestsTheCorrectUrlWithLogin() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationsClient(gitHubClient); + + client.GetAllAuthorizations("org", "login"); + + gitHubClient.Received().Organization.GetAllAuthorizations("org", "login"); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptionsWithLogin() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationsClient(gitHubClient); + + var options = new ApiOptions + { + StartPage = 1, + PageCount = 1, + PageSize = 1 + }; + + client.GetAllAuthorizations("org", "login", options); + + gitHubClient.Received().Organization.GetAllAuthorizations("org", "login", options); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationsClient(gitHubClient); + + Assert.Throws<ArgumentNullException>(() => client.GetAllAuthorizations(null)); + Assert.Throws<ArgumentNullException>(() => client.GetAllAuthorizations(null, ApiOptions.None)); + Assert.Throws<ArgumentNullException>(() => client.GetAllAuthorizations("username", (string)null)); + Assert.Throws<ArgumentNullException>(() => client.GetAllAuthorizations("username", null, ApiOptions.None)); + + Assert.Throws<ArgumentNullException>(() => client.GetAllAuthorizations("asd", (ApiOptions)null)); + Assert.Throws<ArgumentNullException>(() => client.GetAllAuthorizations("asd", "asd", null)); + } + } } } \ No newline at end of file diff --git a/Octokit/Clients/IOrganizationsClient.cs b/Octokit/Clients/IOrganizationsClient.cs index 63f7c5758c..5f3f2fc6fb 100644 --- a/Octokit/Clients/IOrganizationsClient.cs +++ b/Octokit/Clients/IOrganizationsClient.cs @@ -113,5 +113,37 @@ public interface IOrganizationsClient /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="Organization"/></returns> Task<Organization> Update(string org, OrganizationUpdate updateRequest); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org, ApiOptions options); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org, string login); + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org, string login, ApiOptions options); } } diff --git a/Octokit/Clients/OrganizationsClient.cs b/Octokit/Clients/OrganizationsClient.cs index 42a89cd13b..fb07b3a90e 100644 --- a/Octokit/Clients/OrganizationsClient.cs +++ b/Octokit/Clients/OrganizationsClient.cs @@ -167,5 +167,73 @@ public Task<Organization> Update(string org, OrganizationUpdate updateRequest) return ApiConnection.Patch<Organization>(updateUri, updateRequest); } + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + [ManualRoute("GET", "/orgs/{org}/credential-authorizations")] + public Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + var url = ApiUrls.AllOrganizationCredentials(org); + + return ApiConnection.GetAll<OrganizationCredential>(url); + } + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + [ManualRoute("GET", "/orgs/{org}/credential-authorizations")] + public Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNull(options, nameof(options)); + + var url = ApiUrls.AllOrganizationCredentials(org); + + return ApiConnection.GetAll<OrganizationCredential>(url, options); + } + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + [ManualRoute("GET", "/orgs/{org}/credential-authorizations")] + public Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org, string login) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(login, nameof(login)); + + var url = ApiUrls.AllOrganizationCredentials(org, login); + + return ApiConnection.GetAll<OrganizationCredential>(url); + } + + /// <summary> + /// Returns all <see cref="OrganizationCredential" />s. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of <see cref="OrganizationCredential"/>s.</returns> + [ManualRoute("GET", "/orgs/{org}/credential-authorizations")] + public Task<IReadOnlyList<OrganizationCredential>> GetAllAuthorizations(string org, string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(login, nameof(login)); + Ensure.ArgumentNotNull(options, nameof(options)); + + var url = ApiUrls.AllOrganizationCredentials(org, login); + + return ApiConnection.GetAll<OrganizationCredential>(url, options); + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 86679989c4..b8a7cbe88f 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -4458,6 +4458,29 @@ public static Uri Meta() return "meta".FormatUri(); } + /// <summary> + /// Returns the <see cref="Uri"/> that returns all organization credentials in + /// response to a GET request. + /// </summary> + /// <param name="org">The organization name.</param> + /// <returns>The <see cref="Uri"/> to meta.</returns> + public static Uri AllOrganizationCredentials(string org) + { + return "orgs/{0}/credential-authorizations".FormatUri(org); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that returns all organization credentials for a given login in + /// response to a GET request. + /// </summary> + /// <param name="org">The organization name.</param> + /// <param name="login">Limits the list of credentials authorizations for an organization to a specific login</param> + /// <returns>The <see cref="Uri"/> to meta.</returns> + public static Uri AllOrganizationCredentials(string org, string login) + { + return "orgs/{0}/credential-authorizations?login={1}".FormatUri(org, login); + } + /// <summary> /// Returns the <see cref="Uri"/> for the Packages request /// </summary> diff --git a/Octokit/Models/Response/OrganizationCredential.cs b/Octokit/Models/Response/OrganizationCredential.cs new file mode 100644 index 0000000000..235d9dbb64 --- /dev/null +++ b/Octokit/Models/Response/OrganizationCredential.cs @@ -0,0 +1,101 @@ +using Octokit.Internal; +using System; +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OrganizationCredential + { + public OrganizationCredential() { } + + public OrganizationCredential( + string login, + long credentialId, + string credentialType, + string tokenLastEight, + DateTime credentialAuthorizedAt, + string[] scopes, + string fingerprint, + DateTime? credentialAccessedAt, + long? authorizedCredentialId, + string authorizedCredentialTitle, + string authorizedCredentialNote, + DateTime? authorizedCredentialExpiresAt) + { + Login = login; + CredentialId = credentialId; + CredentialType = credentialType; + TokenLastEight = tokenLastEight; + CredentialAuthorizedAt = credentialAuthorizedAt; + Scopes = scopes; + Fingerprint = fingerprint; + CredentialAccessedAt = credentialAccessedAt; + AuthorizedCredentialId = authorizedCredentialId; + AuthorizedCredentialTitle = authorizedCredentialTitle; + AuthorizedCredentialNote = authorizedCredentialNote; + AuthorizedCredentialExpiresAt = authorizedCredentialExpiresAt; + } + + + + /// <summary> + /// User login that owns the underlying credential. + /// </summary> + public string Login { get; private set; } + + /// <summary> + /// Unique identifier for the credential. + /// </summary> + public long CredentialId { get; private set; } + + /// <summary> + /// Human-readable description of the credential type. + /// </summary> + public string CredentialType { get; private set; } + + /// <summary> + /// Last eight characters of the credential. Only included in responses with credential_type of personal access token. + /// </summary> + public string TokenLastEight { get; private set; } + + /// <summary> + /// Date when the credential was authorized for use. + /// </summary> + public DateTime CredentialAuthorizedAt { get; private set; } + + /// <summary> + /// List of oauth scopes the token has been granted. + /// </summary> + public string[] Scopes { get; private set; } + + /// <summary> + /// Unique string to distinguish the credential. Only included in responses with credential_type of SSH Key. + /// </summary> + public string Fingerprint { get; private set; } + + /// <summary> + /// Date when the credential was last accessed. May be null if it was never accessed + /// </summary> + public DateTime? CredentialAccessedAt { get; private set; } + + public long? AuthorizedCredentialId { get; private set; } + + /// <summary> + /// The title given to the ssh key. This will only be present when the credential is an ssh key. + /// </summary> + public string AuthorizedCredentialTitle { get; private set; } + + /// <summary> + /// The note given to the token. This will only be present when the credential is a token. + /// </summary> + public string AuthorizedCredentialNote { get; private set; } + + /// <summary> + /// The expiry for the token. This will only be present when the credential is a token. + /// </summary> + public DateTime? AuthorizedCredentialExpiresAt { get; private set; } + + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); + } +} \ No newline at end of file From 05aa951d41c18f756a18bdae10e691a7488ace2a Mon Sep 17 00:00:00 2001 From: Sean Killeen <SeanKilleen@gmail.com> Date: Tue, 20 Sep 2022 14:35:13 -0500 Subject: [PATCH 128/209] Remove `/en` slug in docs.github.com links (and stop VSCode from formatting on save) (#2573) --- .github/workflows/codeql-analysis.yml | 10 +++++----- .vscode/settings.json | 1 + .../Enterprise/IObservableEnterpriseClient.cs | 2 +- ...bservableEnterprisePreReceiveHooksClient.cs | 14 +++++++------- .../Enterprise/ObservableEnterpriseClient.cs | 2 +- ...bservableEnterprisePreReceiveHooksClient.cs | 14 +++++++------- .../IObservableCommitCommentReactionsClient.cs | 8 ++++---- .../IObservableIssueCommentReactionsClient.cs | 12 ++++++------ .../Clients/IObservableIssueReactionsClient.cs | 12 ++++++------ .../IObservableOrganizationMembersClient.cs | 8 ++++---- ...ePullRequestReviewCommentReactionsClient.cs | 12 ++++++------ .../Clients/IObservableReleasesClient.cs | 4 ++-- .../Clients/IObservableRepositoriesClient.cs | 18 +++++++++--------- .../ObservableCommitCommentReactionsClient.cs | 10 +++++----- .../ObservableIssueCommentReactionsClient.cs | 12 ++++++------ .../Clients/ObservableIssueReactionsClient.cs | 12 ++++++------ .../ObservableOrganizationMembersClient.cs | 8 ++++---- ...ePullRequestReviewCommentReactionsClient.cs | 10 +++++----- .../Clients/ObservableReleasesClient.cs | 4 ++-- .../Clients/ObservableRepositoriesClient.cs | 14 +++++++------- .../Clients/CommitCommentReactionsClient.cs | 4 ++-- Octokit/Clients/Enterprise/EnterpriseClient.cs | 2 +- .../EnterprisePreReceiveHooksClient.cs | 14 +++++++------- .../Clients/Enterprise/IEnterpriseClient.cs | 2 +- .../IEnterprisePreReceiveHooksClient.cs | 16 ++++++++-------- .../Clients/ICommitCommentReactionsClient.cs | 10 +++++----- .../Clients/IIssueCommentReactionsClient.cs | 12 ++++++------ Octokit/Clients/IIssueReactionsClient.cs | 12 ++++++------ Octokit/Clients/IOrganizationMembersClient.cs | 8 ++++---- ...IPullRequestReviewCommentReactionsClient.cs | 12 ++++++------ Octokit/Clients/IReleasesClient.cs | 4 ++-- Octokit/Clients/IRepositoriesClient.cs | 18 +++++++++--------- Octokit/Clients/IssueReactionsClient.cs | 4 ++-- Octokit/Clients/OrganizationMembersClient.cs | 4 ++-- Octokit/Clients/PackagesClient.cs | 6 +++--- .../PullRequestReviewCommentReactionsClient.cs | 4 ++-- Octokit/Clients/ReleasesClient.cs | 4 ++-- Octokit/Clients/RepositoriesClient.cs | 16 ++++++++-------- .../SecondaryRateLimitExceededException.cs | 2 +- Octokit/GitHubClient.cs | 2 +- Octokit/IGitHubClient.cs | 2 +- .../Request/GenerateReleaseNotesRequest.cs | 2 +- .../Models/Response/GeneratedReleaseNotes.cs | 2 +- 43 files changed, 175 insertions(+), 174 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3db6f6ad88..8bc1f9ff72 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -48,20 +48,20 @@ jobs: # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + + # Details on CodeQL's query packs refer to : https://docs.github.com/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # 📚 See https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. + # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | diff --git a/.vscode/settings.json b/.vscode/settings.json index c51385840c..0c1ea17bae 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { + "editor.formatOnSave": false, "files.exclude": { "**/bin": true, "**/obj": true, diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs index ed7cf6467e..d1b8a384f7 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseClient.cs @@ -68,7 +68,7 @@ public interface IObservableEnterpriseClient /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> IObservableEnterprisePreReceiveHooksClient PreReceiveHook { get; } } diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs index 1cd389481f..e90b23b9cd 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterprisePreReceiveHooksClient.cs @@ -7,7 +7,7 @@ namespace Octokit.Reactive /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> public interface IObservableEnterprisePreReceiveHooksClient { @@ -15,7 +15,7 @@ public interface IObservableEnterprisePreReceiveHooksClient /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> IObservable<PreReceiveHook> GetAll(); @@ -24,7 +24,7 @@ public interface IObservableEnterprisePreReceiveHooksClient /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -34,7 +34,7 @@ public interface IObservableEnterprisePreReceiveHooksClient /// Gets a single <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> @@ -45,7 +45,7 @@ public interface IObservableEnterprisePreReceiveHooksClient /// Creates a new <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -55,7 +55,7 @@ public interface IObservableEnterprisePreReceiveHooksClient /// Edits an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> @@ -67,7 +67,7 @@ public interface IObservableEnterprisePreReceiveHooksClient /// Deletes an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs index 44ddd5f528..c542cb8f73 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseClient.cs @@ -82,7 +82,7 @@ public ObservableEnterpriseClient(IGitHubClient client) /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> public IObservableEnterprisePreReceiveHooksClient PreReceiveHook { get; private set; } } diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs index 7320aaa067..5747e20516 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterprisePreReceiveHooksClient.cs @@ -9,7 +9,7 @@ namespace Octokit.Reactive /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> public class ObservableEnterprisePreReceiveHooksClient : IObservableEnterprisePreReceiveHooksClient { @@ -28,7 +28,7 @@ public ObservableEnterprisePreReceiveHooksClient(IGitHubClient client) /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public IObservable<PreReceiveHook> GetAll() @@ -40,7 +40,7 @@ public IObservable<PreReceiveHook> GetAll() /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -55,7 +55,7 @@ public IObservable<PreReceiveHook> GetAll(ApiOptions options) /// Gets a single <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> @@ -69,7 +69,7 @@ public IObservable<PreReceiveHook> Get(long hookId) /// Creates a new <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -84,7 +84,7 @@ public IObservable<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook) /// Edits an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> @@ -101,7 +101,7 @@ public IObservable<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook update /// Deletes an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs index b44b78ba7b..e76acd4dde 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs @@ -38,7 +38,7 @@ public interface IObservableCommitCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> /// <returns></returns> IObservable<Reaction> GetAll(string owner, string name, int number); @@ -58,7 +58,7 @@ public interface IObservableCommitCommentReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> /// <param name="repositoryId">The owner of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> /// <returns></returns> IObservable<Reaction> GetAll(long repositoryId, int number); @@ -75,7 +75,7 @@ public interface IObservableCommitCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -86,7 +86,7 @@ public interface IObservableCommitCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs index 43fcef4e4d..22f74fbdc3 100644 --- a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs @@ -36,7 +36,7 @@ public interface IObservableIssueCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> IObservable<Reaction> GetAll(string owner, string name, int number); /// <summary> @@ -46,7 +46,7 @@ public interface IObservableIssueCommentReactionsClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> IObservable<Reaction> GetAll(string owner, string name, int number, ApiOptions options); /// <summary> @@ -54,7 +54,7 @@ public interface IObservableIssueCommentReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> IObservable<Reaction> GetAll(long repositoryId, int number); /// <summary> @@ -63,13 +63,13 @@ public interface IObservableIssueCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options); /// <summary> /// Deletes a reaction for a specified Issue Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -80,7 +80,7 @@ public interface IObservableIssueCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-comment-reaction</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index 6acd9b2731..c8b3baa623 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -17,7 +17,7 @@ public interface IObservableIssueReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The issue id</param> + /// <param name="number">The issue id</param> IObservable<Reaction> GetAll(string owner, string name, int number); /// <summary> @@ -27,7 +27,7 @@ public interface IObservableIssueReactionsClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> IObservable<Reaction> GetAll(string owner, string name, int number, ApiOptions options); /// <summary> @@ -35,7 +35,7 @@ public interface IObservableIssueReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue id</param> + /// <param name="number">The issue id</param> IObservable<Reaction> GetAll(long repositoryId, int number); /// <summary> @@ -44,7 +44,7 @@ public interface IObservableIssueReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options); /// <summary> @@ -69,7 +69,7 @@ public interface IObservableIssueReactionsClient /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="issueNumber">The issue number</param> @@ -80,7 +80,7 @@ public interface IObservableIssueReactionsClient /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="issueNumber">The issue number</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs index 7bdea7fff3..1097771f85 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs @@ -253,7 +253,7 @@ public interface IObservableOrganizationMembersClient /// </summary> /// <remarks> /// This method requires authentication. - /// See the <a href="http://developer.github.com/v3/orgs/members/#publicize-a-users-membership">API documentation</a> + /// See the <a href="http://developer.github.com/v3/orgs/members/#publicize-a-users-membership">API documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> @@ -289,7 +289,7 @@ public interface IObservableOrganizationMembersClient IObservable<OrganizationMembership> GetOrganizationMembership(string org, string user); /// <summary> - /// Add a user to the organization or update the user's role withing the organization. + /// Add a user to the organization or update the user's role withing the organization. /// </summary> /// <remarks> /// This method requires authentication. @@ -345,7 +345,7 @@ public interface IObservableOrganizationMembersClient /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> @@ -356,7 +356,7 @@ public interface IObservableOrganizationMembersClient /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> diff --git a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs index 0c3e06e0b3..4fdf13a006 100644 --- a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs @@ -17,7 +17,7 @@ public interface IObservablePullRequestReviewCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> IObservable<Reaction> GetAll(string owner, string name, int number); /// <summary> @@ -27,7 +27,7 @@ public interface IObservablePullRequestReviewCommentReactionsClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> IObservable<Reaction> GetAll(string owner, string name, int number, ApiOptions options); /// <summary> @@ -35,7 +35,7 @@ public interface IObservablePullRequestReviewCommentReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> IObservable<Reaction> GetAll(long repositoryId, int number); /// <summary> @@ -44,7 +44,7 @@ public interface IObservablePullRequestReviewCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options); /// <summary> @@ -69,7 +69,7 @@ public interface IObservablePullRequestReviewCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -80,7 +80,7 @@ public interface IObservablePullRequestReviewCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit.Reactive/Clients/IObservableReleasesClient.cs b/Octokit.Reactive/Clients/IObservableReleasesClient.cs index 072aba0ff2..5a8773b3a1 100644 --- a/Octokit.Reactive/Clients/IObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/IObservableReleasesClient.cs @@ -17,7 +17,7 @@ public interface IObservableReleasesClient /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="owner">The repository's owner</param> /// <param name="name">The repository's name</param> @@ -29,7 +29,7 @@ public interface IObservableReleasesClient /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="data">The request for generating release notes</param> diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 3d5167d8df..562ea50de9 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -76,7 +76,7 @@ public interface IObservableRepositoriesClient /// Checks if vulnerability alerts are enabled for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. /// </remarks> /// <param name="owner">The current owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -209,7 +209,7 @@ public interface IObservableRepositoriesClient /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/statuses/">Commit Status API documentation</a> for more - /// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a> + /// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a> /// that announced this feature. /// </remarks> IObservableCommitStatusClient Status { get; } @@ -249,7 +249,7 @@ public interface IObservableRepositoriesClient /// <summary> /// A client for GitHub's Repository Forks API. /// </summary> - /// <remarks>See <a href="http://developer.github.com/v3/repos/forks/">Forks API documentation</a> for more information.</remarks> + /// <remarks>See <a href="http://developer.github.com/v3/repos/forks/">Forks API documentation</a> for more information.</remarks> IObservableRepositoryForksClient Forks { get; } /// <summary> @@ -583,7 +583,7 @@ public interface IObservableRepositoriesClient /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -595,7 +595,7 @@ public interface IObservableRepositoriesClient /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -606,7 +606,7 @@ public interface IObservableRepositoriesClient /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <param name="options">Options for changing the API response</param> @@ -617,7 +617,7 @@ public interface IObservableRepositoriesClient /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <returns>All topics associated with the repository.</returns> @@ -627,7 +627,7 @@ public interface IObservableRepositoriesClient /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> @@ -640,7 +640,7 @@ public interface IObservableRepositoriesClient /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index 7193521746..36400e8723 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -63,7 +63,7 @@ public IObservable<Reaction> Create(long repositoryId, int number, NewReaction r /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> /// <returns></returns> public IObservable<Reaction> GetAll(string owner, string name, int number) { @@ -77,7 +77,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> /// <returns></returns> public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOptions options) { @@ -93,7 +93,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> /// <param name="repositoryId">The owner of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> /// <returns></returns> public IObservable<Reaction> GetAll(long repositoryId, int number) { @@ -118,7 +118,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -136,7 +136,7 @@ public IObservable<Unit> Delete(string owner, string name, int commentId, int re /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionid">The reaction id</param> diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index d8753a093c..747e5c3f4b 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -61,7 +61,7 @@ public IObservable<Reaction> Create(long repositoryId, int number, NewReaction r /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> public IObservable<Reaction> GetAll(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -77,7 +77,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -92,7 +92,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> public IObservable<Reaction> GetAll(long repositoryId, int number) { return GetAll(repositoryId, number, ApiOptions.None); @@ -104,7 +104,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number) /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); @@ -115,7 +115,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions op /// <summary> /// Deletes a reaction for a specified Issue Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -133,7 +133,7 @@ public IObservable<Unit> Delete(string owner, string name, int commentId, int re /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-comment-reaction</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index 8a9c451e3b..00153f0b52 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -30,7 +30,7 @@ public ObservableIssueReactionsClient(IGitHubClient client) /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The issue id</param> + /// <param name="number">The issue id</param> public IObservable<Reaction> GetAll(string owner, string name, int number) { return GetAll(owner, name, number, ApiOptions.None); @@ -43,7 +43,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number) /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); @@ -58,7 +58,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue id</param> + /// <param name="number">The issue id</param> public IObservable<Reaction> GetAll(long repositoryId, int number) { return GetAll(repositoryId, number, ApiOptions.None); @@ -70,7 +70,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number) /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); @@ -112,7 +112,7 @@ public IObservable<Reaction> Create(long repositoryId, int number, NewReaction r /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="issueNumber">The issue number</param> @@ -130,7 +130,7 @@ public IObservable<Unit> Delete(string owner, string name, int issueNumber, int /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="issueNumber">The issue number</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs index 64a97cbcbe..1a1b547399 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs @@ -343,7 +343,7 @@ public IObservable<Unit> Delete(string org, string user) /// </summary> /// <remarks> /// This method requires authentication. - /// See the <a href="http://developer.github.com/v3/orgs/members/#publicize-a-users-membership">API documentation</a> + /// See the <a href="http://developer.github.com/v3/orgs/members/#publicize-a-users-membership">API documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> @@ -397,7 +397,7 @@ public IObservable<OrganizationMembership> GetOrganizationMembership(string org, } /// <summary> - /// Add a user to the organization or update the user's role withing the organization. + /// Add a user to the organization or update the user's role withing the organization. /// </summary> /// <remarks> /// This method requires authentication. @@ -477,7 +477,7 @@ public IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(st /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> @@ -493,7 +493,7 @@ public IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(str /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs index 858d793757..7a4179b932 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs @@ -30,7 +30,7 @@ public ObservablePullRequestReviewCommentReactionsClient(IGitHubClient client) /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> public IObservable<Reaction> GetAll(string owner, string name, int number) { return GetAll(owner, name, number, ApiOptions.None); @@ -50,7 +50,7 @@ public IObservable<Reaction> GetAll(string owner, string name, int number, ApiOp /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> public IObservable<Reaction> GetAll(long repositoryId, int number) { return GetAll(repositoryId, number, ApiOptions.None); @@ -62,7 +62,7 @@ public IObservable<Reaction> GetAll(long repositoryId, int number) /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> public IObservable<Reaction> GetAll(long repositoryId, int number, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); @@ -104,7 +104,7 @@ public IObservable<Reaction> Create(long repositoryId, int number, NewReaction r /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -122,7 +122,7 @@ public IObservable<Unit> Delete(string owner, string name, int commentId, int re /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit.Reactive/Clients/ObservableReleasesClient.cs b/Octokit.Reactive/Clients/ObservableReleasesClient.cs index dcab994bff..3c1679d440 100644 --- a/Octokit.Reactive/Clients/ObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReleasesClient.cs @@ -29,7 +29,7 @@ public ObservableReleasesClient(IGitHubClient client) /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="owner">The repository's owner</param> /// <param name="name">The repository's name</param> @@ -48,7 +48,7 @@ public IObservable<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, str /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="data">The request for generating release notes</param> diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 4e23db5923..13bb249fc2 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -155,7 +155,7 @@ public IObservable<Repository> Transfer(long repositoryId, RepositoryTransfer re /// Checks if vulnerability alerts are enabled for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. /// </remarks> /// <param name="owner">The current owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -889,7 +889,7 @@ public IObservable<CompareResult> Compare(string owner, string name, string @bas /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -904,7 +904,7 @@ public IObservable<RepositoryTopics> GetAllTopics(string owner, string name, Api /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -918,7 +918,7 @@ public IObservable<RepositoryTopics> GetAllTopics(string owner, string name) /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <param name="options">Options for changing the API response</param> @@ -932,7 +932,7 @@ public IObservable<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <returns>All topics associated with the repository.</returns> @@ -945,7 +945,7 @@ public IObservable<RepositoryTopics> GetAllTopics(long repositoryId) /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> @@ -961,7 +961,7 @@ public IObservable<RepositoryTopics> ReplaceAllTopics(long repositoryId, Reposit /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> diff --git a/Octokit/Clients/CommitCommentReactionsClient.cs b/Octokit/Clients/CommitCommentReactionsClient.cs index 1c05c0f3ce..96fe0a7976 100644 --- a/Octokit/Clients/CommitCommentReactionsClient.cs +++ b/Octokit/Clients/CommitCommentReactionsClient.cs @@ -116,7 +116,7 @@ public Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOp /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -134,7 +134,7 @@ public Task Delete(string owner, string name, int commentId, int reactionId) /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit/Clients/Enterprise/EnterpriseClient.cs b/Octokit/Clients/Enterprise/EnterpriseClient.cs index adfdaf1af3..c97e938b81 100644 --- a/Octokit/Clients/Enterprise/EnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseClient.cs @@ -84,7 +84,7 @@ public EnterpriseClient(IApiConnection apiConnection) : base(apiConnection) /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> public IEnterprisePreReceiveHooksClient PreReceiveHook { get; private set; } } diff --git a/Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs b/Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs index 6bde1e1952..23749788e2 100644 --- a/Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs +++ b/Octokit/Clients/Enterprise/EnterprisePreReceiveHooksClient.cs @@ -7,7 +7,7 @@ namespace Octokit /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> public class EnterprisePreReceiveHooksClient : ApiClient, IEnterprisePreReceiveHooksClient { @@ -23,7 +23,7 @@ public EnterprisePreReceiveHooksClient(IApiConnection apiConnection) /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> [ManualRoute("GET", "/admin/pre-receive-hooks")] @@ -36,7 +36,7 @@ public Task<IReadOnlyList<PreReceiveHook>> GetAll() /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -51,7 +51,7 @@ public Task<IReadOnlyList<PreReceiveHook>> GetAll(ApiOptions options) /// Gets a single <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> @@ -67,7 +67,7 @@ public Task<PreReceiveHook> Get(long hookId) /// Creates a new <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -84,7 +84,7 @@ public Task<PreReceiveHook> Create(NewPreReceiveHook newPreReceiveHook) /// Edits an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> @@ -103,7 +103,7 @@ public Task<PreReceiveHook> Edit(long hookId, UpdatePreReceiveHook updatePreRece /// Deletes an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> diff --git a/Octokit/Clients/Enterprise/IEnterpriseClient.cs b/Octokit/Clients/Enterprise/IEnterpriseClient.cs index 30b1502d69..54a0313c3e 100644 --- a/Octokit/Clients/Enterprise/IEnterpriseClient.cs +++ b/Octokit/Clients/Enterprise/IEnterpriseClient.cs @@ -68,7 +68,7 @@ public interface IEnterpriseClient /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server@3.3/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server@3.3/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> IEnterprisePreReceiveHooksClient PreReceiveHook { get; } } diff --git a/Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs b/Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs index eb1e0e09a2..fa96eb4808 100644 --- a/Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs +++ b/Octokit/Clients/Enterprise/IEnterprisePreReceiveHooksClient.cs @@ -7,7 +7,7 @@ namespace Octokit /// A client for GitHub's Enterprise Pre-receive Hooks API /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#pre-receive-hooks">Enterprise Pre-receive Hooks API documentation</a> for more information. ///</remarks> public interface IEnterprisePreReceiveHooksClient { @@ -15,7 +15,7 @@ public interface IEnterprisePreReceiveHooksClient /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> Task<IReadOnlyList<PreReceiveHook>> GetAll(); @@ -24,7 +24,7 @@ public interface IEnterprisePreReceiveHooksClient /// Gets all <see cref="PreReceiveHook"/>s. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#list-pre-receive-hooks">API documentation</a> for more information. /// </remarks> /// <param name="options">Options for changing the API response</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -34,7 +34,7 @@ public interface IEnterprisePreReceiveHooksClient /// Gets a single <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#get-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> @@ -45,7 +45,7 @@ public interface IEnterprisePreReceiveHooksClient /// Creates a new <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#create-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="newPreReceiveHook">A description of the pre-receive hook to create</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> @@ -55,7 +55,7 @@ public interface IEnterprisePreReceiveHooksClient /// Edits an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#update-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <param name="updatePreReceiveHook">A description of the pre-receive hook to edit</param> @@ -67,11 +67,11 @@ public interface IEnterprisePreReceiveHooksClient /// Deletes an existing <see cref="PreReceiveHook"/>. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/enterprise-server/rest/reference/enterprise-admin#delete-a-pre-receive-hook">API documentation</a> for more information. /// </remarks> /// <param name="hookId">The id of the pre-receive hook</param> /// <exception cref="NotFoundException">Thrown when the specified <paramref name="hookId"/> does not exist.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> Task Delete(long hookId); } -} \ No newline at end of file +} diff --git a/Octokit/Clients/ICommitCommentReactionsClient.cs b/Octokit/Clients/ICommitCommentReactionsClient.cs index f35bb62058..f473269a3f 100644 --- a/Octokit/Clients/ICommitCommentReactionsClient.cs +++ b/Octokit/Clients/ICommitCommentReactionsClient.cs @@ -38,7 +38,7 @@ public interface ICommitCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> /// <returns></returns> Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number); @@ -58,7 +58,7 @@ public interface ICommitCommentReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> /// <param name="repositoryId">The owner of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> /// <returns></returns> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number); @@ -68,14 +68,14 @@ public interface ICommitCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> /// <returns></returns> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options); /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -86,7 +86,7 @@ public interface ICommitCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit/Clients/IIssueCommentReactionsClient.cs b/Octokit/Clients/IIssueCommentReactionsClient.cs index aafaa87ea4..ef41ef39bd 100644 --- a/Octokit/Clients/IIssueCommentReactionsClient.cs +++ b/Octokit/Clients/IIssueCommentReactionsClient.cs @@ -36,7 +36,7 @@ public interface IIssueCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number); /// <summary> @@ -46,7 +46,7 @@ public interface IIssueCommentReactionsClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number, ApiOptions options); /// <summary> @@ -54,7 +54,7 @@ public interface IIssueCommentReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number); /// <summary> @@ -63,13 +63,13 @@ public interface IIssueCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options); /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -80,7 +80,7 @@ public interface IIssueCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Commit Comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-commit-comment-reaction</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit/Clients/IIssueReactionsClient.cs b/Octokit/Clients/IIssueReactionsClient.cs index bcd3a0028d..3458454be0 100644 --- a/Octokit/Clients/IIssueReactionsClient.cs +++ b/Octokit/Clients/IIssueReactionsClient.cs @@ -17,7 +17,7 @@ public interface IIssueReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The issue id</param> + /// <param name="number">The issue id</param> Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number); /// <summary> @@ -27,7 +27,7 @@ public interface IIssueReactionsClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The issue id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number, ApiOptions options); /// <summary> @@ -35,7 +35,7 @@ public interface IIssueReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The issue id</param> + /// <param name="number">The issue id</param> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number); /// <summary> @@ -44,7 +44,7 @@ public interface IIssueReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options); /// <summary> @@ -69,7 +69,7 @@ public interface IIssueReactionsClient /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="issueNumber">The issue number</param> @@ -80,7 +80,7 @@ public interface IIssueReactionsClient /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="issueNumber">The issue number</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit/Clients/IOrganizationMembersClient.cs b/Octokit/Clients/IOrganizationMembersClient.cs index 91f102daec..328db251a9 100644 --- a/Octokit/Clients/IOrganizationMembersClient.cs +++ b/Octokit/Clients/IOrganizationMembersClient.cs @@ -259,7 +259,7 @@ public interface IOrganizationMembersClient /// </summary> /// <remarks> /// This method requires authentication. - /// See the <a href="http://developer.github.com/v3/orgs/members/#publicize-a-users-membership">API documentation</a> + /// See the <a href="http://developer.github.com/v3/orgs/members/#publicize-a-users-membership">API documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> @@ -295,7 +295,7 @@ public interface IOrganizationMembersClient Task<OrganizationMembership> GetOrganizationMembership(string org, string user); /// <summary> - /// Add a user to the organization or update the user's role withing the organization. + /// Add a user to the organization or update the user's role withing the organization. /// </summary> /// <remarks> /// This method requires authentication. @@ -351,7 +351,7 @@ public interface IOrganizationMembersClient /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> @@ -362,7 +362,7 @@ public interface IOrganizationMembersClient /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> diff --git a/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs index 128856fb0d..7e1b455456 100644 --- a/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs +++ b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs @@ -17,7 +17,7 @@ public interface IPullRequestReviewCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number); /// <summary> @@ -27,7 +27,7 @@ public interface IPullRequestReviewCommentReactionsClient /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> Task<IReadOnlyList<Reaction>> GetAll(string owner, string name, int number, ApiOptions options); /// <summary> @@ -35,7 +35,7 @@ public interface IPullRequestReviewCommentReactionsClient /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> - /// <param name="number">The comment id</param> + /// <param name="number">The comment id</param> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number); /// <summary> @@ -44,7 +44,7 @@ public interface IPullRequestReviewCommentReactionsClient /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> - /// <param name="options">Options for changing the API response</param> + /// <param name="options">Options for changing the API response</param> Task<IReadOnlyList<Reaction>> GetAll(long repositoryId, int number, ApiOptions options); /// <summary> @@ -69,7 +69,7 @@ public interface IPullRequestReviewCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The issue id</param> @@ -80,7 +80,7 @@ public interface IPullRequestReviewCommentReactionsClient /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="commentId">The issue id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit/Clients/IReleasesClient.cs b/Octokit/Clients/IReleasesClient.cs index 0af33be082..874fa77935 100644 --- a/Octokit/Clients/IReleasesClient.cs +++ b/Octokit/Clients/IReleasesClient.cs @@ -17,7 +17,7 @@ public interface IReleasesClient /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="owner">The repository's owner</param> /// <param name="name">The repository's name</param> @@ -29,7 +29,7 @@ public interface IReleasesClient /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="data">The request for generating release notes</param> diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index e4dc59a28e..56a4b7540a 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -137,7 +137,7 @@ public interface IRepositoriesClient /// Checks if vulnerability alerts are enabled for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. /// </remarks> /// <param name="owner">The current owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -303,7 +303,7 @@ public interface IRepositoriesClient /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/repos/statuses/">Commit Status API documentation</a> for more - /// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a> + /// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a> /// that announced this feature. /// </remarks> ICommitStatusClient Status { get; } @@ -317,7 +317,7 @@ public interface IRepositoriesClient /// <summary> /// A client for GitHub's Repository Forks API. /// </summary> - /// <remarks>See <a href="http://developer.github.com/v3/repos/forks/">Forks API documentation</a> for more information.</remarks> + /// <remarks>See <a href="http://developer.github.com/v3/repos/forks/">Forks API documentation</a> for more information.</remarks> IRepositoryForksClient Forks { get; } /// <summary> @@ -647,7 +647,7 @@ public interface IRepositoriesClient /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -659,7 +659,7 @@ public interface IRepositoriesClient /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -670,7 +670,7 @@ public interface IRepositoriesClient /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <param name="options">Options for changing the API response</param> @@ -681,7 +681,7 @@ public interface IRepositoriesClient /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <returns>All topics associated with the repository.</returns> @@ -691,7 +691,7 @@ public interface IRepositoriesClient /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> @@ -704,7 +704,7 @@ public interface IRepositoriesClient /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index 65f812965d..a944d7b044 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -110,7 +110,7 @@ public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="issueNumber">The issue id</param> @@ -128,7 +128,7 @@ public Task Delete(string owner, string name, int issueNumber, int reactionId) /// <summary> /// Deletes a reaction for a specified Issue /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-an-issue-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-an-issue-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="issueNumber">The issue id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index 4bed05e1ad..d9f9d4fa9f 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -572,7 +572,7 @@ public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvita /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> @@ -589,7 +589,7 @@ public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllFailedInvitat /// List failed organization invitations. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> + /// See the <a href="https://docs.github.com/rest/orgs/members#list-failed-organization-invitations">API Documentation</a> /// for more information. /// </remarks> /// <param name="org">The login for the organization</param> diff --git a/Octokit/Clients/PackagesClient.cs b/Octokit/Clients/PackagesClient.cs index d5de960fb0..91a6983315 100644 --- a/Octokit/Clients/PackagesClient.cs +++ b/Octokit/Clients/PackagesClient.cs @@ -7,7 +7,7 @@ namespace Octokit /// A client for GitHub's Packages API. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/packages">Packages API documentation</a> for more details. + /// See the <a href="https://docs.github.com/rest/packages">Packages API documentation</a> for more details. /// </remarks> public class PackagesClient : ApiClient, IPackagesClient { @@ -55,7 +55,7 @@ public Task<Package> GetForOrg(string org, PackageType packageType, string packa Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); var route = ApiUrls.PackageOrg(org, packageType, packageName); - + return ApiConnection.Get<Package>(route); } @@ -95,7 +95,7 @@ public Task RestoreForOrg(string org, PackageType packageType, string packageNam Ensure.ArgumentNotNullOrEmptyString(packageName, nameof(packageName)); var route = ApiUrls.PackageRestoreOrg(org, packageType, packageName); - + return ApiConnection.Post(route); } #endregion diff --git a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs index 09876a507d..a050cc7d80 100644 --- a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs +++ b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs @@ -110,7 +110,7 @@ public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="commentId">The comment id</param> @@ -128,7 +128,7 @@ public Task Delete(string owner, string name, int commentId, int reactionId) /// <summary> /// Deletes a reaction for a specified Pull Request comment /// </summary> - /// <remarks>https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction</remarks> + /// <remarks>https://docs.github.com/rest/reactions#delete-a-pull-request-comment-reaction</remarks> /// <param name="repositoryId">The owner of the repository</param> /// <param name="commentId">The comment id</param> /// <param name="reactionId">The reaction id</param> diff --git a/Octokit/Clients/ReleasesClient.cs b/Octokit/Clients/ReleasesClient.cs index bc988dd876..435bd36882 100644 --- a/Octokit/Clients/ReleasesClient.cs +++ b/Octokit/Clients/ReleasesClient.cs @@ -24,7 +24,7 @@ public ReleasesClient(IApiConnection apiConnection) : base(apiConnection) /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="owner">The repository's owner</param> /// <param name="name">The repository's name</param> @@ -45,7 +45,7 @@ public Task<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, string nam /// Generates a <see cref="GeneratedReleaseNotes"/>s for the specified repository with auto generated notes. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="data">The request for generating release notes</param> diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 803361991f..9de3bc7035 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -211,7 +211,7 @@ public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositor /// Checks if vulnerability alerts are enabled for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. + /// See the <a href="https://docs.github.com/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository">API documentation</a> for more information. /// </remarks> /// <param name="owner">The current owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -307,7 +307,7 @@ public Task<Repository> Get(long repositoryId) /// </remarks> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> + /// <returns>A <see cref="IReadOnlyList{Repository}"/> of <see cref="Repository"/>.</returns> [ManualRoute("GET", "/repositories")] public Task<IReadOnlyList<Repository>> GetAllPublic() { @@ -749,7 +749,7 @@ public Task<IReadOnlyList<RepositoryContributor>> GetAllContributors(long reposi /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <param name="options">Options for changing the API response</param> @@ -768,7 +768,7 @@ public async Task<RepositoryTopics> GetAllTopics(long repositoryId, ApiOptions o /// Gets all topics for the specified repository ID. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The ID of the repository</param> /// <returns>All topics associated with the repository.</returns> @@ -783,7 +783,7 @@ public Task<RepositoryTopics> GetAllTopics(long repositoryId) /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -806,7 +806,7 @@ public async Task<RepositoryTopics> GetAllTopics(string owner, string name, ApiO /// Gets all topics for the specified owner and repository name. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> @@ -822,7 +822,7 @@ public Task<RepositoryTopics> GetAllTopics(string owner, string name) /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> @@ -847,7 +847,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(string owner, string name, /// Replaces all topics for the specified repository. /// </summary> /// <remarks> - /// See the <a href="https://docs.github.com/en/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details + /// See the <a href="https://docs.github.com/rest/reference/repos#replace-all-repository-topics">API documentation</a> for more details /// /// This is a replacement operation; it is not additive. To clear repository topics, for example, you could specify an empty list of topics here. /// </remarks> diff --git a/Octokit/Exceptions/SecondaryRateLimitExceededException.cs b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs index dc0795b742..58b2ec4131 100644 --- a/Octokit/Exceptions/SecondaryRateLimitExceededException.cs +++ b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs @@ -12,7 +12,7 @@ namespace Octokit /// This occurs when GitHub perceives misuse of the API. You may get this if /// you are polling heavily, creating content rapidly or making concurrent requests. /// </para> - /// <para>See https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits for more details.</para> + /// <para>See https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits for more details.</para> /// </summary> [Serializable] [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index f3b2f0c0ca..d6c2cc11ab 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -230,7 +230,7 @@ public Uri BaseAddress /// Access GitHub's Pacakges API. /// </summary> /// <remarks> - /// Refer to the API documentation for more information: https://docs.github.com/en/rest/packages + /// Refer to the API documentation for more information: https://docs.github.com/rest/packages /// </remarks> public IPackagesClient Packages { get; private set; } diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 0d2ee9523f..8ce93a976a 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -91,7 +91,7 @@ public interface IGitHubClient : IApiInfoProvider /// Access GitHub's Pacakges API. /// </summary> /// <remarks> - /// Refer to the API documentation for more information: https://docs.github.com/en/rest/packages + /// Refer to the API documentation for more information: https://docs.github.com/rest/packages /// </remarks> IPackagesClient Packages { get; } diff --git a/Octokit/Models/Request/GenerateReleaseNotesRequest.cs b/Octokit/Models/Request/GenerateReleaseNotesRequest.cs index f3aef13039..0062b63eba 100644 --- a/Octokit/Models/Request/GenerateReleaseNotesRequest.cs +++ b/Octokit/Models/Request/GenerateReleaseNotesRequest.cs @@ -7,7 +7,7 @@ namespace Octokit /// Used to generate release notes for a given tag. /// </summary> /// <remarks> - /// API: https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release + /// API: https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release /// </remarks> [DebuggerDisplay("{DebuggerDisplay,nq}")] public class GenerateReleaseNotesRequest diff --git a/Octokit/Models/Response/GeneratedReleaseNotes.cs b/Octokit/Models/Response/GeneratedReleaseNotes.cs index 009e3dcf9a..411f5e6fa5 100644 --- a/Octokit/Models/Response/GeneratedReleaseNotes.cs +++ b/Octokit/Models/Response/GeneratedReleaseNotes.cs @@ -7,7 +7,7 @@ namespace Octokit /// Used to retrieve generated release notes. /// </summary> /// <remarks> - /// API: https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release + /// API: https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release /// The generated release notes are not saved anywhere. /// They are intended to be generated and used when creating a new release. /// </remarks> From 3c05db4065a0773b46a6a1e459fc10d248a8720f Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Tue, 20 Sep 2022 20:37:49 +0100 Subject: [PATCH 129/209] Splitting out the misc client into separate clients as per current documentation (#2574) --- .../Clients/IObservableEmojiClient.cs | 20 +++++ .../Clients/IObservableGitIgnoreClient.cs | 25 ++++++ .../Clients/IObservableLicensesClient.cs | 35 ++++++++ .../Clients/IObservableMarkdownClient.cs | 29 +++++++ .../Clients/IObservableMetaClient.cs | 20 +++++ .../Clients/IObservableMiscellaneousClient.cs | 18 ++-- .../Clients/IObservableRateLimitClient.cs | 20 +++++ .../Clients/ObservableEmojiClient.cs | 34 ++++++++ .../Clients/ObservableGitIgnoreClient.cs | 42 +++++++++ .../Clients/ObservableLicensesClient.cs | 55 ++++++++++++ .../Clients/ObservableMarkdownClient.cs | 46 ++++++++++ .../Clients/ObservableMetaClient.cs | 34 ++++++++ .../Clients/ObservableMiscellaneousClient.cs | 14 ++- .../Clients/ObservableRateLimitClient.cs | 34 ++++++++ Octokit.Reactive/IObservableGitHubClient.cs | 6 ++ Octokit.Reactive/ObservableGitHubClient.cs | 12 +++ .../Clients/EmojisClientTests.cs | 18 ++++ .../Clients/GitIgnoreClientTests.cs | 18 ++++ .../Clients/LicensesClientTests.cs | 85 +++++++++++++++++++ .../Clients/MarkdownClientTests.cs | 18 ++++ .../Clients/MetaClientTests.cs | 26 ++++++ .../Clients/RateLimitClientTests.cs | 37 ++++++++ Octokit.Tests/Clients/EmojisClientTests.cs | 46 ++++++++++ Octokit.Tests/Clients/LicensesClientTests.cs | 59 +++++++++++++ Octokit.Tests/Clients/MarkdownClientTests.cs | 70 +++++++++++++++ Octokit.Tests/Clients/MetaClientTests.cs | 51 +++++++++++ Octokit.Tests/Clients/RateLimitClientTests.cs | 74 ++++++++++++++++ .../Reactive/ObservableEmojiClientTests.cs | 33 +++++++ .../ObservableGitIgnoreClientTests.cs | 47 ++++++++++ .../Reactive/ObservableLicensesClientTests.cs | 47 ++++++++++ .../Reactive/ObservableMarkdownClientTests.cs | 47 ++++++++++ .../Reactive/ObservableMetaClientTests.cs | 33 +++++++ .../ObservableRateLimitClientTests.cs | 33 +++++++ Octokit/Clients/EmojisClient.cs | 34 ++++++++ Octokit/Clients/GitIgnoreClient.cs | 46 ++++++++++ Octokit/Clients/IEmojisClient.cs | 22 +++++ Octokit/Clients/IGitIgnoreClient.cs | 29 +++++++ Octokit/Clients/ILicensesClient.cs | 36 ++++++++ Octokit/Clients/IMarkdownClient.cs | 29 +++++++ Octokit/Clients/IMetaClient.cs | 20 +++++ Octokit/Clients/IMiscellaneousClient.cs | 18 ++-- Octokit/Clients/IRateLimitClient.cs | 20 +++++ Octokit/Clients/LicensesClient.cs | 59 +++++++++++++ Octokit/Clients/MarkdownClient.cs | 46 ++++++++++ Octokit/Clients/MetaClient.cs | 35 ++++++++ Octokit/Clients/MiscellaneousClient.cs | 49 ++++++++--- Octokit/Clients/RateLimitClient.cs | 35 ++++++++ Octokit/GitHubClient.cs | 54 ++++++++++++ Octokit/IGitHubClient.cs | 41 +++++++++ 49 files changed, 1729 insertions(+), 30 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableEmojiClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableGitIgnoreClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableLicensesClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableMarkdownClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableMetaClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableRateLimitClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableEmojiClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableGitIgnoreClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableLicensesClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableMarkdownClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableMetaClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableRateLimitClient.cs create mode 100644 Octokit.Tests.Integration/Clients/EmojisClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/GitIgnoreClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/LicensesClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/MarkdownClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/MetaClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/RateLimitClientTests.cs create mode 100644 Octokit.Tests/Clients/EmojisClientTests.cs create mode 100644 Octokit.Tests/Clients/LicensesClientTests.cs create mode 100644 Octokit.Tests/Clients/MarkdownClientTests.cs create mode 100644 Octokit.Tests/Clients/MetaClientTests.cs create mode 100644 Octokit.Tests/Clients/RateLimitClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableEmojiClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableGitIgnoreClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableLicensesClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableMarkdownClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableMetaClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableRateLimitClientTests.cs create mode 100644 Octokit/Clients/EmojisClient.cs create mode 100644 Octokit/Clients/GitIgnoreClient.cs create mode 100644 Octokit/Clients/IEmojisClient.cs create mode 100644 Octokit/Clients/IGitIgnoreClient.cs create mode 100644 Octokit/Clients/ILicensesClient.cs create mode 100644 Octokit/Clients/IMarkdownClient.cs create mode 100644 Octokit/Clients/IMetaClient.cs create mode 100644 Octokit/Clients/IRateLimitClient.cs create mode 100644 Octokit/Clients/LicensesClient.cs create mode 100644 Octokit/Clients/MarkdownClient.cs create mode 100644 Octokit/Clients/MetaClient.cs create mode 100644 Octokit/Clients/RateLimitClient.cs diff --git a/Octokit.Reactive/Clients/IObservableEmojiClient.cs b/Octokit.Reactive/Clients/IObservableEmojiClient.cs new file mode 100644 index 0000000000..74f93fa5cf --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableEmojiClient.cs @@ -0,0 +1,20 @@ +using System; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Emojis APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/emojis">Emojis API documentation</a> for more details. + /// </remarks> + public interface IObservableEmojisClient + { + /// <summary> + /// Gets all the emojis available to use on GitHub. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="IObservable{Emoji}"/> of emoji and their URI.</returns> + IObservable<Emoji> GetAllEmojis(); + } +} diff --git a/Octokit.Reactive/Clients/IObservableGitIgnoreClient.cs b/Octokit.Reactive/Clients/IObservableGitIgnoreClient.cs new file mode 100644 index 0000000000..b372620ade --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableGitIgnoreClient.cs @@ -0,0 +1,25 @@ +using System; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's gitignore APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/gitignore">GitIgnore API documentation</a> for more details. + /// </remarks> + public interface IObservableGitIgnoreClient + { + /// <summary> + /// List all templates available to pass as an option when creating a repository. + /// </summary> + /// <returns>An observable list of gitignore template names.</returns> + IObservable<string> GetAllGitIgnoreTemplates(); + + /// <summary> + /// Retrieves the source for a single GitIgnore template + /// </summary> + /// <param name="templateName">Returns the template source for the given template</param> + IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName); + } +} diff --git a/Octokit.Reactive/Clients/IObservableLicensesClient.cs b/Octokit.Reactive/Clients/IObservableLicensesClient.cs new file mode 100644 index 0000000000..030aa77578 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableLicensesClient.cs @@ -0,0 +1,35 @@ +using System; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's licenses APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/licenses">Licenses API documentation</a> for more details. + /// </remarks> + public interface IObservableLicensesClient + { + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <returns>A list of licenses available on the site</returns> + IObservable<LicenseMetadata> GetAllLicenses(); + + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of licenses available on the site</returns> + IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options); + + /// <summary> + /// Retrieves a license based on the license key such as "MIT" + /// </summary> + /// <param name="key"></param> + /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> + IObservable<License> GetLicense(string key); + } +} diff --git a/Octokit.Reactive/Clients/IObservableMarkdownClient.cs b/Octokit.Reactive/Clients/IObservableMarkdownClient.cs new file mode 100644 index 0000000000..c779dfcc9e --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableMarkdownClient.cs @@ -0,0 +1,29 @@ +using System; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's markdown APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/markdown">Markdown API documentation</a> for more details. + /// </remarks> + public interface IObservableMarkdownClient + { + /// <summary> + /// Gets the rendered Markdown for an arbitrary markdown document. + /// </summary> + /// <param name="markdown">An arbitrary Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown); + + /// <summary> + /// Gets the rendered Markdown for the specified plain-text Markdown document. + /// </summary> + /// <param name="markdown">A plain-text Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + IObservable<string> RenderRawMarkdown(string markdown); + } +} diff --git a/Octokit.Reactive/Clients/IObservableMetaClient.cs b/Octokit.Reactive/Clients/IObservableMetaClient.cs new file mode 100644 index 0000000000..97d63d19e3 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableMetaClient.cs @@ -0,0 +1,20 @@ +using System; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's meta APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/meta">Meta API documentation</a> for more details. + /// </remarks> + public interface IObservableMetaClient + { + /// <summary> + /// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> + IObservable<Meta> GetMetadata(); + } +} diff --git a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs index 2122d9be64..cfd6ad0dbe 100644 --- a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs @@ -1,8 +1,8 @@ using System; -using System.Diagnostics.CodeAnalysis; namespace Octokit.Reactive { + [Obsolete("Use individual clients for these methods")] public interface IObservableMiscellaneousClient { /// <summary> @@ -10,8 +10,7 @@ public interface IObservableMiscellaneousClient /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="IObservable{Emoji}"/> of emoji and their URI.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", - Justification = "Makes a network request")] + [Obsolete("This client is being deprecated and will be removed in the future. Use EmojisClient.GetAllEmojis instead.")] IObservable<Emoji> GetAllEmojis(); /// <summary> @@ -20,6 +19,7 @@ public interface IObservableMiscellaneousClient /// <param name="markdown">An arbitrary Markdown document</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderArbitraryMarkdown instead.")] IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown); /// <summary> @@ -28,19 +28,21 @@ public interface IObservableMiscellaneousClient /// <param name="markdown">A plain-text Markdown document</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderRawMarkdown instead.")] IObservable<string> RenderRawMarkdown(string markdown); /// <summary> /// List all templates available to pass as an option when creating a repository. /// </summary> /// <returns>An observable list of gitignore template names.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetAllGitIgnoreTemplates instead.")] IObservable<string> GetAllGitIgnoreTemplates(); /// <summary> /// Retrieves the source for a single GitIgnore template /// </summary> /// <param name="templateName">Returns the template source for the given template</param> + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetGitIgnoreTemplate instead.")] IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName); /// <summary> @@ -48,7 +50,7 @@ public interface IObservableMiscellaneousClient /// list of all possible OSS licenses. /// </summary> /// <returns>A list of licenses available on the site</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")] IObservable<LicenseMetadata> GetAllLicenses(); /// <summary> @@ -57,6 +59,7 @@ public interface IObservableMiscellaneousClient /// </summary> /// <param name="options">Options for changing the API response</param> /// <returns>A list of licenses available on the site</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")] IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options); /// <summary> @@ -64,6 +67,7 @@ public interface IObservableMiscellaneousClient /// </summary> /// <param name="key"></param> /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetLicense instead.")] IObservable<License> GetLicense(string key); /// <summary> @@ -71,7 +75,7 @@ public interface IObservableMiscellaneousClient /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use RateLimitClient.GetRateLimits instead.")] IObservable<MiscellaneousRateLimit> GetRateLimits(); /// <summary> @@ -79,7 +83,7 @@ public interface IObservableMiscellaneousClient /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use MetaClient.GetMetadata instead.")] IObservable<Meta> GetMetadata(); } } diff --git a/Octokit.Reactive/Clients/IObservableRateLimitClient.cs b/Octokit.Reactive/Clients/IObservableRateLimitClient.cs new file mode 100644 index 0000000000..62e3224dbc --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableRateLimitClient.cs @@ -0,0 +1,20 @@ +using System; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's rate-limit APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/rate-limit">Rate-Limit API documentation</a> for more details. + /// </remarks> + public interface IObservableRateLimitClient + { + /// <summary> + /// Gets API Rate Limits (API service rather than header info). + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> + IObservable<MiscellaneousRateLimit> GetRateLimits(); + } +} diff --git a/Octokit.Reactive/Clients/ObservableEmojiClient.cs b/Octokit.Reactive/Clients/ObservableEmojiClient.cs new file mode 100644 index 0000000000..1eca68c87a --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableEmojiClient.cs @@ -0,0 +1,34 @@ +using System; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Emojis APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/emojis">Emojis API documentation</a> for more details. + /// </remarks> + public class ObservableEmojisClient : IObservableEmojisClient + { + private readonly IEmojisClient _client; + + public ObservableEmojisClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Emojis; + } + + /// <summary> + /// Gets all the emojis available to use on GitHub. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="IObservable{Emoji}"/> of emoji and their URI.</returns> + public IObservable<Emoji> GetAllEmojis() + { + return _client.GetAllEmojis().ToObservable().SelectMany(e => e); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableGitIgnoreClient.cs b/Octokit.Reactive/Clients/ObservableGitIgnoreClient.cs new file mode 100644 index 0000000000..4faca614fe --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableGitIgnoreClient.cs @@ -0,0 +1,42 @@ +using System; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's gitignore APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/gitignore">GitIgnore API documentation</a> for more details. + /// </remarks> + public class ObservableGitIgnoreClient : IObservableGitIgnoreClient + { + private readonly IGitIgnoreClient _client; + + public ObservableGitIgnoreClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.GitIgnore; + } + + /// <summary> + /// List all templates available to pass as an option when creating a repository. + /// </summary> + /// <returns>An observable list of gitignore template names.</returns> + public IObservable<string> GetAllGitIgnoreTemplates() + { + return _client.GetAllGitIgnoreTemplates().ToObservable().SelectMany(t => t); + } + + /// <summary> + /// Retrieves the source for a single GitIgnore template + /// </summary> + /// <param name="templateName">Returns the template source for the given template</param> + public IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName) + { + return _client.GetGitIgnoreTemplate(templateName).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableLicensesClient.cs b/Octokit.Reactive/Clients/ObservableLicensesClient.cs new file mode 100644 index 0000000000..c247e018a3 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableLicensesClient.cs @@ -0,0 +1,55 @@ +using System; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's licenses APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/licenses">Licenses API documentation</a> for more details. + /// </remarks> + public class ObservableLicensesClient : IObservableLicensesClient + { + private readonly ILicensesClient _client; + + public ObservableLicensesClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Licenses; + } + + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <returns>A list of licenses available on the site</returns> + public IObservable<LicenseMetadata> GetAllLicenses() + { + return GetAllLicenses(ApiOptions.None); + } + + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of licenses available on the site</returns> + public IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options) + { + return _client.GetAllLicenses(options).ToObservable().SelectMany(l => l); + } + + /// <summary> + /// Retrieves a license based on the license key such as "MIT" + /// </summary> + /// <param name="key"></param> + /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> + public IObservable<License> GetLicense(string key) + { + return _client.GetLicense(key).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableMarkdownClient.cs b/Octokit.Reactive/Clients/ObservableMarkdownClient.cs new file mode 100644 index 0000000000..e29b6d372b --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableMarkdownClient.cs @@ -0,0 +1,46 @@ +using System; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's markdown APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/markdown">Markdown API documentation</a> for more details. + /// </remarks> + public class ObservableMarkdownClient : IObservableMarkdownClient + { + private readonly IMarkdownClient _client; + + public ObservableMarkdownClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Markdown; + } + + /// <summary> + /// Gets the rendered Markdown for an arbitrary markdown document. + /// </summary> + /// <param name="markdown">An arbitrary Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + public IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) + { + return _client.RenderArbitraryMarkdown(markdown).ToObservable(); + } + + /// <summary> + /// Gets the rendered Markdown for the specified plain-text Markdown document. + /// </summary> + /// <param name="markdown">A plain-text Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + public IObservable<string> RenderRawMarkdown(string markdown) + { + return _client.RenderRawMarkdown(markdown).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableMetaClient.cs b/Octokit.Reactive/Clients/ObservableMetaClient.cs new file mode 100644 index 0000000000..3df88872d7 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableMetaClient.cs @@ -0,0 +1,34 @@ +using System; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's meta APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/meta">Meta API documentation</a> for more details. + /// </remarks> + public class ObservableMetaClient : IObservableMetaClient + { + private readonly IMetaClient _client; + + public ObservableMetaClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Meta; + } + + /// <summary> + /// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> + public IObservable<Meta> GetMetadata() + { + return _client.GetMetadata().ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs index 86973c6475..e34a341996 100644 --- a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs @@ -1,10 +1,10 @@ using System; -using System.Diagnostics.CodeAnalysis; using System.Reactive.Linq; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive { + [Obsolete("Use individual clients available on the GitHubClient for these methods")] public class ObservableMiscellaneousClient : IObservableMiscellaneousClient { readonly IMiscellaneousClient _client; @@ -21,6 +21,7 @@ public ObservableMiscellaneousClient(IGitHubClient client) /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="IObservable{Emoji}"/> of emoji and their URI.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use EmojisClient.GetAllEmojis instead.")] public IObservable<Emoji> GetAllEmojis() { return _client.GetAllEmojis().ToObservable().SelectMany(e => e); @@ -32,6 +33,7 @@ public IObservable<Emoji> GetAllEmojis() /// <param name="markdown">An arbitrary Markdown document</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderArbitraryMarkdown instead.")] public IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) { return _client.RenderArbitraryMarkdown(markdown).ToObservable(); @@ -43,6 +45,7 @@ public IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown /// <param name="markdown">A plain-text Markdown document</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderRawMarkdown instead.")] public IObservable<string> RenderRawMarkdown(string markdown) { return _client.RenderRawMarkdown(markdown).ToObservable(); @@ -52,6 +55,7 @@ public IObservable<string> RenderRawMarkdown(string markdown) /// List all templates available to pass as an option when creating a repository. /// </summary> /// <returns>An observable list of gitignore template names.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetAllGitIgnoreTemplates instead.")] public IObservable<string> GetAllGitIgnoreTemplates() { return _client.GetAllGitIgnoreTemplates().ToObservable().SelectMany(t => t); @@ -61,6 +65,7 @@ public IObservable<string> GetAllGitIgnoreTemplates() /// Retrieves the source for a single GitIgnore template /// </summary> /// <param name="templateName">Returns the template source for the given template</param> + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetGitIgnoreTemplate instead.")] public IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName) { return _client.GetGitIgnoreTemplate(templateName).ToObservable(); @@ -71,6 +76,7 @@ public IObservable<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName) /// list of all possible OSS licenses. /// </summary> /// <returns>A list of licenses available on the site</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")] public IObservable<LicenseMetadata> GetAllLicenses() { return GetAllLicenses(ApiOptions.None); @@ -82,6 +88,7 @@ public IObservable<LicenseMetadata> GetAllLicenses() /// </summary> /// <param name="options">Options for changing the API response</param> /// <returns>A list of licenses available on the site</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")] public IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options) { return _client.GetAllLicenses(options).ToObservable().SelectMany(l => l); @@ -92,6 +99,7 @@ public IObservable<LicenseMetadata> GetAllLicenses(ApiOptions options) /// </summary> /// <param name="key"></param> /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetLicense instead.")] public IObservable<License> GetLicense(string key) { return _client.GetLicense(key).ToObservable(); @@ -102,7 +110,7 @@ public IObservable<License> GetLicense(string key) /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use RateLimitClient.GetRateLimits instead.")] public IObservable<MiscellaneousRateLimit> GetRateLimits() { return _client.GetRateLimits().ToObservable(); @@ -113,7 +121,7 @@ public IObservable<MiscellaneousRateLimit> GetRateLimits() /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use MetaClient.GetMetadata instead.")] public IObservable<Meta> GetMetadata() { return _client.GetMetadata().ToObservable(); diff --git a/Octokit.Reactive/Clients/ObservableRateLimitClient.cs b/Octokit.Reactive/Clients/ObservableRateLimitClient.cs new file mode 100644 index 0000000000..f0513a4fcc --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableRateLimitClient.cs @@ -0,0 +1,34 @@ +using System; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's rate-limit APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/rate-limit">Rate-Limit API documentation</a> for more details. + /// </remarks> + public class ObservableRateLimitClient : IObservableRateLimitClient + { + private readonly IRateLimitClient _client; + + public ObservableRateLimitClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.RateLimit; + } + + /// <summary> + /// Gets API Rate Limits (API service rather than header info). + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> + public IObservable<MiscellaneousRateLimit> GetRateLimits() + { + return _client.GetRateLimits().ToObservable(); + } + } +} diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 5563afe5c2..f5ed4393d1 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -35,5 +35,11 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableReactionsClient Reaction { get; } IObservableChecksClient Check { get; } IObservablePackagesClient Packages{ get; } + IObservableEmojisClient Emojis { get; } + IObservableMarkdownClient Markdown { get; } + IObservableGitIgnoreClient GitIgnore { get; } + IObservableLicensesClient Licenses { get; } + IObservableRateLimitClient RateLimit { get; } + IObservableMetaClient Meta { get; } } } \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index e84e191b1f..648360f4c8 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -50,6 +50,12 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Reaction = new ObservableReactionsClient(gitHubClient); Check = new ObservableChecksClient(gitHubClient); Packages = new ObservablePackagesClient(gitHubClient); + Emojis = new ObservableEmojisClient(gitHubClient); + Markdown = new ObservableMarkdownClient(gitHubClient); + GitIgnore = new ObservableGitIgnoreClient(gitHubClient); + Licenses = new ObservableLicensesClient(gitHubClient); + RateLimit = new ObservableRateLimitClient(gitHubClient); + Meta = new ObservableMetaClient(gitHubClient); } public IConnection Connection @@ -90,6 +96,12 @@ public void SetRequestTimeout(TimeSpan timeout) public IObservableReactionsClient Reaction { get; private set; } public IObservableChecksClient Check { get; private set; } public IObservablePackagesClient Packages { get; private set; } + public IObservableEmojisClient Emojis { get; private set; } + public IObservableMarkdownClient Markdown { get; private set; } + public IObservableGitIgnoreClient GitIgnore { get; private set; } + public IObservableLicensesClient Licenses { get; private set; } + public IObservableRateLimitClient RateLimit { get; private set; } + public IObservableMetaClient Meta { get; private set; } /// <summary> /// Gets the latest API Info - this will be null if no API calls have been made diff --git a/Octokit.Tests.Integration/Clients/EmojisClientTests.cs b/Octokit.Tests.Integration/Clients/EmojisClientTests.cs new file mode 100644 index 0000000000..b76b4bddfb --- /dev/null +++ b/Octokit.Tests.Integration/Clients/EmojisClientTests.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class EmojisClientTests + { + [IntegrationTest] + public async Task GetsAllTheEmojis() + { + var github = Helper.GetAuthenticatedClient(); + + var emojis = await github.Emojis.GetAllEmojis(); + + Assert.True(emojis.Count > 1); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/GitIgnoreClientTests.cs b/Octokit.Tests.Integration/Clients/GitIgnoreClientTests.cs new file mode 100644 index 0000000000..3f2a34ed32 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/GitIgnoreClientTests.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class GitIgnoreClientTests + { + [IntegrationTest] + public async Task ReturnsListOfGitIgnoreTemplates() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.GitIgnore.GetAllGitIgnoreTemplates(); + + Assert.True(result.Count > 2); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/LicensesClientTests.cs b/Octokit.Tests.Integration/Clients/LicensesClientTests.cs new file mode 100644 index 0000000000..8bf3c2dc9d --- /dev/null +++ b/Octokit.Tests.Integration/Clients/LicensesClientTests.cs @@ -0,0 +1,85 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class LicensesClientTests + { + public class TheGetLicensesMethod + { + [IntegrationTest] + public async Task CanRetrieveListOfLicenses() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.Licenses.GetAllLicenses(); + + Assert.True(result.Count > 2); + Assert.Contains(result, license => license.Key == "mit"); + } + + [IntegrationTest] + public async Task CanRetrieveListOfLicensesWithPagination() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 5, + }; + + var result = await github.Licenses.GetAllLicenses(options); + + Assert.Equal(5, result.Count); + } + + [IntegrationTest] + public async Task CanRetrieveDistinctListOfLicensesBasedOnPageStart() + { + var github = Helper.GetAuthenticatedClient(); + + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstPage = await github.Licenses.GetAllLicenses(startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await github.Licenses.GetAllLicenses(skipStartOptions); + + Assert.NotEqual(firstPage[0].Key, secondPage[0].Key); + } + } + + public class TheGetLicenseMethod + { + [IntegrationTest] + public async Task CanRetrieveListOfLicenses() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.Licenses.GetLicense("mit"); + + Assert.Equal("mit", result.Key); + Assert.Equal("MIT License", result.Name); + } + + [IntegrationTest] + public async Task ReportsErrorWhenInvalidLicenseProvided() + { + var github = Helper.GetAuthenticatedClient(); + + await Assert.ThrowsAsync<NotFoundException>(() => github.Licenses.GetLicense("purple-monkey-dishwasher")); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/MarkdownClientTests.cs b/Octokit.Tests.Integration/Clients/MarkdownClientTests.cs new file mode 100644 index 0000000000..9e16f11c3f --- /dev/null +++ b/Octokit.Tests.Integration/Clients/MarkdownClientTests.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class MarkdownClientTests + { + [IntegrationTest] + public async Task CanRenderGitHubFlavoredMarkdown() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.Markdown.RenderRawMarkdown("This is\r\n a **test**"); + + Assert.Equal("<p>This is\na <strong>test</strong></p>\n", result); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/MetaClientTests.cs b/Octokit.Tests.Integration/Clients/MetaClientTests.cs new file mode 100644 index 0000000000..ddf5188114 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/MetaClientTests.cs @@ -0,0 +1,26 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class MetaClientTests + { + public class TheGetMetadataMethod + { + [IntegrationTest] + public async Task CanRetrieveMetadata() + { + var github = Helper.GetAnonymousClient(); + + var result = await github.Meta.GetMetadata(); + + Assert.True(result.VerifiablePasswordAuthentication); + Assert.NotEmpty(result.GitHubServicesSha); + Assert.True(result.Hooks.Count > 0); + Assert.True(result.Git.Count > 0); + Assert.True(result.Pages.Count > 0); + Assert.True(result.Importer.Count > 0); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/RateLimitClientTests.cs b/Octokit.Tests.Integration/Clients/RateLimitClientTests.cs new file mode 100644 index 0000000000..9719383836 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/RateLimitClientTests.cs @@ -0,0 +1,37 @@ +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class RateLimitClientTests + { + [IntegrationTest] + public async Task CanRetrieveResourceRateLimits() + { + var github = Helper.GetAuthenticatedClient(); + + var result = await github.RateLimit.GetRateLimits(); + + // Test the core limits + Assert.True(result.Resources.Core.Limit > 0); + Assert.True(result.Resources.Core.Remaining > -1); + Assert.True(result.Resources.Core.Remaining <= result.Resources.Core.Limit); + Assert.True(result.Resources.Core.ResetAsUtcEpochSeconds > 0); + Assert.NotEqual(default, result.Resources.Core.Reset); + + // Test the search limits + Assert.True(result.Resources.Search.Limit > 0); + Assert.True(result.Resources.Search.Remaining > -1); + Assert.True(result.Resources.Search.Remaining <= result.Resources.Search.Limit); + Assert.True(result.Resources.Search.ResetAsUtcEpochSeconds > 0); + Assert.NotEqual(default, result.Resources.Search.Reset); + + // Test the depreciated rate limits + Assert.True(result.Rate.Limit > 0); + Assert.True(result.Rate.Remaining > -1); + Assert.True(result.Rate.Remaining <= result.Rate.Limit); + Assert.True(result.Resources.Search.ResetAsUtcEpochSeconds > 0); + Assert.NotEqual(default, result.Resources.Search.Reset); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/EmojisClientTests.cs b/Octokit.Tests/Clients/EmojisClientTests.cs new file mode 100644 index 0000000000..3f60d10ace --- /dev/null +++ b/Octokit.Tests/Clients/EmojisClientTests.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class EmojisClientTests + { + public class TheGetEmojisMethod + { + [Fact] + public async Task RequestsTheEmojiEndpoint() + { + IReadOnlyList<Emoji> response = new List<Emoji> + { + { new Emoji("foo", "http://example.com/foo.gif") }, + { new Emoji("bar", "http://example.com/bar.gif") } + }; + + var apiConnection = Substitute.For<IApiConnection>(); + apiConnection.GetAll<Emoji>(Args.Uri) + .Returns(Task.FromResult(response)); + + var client = new EmojisClient(apiConnection); + + var emojis = await client.GetAllEmojis(); + + Assert.Equal(2, emojis.Count); + Assert.Equal("foo", emojis[0].Name); + apiConnection.Received() + .GetAll<Emoji>(Arg.Is<Uri>(u => u.ToString() == "emojis")); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new EmojisClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Clients/LicensesClientTests.cs b/Octokit.Tests/Clients/LicensesClientTests.cs new file mode 100644 index 0000000000..852c50d9ec --- /dev/null +++ b/Octokit.Tests/Clients/LicensesClientTests.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class LicensesClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new LicensesClient(null)); + } + } + + public class TheGetAllLicensesMethod + { + [Fact] + public void EnsuresNonNullArguments() + { + var client = new LicensesClient(Substitute.For<IApiConnection>()); + + Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllLicenses(null)); + } + + [Fact] + public async Task RequestsTheLicensesEndpoint() + { + IReadOnlyList<LicenseMetadata> response = new ReadOnlyCollection<LicenseMetadata>(new List<LicenseMetadata>() + { + new LicenseMetadata("foo1", "node-id-1", "foo2", "something", "http://example.com/foo1", true), + new LicenseMetadata("bar1", "node-id-1", "bar2", "something else", "http://example.com/bar1", false) + }); + + var connection = Substitute.For<IApiConnection>(); + connection.GetAll<LicenseMetadata>(Arg.Is<Uri>(u => u.ToString() == "licenses"), Args.ApiOptions) + .Returns(Task.FromResult(response)); + var client = new LicensesClient(connection); + + var licenses = await client.GetAllLicenses(); + + Assert.Equal(2, licenses.Count); + Assert.Equal("foo1", licenses[0].Key); + Assert.Equal("foo2", licenses[0].Name); + Assert.Equal("http://example.com/foo1", licenses[0].Url); + Assert.Equal("bar1", licenses[1].Key); + Assert.Equal("bar2", licenses[1].Name); + Assert.Equal("http://example.com/bar1", licenses[1].Url); + connection.Received() + .GetAll<LicenseMetadata>(Arg.Is<Uri>(u => u.ToString() == "licenses"), Args.ApiOptions); + } + } + } +} diff --git a/Octokit.Tests/Clients/MarkdownClientTests.cs b/Octokit.Tests/Clients/MarkdownClientTests.cs new file mode 100644 index 0000000000..49e5d1dcb3 --- /dev/null +++ b/Octokit.Tests/Clients/MarkdownClientTests.cs @@ -0,0 +1,70 @@ +using System; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class MarkdownClientTests + { + public class TheRenderRawMarkdownMethod + { + [Fact] + public async Task RequestsTheRawMarkdownEndpoint() + { + var markdown = "**Test**"; + var response = "<strong>Test</strong>"; + var apiConnection = Substitute.For<IApiConnection>(); + apiConnection.Post<string>( + Arg.Is<Uri>(u => u.ToString() == "markdown/raw"), + markdown, + "text/html", + "text/plain") + .Returns(Task.FromResult(response)); + var client = new MarkdownClient(apiConnection); + + var html = await client.RenderRawMarkdown(markdown); + + Assert.Equal("<strong>Test</strong>", html); + apiConnection.Received() + .Post<string>(Arg.Is<Uri>(u => u.ToString() == "markdown/raw"), + markdown, + "text/html", + "text/plain"); + } + } + public class TheRenderArbitraryMarkdownMethod + { + [Fact] + public async Task RequestsTheMarkdownEndpoint() + { + var response = "<strong>Test</strong>"; + + var payload = new NewArbitraryMarkdown("testMarkdown", "gfm", "testContext"); + + var apiConnection = Substitute.For<IApiConnection>(); + apiConnection.Post<string>(Args.Uri, payload, "text/html", "text/plain") + .Returns(Task.FromResult(response)); + + var client = new MarkdownClient(apiConnection); + + var html = await client.RenderArbitraryMarkdown(payload); + Assert.Equal("<strong>Test</strong>", html); + apiConnection.Received() + .Post<string>(Arg.Is<Uri>(u => u.ToString() == "markdown"), + payload, + "text/html", + "text/plain"); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new MiscellaneousClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Clients/MetaClientTests.cs b/Octokit.Tests/Clients/MetaClientTests.cs new file mode 100644 index 0000000000..c804a39726 --- /dev/null +++ b/Octokit.Tests/Clients/MetaClientTests.cs @@ -0,0 +1,51 @@ +using System; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class MetaClientTests + { + public class TheGetMetadataMethod + { + [Fact] + public async Task RequestsTheMetadataEndpoint() + { + var meta = new Meta( + false, + "12345ABCDE", + new[] { "1.1.1.1/24", "1.1.1.2/24" }, + new[] { "1.1.2.1/24", "1.1.2.2/24" }, + new[] { "1.1.3.1/24", "1.1.3.2/24" }, + new[] { "1.1.4.1", "1.1.4.2" } + ); + + var apiConnection = Substitute.For<IApiConnection>(); + apiConnection.Get<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta")).Returns(Task.FromResult(meta)); + var client = new MetaClient(apiConnection); + + var result = await client.GetMetadata(); + + Assert.False(result.VerifiablePasswordAuthentication); + Assert.Equal("12345ABCDE", result.GitHubServicesSha); + Assert.Equal(result.Hooks, new[] { "1.1.1.1/24", "1.1.1.2/24" }); + Assert.Equal(result.Git, new[] { "1.1.2.1/24", "1.1.2.2/24" }); + Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" }); + Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" }); + + apiConnection.Received() + .Get<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta")); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new MetaClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Clients/RateLimitClientTests.cs b/Octokit.Tests/Clients/RateLimitClientTests.cs new file mode 100644 index 0000000000..4c086d0b85 --- /dev/null +++ b/Octokit.Tests/Clients/RateLimitClientTests.cs @@ -0,0 +1,74 @@ +using System; +using System.Threading.Tasks; +using NSubstitute; +using Xunit; +using System.Globalization; + +namespace Octokit.Tests.Clients +{ + public class RateLimitClientTests + { + public class TheGetResourceRateLimitsMethod + { + [Fact] + public async Task RequestsTheResourceRateLimitEndpoint() + { + var rateLimit = new MiscellaneousRateLimit( + new ResourceRateLimit( + new RateLimit(5000, 4999, 1372700873), + new RateLimit(30, 18, 1372700873) + ), + new RateLimit(100, 75, 1372700873) + ); + var apiConnection = Substitute.For<IApiConnection>(); + apiConnection.Get<MiscellaneousRateLimit>(Arg.Is<Uri>(u => u.ToString() == "rate_limit")).Returns(Task.FromResult(rateLimit)); + + var client = new RateLimitClient(apiConnection); + + var result = await client.GetRateLimits(); + + // Test the core limits + Assert.Equal(5000, result.Resources.Core.Limit); + Assert.Equal(4999, result.Resources.Core.Remaining); + Assert.Equal(1372700873, result.Resources.Core.ResetAsUtcEpochSeconds); + var expectedReset = DateTimeOffset.ParseExact( + "Mon 01 Jul 2013 5:47:53 PM -00:00", + "ddd dd MMM yyyy h:mm:ss tt zzz", + CultureInfo.InvariantCulture); + Assert.Equal(expectedReset, result.Resources.Core.Reset); + + // Test the search limits + Assert.Equal(30, result.Resources.Search.Limit); + Assert.Equal(18, result.Resources.Search.Remaining); + Assert.Equal(1372700873, result.Resources.Search.ResetAsUtcEpochSeconds); + expectedReset = DateTimeOffset.ParseExact( + "Mon 01 Jul 2013 5:47:53 PM -00:00", + "ddd dd MMM yyyy h:mm:ss tt zzz", + CultureInfo.InvariantCulture); + Assert.Equal(expectedReset, result.Resources.Search.Reset); + + // Test the depreciated rate limits + Assert.Equal(100, result.Rate.Limit); + Assert.Equal(75, result.Rate.Remaining); + Assert.Equal(1372700873, result.Rate.ResetAsUtcEpochSeconds); + expectedReset = DateTimeOffset.ParseExact( + "Mon 01 Jul 2013 5:47:53 PM -00:00", + "ddd dd MMM yyyy h:mm:ss tt zzz", + CultureInfo.InvariantCulture); + Assert.Equal(expectedReset, result.Rate.Reset); + + apiConnection.Received() + .Get<MiscellaneousRateLimit>(Arg.Is<Uri>(u => u.ToString() == "rate_limit")); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new RateLimitClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableEmojiClientTests.cs b/Octokit.Tests/Reactive/ObservableEmojiClientTests.cs new file mode 100644 index 0000000000..eac88d8771 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableEmojiClientTests.cs @@ -0,0 +1,33 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableEmojiClientTests + { + public class TheGetAllEmojisMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableEmojisClient(gitHubClient); + + client.GetAllEmojis(); + + gitHubClient.Emojis.Received(1).GetAllEmojis(); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableEmojisClient((IGitHubClient)null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableGitIgnoreClientTests.cs b/Octokit.Tests/Reactive/ObservableGitIgnoreClientTests.cs new file mode 100644 index 0000000000..51e4634149 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableGitIgnoreClientTests.cs @@ -0,0 +1,47 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableGitIgnoreClientTests + { + public class TheGetAllGitIgnoreTemplatesMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableGitIgnoreClient(gitHubClient); + + client.GetAllGitIgnoreTemplates(); + + gitHubClient.GitIgnore.Received(1).GetAllGitIgnoreTemplates(); + } + } + + public class TheGetGitIgnoreTemplate + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableGitIgnoreClient(gitHubClient); + + client.GetGitIgnoreTemplate("template"); + + gitHubClient.GitIgnore.Received(1).GetGitIgnoreTemplate("template"); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableGitIgnoreClient((IGitHubClient)null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableLicensesClientTests.cs b/Octokit.Tests/Reactive/ObservableLicensesClientTests.cs new file mode 100644 index 0000000000..b72b59924f --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableLicensesClientTests.cs @@ -0,0 +1,47 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableLicensesClientTests + { + public class TheGetAllLicensesMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableLicensesClient(gitHubClient); + + client.GetAllLicenses(); + + gitHubClient.Licenses.Received(1).GetAllLicenses(Args.ApiOptions); + } + } + + public class TheGetLicenseMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableLicensesClient(gitHubClient); + + client.GetLicense("key"); + + gitHubClient.Licenses.Received(1).GetLicense("key"); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableLicensesClient((IGitHubClient)null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableMarkdownClientTests.cs b/Octokit.Tests/Reactive/ObservableMarkdownClientTests.cs new file mode 100644 index 0000000000..a61753550b --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableMarkdownClientTests.cs @@ -0,0 +1,47 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableMarkdownClientTests + { + public class TheRenderArbitraryMarkdownMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableMarkdownClient(gitHubClient); + + client.RenderArbitraryMarkdown(new NewArbitraryMarkdown("# test")); + + gitHubClient.Markdown.Received(1).RenderArbitraryMarkdown(Arg.Is<NewArbitraryMarkdown>(a => a.Text == "# test")); + } + } + + public class TheRenderRawMarkdownMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableMarkdownClient(gitHubClient); + + client.RenderRawMarkdown("# test"); + + gitHubClient.Markdown.Received(1).RenderRawMarkdown("# test"); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableMarkdownClient((IGitHubClient)null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableMetaClientTests.cs b/Octokit.Tests/Reactive/ObservableMetaClientTests.cs new file mode 100644 index 0000000000..a2e0d71c41 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableMetaClientTests.cs @@ -0,0 +1,33 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableMetaClientTests + { + public class TheGetMetadataMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableMetaClient(gitHubClient); + + client.GetMetadata(); + + gitHubClient.Meta.Received(1).GetMetadata(); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableMetaClient((IGitHubClient)null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableRateLimitClientTests.cs b/Octokit.Tests/Reactive/ObservableRateLimitClientTests.cs new file mode 100644 index 0000000000..daad9fc330 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableRateLimitClientTests.cs @@ -0,0 +1,33 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableRateLimitClientTests + { + public class TheGetRateLimitsMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRateLimitClient(gitHubClient); + + client.GetRateLimits(); + + gitHubClient.RateLimit.Received(1).GetRateLimits(); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableRateLimitClient((IGitHubClient)null)); + } + } + } +} diff --git a/Octokit/Clients/EmojisClient.cs b/Octokit/Clients/EmojisClient.cs new file mode 100644 index 0000000000..cdec98eff8 --- /dev/null +++ b/Octokit/Clients/EmojisClient.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Emojis APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/emojis">Emojis API documentation</a> for more details. + /// </remarks> + public class EmojisClient : ApiClient, IEmojisClient + { + /// <summary> + /// Initializes a new GitHub emojis API client. + /// </summary> + /// <param name="apiConnection">An API connection.</param> + public EmojisClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// <summary> + /// Gets all the emojis available to use on GitHub. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="IReadOnlyDictionary{TKey,TValue}"/> of emoji and their URI.</returns> + [ManualRoute("GET", "/emojis")] + public Task<IReadOnlyList<Emoji>> GetAllEmojis() + { + return ApiConnection.GetAll<Emoji>(ApiUrls.Emojis()); + } + } +} diff --git a/Octokit/Clients/GitIgnoreClient.cs b/Octokit/Clients/GitIgnoreClient.cs new file mode 100644 index 0000000000..8171dd1d38 --- /dev/null +++ b/Octokit/Clients/GitIgnoreClient.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's gitignore APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/gitignore">GitIgnore API documentation</a> for more details. + /// </remarks> + public class GitIgnoreClient : ApiClient, IGitIgnoreClient + { + /// <summary> + /// Initializes a new GitHub gitignore API client. + /// </summary> + /// <param name="apiConnection">An API connection.</param> + public GitIgnoreClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// <summary> + /// List all templates available to pass as an option when creating a repository. + /// </summary> + /// <returns>A list of template names</returns> + [ManualRoute("GET", "/gitignore/templates")] + public Task<IReadOnlyList<string>> GetAllGitIgnoreTemplates() + { + return ApiConnection.GetAll<string>(ApiUrls.GitIgnoreTemplates()); + } + + /// <summary> + /// Retrieves the source for a single GitIgnore template + /// </summary> + /// <param name="templateName"></param> + /// <returns>A template and its source</returns> + [ManualRoute("GET", "/gitignore/templates/{name}")] + public Task<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName) + { + Ensure.ArgumentNotNullOrEmptyString(templateName, nameof(templateName)); + + return ApiConnection.Get<GitIgnoreTemplate>(ApiUrls.GitIgnoreTemplates(templateName)); + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/IEmojisClient.cs b/Octokit/Clients/IEmojisClient.cs new file mode 100644 index 0000000000..5a1307ee2c --- /dev/null +++ b/Octokit/Clients/IEmojisClient.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Emojis APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/emojis">Emojis API documentation</a> for more details. + /// </remarks> + public interface IEmojisClient + { + /// <summary> + /// Gets all the emojis available to use on GitHub. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="IReadOnlyDictionary{TKey,TValue}"/> of emoji and their URI.</returns> + [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] + Task<IReadOnlyList<Emoji>> GetAllEmojis(); + } +} \ No newline at end of file diff --git a/Octokit/Clients/IGitIgnoreClient.cs b/Octokit/Clients/IGitIgnoreClient.cs new file mode 100644 index 0000000000..f69d6f5a88 --- /dev/null +++ b/Octokit/Clients/IGitIgnoreClient.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's gitignore APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/gitignore">GitIgnore API documentation</a> for more details. + /// </remarks> + public interface IGitIgnoreClient + { + /// <summary> + /// List all templates available to pass as an option when creating a repository. + /// </summary> + /// <returns>A list of template names</returns> + [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] + Task<IReadOnlyList<string>> GetAllGitIgnoreTemplates(); + + + /// <summary> + /// Retrieves the source for a single GitIgnore template + /// </summary> + /// <param name="templateName"></param> + /// <returns>A template and its source</returns> + Task<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName); + } +} \ No newline at end of file diff --git a/Octokit/Clients/ILicensesClient.cs b/Octokit/Clients/ILicensesClient.cs new file mode 100644 index 0000000000..f5b5cae9ea --- /dev/null +++ b/Octokit/Clients/ILicensesClient.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's licenses APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/licenses">Licenses API documentation</a> for more details. + /// </remarks> + public interface ILicensesClient + { + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <returns>A list of licenses available on the site</returns> + Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses(); + + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of licenses available on the site</returns> + Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses(ApiOptions options); + + /// <summary> + /// Retrieves a license based on the license key such as "mit" + /// </summary> + /// <param name="key"></param> + /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> + Task<License> GetLicense(string key); + } +} \ No newline at end of file diff --git a/Octokit/Clients/IMarkdownClient.cs b/Octokit/Clients/IMarkdownClient.cs new file mode 100644 index 0000000000..e4cd5abdc1 --- /dev/null +++ b/Octokit/Clients/IMarkdownClient.cs @@ -0,0 +1,29 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's markdown APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/markdown">Markdown API documentation</a> for more details. + /// </remarks> + public interface IMarkdownClient + { + /// <summary> + /// Gets the rendered Markdown for the specified plain-text Markdown document. + /// </summary> + /// <param name="markdown">A plain-text Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + Task<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown); + + /// <summary> + /// Gets the rendered Markdown for an arbitrary markdown document. + /// </summary> + /// <param name="markdown">An arbitrary Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + Task<string> RenderRawMarkdown(string markdown); + } +} \ No newline at end of file diff --git a/Octokit/Clients/IMetaClient.cs b/Octokit/Clients/IMetaClient.cs new file mode 100644 index 0000000000..f4c21714d0 --- /dev/null +++ b/Octokit/Clients/IMetaClient.cs @@ -0,0 +1,20 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's meta APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/meta">Meta API documentation</a> for more details. + /// </remarks> + public interface IMetaClient + { + /// <summary> + /// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> + Task<Meta> GetMetadata(); + } +} \ No newline at end of file diff --git a/Octokit/Clients/IMiscellaneousClient.cs b/Octokit/Clients/IMiscellaneousClient.cs index 1766c79bb5..8463444b72 100644 --- a/Octokit/Clients/IMiscellaneousClient.cs +++ b/Octokit/Clients/IMiscellaneousClient.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; +using System; namespace Octokit { @@ -10,6 +10,7 @@ namespace Octokit /// <remarks> /// See the <a href="http://developer.github.com/v3/misc/">Miscellaneous API documentation</a> for more details. /// </remarks> + [Obsolete("Use individual clients available on the GitHubClient for these methods")] public interface IMiscellaneousClient { /// <summary> @@ -17,8 +18,8 @@ public interface IMiscellaneousClient /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="IReadOnlyDictionary{TKey,TValue}"/> of emoji and their URI.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] + [Obsolete("This client is being deprecated and will be removed in the future. Use EmojisClient.GetAllEmojis instead.")] Task<IReadOnlyList<Emoji>> GetAllEmojis(); /// <summary> @@ -27,6 +28,7 @@ public interface IMiscellaneousClient /// <param name="markdown">A plain-text Markdown document</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderRawMarkdown instead.")] Task<string> RenderRawMarkdown(string markdown); /// <summary> @@ -35,14 +37,15 @@ public interface IMiscellaneousClient /// <param name="markdown">An arbitrary Markdown document</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderArbitraryMarkdown instead.")] Task<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown); /// <summary> /// List all templates available to pass as an option when creating a repository. /// </summary> /// <returns>A list of template names</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] [ExcludeFromPaginationApiOptionsConventionTest("Pagination not supported by GitHub API (tested 29/08/2017)")] + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetAllGitIgnoreTemplates instead.")] Task<IReadOnlyList<string>> GetAllGitIgnoreTemplates(); /// <summary> @@ -50,6 +53,7 @@ public interface IMiscellaneousClient /// </summary> /// <param name="templateName"></param> /// <returns>A template and its source</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetAllGitIgnoreTemplates instead.")] Task<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName); /// <summary> @@ -57,7 +61,7 @@ public interface IMiscellaneousClient /// list of all possible OSS licenses. /// </summary> /// <returns>A list of licenses available on the site</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetGitIgnoreTemplate instead.")] Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses(); /// <summary> @@ -66,6 +70,7 @@ public interface IMiscellaneousClient /// </summary> /// <param name="options">Options for changing the API response</param> /// <returns>A list of licenses available on the site</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")] Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses(ApiOptions options); /// <summary> @@ -73,6 +78,7 @@ public interface IMiscellaneousClient /// </summary> /// <param name="key">The license identifier to look for</param> /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetLicense instead.")] Task<License> GetLicense(string key); /// <summary> @@ -80,7 +86,7 @@ public interface IMiscellaneousClient /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use RateLimitClient.GetRateLimits instead.")] Task<MiscellaneousRateLimit> GetRateLimits(); /// <summary> @@ -88,7 +94,7 @@ public interface IMiscellaneousClient /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [Obsolete("This client is being deprecated and will be removed in the future. Use MetaClient.GetMetadata instead.")] Task<Meta> GetMetadata(); } } diff --git a/Octokit/Clients/IRateLimitClient.cs b/Octokit/Clients/IRateLimitClient.cs new file mode 100644 index 0000000000..32e6bffdc9 --- /dev/null +++ b/Octokit/Clients/IRateLimitClient.cs @@ -0,0 +1,20 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's rate-limit APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/rate-limit">Rate-Limit API documentation</a> for more details. + /// </remarks> + public interface IRateLimitClient + { + /// <summary> + /// Gets API Rate Limits (API service rather than header info). + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> + Task<MiscellaneousRateLimit> GetRateLimits(); + } +} \ No newline at end of file diff --git a/Octokit/Clients/LicensesClient.cs b/Octokit/Clients/LicensesClient.cs new file mode 100644 index 0000000000..03cbbd18d8 --- /dev/null +++ b/Octokit/Clients/LicensesClient.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's licenses APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/licenses">Licenses API documentation</a> for more details. + /// </remarks> + public class LicensesClient : ApiClient, ILicensesClient + { + /// <summary> + /// Initializes a new GitHub gitignore API client. + /// </summary> + /// <param name="apiConnection">An API connection.</param> + public LicensesClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <returns>A list of licenses available on the site</returns> + [ManualRoute("GET", "/licenses")] + public Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses() + { + return GetAllLicenses(ApiOptions.None); + } + + /// <summary> + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// </summary> + /// <param name="options">Options for changing the API response</param> + /// <returns>A list of licenses available on the site</returns> + [ManualRoute("GET", "/licenses")] + public Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll<LicenseMetadata>(ApiUrls.Licenses(), options); + } + + /// <summary> + /// Retrieves a license based on the license key such as "mit" + /// </summary> + /// <param name="key"></param> + /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> + [ManualRoute("GET", "/licenses/{key}")] + public Task<License> GetLicense(string key) + { + return ApiConnection.Get<License>(ApiUrls.Licenses(key)); + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/MarkdownClient.cs b/Octokit/Clients/MarkdownClient.cs new file mode 100644 index 0000000000..99944c580c --- /dev/null +++ b/Octokit/Clients/MarkdownClient.cs @@ -0,0 +1,46 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's markdown APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/markdown">Markdown API documentation</a> for more details. + /// </remarks> + public class MarkdownClient : ApiClient, IMarkdownClient + { + /// <summary> + /// Initializes a new GitHub markdown API client. + /// </summary> + /// <param name="apiConnection">An API connection.</param> + public MarkdownClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// <summary> + /// Gets the rendered Markdown for the specified plain-text Markdown document. + /// </summary> + /// <param name="markdown">A plain-text Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + [ManualRoute("POST", "/markdown/raw")] + public Task<string> RenderRawMarkdown(string markdown) + { + return ApiConnection.Post<string>(ApiUrls.RawMarkdown(), markdown, "text/html", "text/plain"); + } + + /// <summary> + /// Gets the rendered Markdown for an arbitrary markdown document. + /// </summary> + /// <param name="markdown">An arbitrary Markdown document</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>The rendered Markdown.</returns> + [ManualRoute("POST", "/markdown")] + public Task<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) + { + return ApiConnection.Post<string>(ApiUrls.Markdown(), markdown, "text/html", "text/plain"); + } + } +} diff --git a/Octokit/Clients/MetaClient.cs b/Octokit/Clients/MetaClient.cs new file mode 100644 index 0000000000..c683a34bba --- /dev/null +++ b/Octokit/Clients/MetaClient.cs @@ -0,0 +1,35 @@ +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's meta APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/meta">Meta API documentation</a> for more details. + /// </remarks> + public class MetaClient : ApiClient, IMetaClient + { + /// <summary> + /// Initializes a new GitHub meta API client. + /// </summary> + /// <param name="apiConnection">An API connection.</param> + public MetaClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// <summary> + /// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation. + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [ManualRoute("GET", "/meta")] + public Task<Meta> GetMetadata() + { + return ApiConnection.Get<Meta>(ApiUrls.Meta()); + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index 3ff32aa081..872753c393 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; namespace Octokit @@ -11,8 +10,16 @@ namespace Octokit /// <remarks> /// See the <a href="http://developer.github.com/v3/misc/">Miscellaneous API documentation</a> for more details. /// </remarks> + [Obsolete("Use individual clients available on the GitHubClient for these methods")] public class MiscellaneousClient : ApiClient, IMiscellaneousClient { + private readonly IEmojisClient _emojisClient; + private readonly IMarkdownClient _markdownClient; + private readonly IGitIgnoreClient _gitIgnoreClient; + private readonly ILicensesClient _licensesClient; + private readonly IRateLimitClient _rateLimitClient; + private readonly IMetaClient _metaClient; + /// <summary> /// Initializes a new GitHub miscellaneous API client. /// </summary> @@ -20,6 +27,12 @@ public class MiscellaneousClient : ApiClient, IMiscellaneousClient public MiscellaneousClient(IApiConnection apiConnection) : base(apiConnection) { + _emojisClient = new EmojisClient(apiConnection); + _markdownClient = new MarkdownClient(apiConnection); + _gitIgnoreClient = new GitIgnoreClient(apiConnection); + _licensesClient = new LicensesClient(apiConnection); + _rateLimitClient = new RateLimitClient(apiConnection); + _metaClient = new MetaClient(apiConnection); } /// <summary> @@ -28,9 +41,10 @@ public MiscellaneousClient(IApiConnection apiConnection) /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="IReadOnlyDictionary{TKey,TValue}"/> of emoji and their URI.</returns> [ManualRoute("GET", "/emojis")] + [Obsolete("This client is being deprecated and will be removed in the future. Use EmojisClient.GetAllEmojis instead.")] public Task<IReadOnlyList<Emoji>> GetAllEmojis() { - return ApiConnection.GetAll<Emoji>(ApiUrls.Emojis()); + return _emojisClient.GetAllEmojis(); } /// <summary> @@ -40,9 +54,10 @@ public Task<IReadOnlyList<Emoji>> GetAllEmojis() /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> [ManualRoute("POST", "/markdown/raw")] + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderRawMarkdown instead.")] public Task<string> RenderRawMarkdown(string markdown) { - return ApiConnection.Post<string>(ApiUrls.RawMarkdown(), markdown, "text/html", "text/plain"); + return _markdownClient.RenderRawMarkdown(markdown); } /// <summary> @@ -52,9 +67,10 @@ public Task<string> RenderRawMarkdown(string markdown) /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>The rendered Markdown.</returns> [ManualRoute("POST", "/markdown")] + [Obsolete("This client is being deprecated and will be removed in the future. Use MarkdownClient.RenderArbitraryMarkdown instead.")] public Task<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) { - return ApiConnection.Post<string>(ApiUrls.Markdown(), markdown, "text/html", "text/plain"); + return _markdownClient.RenderArbitraryMarkdown(markdown); } /// <summary> @@ -62,9 +78,10 @@ public Task<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) /// </summary> /// <returns>A list of template names</returns> [ManualRoute("GET", "/gitignore/templates")] + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetAllGitIgnoreTemplates instead.")] public Task<IReadOnlyList<string>> GetAllGitIgnoreTemplates() { - return ApiConnection.GetAll<string>(ApiUrls.GitIgnoreTemplates()); + return _gitIgnoreClient.GetAllGitIgnoreTemplates(); } /// <summary> @@ -73,11 +90,12 @@ public Task<IReadOnlyList<string>> GetAllGitIgnoreTemplates() /// <param name="templateName"></param> /// <returns>A template and its source</returns> [ManualRoute("GET", "/gitignore/templates/{name}")] + [Obsolete("This client is being deprecated and will be removed in the future. Use GitIgnoreClient.GetGitIgnoreTemplate instead.")] public Task<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName) { Ensure.ArgumentNotNullOrEmptyString(templateName, nameof(templateName)); - return ApiConnection.Get<GitIgnoreTemplate>(ApiUrls.GitIgnoreTemplates(templateName)); + return _gitIgnoreClient.GetGitIgnoreTemplate(templateName); } /// <summary> @@ -85,10 +103,11 @@ public Task<GitIgnoreTemplate> GetGitIgnoreTemplate(string templateName) /// list of all possible OSS licenses. /// </summary> /// <returns>A list of licenses available on the site</returns> + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")] [ManualRoute("GET", "/licenses")] public Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses() { - return GetAllLicenses(ApiOptions.None); + return _licensesClient.GetAllLicenses(); } /// <summary> @@ -98,11 +117,12 @@ public Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses() /// <param name="options">Options for changing the API response</param> /// <returns>A list of licenses available on the site</returns> [ManualRoute("GET", "/licenses")] + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetAllLicenses instead.")] public Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses(ApiOptions options) { Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll<LicenseMetadata>(ApiUrls.Licenses(), options); + return _licensesClient.GetAllLicenses(options); } /// <summary> @@ -111,9 +131,10 @@ public Task<IReadOnlyList<LicenseMetadata>> GetAllLicenses(ApiOptions options) /// <param name="key"></param> /// <returns>A <see cref="License" /> that includes the license key, text, and attributes of the license.</returns> [ManualRoute("GET", "/licenses/{key}")] + [Obsolete("This client is being deprecated and will be removed in the future. Use LicensesClient.GetLicense instead.")] public Task<License> GetLicense(string key) { - return ApiConnection.Get<License>(ApiUrls.Licenses(key)); + return _licensesClient.GetLicense(key); } /// <summary> @@ -121,11 +142,11 @@ public Task<License> GetLicense(string key) /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] [ManualRoute("GET", "/rate_limit")] + [Obsolete("This client is being deprecated and will be removed in the future. Use RateLimitClient.GetRateLimits instead.")] public Task<MiscellaneousRateLimit> GetRateLimits() { - return ApiConnection.Get<MiscellaneousRateLimit>(ApiUrls.RateLimit()); + return _rateLimitClient.GetRateLimits(); } /// <summary> @@ -133,11 +154,11 @@ public Task<MiscellaneousRateLimit> GetRateLimits() /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>An <see cref="Meta"/> containing metadata about the GitHub instance.</returns> - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] [ManualRoute("GET", "/meta")] + [Obsolete("This client is being deprecated and will be removed in the future. Use MetaClient.GetMetadata instead.")] public Task<Meta> GetMetadata() { - return ApiConnection.Get<Meta>(ApiUrls.Meta()); + return _metaClient.GetMetadata(); } } -} +} \ No newline at end of file diff --git a/Octokit/Clients/RateLimitClient.cs b/Octokit/Clients/RateLimitClient.cs new file mode 100644 index 0000000000..df2d39bded --- /dev/null +++ b/Octokit/Clients/RateLimitClient.cs @@ -0,0 +1,35 @@ +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's rate-limit APIs. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/rest/rate-limit">Rate-Limit API documentation</a> for more details. + /// </remarks> + public class RateLimitClient : ApiClient, IRateLimitClient + { + /// <summary> + /// Initializes a new GitHub rate-limit API client. + /// </summary> + /// <param name="apiConnection">An API connection.</param> + public RateLimitClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// <summary> + /// Gets API Rate Limits (API service rather than header info). + /// </summary> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>An <see cref="MiscellaneousRateLimit"/> of Rate Limits.</returns> + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + [ManualRoute("GET", "/rate_limit")] + public Task<MiscellaneousRateLimit> GetRateLimits() + { + return ApiConnection.Get<MiscellaneousRateLimit>(ApiUrls.RateLimit()); + } + } +} \ No newline at end of file diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index d6c2cc11ab..ba2d8a2633 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -112,6 +112,12 @@ public GitHubClient(IConnection connection) Reaction = new ReactionsClient(apiConnection); Check = new ChecksClient(apiConnection); Packages = new PackagesClient(apiConnection); + Emojis = new EmojisClient(apiConnection); + Markdown = new MarkdownClient(apiConnection); + GitIgnore = new GitIgnoreClient(apiConnection); + Licenses = new LicensesClient(apiConnection); + RateLimit = new RateLimitClient(apiConnection); + Meta = new MetaClient(apiConnection); } /// <summary> @@ -186,6 +192,14 @@ public Uri BaseAddress /// </remarks> public IActivitiesClient Activity { get; private set; } + /// <summary> + /// Access GitHub's Emojis API. + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/emojis + /// </remarks> + public IEmojisClient Emojis { get; private set; } + /// <summary> /// Access GitHub's Issue API. /// </summary> @@ -314,6 +328,46 @@ public Uri BaseAddress /// </remarks> public IChecksClient Check { get; private set; } + /// <summary> + /// Access GitHub's Meta API. + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/meta + /// </remarks> + public IMetaClient Meta { get; private set; } + + /// <summary> + /// Access GitHub's Rate Limit API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/rate-limit + /// </remarks> + public IRateLimitClient RateLimit { get; private set; } + + /// <summary> + /// Access GitHub's Licenses API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/licenses + /// </remarks> + public ILicensesClient Licenses { get; private set; } + + /// <summary> + /// Access GitHub's Git Ignore API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/gitignore + /// </remarks> + public IGitIgnoreClient GitIgnore { get; private set; } + + /// <summary> + /// Access GitHub's Markdown API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/markdown + /// </remarks> + public IMarkdownClient Markdown { get; private set; } + static Uri FixUpBaseUri(Uri uri) { Ensure.ArgumentNotNull(uri, nameof(uri)); diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 8ce93a976a..2de41eb246 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -166,5 +166,46 @@ public interface IGitHubClient : IApiInfoProvider /// Refer to the API documentation for more information: https://developer.github.com/v3/checks/ /// </remarks> IChecksClient Check { get; } + + /// <summary> + /// Access GitHub's Meta API. + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/meta + /// </remarks> + IMetaClient Meta { get; } + + /// <summary> + /// Access GitHub's Rate Limit API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/rate-limit + /// </remarks> + IRateLimitClient RateLimit { get; } + + /// <summary> + /// Access GitHub's Markdown API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/markdown + /// </remarks> + IMarkdownClient Markdown { get; } + + /// <summary> + /// Access GitHub's Git Ignore API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/gitignore + /// </remarks> + IGitIgnoreClient GitIgnore { get; } + + /// <summary> + /// Access GitHub's Licenses API + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/rest/licenses + /// </remarks> + ILicensesClient Licenses { get; } + IEmojisClient Emojis { get; } } } From 2701be5e79a47a88ec075ee2df24e905a770142a Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Tue, 20 Sep 2022 21:15:19 +0100 Subject: [PATCH 130/209] Fix deserializing of Emoji types (#2577) --- .../Clients/MiscellaneousClientTests.cs | 12 +++--- Octokit/Clients/MiscellaneousClient.cs | 11 +++-- Octokit/Http/AssignableExtensions.cs | 40 +++++++++++++++++++ Octokit/Http/JsonHttpPipeline.cs | 2 +- 4 files changed, 54 insertions(+), 11 deletions(-) create mode 100644 Octokit/Http/AssignableExtensions.cs diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 059316e354..1c44aec35e 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -65,15 +65,15 @@ public class TheGetEmojisMethod [Fact] public async Task RequestsTheEmojiEndpoint() { - IReadOnlyList<Emoji> response = new List<Emoji> + IDictionary<string, string> response = new Dictionary<string, string> { - { new Emoji("foo", "http://example.com/foo.gif") }, - { new Emoji("bar", "http://example.com/bar.gif") } + { "foo", "http://example.com/foo.gif" }, + { "bar", "http://example.com/bar.gif" } }; var apiConnection = Substitute.For<IApiConnection>(); - apiConnection.GetAll<Emoji>(Args.Uri) - .Returns(Task.FromResult(response)); + apiConnection.Get<IDictionary<string, string>>(Args.Uri) + .Returns(Task.FromResult(response)); var client = new MiscellaneousClient(apiConnection); @@ -82,7 +82,7 @@ public async Task RequestsTheEmojiEndpoint() Assert.Equal(2, emojis.Count); Assert.Equal("foo", emojis[0].Name); apiConnection.Received() - .GetAll<Emoji>(Arg.Is<Uri>(u => u.ToString() == "emojis")); + .Get<IDictionary<string, string>>(Arg.Is<Uri>(u => u.ToString() == "emojis")); } } diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index 872753c393..ab64a8ee16 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Threading.Tasks; namespace Octokit @@ -39,12 +41,13 @@ public MiscellaneousClient(IApiConnection apiConnection) /// Gets all the emojis available to use on GitHub. /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - /// <returns>An <see cref="IReadOnlyDictionary{TKey,TValue}"/> of emoji and their URI.</returns> + /// <returns>An <see cref="IReadOnlyList{Emoji}"/> of emoji and their URI.</returns> [ManualRoute("GET", "/emojis")] - [Obsolete("This client is being deprecated and will be removed in the future. Use EmojisClient.GetAllEmojis instead.")] - public Task<IReadOnlyList<Emoji>> GetAllEmojis() + public async Task<IReadOnlyList<Emoji>> GetAllEmojis() { - return _emojisClient.GetAllEmojis(); + var result = await ApiConnection.Get<IDictionary<string, string>>(ApiUrls.Emojis()); + + return result.Select(x => new Emoji(x.Key, x.Value)).ToList(); } /// <summary> diff --git a/Octokit/Http/AssignableExtensions.cs b/Octokit/Http/AssignableExtensions.cs new file mode 100644 index 0000000000..6fd2de8fb5 --- /dev/null +++ b/Octokit/Http/AssignableExtensions.cs @@ -0,0 +1,40 @@ +using System; +using System.Linq; + +namespace Octokit +{ + public static class AssignableExtensions + { + /// <summary> + /// Determines whether the <paramref name="genericType"/> is assignable from + /// <paramref name="givenType"/> taking into account generic definitions + /// </summary> + public static bool IsAssignableToGenericType(this Type givenType, Type genericType) + { + if (givenType == null || genericType == null) + { + return false; + } + + return givenType == genericType + || givenType.MapsToGenericTypeDefinition(genericType) + || givenType.HasInterfaceThatMapsToGenericTypeDefinition(genericType) + || givenType.BaseType.IsAssignableToGenericType(genericType); + } + + private static bool HasInterfaceThatMapsToGenericTypeDefinition(this Type givenType, Type genericType) + { + return givenType + .GetInterfaces() + .Where(it => it.IsGenericType) + .Any(it => it.GetGenericTypeDefinition() == genericType); + } + + private static bool MapsToGenericTypeDefinition(this Type givenType, Type genericType) + { + return genericType.IsGenericTypeDefinition + && givenType.IsGenericType + && givenType.GetGenericTypeDefinition() == genericType; + } + } +} diff --git a/Octokit/Http/JsonHttpPipeline.cs b/Octokit/Http/JsonHttpPipeline.cs index 7296cd378a..e40a347d1d 100644 --- a/Octokit/Http/JsonHttpPipeline.cs +++ b/Octokit/Http/JsonHttpPipeline.cs @@ -49,7 +49,7 @@ public IApiResponse<T> DeserializeResponse<T>(IResponse response) // simple json does not support the root node being empty. Will submit a pr but in the mean time.... if (!string.IsNullOrEmpty(body) && body != "{}") { - var typeIsDictionary = typeof(IDictionary).IsAssignableFrom(typeof(T)); + var typeIsDictionary = typeof(IDictionary).IsAssignableFrom(typeof(T)) || typeof(T).IsAssignableToGenericType(typeof(System.Collections.Generic.IDictionary<,>)); var typeIsEnumerable = typeof(IEnumerable).IsAssignableFrom(typeof(T)); var responseIsObject = body.StartsWith("{", StringComparison.Ordinal); From 3e5c5496b9cc09c39da1c66019469db153fdfe12 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Tue, 20 Sep 2022 21:17:48 +0100 Subject: [PATCH 131/209] =?UTF-8?q?Fixes=20the=20meta=20dto=20and=20meta?= =?UTF-8?q?=20tests=20so=20they=20pass=20and=20are=20fully=20the=20same?= =?UTF-8?q?=E2=80=A6=20(#2579)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clients/MiscellaneousClientTests.cs | 11 +++- .../Clients/MiscellaneousClientTests.cs | 20 ++++++-- Octokit/Models/Response/Meta.cs | 50 ++++++++++++++++++- 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs index 0dce4f856b..c671b730aa 100644 --- a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs @@ -162,12 +162,19 @@ public async Task CanRetrieveMetadata() var result = await github.Miscellaneous.GetMetadata(); - Assert.True(result.VerifiablePasswordAuthentication); - Assert.NotEmpty(result.GitHubServicesSha); + Assert.False(result.VerifiablePasswordAuthentication); // is username password allowed, probably not any more +#pragma warning disable CS0618 // Type or member is obsolete + Assert.True(string.IsNullOrEmpty(result.GitHubServicesSha)); +#pragma warning restore CS0618 // Type or member is obsolete Assert.True(result.Hooks.Count > 0); + Assert.True(result.Web.Count > 0); + Assert.True(result.Api.Count > 0); Assert.True(result.Git.Count > 0); + Assert.True(result.Packages.Count > 0); Assert.True(result.Pages.Count > 0); Assert.True(result.Importer.Count > 0); + Assert.True(result.Actions.Count > 0); + Assert.True(result.Dependabot.Count > 0); } } } diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 1c44aec35e..c7a974f63e 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -151,7 +151,12 @@ public async Task RequestsTheMetadataEndpoint() new[] { "1.1.1.1/24", "1.1.1.2/24" }, new[] { "1.1.2.1/24", "1.1.2.2/24" }, new[] { "1.1.3.1/24", "1.1.3.2/24" }, - new[] { "1.1.4.1", "1.1.4.2" } + new[] { "1.1.4.1/24", "1.1.4.2/24" }, + new[] { "1.1.5.1/24", "1.1.5.2/24" }, + new[] { "1.1.6.1/24", "1.1.6.2/24" }, + new[] { "1.1.7.1", "1.1.7.2" }, + new[] { "1.1.8.1/24", "1.1.8.2/24" }, + new[] { "1.1.9.1", "1.1.9.2" } ); var apiConnection = Substitute.For<IApiConnection>(); @@ -161,11 +166,18 @@ public async Task RequestsTheMetadataEndpoint() var result = await client.GetMetadata(); Assert.False(result.VerifiablePasswordAuthentication); +#pragma warning disable CS0618 // Type or member is obsolete Assert.Equal("12345ABCDE", result.GitHubServicesSha); +#pragma warning restore CS0618 // Type or member is obsolete Assert.Equal(result.Hooks, new[] { "1.1.1.1/24", "1.1.1.2/24" }); - Assert.Equal(result.Git, new[] { "1.1.2.1/24", "1.1.2.2/24" }); - Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" }); - Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" }); + Assert.Equal(result.Web, new[] { "1.1.2.1/24", "1.1.2.2/24" }); + Assert.Equal(result.Api, new[] { "1.1.3.1/24", "1.1.3.2/24" }); + Assert.Equal(result.Git, new[] { "1.1.4.1/24", "1.1.4.2/24" }); + Assert.Equal(result.Packages, new[] { "1.1.5.1/24", "1.1.5.2/24" }); + Assert.Equal(result.Pages, new[] { "1.1.6.1/24", "1.1.6.2/24" }); + Assert.Equal(result.Importer, new[] { "1.1.7.1", "1.1.7.2" }); + Assert.Equal(result.Actions, new[] { "1.1.8.1/24", "1.1.8.2/24" }); + Assert.Equal(result.Dependabot, new[] { "1.1.9.1", "1.1.9.2" }); apiConnection.Received() .Get<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta")); diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index 0dec38c95f..a5a8a644b4 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using Octokit.Internal; @@ -24,23 +25,40 @@ public Meta() /// <param name="verifiablePasswordAuthentication">Whether authentication with username and password is supported.</param> /// <param name="gitHubServicesSha">The currently-deployed SHA of github-services.</param> /// <param name="hooks">An array of IP addresses in CIDR format specifying the addresses that incoming service hooks will originate from on GitHub.com.</param> + /// <param name="web">An array of IP addresses in CIDR format specifying the Web servers for GitHub</param> + /// <param name="api">An array of IP addresses in CIDR format specifying the Api servers for GitHub</param> /// <param name="git">An array of IP addresses in CIDR format specifying the Git servers for the GitHub server</param> + /// <param name="packages">An array of IP addresses in CIDR format specifying the Packages servers for GitHub</param> /// <param name="pages">An array of IP addresses in CIDR format specifying the A records for GitHub Pages.</param> /// <param name="importer">An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com.</param> + /// <param name="actions">An array of IP addresses in CIDR format specifying the Actions servers for GitHub</param> + /// <param name="dependabot">An array of IP addresses in CIDR format specifying the Dependabot servers for GitHub</param> public Meta( bool verifiablePasswordAuthentication, string gitHubServicesSha, IReadOnlyList<string> hooks, + IReadOnlyList<string> web, + IReadOnlyList<string> api, IReadOnlyList<string> git, + IReadOnlyList<string> packages, IReadOnlyList<string> pages, - IReadOnlyList<string> importer) + IReadOnlyList<string> importer, + IReadOnlyList<string> actions, + IReadOnlyList<string> dependabot) { VerifiablePasswordAuthentication = verifiablePasswordAuthentication; +#pragma warning disable CS0618 // Type or member is obsolete GitHubServicesSha = gitHubServicesSha; +#pragma warning restore CS0618 // Type or member is obsolete Hooks = hooks; + Web = web; + Api = api; Git = git; + Packages = packages; Pages = pages; Importer = importer; + Actions = actions; + Dependabot = dependabot; } /// <summary> @@ -54,6 +72,7 @@ public Meta( /// The currently-deployed SHA of github-services. /// </summary> [Parameter(Key = "github_services_sha")] + [Obsolete("No longer returned so always null")] public string GitHubServicesSha { get; private set; } /// <summary> @@ -63,11 +82,28 @@ public Meta( /// </summary> public IReadOnlyList<string> Hooks { get; private set; } + /// <summary> + /// An Array of IP addresses in CIDR format specifying the Web servers for GitHub.com. + /// </summary> + public IReadOnlyList<string> Web { get; private set; } + + + /// <summary> + /// An Array of IP addresses in CIDR format specifying the Api servers for GitHub.com. + /// </summary> + public IReadOnlyList<string> Api { get; private set; } + /// <summary> /// An Array of IP addresses in CIDR format specifying the Git servers for GitHub.com. /// </summary> public IReadOnlyList<string> Git { get; private set; } + + /// <summary> + /// An Array of IP addresses in CIDR format specifying the Packages servers for GitHub.com. + /// </summary> + public IReadOnlyList<string> Packages { get; private set; } + /// <summary> /// An Array of IP addresses in CIDR format specifying the A records for GitHub Pages. /// </summary> @@ -78,6 +114,16 @@ public Meta( /// </summary> public IReadOnlyList<string> Importer { get; private set; } + /// <summary> + /// An Array of IP addresses in CIDR format specifying the Actions servers. + /// </summary> + public IReadOnlyList<string> Actions { get; private set; } + + /// <summary> + /// An Array of IP addresses in CIDR format specifying the Dependabot servers. + /// </summary> + public IReadOnlyList<string> Dependabot { get; private set; } + internal string DebuggerDisplay { get From a7ffa3f4112f86629fad397f5a85dca92d699564 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Tue, 20 Sep 2022 16:21:58 -0500 Subject: [PATCH 132/209] updates tests to include new fields for the meta resource (#2581) --- Octokit.Tests/Clients/MetaClientTests.cs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests/Clients/MetaClientTests.cs b/Octokit.Tests/Clients/MetaClientTests.cs index c804a39726..9e5b5b584b 100644 --- a/Octokit.Tests/Clients/MetaClientTests.cs +++ b/Octokit.Tests/Clients/MetaClientTests.cs @@ -12,15 +12,21 @@ public class TheGetMetadataMethod [Fact] public async Task RequestsTheMetadataEndpoint() { - var meta = new Meta( + var meta = new Meta( false, "12345ABCDE", new[] { "1.1.1.1/24", "1.1.1.2/24" }, new[] { "1.1.2.1/24", "1.1.2.2/24" }, new[] { "1.1.3.1/24", "1.1.3.2/24" }, - new[] { "1.1.4.1", "1.1.4.2" } + new[] { "1.1.4.1/24", "1.1.4.2/24" }, + new[] { "1.1.5.1/24", "1.1.5.2/24" }, + new[] { "1.1.6.1/24", "1.1.6.2/24" }, + new[] { "1.1.7.1", "1.1.7.2" }, + new[] { "1.1.8.1/24", "1.1.8.2/24" }, + new[] { "1.1.9.1", "1.1.9.2" } ); + var apiConnection = Substitute.For<IApiConnection>(); apiConnection.Get<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta")).Returns(Task.FromResult(meta)); var client = new MetaClient(apiConnection); @@ -28,11 +34,18 @@ public async Task RequestsTheMetadataEndpoint() var result = await client.GetMetadata(); Assert.False(result.VerifiablePasswordAuthentication); + #pragma warning disable CS0618 // Type or member is obsolete Assert.Equal("12345ABCDE", result.GitHubServicesSha); + #pragma warning restore CS0618 // Type or member is obsolete Assert.Equal(result.Hooks, new[] { "1.1.1.1/24", "1.1.1.2/24" }); - Assert.Equal(result.Git, new[] { "1.1.2.1/24", "1.1.2.2/24" }); - Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" }); - Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" }); + Assert.Equal(result.Web, new[] { "1.1.2.1/24", "1.1.2.2/24" }); + Assert.Equal(result.Api, new[] { "1.1.3.1/24", "1.1.3.2/24" }); + Assert.Equal(result.Git, new[] { "1.1.4.1/24", "1.1.4.2/24" }); + Assert.Equal(result.Packages, new[] { "1.1.5.1/24", "1.1.5.2/24" }); + Assert.Equal(result.Pages, new[] { "1.1.6.1/24", "1.1.6.2/24" }); + Assert.Equal(result.Importer, new[] { "1.1.7.1", "1.1.7.2" }); + Assert.Equal(result.Actions, new[] { "1.1.8.1/24", "1.1.8.2/24" }); + Assert.Equal(result.Dependabot, new[] { "1.1.9.1", "1.1.9.2" }); apiConnection.Received() .Get<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta")); From 30fdeca1d2134c07d66e0b1ee51e0ddaef52bf41 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:24:52 -0700 Subject: [PATCH 133/209] ci(netcore.yml): set version v3 to actions/checkout --- .github/workflows/netcore.yml | 48 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index d7c39fdcf9..83676e46f0 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -1,36 +1,34 @@ name: CI Build - -on: +"on": pull_request: branches: - - "main" + - main push: branches: - - "main" - + - main jobs: build: - strategy: matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - + platform: + - ubuntu-latest + - macos-latest + - windows-latest runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v1 - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.* - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.* - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.* - - name: Build with dotnet - run: ./build.sh --linksources=true --verbosity=verbose - shell: bash + - uses: actions/checkout@v3 + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.* + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + - name: Build with dotnet + run: ./build.sh --linksources=true --verbosity=verbose + shell: bash From 0d6b7c4119f38b56c547900cee8e2f9797d2844d Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Tue, 27 Sep 2022 15:24:53 -0700 Subject: [PATCH 134/209] ci(publish.yml): set version v3 to actions/checkout --- .github/workflows/publish.yml | 49 ++++++++++++++++------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e6c84a6813..74f2662219 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,35 +1,30 @@ name: Publish Release to NuGet - -on: +"on": push: tags: - v* - jobs: build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.* - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.* - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.* - - - name: Build with dotnet - run: ./build.sh --linksources=true --verbosity=verbose - shell: bash - - - name: Publish to NuGet - run: dotnet nuget push packaging/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} - shell: bash + - uses: actions/checkout@v3 + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.* + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + - name: Build with dotnet + run: ./build.sh --linksources=true --verbosity=verbose + shell: bash + - name: Publish to NuGet + run: >- + dotnet nuget push packaging/*.nupkg --api-key ${{ + secrets.NUGET_API_KEY }} + shell: bash From a49cc2ed6682335ad5126030d094ab09b1bb4eaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Sep 2022 08:25:17 -0500 Subject: [PATCH 135/209] build(deps): bump Microsoft.NET.Test.Sdk from 17.3.1 to 17.3.2 (#2583) --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 7b0589b97c..83f08e897f 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index ae37077f7a..e39bcfe252 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -33,7 +33,7 @@ <ItemGroup> <PackageReference Include="GitHubJwt" Version="0.0.5" /> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 30f7d910f7..88a8ea3eb2 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> From 8624d90e8070e2594f2b1634d4f196363bb013a0 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Wed, 28 Sep 2022 12:18:19 -0700 Subject: [PATCH 136/209] ci: revert 0d6b7c41 and 30fdeca1 (#2584) --- .github/workflows/netcore.yml | 48 ++++++++++++++++++---------------- .github/workflows/publish.yml | 49 +++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 45 deletions(-) diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index 83676e46f0..d7c39fdcf9 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -1,34 +1,36 @@ name: CI Build -"on": + +on: pull_request: branches: - - main + - "main" push: branches: - - main + - "main" + jobs: build: + strategy: matrix: - platform: - - ubuntu-latest - - macos-latest - - windows-latest + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: - - uses: actions/checkout@v3 - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.* - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.* - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.* - - name: Build with dotnet - run: ./build.sh --linksources=true --verbosity=verbose - shell: bash + - uses: actions/checkout@v1 + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.* + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + - name: Build with dotnet + run: ./build.sh --linksources=true --verbosity=verbose + shell: bash diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 74f2662219..e6c84a6813 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,30 +1,35 @@ name: Publish Release to NuGet -"on": + +on: push: tags: - v* + jobs: build: + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.* - - name: Setup .NET 6 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.* - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.* - - name: Build with dotnet - run: ./build.sh --linksources=true --verbosity=verbose - shell: bash - - name: Publish to NuGet - run: >- - dotnet nuget push packaging/*.nupkg --api-key ${{ - secrets.NUGET_API_KEY }} - shell: bash + - uses: actions/checkout@v1 + + - name: Setup .NET 5 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.* + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.* + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.* + + - name: Build with dotnet + run: ./build.sh --linksources=true --verbosity=verbose + shell: bash + + - name: Publish to NuGet + run: dotnet nuget push packaging/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} + shell: bash From 92524a1b40e6ee50bfab3f272933faa6febedf3d Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Fri, 7 Oct 2022 16:30:43 +0000 Subject: [PATCH 137/209] updates rhow to deploy to simplify --- DEPLOYMENT.md | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 1de4dc0525..adb084c1b9 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -7,30 +7,27 @@ Creating a new release and deploying the package to nuget are administrative tas 2. Admin rights to the [octokit.net](https://github.com/octokit/octokit.net) repository 3. For any PRs that should be noted in the release notes, each pull request must have a comment formatted like `release_notes: description` where description represents the details of the change. -### Prepare the changeset & publish to nuget.org - -1. Create a branch named `release`. -2. Push the branch to GitHub and create a pull request. This will kick off the CI builds to verify the changes. -3. Test! -4. [Generate](https://github.com/shiftkey/octokit.releasenotes) the release notes. `Octokit.ReleaseNotes generate v0.50.0 [BASE] [HEAD]` - Any PRs that should be noted in the release notes, each pull request must have a comment formatted like `release_notes: description` where description represents the details of the change. Make sure for the commit range any changeset in a PR that should be represented has a comment on the PR prefixed with `release_notes:` and corresponding label (details below) -5. When you're satisfied with this release, create a tag `git tag v#.#.#`. For example, to create a tag for 1.0.0 -`git tag v1.0.0` -6. Push the tag to the server. `git push --tags` -7. When the tag is successfully pushed, the [publish workflow](https://github.com/octokit/octokit.net/blob/main/.github/workflows/publish.yml) will run and build and push the package to nuget -8. Verify that the package has been uploaded to [nuget.org](https://www.nuget.org/packages/Octokit/) -8. Accept the pull request -9. Create a [new release](https://github.com/octokit/octokit.net/releases/new) -using the tag you just created and pasting in the release notes you just generated +### Publish to nuget.org + +1. Run test and perform manual tests from `main` +2. [Generate](https://github.com/shiftkey/octokit.releasenotes) the release notes. `Octokit.ReleaseNotes generate main [LAST RELEASE TAG]` (i.e. `dotnet run generate main v3.0.0`) +3. When you're satisfied with this release, create a tag `git tag v#.#.#`. For example, to create a tag for 3.0.1 +`git tag v3.0.1` +4. Push the tag to the server. `git push --tags` +5. When the tag is successfully pushed, the [publish workflow](https://github.com/octokit/octokit.net/blob/main/.github/workflows/publish.yml) will run and build and push the package to nuget +6. Verify that the package has been uploaded to [nuget.org](https://www.nuget.org/packages/Octokit/) +7. Create a [new release](https://github.com/octokit/octokit.net/releases/new) using the tag you just created and pasting in the release notes you just generated --- -### Details on the release notes generator +### Release notes generator Release notes [generator](https://github.com/shiftkey/octokit.releasenotes): this is used to pull details using the GitHub API to generate the release notes. The generator helps in that it produces release notes that are consistently formatted based on information directly from the change scope (from the previous release to the current tip i.e. the `release` branch). +Any PRs that should be noted in the release notes, each pull request must have a comment formatted like `release_notes: description` where description represents the details of the change. Make sure for the commit range any changeset in a PR that should be represented has a comment on the PR prefixed with `release_notes:` and corresponding label. + The nuances are mostly around how it gets and parses release notes from the PRs found in the changeset. The following are the comment prefixes that the generator currently supports: * `release_notes` - Having this in the comment with a corresponding "category" label on the PR will put the given note under the "Release Notes" section of the output in the group for the given label From 971fa50d6ea339e05134b2c6b03596ff8008b6f9 Mon Sep 17 00:00:00 2001 From: Chris Simpson <snyrting6@hotmail.com> Date: Fri, 7 Oct 2022 18:32:36 +0100 Subject: [PATCH 138/209] Base classes need protected setters, ActivityPayload had privates (#2591) --- Octokit.Tests/Models/CheckSuiteEventTests.cs | 3 +++ Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests/Models/CheckSuiteEventTests.cs b/Octokit.Tests/Models/CheckSuiteEventTests.cs index 45da12ea2e..a0c066f4f6 100644 --- a/Octokit.Tests/Models/CheckSuiteEventTests.cs +++ b/Octokit.Tests/Models/CheckSuiteEventTests.cs @@ -18,6 +18,9 @@ public void CanBeDeserialized() Assert.Equal("rerequested", payload.Action); Assert.Equal("73955d02043135d48809add98052c2170522158f", payload.CheckSuite.HeadSha); Assert.Equal(CheckStatus.Queued, payload.CheckSuite.Status.Value); + Assert.NotNull(payload.Installation); + Assert.NotNull(payload.Repository); + Assert.NotNull(payload.Sender); } } } diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs index 0e0ec2a074..ea89c33195 100644 --- a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs @@ -15,9 +15,9 @@ public ActivityPayload(Repository repository, User sender, InstallationId instal Installation = installation; } - public Repository Repository { get; private set; } - public User Sender { get; private set; } - public InstallationId Installation { get; private set; } + public Repository Repository { get; protected set; } + public User Sender { get; protected set; } + public InstallationId Installation { get; protected set; } internal string DebuggerDisplay { From fa29939f50bbb2b1c114bab211272492b549bbe6 Mon Sep 17 00:00:00 2001 From: Riccardo De Agostini <me@riccar.do> Date: Fri, 7 Oct 2022 20:06:53 +0200 Subject: [PATCH 139/209] Use correct methods and URL to generate release notes (#2592) --- Octokit.Tests/Clients/ReleasesClientTests.cs | 4 ++-- Octokit/Clients/ReleasesClient.cs | 8 ++++---- Octokit/Helpers/ApiUrls.cs | 21 ++++++++++++++++++++ docs/releases.md | 14 +++++++++---- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Octokit.Tests/Clients/ReleasesClientTests.cs b/Octokit.Tests/Clients/ReleasesClientTests.cs index 903d8115e9..151734580a 100644 --- a/Octokit.Tests/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests/Clients/ReleasesClientTests.cs @@ -31,7 +31,7 @@ public async Task RequestsCorrectUrl() await releasesClient.GenerateReleaseNotes("fake", "repo", data); - client.Received().Post<GeneratedReleaseNotes>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases"), + client.Received().Post<GeneratedReleaseNotes>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/generate-notes"), data, "application/vnd.github.v3"); } @@ -45,7 +45,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await releasesClient.GenerateReleaseNotes(1, data); - client.Received().Post<GeneratedReleaseNotes>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases"), + client.Received().Post<GeneratedReleaseNotes>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases/generate-notes"), data, "application/vnd.github.v3"); } diff --git a/Octokit/Clients/ReleasesClient.cs b/Octokit/Clients/ReleasesClient.cs index 435bd36882..0ab33084ec 100644 --- a/Octokit/Clients/ReleasesClient.cs +++ b/Octokit/Clients/ReleasesClient.cs @@ -30,14 +30,14 @@ public ReleasesClient(IApiConnection apiConnection) : base(apiConnection) /// <param name="name">The repository's name</param> /// <param name="data">The request for generating release notes</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - [ManualRoute("GET", "/repos/{owner}/{repo}/releases")] + [ManualRoute("POST", "/repos/{owner}/{repo}/releases/generate-notes")] public Task<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, string name, GenerateReleaseNotesRequest data) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(data, nameof(data)); - var endpoint = ApiUrls.Releases(owner, name); + var endpoint = ApiUrls.ReleasesGenerateNotes(owner, name); return ApiConnection.Post<GeneratedReleaseNotes>(endpoint, data, AcceptHeaders.StableVersion); } @@ -50,12 +50,12 @@ public Task<GeneratedReleaseNotes> GenerateReleaseNotes(string owner, string nam /// <param name="repositoryId">The Id of the repository</param> /// <param name="data">The request for generating release notes</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> - [ManualRoute("GET", "/repos/{owner}/{repo}/releases")] + [ManualRoute("POST", "/repositories/{id}/releases/generate-notes")] public Task<GeneratedReleaseNotes> GenerateReleaseNotes(long repositoryId, GenerateReleaseNotesRequest data) { Ensure.ArgumentNotNull(data, nameof(data)); - var endpoint = ApiUrls.Releases(repositoryId); + var endpoint = ApiUrls.ReleasesGenerateNotes(repositoryId); return ApiConnection.Post<GeneratedReleaseNotes>(endpoint, data, AcceptHeaders.StableVersion); } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index b8a7cbe88f..e24de63a42 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -191,6 +191,17 @@ public static Uri Releases(string owner, string name) return "repos/{0}/{1}/releases".FormatUri(owner, name); } + /// <summary> + /// Returns the <see cref="Uri"/> that generates release notes for the specified repository. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <returns>The <see cref="Uri"/> that generates release notes for the specified repository.</returns> + public static Uri ReleasesGenerateNotes(string owner, string name) + { + return "repos/{0}/{1}/releases/generate-notes".FormatUri(owner, name); + } + /// <summary> /// Returns the <see cref="Uri"/> that returns a single release for the specified repository /// </summary> @@ -3441,6 +3452,16 @@ public static Uri Releases(long repositoryId) return "repositories/{0}/releases".FormatUri(repositoryId); } + /// <summary> + /// Returns the <see cref="Uri"/> that generates release notes for the specified repository. + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <returns>The <see cref="Uri"/> that generates release notes for the specified repository.</returns> + public static Uri ReleasesGenerateNotes(long repositoryId) + { + return "repositories/{0}/releases/generate-notes".FormatUri(repositoryId); + } + /// <summary> /// Returns the <see cref="Uri"/> that returns a single release for the specified repository /// </summary> diff --git a/docs/releases.md b/docs/releases.md index 3f9e9582c3..e863e950e0 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -30,19 +30,25 @@ Console.WriteLine("Created release id {0}", result.Id); Note that the `Draft` flag is used to indicate when a release should be published to the world, whereas the `PreRelease` flag is used to indicate whether a release is unofficial or preview release. -#### Generate release notes +### Generate release notes -Additionally, you can ask GitHub to generate a name and body before creating a new release. +GitHub can generate a name and body for a new release [automatically](https://github.blog/2021-10-04-beta-github-releases-improving-release-experience/#introducing-auto-generated-release-notes), based upon merged pull requests. +[This is an example](https://github.com/MylesBorins/release-notes-test/releases/tag/v2.0.0) of automatically generated text. ```csharp -var generationRequest = new GenerateReleaseNotesRequest("v2.0.0"); +var newTag = "v1.5.7"; +var generationRequest = new GenerateReleaseNotesRequest(newTag); +generationRequest.TargetCommitish = "main"; // Optional, can be a branch, tag, or SHA; defaults to the main branch. +generationRequest.PreviousTagName = "v1.5.6"; // Optional; default is automagically determined, based on existing tags. var releaseNotes = await client.Repository.Release.GenerateReleaseNotes("octokit", "octokit.net", generationRequest); -var newRelease = new NewRelease("v1.0.0"); +var newRelease = new NewRelease(newTag); // Use the same tag as before, because it now appears in generated text. newRelease.Name = releaseNotes.Name; newRelease.Body = releaseNotes.Body; ``` +This feature can be customized at the repository level, by following [these instructions](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes). + ### Update Once the release is ready for the public, you can apply an update to the release: From 40b2111f4d676a96fbcbe270b546966aaa7d9b6e Mon Sep 17 00:00:00 2001 From: Andrey Tretyak <andreyt@microsoft.com> Date: Mon, 10 Oct 2022 10:03:51 -0700 Subject: [PATCH 140/209] Add strong name signing (#2575) --- Directory.Build.props | 7 +++++++ .../Octokit.Tests.Integration.csproj | 1 + Octokit/Octokit.csproj | 5 +++++ Octokit/Properties/AssemblyInfo.cs | 3 --- build/Build.csproj | 1 + key.snk | Bin 0 -> 596 bytes 6 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 Directory.Build.props delete mode 100644 Octokit/Properties/AssemblyInfo.cs create mode 100644 key.snk diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000000..c7568165b2 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,7 @@ +<Project> + <PropertyGroup Label="Strong name signing"> + <SignAssembly>true</SignAssembly> + <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\key.snk</AssemblyOriginatorKeyFile> + <StrongNameSuffix>, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f1e6b635f0c0b44c03d712e4f2cf789ddb54d7f74a9b34e2ece3aafb6afbfd46ec2b033f4104ef88f6afec226c5c647f453852ba3847fd9e37727c7dcb54e24731a288a107457a2c3e8b26ab04c25b206797be48cfe7a2b2c427422d0b0dd18c82111f21798f997e5d33ecc25c677744709c3785e0e650d6e0456a034a31acc4</StrongNameSuffix> + </PropertyGroup> +</Project> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index e39bcfe252..2f00a3dfe2 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -5,6 +5,7 @@ <AssemblyTitle>Octokit.Tests.Integration</AssemblyTitle> <Authors>GitHub</Authors> <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> + <SignAssembly>false</SignAssembly> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Integration</AssemblyName> <PackageId>Octokit.Tests.Integration</PackageId> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 33b13e2f7c..b212b79773 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -32,4 +32,9 @@ <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> </ItemGroup> + <ItemGroup Label="InternalsVisibleTo attributes"> + <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> + <_Parameter1>Octokit.Tests$(StrongNameSuffix)</_Parameter1> + </AssemblyAttribute> + </ItemGroup> </Project> diff --git a/Octokit/Properties/AssemblyInfo.cs b/Octokit/Properties/AssemblyInfo.cs deleted file mode 100644 index e783bcb861..0000000000 --- a/Octokit/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Octokit.Tests")] \ No newline at end of file diff --git a/build/Build.csproj b/build/Build.csproj index 97efd74a08..0055bcf040 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -2,6 +2,7 @@ <PropertyGroup> <OutputType>Exe</OutputType> + <SignAssembly>false</SignAssembly> <TargetFramework>netcoreapp3.1</TargetFramework> <RunWorkingDirectory>$(MSBuildProjectDirectory)/..</RunWorkingDirectory> </PropertyGroup> diff --git a/key.snk b/key.snk new file mode 100644 index 0000000000000000000000000000000000000000..e85f2d4c92bc11acea21daddbf806293fbac9145 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098;=C(EPz_d&Q*AnFN&v>2NRM+=Pn>6C= z<Er~=`~61jD+5141n-FUuk0dhTx5SmI8wSeNBy2Ra(sQuRN_Z5qKKgfMS3hgizcfC z!doC`m%d2P=c2O2CqgX?4bhB(5g#FWkC}d5Gwi}#XLm$!oHvEw=1|t)MQQ^|F|5QR zz<YF_5Llz}Ao)JgCM2Z`OVu2$-w6R%M${tVy6u(bP$?ejf~v=o-$MyUTtipiXzXah z97P#AXf<^V(Sz38V+6cfq34N{9Pe7gCdcbwIspB$PXYFIy?kG-d4GKz6J1o;gKhNZ z1|&fENjW+_?bScdrXqKKO60!33bpDnckBhjpe~^g0Hicuul0B5zqXxm?=mV7MEj1Z z)0$sBq1j|9s2*YKd?rS7mppEe6+pwGt;DrH_E>YdY26h~CUT5WQ3-jrS&QgCIsW(! zl3S}~n?AQ##)RU-ySzy%n?DsKJ15W#PdQ__tqVWC1jmas?b`@FZLr4zCCA=GYqbky z<qBAGa`{c>9DB5aK68|_jFjsfov-JZ35fLZ5<#no8Ql4}_BzxF?mNUEnNtn1KJK7E z4$=(In|d{cV`<i|+7F!EQ4OGN!Z<jGk15v`i!<Mu6#8YDnSW+QDmvhg8|KI};KajE zwP1607~19x!t6>heGRD^#d&>kJMzz^FZOJC<Tb~EPg(c}8gR;T@cRT`c5?QWNHs=R i%xmkE*js*O-y?S<No~$i%#dFHT6uRhSBJR}oFry*>>VHg literal 0 HcmV?d00001 From d68fc27c13d0f6d73c2a38f08e12e6ebe0b79be9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 16:18:58 -0700 Subject: [PATCH 141/209] build(deps): bump Cake.Frosting from 2.2.0 to 2.3.0 in /build (#2597) Bumps [Cake.Frosting](https://github.com/cake-build/cake) from 2.2.0 to 2.3.0. - [Release notes](https://github.com/cake-build/cake/releases) - [Changelog](https://github.com/cake-build/cake/blob/develop/ReleaseNotes.md) - [Commits](https://github.com/cake-build/cake/compare/v2.2.0...v2.3.0) --- updated-dependencies: - dependency-name: Cake.Frosting dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build/Build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.csproj b/build/Build.csproj index 0055bcf040..ff64d50664 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -9,7 +9,7 @@ <ItemGroup> <PackageReference Include="Cake.Coverlet" Version="2.5.4" /> - <PackageReference Include="Cake.Frosting" Version="2.2.0" /> + <PackageReference Include="Cake.Frosting" Version="2.3.0" /> </ItemGroup> </Project> From 7b6d57af336a4794b7cd9a6580dd624b3e6da8b4 Mon Sep 17 00:00:00 2001 From: Matt <mryanmurphy@gmail.com> Date: Tue, 18 Oct 2022 01:38:50 -0400 Subject: [PATCH 142/209] Add `NewRelease.GenerateReleaseNotes` property (#2596) * Add `GenerateReleaseNotes` property Enable generating release notes during creation of a release. * Update release docs --- Octokit/Models/Request/NewRelease.cs | 15 +++++++++++++-- Octokit/Models/Request/ReleaseUpdate.cs | 6 +++--- docs/releases.md | 16 ++++++++++++---- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Octokit/Models/Request/NewRelease.cs b/Octokit/Models/Request/NewRelease.cs index 23e561d2f0..050be78837 100644 --- a/Octokit/Models/Request/NewRelease.cs +++ b/Octokit/Models/Request/NewRelease.cs @@ -7,7 +7,7 @@ namespace Octokit /// Used to create a new release. /// </summary> /// <remarks> - /// API: https://developer.github.com/v3/repos/releases/#create-a-release + /// API: https://docs.github.com/rest/releases/releases#create-a-release /// </remarks> [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewRelease @@ -73,6 +73,17 @@ public NewRelease(string tagName) /// </value> public bool Prerelease { get; set; } + /// <summary> + /// Gets or sets a value indicating whether to automatically generate the name and body for this release. + /// If <see cref="Name">name</see> is specified, the specified name will be used; otherwise, a name will + /// be automatically generated. If <see cref="Body">body</see> is specified, the body will be pre-pended to the + /// automatically generated notes. + /// </summary> + /// <value> + /// <c>true</c> to generate release notes; otherwise, <c>false</c>. + /// </value> + public bool GenerateReleaseNotes { get; set; } + internal string DebuggerDisplay { get @@ -81,4 +92,4 @@ internal string DebuggerDisplay } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Request/ReleaseUpdate.cs b/Octokit/Models/Request/ReleaseUpdate.cs index 64399e78ab..9bf687bb55 100644 --- a/Octokit/Models/Request/ReleaseUpdate.cs +++ b/Octokit/Models/Request/ReleaseUpdate.cs @@ -7,7 +7,7 @@ namespace Octokit /// Used to update a release. /// </summary> /// <remarks> - /// API: https://developer.github.com/v3/repos/releases/#create-a-release + /// API: https://docs.github.com/rest/releases/releases#update-a-release /// </remarks> [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ReleaseUpdate @@ -47,7 +47,7 @@ public class ReleaseUpdate public string Body { get; set; } /// <summary> - /// Gets or sets a value indicating whether this <see cref="NewRelease"/> is a draft (unpublished). + /// Gets or sets a value indicating whether this <see cref="ReleaseUpdate"/> is a draft (unpublished). /// Default: false /// </summary> /// <value> @@ -56,7 +56,7 @@ public class ReleaseUpdate public bool? Draft { get; set; } /// <summary> - /// Gets or sets a value indicating whether this <see cref="NewRelease"/> is prerelease. + /// Gets or sets a value indicating whether this <see cref="ReleaseUpdate"/> is prerelease. /// </summary> /// <value> /// <c>true</c> if prerelease; otherwise, <c>false</c>. diff --git a/docs/releases.md b/docs/releases.md index e863e950e0..3d92c78e44 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -8,8 +8,8 @@ To retrieve all releases for a repository: var releases = await client.Repository.Release.GetAll("octokit", "octokit.net"); var latest = releases[0]; Console.WriteLine( - "The latest release is tagged at {0} and is named {1}", - latest.TagName, + "The latest release is tagged at {0} and is named {1}", + latest.TagName, latest.Name); ``` @@ -35,6 +35,14 @@ Note that the `Draft` flag is used to indicate when a release should be publishe GitHub can generate a name and body for a new release [automatically](https://github.blog/2021-10-04-beta-github-releases-improving-release-experience/#introducing-auto-generated-release-notes), based upon merged pull requests. [This is an example](https://github.com/MylesBorins/release-notes-test/releases/tag/v2.0.0) of automatically generated text. +```csharp +var newTag = "v1.5.7"; +var newRelease = new NewRelease(newTag); +newRelease.GenerateReleaseNotes = true; // Set for Name and Body to be generated. +newRelease.TargetCommitish = "main"; // Optional, can be a branch, tag, or SHA; defaults to the main branch. +``` + +#### Customizing generated notes ```csharp var newTag = "v1.5.7"; var generationRequest = new GenerateReleaseNotesRequest(newTag); @@ -47,7 +55,7 @@ newRelease.Name = releaseNotes.Name; newRelease.Body = releaseNotes.Body; ``` -This feature can be customized at the repository level, by following [these instructions](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes). +This feature can be customized at the repository level, by following [these instructions](https://docs.github.com/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes). ### Update @@ -68,7 +76,7 @@ If you have any assets to include with the release, you can upload them after cr ```csharp using(var archiveContents = File.OpenRead("output.zip")) { // TODO: better sample - var assetUpload = new ReleaseAssetUpload() + var assetUpload = new ReleaseAssetUpload() { FileName = "my-cool-project-1.0.zip", ContentType = "application/zip", From 9c5392b3235bbb851e85679de7363b3c51978467 Mon Sep 17 00:00:00 2001 From: bloslo <bloslo@users.noreply.github.com> Date: Wed, 19 Oct 2022 21:50:19 +0000 Subject: [PATCH 143/209] Add missing properties to `IssueEvent`. (#2585) * Add missing properties to `IssueEvent`. * Assign `Milestone` propety in constructor. Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- .../Models/Response/DismissedReviewInfo.cs | 29 +++++++++++++ Octokit/Models/Response/IssueEvent.cs | 43 ++++++++++++++++++- Octokit/Models/Response/Milestone.cs | 5 +++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 Octokit/Models/Response/DismissedReviewInfo.cs diff --git a/Octokit/Models/Response/DismissedReviewInfo.cs b/Octokit/Models/Response/DismissedReviewInfo.cs new file mode 100644 index 0000000000..2038ae288b --- /dev/null +++ b/Octokit/Models/Response/DismissedReviewInfo.cs @@ -0,0 +1,29 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class DismissedReviewInfo + { + public DismissedReviewInfo() { } + + public DismissedReviewInfo(PullRequestReviewState state, string reviewId, string dismissalMessage, string dismissalCommitId) + { + State = state; + ReviewId = reviewId; + DismissalMessage = dismissalMessage; + DismissalCommitId = dismissalCommitId; + } + + public StringEnum<PullRequestReviewState> State { get; private set; } + public string ReviewId { get; private set; } + public string DismissalMessage { get; private set; } + public string DismissalCommitId { get; private set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "ReviewId: {0}", ReviewId); } + } + } +} diff --git a/Octokit/Models/Response/IssueEvent.cs b/Octokit/Models/Response/IssueEvent.cs index a32d2864e3..36790c9ab6 100644 --- a/Octokit/Models/Response/IssueEvent.cs +++ b/Octokit/Models/Response/IssueEvent.cs @@ -9,7 +9,7 @@ public class IssueEvent { public IssueEvent() { } - public IssueEvent(long id, string nodeId, string url, User actor, User assignee, Label label, EventInfoState @event, string commitId, DateTimeOffset createdAt, Issue issue, string commitUrl, RenameInfo rename, IssueEventProjectCard projectCard) + public IssueEvent(long id, string nodeId, string url, User actor, User assignee, Label label, EventInfoState @event, string commitId, DateTimeOffset createdAt, Issue issue, string commitUrl, RenameInfo rename, IssueEventProjectCard projectCard, User reviewRequester, User requestedReviewer, User assigner, LockReason lockReason, DismissedReviewInfo dismissedReview, Milestone milestone) { Id = id; NodeId = nodeId; @@ -24,6 +24,12 @@ public IssueEvent(long id, string nodeId, string url, User actor, User assignee, CommitUrl = commitUrl; Rename = rename; ProjectCard = projectCard; + RequestedReviewer = requestedReviewer; + ReviewRequester = reviewRequester; + Assigner = assigner; + LockReason = lockReason; + DismissedReview = dismissedReview; + Milestone = milestone; } /// <summary> @@ -93,6 +99,41 @@ public IssueEvent(long id, string nodeId, string url, User actor, User assignee, /// </summary> public IssueEventProjectCard ProjectCard { get; private set; } + /// <summary> + /// The user that was requested to review the pull request. + /// Only provided for "review_requested" and "review_request_removed" events. + /// </summary> + public User RequestedReviewer { get; private set; } + + /// <summary> + /// The user that requested the review for the pull request. + /// Only provided for "review_requested" and "review_request_removed" events. + /// </summary> + public User ReviewRequester { get; private set; } + + /// <summary> + /// The user who performed the (un)assignment for the issue, if the event is assigned or unassigned. + /// </summary> + public User Assigner { get; private set; } + + /// <summary> + /// The reason an issue or pull request conversation was locked, if one was provided. + /// Only provided for "locked" and "unlocked" events. + /// </summary> + public StringEnum<LockReason> LockReason { get; private set; } + + /// <summary> + /// Object containing dismissed review details. + /// Only provided for "review_dismissed" events. + /// </summary> + public DismissedReviewInfo DismissedReview { get; private set; } + + /// <summary> + /// Milestone object. + /// Only provided for "milestoned" and "demilestoned" events. + /// </summary> + public Milestone Milestone { get; private set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} CreatedAt: {1}", Id, CreatedAt); } diff --git a/Octokit/Models/Response/Milestone.cs b/Octokit/Models/Response/Milestone.cs index 002d22755d..b43c58af08 100644 --- a/Octokit/Models/Response/Milestone.cs +++ b/Octokit/Models/Response/Milestone.cs @@ -14,6 +14,11 @@ public Milestone(int number) Number = number; } + public Milestone(string title) + { + Title = title; + } + public Milestone(string url, string htmlUrl, long id, int number, string nodeId, ItemState state, string title, string description, User creator, int openIssues, int closedIssues, DateTimeOffset createdAt, DateTimeOffset? dueOn, DateTimeOffset? closedAt, DateTimeOffset? updatedAt) { Url = url; From 131ba87e3f386dc14ff3515ae1c98bb849ad7d29 Mon Sep 17 00:00:00 2001 From: Keegan Campbell <me@kfcampbell.com> Date: Thu, 20 Oct 2022 14:59:31 -0700 Subject: [PATCH 144/209] Replay #2221: Implement GitHub Actions Secrets API for both Organization and Repository (#2598) * created the interface and models for the repository secrets client * created a repository actions client to sit between repository and secrets for future extensibility * created the repository secret client and supporting objects to enable data transfer * created object for create or update secret body and made fixes to pass unit tests * created repository action unit tests * created unit tests for RepositorySecretsClient * removed set from secrets interface * fixed docs and added observable actions client * added Actions to repository client * created IObservable repository secrets client * fixed property in wrong interface fixed wrong Ctor unit test * created repository decrets reactive tests and clients * created organization actions and scerets classes and made them available through the oprganizations client * fixed intellisense text * removed uneeded getall call after return type change * created organization secret client and classes to support it * created the observable org secrets client and fixed a typo in a method name * added more ensure checks * removed unused xml doc setting * created the unit tests for the organization secrets client fixed broken unit test for repository secrets client * created observable organization actions and secrets client unit tests * added sodium.core to the integration tests to test secret creation * fixed keyid type * added actions client integration test classes (empty since the class currently doesn't have any native methods) * fixed deserialization issue * changed property name for deserialization issues * added doc for repoid on orginzation secrets url generator * created integration tests for repository and organization secrets * changed how return occurs for setting list of repos for secret * fixed some names and removed reset org name * created integration tests for observable org secrets client * removed default org value * created the integration tests for the observable repository secrets client * removed default owner project value * fixed unit tests * Update links to new docs site * Update doc links to new docs site * Update docs links to new docs site * Fix doc link to point to new docs site * Update links to new docs site * Update doc links to new docs site * Update docs links * Update docs * Update docs * Update doc links * Update docs * Update doc links * Update doc links * Update doc links * updated documentation links in actions and secrets clients * Update Octokit/Models/Response/SecretsPublicKey.cs Removing line for consistency. Co-authored-by: Thomas Hughes <iamhughes@github.com> * Update Octokit/Models/Response/RepositorySecret.cs Removing line for consistency. Co-authored-by: Thomas Hughes <iamhughes@github.com> * set default owner and repo * switched to using the Helper.Organization from a ORG constant set at the top of the file * swapped out variable at top of file for the Helper.Organization property * switched to helper method to create new repositories * Protected setters --> private setters in response models * RepositorySecret needs protected setters Co-authored-by: Mike Tolly <mike.tolly@takeda.com> Co-authored-by: Thomas Hughes <iamhughes@github.com> Co-authored-by: mptolly-takeda <61791994+mptolly-takeda@users.noreply.github.com> --- .../IObservableOrganizationActionsClient.cs | 23 ++ .../IObservableOrganizationSecretsClient.cs | 119 +++++++ .../Clients/IObservableOrganizationsClient.cs | 5 + .../Clients/IObservableRepositoriesClient.cs | 8 + .../IObservableRepositoryActionsClient.cs | 23 ++ .../IObservableRepositorySecretsClient.cs | 79 +++++ .../ObservableOrganizationActionsClient.cs | 40 +++ .../ObservableOrganizationSecretsClient.cs | 193 ++++++++++++ .../Clients/ObservableOrganizationsClient.cs | 7 + .../Clients/ObservableRepositoriesClient.cs | 9 + .../ObservableRepositoryActionsClient.cs | 36 +++ .../ObservableRepositorySecretsClient.cs | 128 ++++++++ .../Clients/OrganizationActionsClientTests.cs | 10 + .../Clients/OrganizationSecretsClientTests.cs | 255 +++++++++++++++ .../Clients/RepositoryActionsClientTests.cs | 10 + .../Clients/RespositorySecretsClientTests.cs | 128 ++++++++ .../Octokit.Tests.Integration.csproj | 2 +- ...bservableOrganizationActionsClientTests.cs | 10 + ...bservableOrganizationSecretsClientTests.cs | 290 ++++++++++++++++++ .../ObservableRepositoryActionsClientTests.cs | 10 + .../ObservableRepositorySecretsClientTests.cs | 138 +++++++++ .../Clients/OrganizationActionsClientTests.cs | 17 + .../Clients/OrganizationSecretsClientTests.cs | 286 +++++++++++++++++ .../Clients/RepositoryActionsClientTests.cs | 17 + .../Clients/RepositorySecretsClientTests.cs | 171 +++++++++++ ...bservableOrganizationActionsClientTests.cs | 20 ++ ...bservableOrganizationSecretsClientTests.cs | 282 +++++++++++++++++ .../ObservableRepositoryActionsClientTests.cs | 20 ++ .../ObservableRepositorySecretsClientTests.cs | 170 ++++++++++ Octokit/Clients/IOrganizationActionsClient.cs | 23 ++ Octokit/Clients/IOrganizationSecretsClient.cs | 118 +++++++ Octokit/Clients/IOrganizationsClient.cs | 5 + Octokit/Clients/IRepositoriesClient.cs | 12 +- Octokit/Clients/IRepositoryActionsClient.cs | 23 ++ Octokit/Clients/IRepositorySecretsClient.cs | 77 +++++ Octokit/Clients/OrganizationActionsClient.cs | 32 ++ Octokit/Clients/OrganizationSecretsClient.cs | 194 ++++++++++++ Octokit/Clients/OrganizationsClient.cs | 6 + Octokit/Clients/RepositoriesClient.cs | 9 + Octokit/Clients/RepositoryActionsClient.cs | 32 ++ Octokit/Clients/RepositorySecretsClient.cs | 134 ++++++++ Octokit/Helpers/ApiUrls.cs | 92 ++++++ .../Request/SelectedRepositoryCollection.cs | 32 ++ .../Request/UpsertOrganizationSecret.cs | 38 +++ .../Models/Request/UpsertRepositorySecret.cs | 35 +++ Octokit/Models/Response/OrganizationSecret.cs | 39 +++ .../OrganizationSecretRepositoryCollection.cs | 38 +++ .../Response/OrganizationSecretsCollection.cs | 38 +++ Octokit/Models/Response/RepositorySecret.cs | 50 +++ .../Response/RepositorySecretsCollection.cs | 36 +++ Octokit/Models/Response/SecretsPublicKey.cs | 41 +++ 51 files changed, 3607 insertions(+), 3 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableOrganizationActionsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableOrganizationSecretsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableRepositoryActionsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableRepositorySecretsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableOrganizationSecretsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableRepositorySecretsClient.cs create mode 100644 Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/OrganizationSecretsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/RespositorySecretsClientTests.cs create mode 100644 Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs create mode 100644 Octokit.Tests.Integration/Reactive/ObservableOrganizationSecretsClientTests.cs create mode 100644 Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs create mode 100644 Octokit.Tests.Integration/Reactive/ObservableRepositorySecretsClientTests.cs create mode 100644 Octokit.Tests/Clients/OrganizationActionsClientTests.cs create mode 100644 Octokit.Tests/Clients/OrganizationSecretsClientTests.cs create mode 100644 Octokit.Tests/Clients/RepositoryActionsClientTests.cs create mode 100644 Octokit.Tests/Clients/RepositorySecretsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableOrganizationSecretsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableRepositorySecretsClientTests.cs create mode 100644 Octokit/Clients/IOrganizationActionsClient.cs create mode 100644 Octokit/Clients/IOrganizationSecretsClient.cs create mode 100644 Octokit/Clients/IRepositoryActionsClient.cs create mode 100644 Octokit/Clients/IRepositorySecretsClient.cs create mode 100644 Octokit/Clients/OrganizationActionsClient.cs create mode 100644 Octokit/Clients/OrganizationSecretsClient.cs create mode 100644 Octokit/Clients/RepositoryActionsClient.cs create mode 100644 Octokit/Clients/RepositorySecretsClient.cs create mode 100644 Octokit/Models/Request/SelectedRepositoryCollection.cs create mode 100644 Octokit/Models/Request/UpsertOrganizationSecret.cs create mode 100644 Octokit/Models/Request/UpsertRepositorySecret.cs create mode 100644 Octokit/Models/Response/OrganizationSecret.cs create mode 100644 Octokit/Models/Response/OrganizationSecretRepositoryCollection.cs create mode 100644 Octokit/Models/Response/OrganizationSecretsCollection.cs create mode 100644 Octokit/Models/Response/RepositorySecret.cs create mode 100644 Octokit/Models/Response/RepositorySecretsCollection.cs create mode 100644 Octokit/Models/Response/SecretsPublicKey.cs diff --git a/Octokit.Reactive/Clients/IObservableOrganizationActionsClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationActionsClient.cs new file mode 100644 index 0000000000..f3d00a623c --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableOrganizationActionsClient.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Org Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions"> Actions API documentation</a> for more information. + /// </remarks> + public interface IObservableOrganizationActionsClient + { + /// <summary> + /// Returns a client to manage organization secrets. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets"> Secrets API documentation</a> for more information. + /// </remarks> + IObservableOrganizationSecretsClient Secrets { get; } + } +} diff --git a/Octokit.Reactive/Clients/IObservableOrganizationSecretsClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationSecretsClient.cs new file mode 100644 index 0000000000..205dfeb229 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableOrganizationSecretsClient.cs @@ -0,0 +1,119 @@ +using System; +using System.Reactive; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Organization Secrets API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets">Organization Secrets API documentation</a> for more details. + /// </remarks> + public interface IObservableOrganizationSecretsClient + { + /// <summary> + /// Get the public signing key to encrypt secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the organization public key.</returns> + IObservable<SecretsPublicKey> GetPublicKey(string org); + + /// <summary> + /// List the secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-organization-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecretsCollection"/> instance for the list of organization secrets.</returns> + IObservable<OrganizationSecretsCollection> GetAll(string org); + + /// <summary> + /// Get a secret from an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret.</returns> + IObservable<OrganizationSecret> Get(string org, string secretName); + + /// <summary> + /// Create or update a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value, id of the encryption key, and visibility info to upsert</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret that was created or updated.</returns> + IObservable<OrganizationSecret> CreateOrUpdate(string org, string secretName, UpsertOrganizationSecret upsertSecret); + + /// <summary> + /// Delete a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<Unit> Delete(string org, string secretName); + + /// <summary> + /// Get the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<OrganizationSecretRepositoryCollection> GetSelectedRepositoriesForSecret(string org, string secretName); + + /// <summary> + /// Set the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repositories">The list of repositories that should have access to view and use the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<Unit> SetSelectedRepositoriesForSecret(string org, string secretName, SelectedRepositoryCollection repositories); + + /// <summary> + /// Add a selected site to the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<Unit> AddRepoToOrganizationSecret(string org, string secretName, long repoId); + + /// <summary> + /// ARemoved a selected site from the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<Unit> RemoveRepoFromOrganizationSecret(string org, string secretName, long repoId); + } +} diff --git a/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs index 8e7596c7c5..d44a187990 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs @@ -26,6 +26,11 @@ public interface IObservableOrganizationsClient /// </summary> IObservableOrganizationOutsideCollaboratorsClient OutsideCollaborator { get; } + /// <summary> + /// Returns a client to manage organization actions. + /// </summary> + IObservableOrganizationActionsClient Actions { get; } + /// <summary> /// Returns the specified organization. /// </summary> diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 562ea50de9..169f86e2ac 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -195,6 +195,14 @@ public interface IObservableRepositoriesClient /// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns> IObservable<Repository> GetAllForOrg(string organization, ApiOptions options); + /// <summary> + /// Access GitHub's Repository Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">API documentation</a> for more details. + /// </remarks> + IObservableRepositoryActionsClient Actions { get; } + /// <summary> /// Client for managing branches in a repository. /// </summary> diff --git a/Octokit.Reactive/Clients/IObservableRepositoryActionsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryActionsClient.cs new file mode 100644 index 0000000000..6f649e0ef4 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableRepositoryActionsClient.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Repository Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Actions API documentation</a> for more details. + /// </remarks> + public interface IObservableRepositoryActionsClient + { + /// <summary> + /// Client for GitHub's Repository Actions API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details + /// </remarks> + IObservableRepositorySecretsClient Secrets { get; } + } +} diff --git a/Octokit.Reactive/Clients/IObservableRepositorySecretsClient.cs b/Octokit.Reactive/Clients/IObservableRepositorySecretsClient.cs new file mode 100644 index 0000000000..0d346d0b31 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableRepositorySecretsClient.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Reactive; +using System.Text; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Repository Secrets API. + /// </summary> + /// <remarks> + /// See the <a href="http://developer.github.com/v3/actions/secrets/">Repository Secrets API documentation</a> for more details. + /// </remarks> + public interface IObservableRepositorySecretsClient + { + /// <summary> + /// Get the public signing key to encrypt secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the repository public key.</returns> + IObservable<SecretsPublicKey> GetPublicKey(string owner, string repoName); + + /// <summary> + /// List the secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-repository-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="IEnumerable{RepositorySecret}"/> instance for the list of repository secrets.</returns> + IObservable<RepositorySecretsCollection> GetAll(string owner, string repoName); + + /// <summary> + /// Get a secret from a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret.</returns> + IObservable<RepositorySecret> Get(string owner, string repoName, string secretName); + + /// <summary> + /// Create or update a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value and id of the encryption key</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret that was created or updated.</returns> + IObservable<RepositorySecret> CreateOrUpdate(string owner, string repoName, string secretName, UpsertRepositorySecret upsertSecret); + + /// <summary> + /// Delete a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + IObservable<Unit> Delete(string owner, string repoName, string secretName); + } +} diff --git a/Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs new file mode 100644 index 0000000000..833a88514a --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Org Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions"> Actions API documentation</a> for more information. + /// </remarks> + public class ObservableOrganizationActionsClient : IObservableOrganizationActionsClient + { + readonly IOrganizationActionsClient _client; + readonly IConnection _connection; + + /// <summary> + /// Initializes a new Organization API client. + /// </summary> + /// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param> + public ObservableOrganizationActionsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + Secrets = new ObservableOrganizationSecretsClient(client); + + _client = client.Organization.Actions; + _connection = client.Connection; + } + + /// <summary> + /// Returns a client to manage organization secrets. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets"> Secrets API documentation</a> for more information. + /// </remarks> + public IObservableOrganizationSecretsClient Secrets { get; private set; } + } +} diff --git a/Octokit.Reactive/Clients/ObservableOrganizationSecretsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationSecretsClient.cs new file mode 100644 index 0000000000..d18febef65 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableOrganizationSecretsClient.cs @@ -0,0 +1,193 @@ +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Organization Secrets API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets">Organization Secrets API documentation</a> for more details. + /// </remarks> + public class ObservableOrganizationSecretsClient : IObservableOrganizationSecretsClient + { + readonly IOrganizationSecretsClient _client; + readonly IConnection _connection; + + /// <summary> + /// Initializes a new Organization API client. + /// </summary> + /// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param> + public ObservableOrganizationSecretsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Organization.Actions.Secrets; + _connection = client.Connection; + } + + /// <summary> + /// Get the public signing key to encrypt secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the organization public key.</returns> + public IObservable<SecretsPublicKey> GetPublicKey(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return _client.GetPublicKey(org).ToObservable(); + } + + /// <summary> + /// List the secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-organization-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecretsCollection"/> instance for the list of organization secrets.</returns> + public IObservable<OrganizationSecretsCollection> GetAll(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return _client.GetAll(org).ToObservable(); + } + + /// <summary> + /// Get a secret from an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret.</returns> + public IObservable<OrganizationSecret> Get(string org, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return _client.Get(org, secretName).ToObservable(); + } + + /// <summary> + /// Create or update a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value, id of the encryption key, and visibility info to upsert</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret that was created or updated.</returns> + public IObservable<OrganizationSecret> CreateOrUpdate(string org, string secretName, UpsertOrganizationSecret upsertSecret) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(upsertSecret, nameof(upsertSecret)); + Ensure.ArgumentNotNull(upsertSecret.EncryptedValue, nameof(upsertSecret.EncryptedValue)); + Ensure.ArgumentNotNull(upsertSecret.KeyId, nameof(upsertSecret.KeyId)); + + return _client.CreateOrUpdate(org, secretName, upsertSecret).ToObservable(); + } + + /// <summary> + /// Delete a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<Unit> Delete(string org, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return _client.Delete(org, secretName).ToObservable(); + } + + /// <summary> + /// Get the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<OrganizationSecretRepositoryCollection> GetSelectedRepositoriesForSecret(string org, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return _client.GetSelectedRepositoriesForSecret(org, secretName).ToObservable(); + } + + /// <summary> + /// Set the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repositories">The list of repositories that should have access to view and use the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<Unit> SetSelectedRepositoriesForSecret(string org, string secretName, SelectedRepositoryCollection repositories) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(repositories, nameof(repositories)); + + return _client.SetSelectedRepositoriesForSecret(org, secretName, repositories).ToObservable(); + } + + /// <summary> + /// Add a selected site to the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<Unit> AddRepoToOrganizationSecret(string org, string secretName, long repoId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(repoId, nameof(repoId)); + + return _client.AddRepoToOrganizationSecret(org, secretName, repoId).ToObservable(); + } + + /// <summary> + /// ARemoved a selected site from the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<Unit> RemoveRepoFromOrganizationSecret(string org, string secretName, long repoId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(repoId, nameof(repoId)); + + return _client.RemoveRepoFromOrganizationSecret(org, secretName, repoId).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs index 348dc49e83..e90bac920f 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; @@ -21,6 +22,7 @@ public ObservableOrganizationsClient(IGitHubClient client) Team = new ObservableTeamsClient(client); Hook = new ObservableOrganizationHooksClient(client); OutsideCollaborator = new ObservableOrganizationOutsideCollaboratorsClient(client); + Actions = new ObservableOrganizationActionsClient(client); _client = client.Organization; _connection = client.Connection; @@ -47,6 +49,11 @@ public ObservableOrganizationsClient(IGitHubClient client) /// </summary> public IObservableOrganizationOutsideCollaboratorsClient OutsideCollaborator { get; private set; } + /// <summary> + /// Returns a client to manage organization actions. + /// </summary> + public IObservableOrganizationActionsClient Actions { get; private set; } + /// <summary> /// Returns the specified organization. /// </summary> diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 13bb249fc2..199fc6fa00 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -40,6 +40,7 @@ public ObservableRepositoriesClient(IGitHubClient client) Invitation = new ObservableRepositoryInvitationsClient(client); Traffic = new ObservableRepositoryTrafficClient(client); Project = new ObservableProjectsClient(client); + Actions = new ObservableRepositoryActionsClient(client); } /// <summary> @@ -805,6 +806,14 @@ public IObservable<CompareResult> Compare(string owner, string name, string @bas return _client.Commit.Compare(owner, name, @base, head).ToObservable(); } + /// <summary> + /// A client for GitHub's Repository Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Actions API documentation</a> for more details + /// </remarks> + public IObservableRepositoryActionsClient Actions { get; private set; } + /// <summary> /// A client for GitHub's Repository Branches API. /// </summary> diff --git a/Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs new file mode 100644 index 0000000000..631bbf4bf4 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Repository Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Actions API documentation</a> for more details. + /// </remarks> + public class ObservableRepositoryActionsClient : IObservableRepositoryActionsClient + { + readonly IRepositoryActionsClient _client; + readonly IConnection _connection; + + public ObservableRepositoryActionsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Repository.Actions; + _connection = client.Connection; + + Secrets = new ObservableRepositorySecretsClient(client); + } + + /// <summary> + /// Client for GitHub's Repository Actions API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details + /// </remarks> + public IObservableRepositorySecretsClient Secrets { get; private set; } + } +} diff --git a/Octokit.Reactive/Clients/ObservableRepositorySecretsClient.cs b/Octokit.Reactive/Clients/ObservableRepositorySecretsClient.cs new file mode 100644 index 0000000000..fa11987edf --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableRepositorySecretsClient.cs @@ -0,0 +1,128 @@ +using Octokit.Reactive.Internal; +using System; +using System.Collections.Generic; +using System.Reactive; +using System.Reactive.Threading.Tasks; +using System.Text; + +namespace Octokit.Reactive +{ + /// <summary> + /// A client for GitHub's Repository Secrets API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Secrets API documentation</a> for more details. + /// </remarks> + public class ObservableRepositorySecretsClient : IObservableRepositorySecretsClient + { + readonly IRepositorySecretsClient _client; + readonly IConnection _connection; + + public ObservableRepositorySecretsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Repository.Actions.Secrets; + _connection = client.Connection; + } + + /// <summary> + /// Get the public signing key to encrypt secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the repository public key.</returns> + public IObservable<SecretsPublicKey> GetPublicKey(string owner, string repoName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + + return _client.GetPublicKey(owner, repoName).ToObservable(); + } + + /// <summary> + /// List the secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-repository-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="IEnumerable{RepositorySecret}"/> instance for the list of repository secrets.</returns> + public IObservable<RepositorySecretsCollection> GetAll(string owner, string repoName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + + return _client.GetAll(owner, repoName).ToObservable(); + } + + /// <summary> + /// Get a secret from a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret.</returns> + public IObservable<RepositorySecret> Get(string owner, string repoName, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return _client.Get(owner, repoName, secretName).ToObservable(); + } + + /// <summary> + /// Create or update a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value and id of the encryption key</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret that was created or updated.</returns> + public IObservable<RepositorySecret> CreateOrUpdate(string owner, string repoName, string secretName, UpsertRepositorySecret upsertSecret) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(upsertSecret, nameof(upsertSecret)); + Ensure.ArgumentNotNullOrEmptyString(upsertSecret.EncryptedValue, nameof(upsertSecret.EncryptedValue)); + Ensure.ArgumentNotNullOrEmptyString(upsertSecret.KeyId, nameof(upsertSecret.KeyId)); + + return _client.CreateOrUpdate(owner, repoName, secretName, upsertSecret).ToObservable(); + } + + /// <summary> + /// Delete a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="repoName">The owner of the repository</param> + /// <param name="owner">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + public IObservable<Unit> Delete(string owner, string repoName, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return _client.Delete(owner, repoName, secretName).ToObservable(); + } + } +} diff --git a/Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs new file mode 100644 index 0000000000..20548d7b1f --- /dev/null +++ b/Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Tests.Integration.Clients +{ + public class OrganizationActionsClientTests + { + } +} diff --git a/Octokit.Tests.Integration/Clients/OrganizationSecretsClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationSecretsClientTests.cs new file mode 100644 index 0000000000..ab93991787 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/OrganizationSecretsClientTests.cs @@ -0,0 +1,255 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Xunit; +using System.Linq; + +#if SODIUM_CORE_AVAILABLE +using Sodium; +#endif + +namespace Octokit.Tests.Integration.Clients +{ + public class OrganizationSecretsClientTests + { + + public class GetPublicKeyMethod + { + [OrganizationTest] + public async Task GetPublicKey() + { + var github = Helper.GetAuthenticatedClient(); + + var key = await github.Organization.Actions.Secrets.GetPublicKey(Helper.Organization); + + Assert.True(!string.IsNullOrWhiteSpace(key.KeyId)); + } + } + + public class GetAllMethod + { + [OrganizationTest] + public async Task GetSecrets() + { + var github = Helper.GetAuthenticatedClient(); + + var secrets = await github.Organization.Actions.Secrets.GetAll(Helper.Organization); + + Assert.NotEmpty(secrets.Secrets); + } + } + + /// <summary> + /// Please create a secret in your specific repo called TEST + /// </summary> + public class GetMethod + { + [OrganizationTest] + public async Task GetSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secret = await github.Organization.Actions.Secrets.Get(Helper.Organization, "TEST"); + + Assert.NotNull(secret); + Assert.True(secret.Name == "TEST"); + } + } + + public class CreateOrUpdateMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task UpsertSecret() + { + var github = Helper.GetAuthenticatedClient(); + var now = DateTime.Now; + + var publicKey = await github.Organization.Actions.Secrets.GetPublicKey(Helper.Organization); + var upsertValue = GetSecretForCreate("value", publicKey); + + var secret = await github.Organization.Actions.Secrets.CreateOrUpdate(Helper.Organization, "UPSERT_TEST", upsertValue); + + Assert.NotNull(secret); + Assert.True(secret.UpdatedAt > now); + } +#endif + } + + public class DeleteMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task DeleteSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secretName = "DELETE_TEST"; + + var publicKey = await github.Organization.Actions.Secrets.GetPublicKey(Helper.Organization); + var upsertValue = GetSecretForCreate("value", publicKey); + + await github.Organization.Actions.Secrets.CreateOrUpdate(Helper.Organization, secretName, upsertValue); + await github.Organization.Actions.Secrets.Delete(Helper.Organization, secretName); + + } +#endif + } + + public class GetSelectedRepositoriesForSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task GetSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secretName = "LIST_SELECTED_REPO_TEST"; + + var repo = await CreateRepoIfNotExists(github, "list-secrets-selected-repo-test"); + + var key = await github.Organization.Actions.Secrets.GetPublicKey(Helper.Organization); + var upsertSecret = GetSecretForCreate("secret", key, new Repository[] { repo }); + var secret = await github.Organization.Actions.Secrets.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + + var visibilityRepos = await github.Organization.Actions.Secrets.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + + Assert.NotEmpty(visibilityRepos.Repositories); + } +#endif + } + + public class SetSelectedRepositoriesForSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task SetSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secretName = "SET_SELECTED_REPO_TEST"; + + var repo1 = await CreateRepoIfNotExists(github, "set-secrets-selected-repo-test-1"); + var repo2 = await CreateRepoIfNotExists(github, "set-secrets-selected-repo-test-2"); + + var key = await github.Organization.Actions.Secrets.GetPublicKey(Helper.Organization); + var upsertSecret = GetSecretForCreate("secret", key, new Repository[] { repo1 }); + await github.Organization.Actions.Secrets.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + + await github.Organization.Actions.Secrets.SetSelectedRepositoriesForSecret(Helper.Organization, secretName, new SelectedRepositoryCollection(new long[] { repo1.Id, repo2.Id })); + + var visibilityRepos = await github.Organization.Actions.Secrets.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + + Assert.NotEmpty(visibilityRepos.Repositories); + Assert.Equal(2, visibilityRepos.Count); + } +#endif + } + + public class AddRepoToOrganizationSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task AddSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secretName = "ADD_SELECTED_REPO_TEST"; + + var repo1 = await CreateRepoIfNotExists(github, "add-secrets-selected-repo-test-1"); + var repo2 = await CreateRepoIfNotExists(github, "add-secrets-selected-repo-test-2"); + + var key = await github.Organization.Actions.Secrets.GetPublicKey(Helper.Organization); + var upsertSecret = GetSecretForCreate("secret", key, new Repository[] { repo1 }); + await github.Organization.Actions.Secrets.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + + await github.Organization.Actions.Secrets.AddRepoToOrganizationSecret(Helper.Organization, secretName, repo2.Id); + + var visibilityRepos = await github.Organization.Actions.Secrets.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + + Assert.NotEmpty(visibilityRepos.Repositories); + Assert.Equal(2, visibilityRepos.Count); + } +#endif + } + + public class RemoveRepoFromOrganizationSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task RemoveSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secretName = "REMOVE_SELECTED_REPO_TEST"; + + var repo1 = await CreateRepoIfNotExists(github, "remove-secrets-selected-repo-test-1"); + var repo2 = await CreateRepoIfNotExists(github, "remove-secrets-selected-repo-test-2"); + + var key = await github.Organization.Actions.Secrets.GetPublicKey(Helper.Organization); + var upsertSecret = GetSecretForCreate("secret", key, new Repository[] { repo1, repo2 }); + await github.Organization.Actions.Secrets.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + + await github.Organization.Actions.Secrets.RemoveRepoFromOrganizationSecret(Helper.Organization, secretName, repo2.Id); + + var visibilityRepos = await github.Organization.Actions.Secrets.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + + Assert.NotEmpty(visibilityRepos.Repositories); + Assert.Equal(1, visibilityRepos.Count); + } +#endif + } + +#if SODIUM_CORE_AVAILABLE + private static UpsertOrganizationSecret GetSecretForCreate(string secretValue, SecretsPublicKey key) + { + var secretBytes = Encoding.UTF8.GetBytes(secretValue); + var publicKey = Convert.FromBase64String(key.Key); + var sealedPublicKeyBox = SealedPublicKeyBox.Create(secretBytes, publicKey); + + var upsertValue = new UpsertOrganizationSecret + { + EncryptedValue = Convert.ToBase64String(sealedPublicKeyBox), + KeyId = key.KeyId, + Visibility = "all" + + }; + + return upsertValue; + } + + private static UpsertOrganizationSecret GetSecretForCreate(string secretValue, SecretsPublicKey key, Repository[] repos) + { + var secretBytes = Encoding.UTF8.GetBytes(secretValue); + var publicKey = Convert.FromBase64String(key.Key); + var sealedPublicKeyBox = SealedPublicKeyBox.Create(secretBytes, publicKey); + + var upsertValue = new UpsertOrganizationSecret + { + EncryptedValue = Convert.ToBase64String(sealedPublicKeyBox), + KeyId = key.KeyId, + Visibility = "selected", + SelectedRepositoriesIds = repos.Select(r => r.Id) + + }; + + return upsertValue; + } +#endif + + private static async Task<Repository> CreateRepoIfNotExists(IGitHubClient github, string name) + { + try + { + var existingRepo = await github.Repository.Get(Helper.Organization, name); + return existingRepo; + } + catch + { + var newRepo = await github.Repository.Create(Helper.Organization, new NewRepository(name)); + return newRepo; + } + } + } +} diff --git a/Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs new file mode 100644 index 0000000000..95f60732d1 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Tests.Integration.Clients +{ + public class RepositoryActionsClientTests + { + } +} diff --git a/Octokit.Tests.Integration/Clients/RespositorySecretsClientTests.cs b/Octokit.Tests.Integration/Clients/RespositorySecretsClientTests.cs new file mode 100644 index 0000000000..e56c2d6cc2 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/RespositorySecretsClientTests.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Versioning; +using System.Text; +using System.Threading.Tasks; +using Octokit; +using Octokit.Tests.Integration; +using Octokit.Tests.Integration.Helpers; +using Xunit; + +#if SODIUM_CORE_AVAILABLE +using Sodium; +#endif + +namespace Octokit.Tests.Integration.Clients +{ + /// <summary> + /// Access to view and update secrets is required for the following tests + /// </summary> + public class RespositorySecretsClientTests + { + /// <summary> + /// Fill these in for tests to work + /// </summary> + internal const string OWNER = "octokit"; + internal const string REPO = "octokit.net"; + + public class GetPublicKeyMethod + { + [IntegrationTest] + public async Task GetPublicKey() + { + var github = Helper.GetAuthenticatedClient(); + + var key = await github.Repository.Actions.Secrets.GetPublicKey(OWNER, REPO); + + Assert.True(!string.IsNullOrWhiteSpace(key.KeyId)); + } + } + + public class GetAllMethod + { + [IntegrationTest] + public async Task GetSecrets() + { + var github = Helper.GetAuthenticatedClient(); + + var secrets = await github.Repository.Actions.Secrets.GetAll(OWNER, REPO); + + Assert.NotEmpty(secrets.Secrets); + } + } + + /// <summary> + /// Please create a secret in your specific repo called TEST + /// </summary> + public class GetMethod + { + [IntegrationTest] + public async Task GetSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secret = await github.Repository.Actions.Secrets.Get(OWNER, REPO, "TEST"); + + Assert.NotNull(secret); + Assert.True(secret.Name == "TEST"); + } + } + + public class CreateOrUpdateMethod + { +#if SODIUM_CORE_AVAILABLE + [IntegrationTest] + public async Task UpsertSecret() + { + var github = Helper.GetAuthenticatedClient(); + var now = DateTime.Now; + + var publicKey = await github.Repository.Actions.Secrets.GetPublicKey(OWNER, REPO); + var upsertValue = GetSecretForCreate("value", publicKey); + + var secret = await github.Repository.Actions.Secrets.CreateOrUpdate(OWNER, REPO, "UPSERT_TEST", upsertValue); + + Assert.NotNull(secret); + Assert.True(secret.UpdatedAt > now); + } +#endif + } + + public class DeleteMethod + { +#if SODIUM_CORE_AVAILABLE + [IntegrationTest] + public async Task DeleteSecret() + { + var github = Helper.GetAuthenticatedClient(); + + var secretName = "DELETE_TEST"; + + var publicKey = await github.Repository.Actions.Secrets.GetPublicKey(OWNER, REPO); + var upsertValue = GetSecretForCreate("value", publicKey); + + await github.Repository.Actions.Secrets.CreateOrUpdate(OWNER, REPO, secretName, upsertValue); + await github.Repository.Actions.Secrets.Delete(OWNER, REPO, secretName); + + } +#endif + } +#if SODIUM_CORE_AVAILABLE + private static UpsertRepositorySecret GetSecretForCreate(string secretValue, SecretsPublicKey key) + { + var secretBytes = Encoding.UTF8.GetBytes(secretValue); + var publicKey = Convert.FromBase64String(key.Key); + var sealedPublicKeyBox = SealedPublicKeyBox.Create(secretBytes, publicKey); + + var upsertValue = new UpsertRepositorySecret + { + EncryptedValue = Convert.ToBase64String(sealedPublicKeyBox), + KeyId = key.KeyId + + }; + + return upsertValue; + } +#endif + } +} diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 2f00a3dfe2..2f045e2d84 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -25,7 +25,7 @@ <EmbeddedResource Include="fixtures\hello-world.txt;fixtures\hello-world.zip" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" /> <None Include="app.config" /> </ItemGroup> - + <ItemGroup> <ProjectReference Include="..\Octokit\Octokit.csproj" /> <ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj" /> diff --git a/Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs new file mode 100644 index 0000000000..e05a22c110 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableOrganizationActionsClientTests + { + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableOrganizationSecretsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableOrganizationSecretsClientTests.cs new file mode 100644 index 0000000000..9cdf668ba8 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableOrganizationSecretsClientTests.cs @@ -0,0 +1,290 @@ +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Text; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; +using System.Linq; +using Octokit.Tests.Integration.Helpers; + +#if SODIUM_CORE_AVAILABLE +using Sodium; +#endif + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableOrganizationSecretsClientTests + { + public class GetPublicKeyMethod + { + [OrganizationTest] + public async Task GetPublicKey() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var keyObservable = clients.GetPublicKey(Helper.Organization); + var key = await keyObservable; + + Assert.True(!string.IsNullOrWhiteSpace(key.KeyId)); + } + } + + public class GetAllMethod + { + [OrganizationTest] + public async Task GetSecrets() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var secretsObservable = clients.GetAll(Helper.Organization); + var secrets = await secretsObservable; + + Assert.NotEmpty(secrets.Secrets); + } + } + + /// <summary> + /// Please create a secret in your specific repo called TEST + /// </summary> + public class GetMethod + { + [OrganizationTest] + public async Task GetSecret() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var secretObservable = clients.Get(Helper.Organization, "TEST"); + var secret = await secretObservable; + + Assert.NotNull(secret); + Assert.True(secret.Name == "TEST"); + } + } + + public class CreateOrUpdateMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task UpsertSecret() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + var now = DateTime.Now; + + var keyObservable = clients.GetPublicKey(Helper.Organization); + var key = await keyObservable; + + var upsertValue = GetSecretForCreate("value", key); + + var secretObservable = clients.CreateOrUpdate(Helper.Organization, "REACTIVE_UPSERT_TEST", upsertValue); + var secret = await secretObservable; + + Assert.NotNull(secret); + Assert.True(secret.UpdatedAt > now); + } +#endif + } + + public class DeleteMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task DeleteSecret() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var secretName = "REACTIVE_DELETE_TEST"; + + var keyObservable = clients.GetPublicKey(Helper.Organization); + var key = await keyObservable; + var upsertValue = GetSecretForCreate("value", key); + + var createSecretObservable = clients.CreateOrUpdate(Helper.Organization, secretName, upsertValue); + await createSecretObservable; + + var deleteSecretObservable = clients.Delete(Helper.Organization, secretName); + await deleteSecretObservable; + } +#endif + } + + public class GetSelectedRepositoriesForSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task GetSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var secretName = "REACTIVE_LIST_SELECTED_REPO_TEST"; + + var repoName = Helper.MakeNameWithTimestamp("reactive-add-secrets-selected-repo-test"); + var repo = await github.CreateRepositoryContext(new NewRepository(repoName)); + + var keyObservable = clients.GetPublicKey(Helper.Organization); + var key = await keyObservable; + var upsertSecret = GetSecretForCreate("value", key, new Repository[] { repo.Repository }); + + var secretObservable = clients.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + await secretObservable; + + var visibilityReposObservable = clients.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + var visibilityRepos = await visibilityReposObservable; + + Assert.NotEmpty(visibilityRepos.Repositories); + } +#endif + } + + public class SetSelectedRepositoriesForSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task SetSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var secretName = "REACTIVE_SET_SELECTED_REPO_TEST"; + + var repo1Name = Helper.MakeNameWithTimestamp("reactive-add-secrets-selected-repo-test-1"); + var repo2Name = Helper.MakeNameWithTimestamp("reactive-add-secrets-selected-repo-test-2"); + + var repo1 = await github.CreateRepositoryContext(new NewRepository(repo1Name)); + var repo2 = await github.CreateRepositoryContext(new NewRepository(repo2Name)); + + var keyObservable = clients.GetPublicKey(Helper.Organization); + var key = await keyObservable; + var upsertSecret = GetSecretForCreate("value", key, new Repository[] { repo1.Repository }); + + var secretObservable = clients.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + await secretObservable; + + var setRepoListObservable = clients.SetSelectedRepositoriesForSecret(Helper.Organization, secretName, new SelectedRepositoryCollection(new long[] { repo1.RepositoryId, repo2.RepositoryId })); + await setRepoListObservable; + + var visibilityReposObservable = clients.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + var visibilityRepos = await visibilityReposObservable; + + Assert.NotEmpty(visibilityRepos.Repositories); + Assert.Equal(2, visibilityRepos.Count); + } +#endif + } + + public class AddRepoToOrganizationSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task AddSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var secretName = "REACTIVE_ADD_SELECTED_REPO_TEST"; + + var repo1Name = Helper.MakeNameWithTimestamp("reactive-add-secrets-selected-repo-test-1"); + var repo2Name = Helper.MakeNameWithTimestamp("reactive-add-secrets-selected-repo-test-2"); + + var repo1 = await github.CreateRepositoryContext(new NewRepository(repo1Name)); + var repo2 = await github.CreateRepositoryContext(new NewRepository(repo2Name)); + + var keyObservable = clients.GetPublicKey(Helper.Organization); + var key = await keyObservable; + var upsertSecret = GetSecretForCreate("value", key, new Repository[] { repo1.Repository }); + + var secretObservable = clients.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + await secretObservable; + + var addRepoListObservable = clients.AddRepoToOrganizationSecret(Helper.Organization, secretName, repo2.RepositoryId); + await addRepoListObservable; + + var visibilityReposObservable = clients.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + var visibilityRepos = await visibilityReposObservable; + + Assert.NotEmpty(visibilityRepos.Repositories); + Assert.Equal(2, visibilityRepos.Count); + } +#endif + } + + public class RemoveRepoFromOrganizationSecretMethod + { +#if SODIUM_CORE_AVAILABLE + [OrganizationTest] + public async Task RemoveSelectedRepositoriesForSecret() + { + var github = Helper.GetAuthenticatedClient(); + var clients = new ObservableOrganizationSecretsClient(github); + + var secretName = "REACTIVE_REMOVE_SELECTED_REPO_TEST"; + + var repo1Name = Helper.MakeNameWithTimestamp("reactive-add-secrets-selected-repo-test-1"); + var repo2Name = Helper.MakeNameWithTimestamp("reactive-add-secrets-selected-repo-test-2"); + + var repo1 = await github.CreateRepositoryContext(new NewRepository(repo1Name)); + var repo2 = await github.CreateRepositoryContext(new NewRepository(repo2Name)); + + var keyObservable = clients.GetPublicKey(Helper.Organization); + var key = await keyObservable; + var upsertSecret = GetSecretForCreate("secret", key, new Repository[] { repo1.Repository, repo2.Repository }); + + var secretObservable = clients.CreateOrUpdate(Helper.Organization, secretName, upsertSecret); + await secretObservable; + + var removeRepoListObservable = clients.RemoveRepoFromOrganizationSecret(Helper.Organization, secretName, repo2.RepositoryId); + await removeRepoListObservable; + + var visibilityReposObservable = clients.GetSelectedRepositoriesForSecret(Helper.Organization, secretName); + var visibilityRepos = await visibilityReposObservable; + + Assert.NotEmpty(visibilityRepos.Repositories); + Assert.Equal(1, visibilityRepos.Count); + } +#endif + } + +#if SODIUM_CORE_AVAILABLE + private static UpsertOrganizationSecret GetSecretForCreate(string secretValue, SecretsPublicKey key) + { + var secretBytes = Encoding.UTF8.GetBytes(secretValue); + var publicKey = Convert.FromBase64String(key.Key); + var sealedPublicKeyBox = SealedPublicKeyBox.Create(secretBytes, publicKey); + + var upsertValue = new UpsertOrganizationSecret + { + EncryptedValue = Convert.ToBase64String(sealedPublicKeyBox), + KeyId = key.KeyId, + Visibility = "all" + + }; + + return upsertValue; + } + + private static UpsertOrganizationSecret GetSecretForCreate(string secretValue, SecretsPublicKey key, Repository[] repos) + { + var secretBytes = Encoding.UTF8.GetBytes(secretValue); + var publicKey = Convert.FromBase64String(key.Key); + var sealedPublicKeyBox = SealedPublicKeyBox.Create(secretBytes, publicKey); + + var upsertValue = new UpsertOrganizationSecret + { + EncryptedValue = Convert.ToBase64String(sealedPublicKeyBox), + KeyId = key.KeyId, + Visibility = "selected", + SelectedRepositoriesIds = repos.Select(r => r.Id) + + }; + + return upsertValue; + } +#endif + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs new file mode 100644 index 0000000000..3e2ca85d2e --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableRepositoryActionsClientTests + { + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositorySecretsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositorySecretsClientTests.cs new file mode 100644 index 0000000000..bb29cd6175 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositorySecretsClientTests.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Xunit; +using Octokit.Reactive; +using System.Reactive.Linq; + +#if SODIUM_CORE_AVAILABLE +using Sodium; +#endif + +namespace Octokit.Tests.Integration.Reactive.Clients +{ + public class ObservableRepositorySecretsClientTests + { + /// <summary> + /// Fill these in for tests to work + /// </summary> + internal const string OWNER = ""; + internal const string REPO = ""; + + public class GetPublicKeyMethod + { + [IntegrationTest] + public async Task GetPublicKey() + { + var github = Helper.GetAuthenticatedClient(); + var client = new ObservableRepositorySecretsClient(github); + + var keyObservable = client.GetPublicKey(OWNER, REPO); + var key = await keyObservable; + + Assert.True(!string.IsNullOrWhiteSpace(key.KeyId)); + } + } + + public class GetAllMethod + { + [IntegrationTest] + public async Task GetSecrets() + { + var github = Helper.GetAuthenticatedClient(); + var client = new ObservableRepositorySecretsClient(github); + + var secretsObservable = client.GetAll(OWNER, REPO); + var secrets = await secretsObservable; + + Assert.NotEmpty(secrets.Secrets); + } + } + + /// <summary> + /// Please create a secret in your specific repo called TEST + /// </summary> + public class GetMethod + { + [IntegrationTest] + public async Task GetSecret() + { + var github = Helper.GetAuthenticatedClient(); + var client = new ObservableRepositorySecretsClient(github); + var secretName = "TEST"; + + var secretsObservable = client.Get(OWNER, REPO, secretName); + var secret = await secretsObservable; + + Assert.NotNull(secret); + Assert.True(secret.Name == secretName); + } + } + + public class CreateOrUpdateMethod + { +#if SODIUM_CORE_AVAILABLE + [IntegrationTest] + public async Task UpsertSecret() + { + var github = Helper.GetAuthenticatedClient(); + var client = new ObservableRepositorySecretsClient(github); + var now = DateTime.Now; + + var keyObservable = client.GetPublicKey(OWNER, REPO); + var key = await keyObservable; + var upsertValue = GetSecretForCreate("value", key); + + var secretObservable = client.CreateOrUpdate(OWNER, REPO, "REACTIVE_UPSERT_TEST", upsertValue); + var secret = await secretObservable; + + Assert.NotNull(secret); + Assert.True(secret.UpdatedAt > now); + } +#endif + } + + public class DeleteMethod + { +#if SODIUM_CORE_AVAILABLE + [IntegrationTest] + public async Task DeleteSecret() + { + var github = Helper.GetAuthenticatedClient(); + var client = new ObservableRepositorySecretsClient(github); + + var secretName = "DELETE_TEST"; + + var keyObservable = client.GetPublicKey(OWNER, REPO); + var key = await keyObservable; + var upsertValue = GetSecretForCreate("value", key); + + var createObservable = client.CreateOrUpdate(OWNER, REPO, secretName, upsertValue); + await createObservable; + + var deleteObservable = client.Delete(OWNER, REPO, secretName); + await deleteObservable; + + } +#endif + } +#if SODIUM_CORE_AVAILABLE + private static UpsertRepositorySecret GetSecretForCreate(string secretValue, SecretsPublicKey key) + { + var secretBytes = Encoding.UTF8.GetBytes(secretValue); + var publicKey = Convert.FromBase64String(key.Key); + var sealedPublicKeyBox = SealedPublicKeyBox.Create(secretBytes, publicKey); + + var upsertValue = new UpsertRepositorySecret + { + EncryptedValue = Convert.ToBase64String(sealedPublicKeyBox), + KeyId = key.KeyId + + }; + + return upsertValue; + } +#endif + } +} diff --git a/Octokit.Tests/Clients/OrganizationActionsClientTests.cs b/Octokit.Tests/Clients/OrganizationActionsClientTests.cs new file mode 100644 index 0000000000..8ac1ef66a5 --- /dev/null +++ b/Octokit.Tests/Clients/OrganizationActionsClientTests.cs @@ -0,0 +1,17 @@ +using System; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class OrganizationActionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new OrganizationActionsClient(null)); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/OrganizationSecretsClientTests.cs b/Octokit.Tests/Clients/OrganizationSecretsClientTests.cs new file mode 100644 index 0000000000..da08c24e58 --- /dev/null +++ b/Octokit.Tests/Clients/OrganizationSecretsClientTests.cs @@ -0,0 +1,286 @@ +using NSubstitute; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class OrganizationSecretsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new OrganizationSecretsClient(null)); + } + } + + public class GetPublicKeyMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.GetPublicKey("org"); + + connection.Received() + .Get<SecretsPublicKey>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/public-key")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetPublicKey(null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetPublicKey("")); + } + } + + public class GetAllMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.GetAll("org"); + + connection.Received() + .Get<OrganizationSecretsCollection>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("")); + } + } + + public class GetMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.Get("org", "secret"); + + connection.Received() + .Get<OrganizationSecret>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "secret")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("org", null)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "secret")); + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("org", "")); + } + } + + public class CreateOrUpdateMethod + { + [Fact] + public async Task PostsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + var upsertSecret = new UpsertOrganizationSecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId", + Visibility = "private" + }; + await client.CreateOrUpdate("org", "secret", upsertSecret); + + connection.Received() + .Put<OrganizationSecret>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret"), upsertSecret); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + var upsertSecret = new UpsertOrganizationSecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId" + }; + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate(null, "secret", upsertSecret)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", null, upsertSecret)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "secret", null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "secret", new UpsertOrganizationSecret())); + + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("", "secret", upsertSecret)); + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("owner", "", upsertSecret)); + } + } + + public class DeleteMethod + { + [Fact] + public async Task DeletesTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.Delete("org", "secret"); + + connection.Received() + .Delete(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "secret")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "secret")); + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "")); + } + } + + public class GetSelectedRepositoriesForSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.GetSelectedRepositoriesForSecret("org", "secret"); + + connection.Received() + .Get<OrganizationSecretRepositoryCollection>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret/repositories")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSelectedRepositoriesForSecret(null, "secret")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSelectedRepositoriesForSecret("org", null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetSelectedRepositoriesForSecret("", "secret")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetSelectedRepositoriesForSecret("org", "")); + } + } + + public class SetSelectedRepositoriesForSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + var repoIds = new List<long> + { + 1, + 2, + 3 + }; + var repos = new SelectedRepositoryCollection(repoIds); + + await client.SetSelectedRepositoriesForSecret("org", "secret", repos); + + connection.Received() + .Put<SelectedRepositoryCollection>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret/repositories"), repos); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + var repoIds = new List<long> + { + 1, + 2, + 3 + }; + var repos = new SelectedRepositoryCollection(repoIds); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret(null, "secret", repos)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret("org", null, repos)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret("org", "secret", null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret("org", "secret", new SelectedRepositoryCollection())); + await Assert.ThrowsAsync<ArgumentException>(() => client.SetSelectedRepositoriesForSecret("", "secret", repos)); + await Assert.ThrowsAsync<ArgumentException>(() => client.SetSelectedRepositoriesForSecret("org", "", repos)); + } + } + + public class AddRepoToOrganizationSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.AddRepoToOrganizationSecret("org", "secret", 1); + + connection.Received() + .Put(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret/repositories/1")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddRepoToOrganizationSecret(null, "secret", 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddRepoToOrganizationSecret("org", null, 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.AddRepoToOrganizationSecret("", "secret", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.AddRepoToOrganizationSecret("org", "", 1)); + } + } + + public class RemoveRepoFromOrganizationSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.RemoveRepoFromOrganizationSecret("org", "secret", 1); + + connection.Received() + .Delete(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret/repositories/1")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepoFromOrganizationSecret(null, "secret", 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepoFromOrganizationSecret("org", null, 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveRepoFromOrganizationSecret("", "secret", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveRepoFromOrganizationSecret("org", "", 1)); + } + } + } +} diff --git a/Octokit.Tests/Clients/RepositoryActionsClientTests.cs b/Octokit.Tests/Clients/RepositoryActionsClientTests.cs new file mode 100644 index 0000000000..36f977d45d --- /dev/null +++ b/Octokit.Tests/Clients/RepositoryActionsClientTests.cs @@ -0,0 +1,17 @@ +using System; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class RepositoryActionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new RepositoryActionsClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Clients/RepositorySecretsClientTests.cs b/Octokit.Tests/Clients/RepositorySecretsClientTests.cs new file mode 100644 index 0000000000..4e8accaed9 --- /dev/null +++ b/Octokit.Tests/Clients/RepositorySecretsClientTests.cs @@ -0,0 +1,171 @@ +using NSubstitute; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class RepositorySecretsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new RepositorySecretsClient(null)); + } + } + + public class GetPublicKeyMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositorySecretsClient(connection); + + await client.GetPublicKey("owner", "repo"); + + connection.Received() + .Get<SecretsPublicKey>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/secrets/public-key")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositorySecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetPublicKey(null, "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetPublicKey("owner", null)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetPublicKey("", "repo")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetPublicKey("owner", "")); + } + } + + public class GetAllMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositorySecretsClient(connection); + + await client.GetAll("owner", "repo"); + + connection.Received() + .Get<RepositorySecretsCollection>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/secrets")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositorySecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "repo")); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "")); + } + } + + public class GetMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositorySecretsClient(connection); + + await client.Get("owner", "repo", "secret"); + + connection.Received() + .Get<RepositorySecret>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/secrets/secret")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositorySecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", "secret")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, "secret")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", "repo", null)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", "secret")); + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", "secret")); + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "repo", "")); + } + } + + public class CreateOrUpdateMethod + { + [Fact] + public async Task PostsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositorySecretsClient(connection); + var upsertSecret = new UpsertRepositorySecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId" + }; + await client.CreateOrUpdate("owner", "repo", "secret", upsertSecret); + + connection.Received() + .Put<RepositorySecret>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/secrets/secret"), upsertSecret); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositorySecretsClient(Substitute.For<IApiConnection>()); + + var upsertSecret = new UpsertRepositorySecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId" + }; + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate(null, "repo", "secret", upsertSecret)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", null, "secret", upsertSecret)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "repo", null, upsertSecret)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "repo", "secret", null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "repo", "secret", new UpsertRepositorySecret())); + + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("", "repo", "secret", upsertSecret)); + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("owner", "", "secret", upsertSecret)); + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("owner", "repo", "", upsertSecret)); + } + } + + public class DeleteMethod + { + [Fact] + public async Task DeletesTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositorySecretsClient(connection); + + await client.Delete("owner", "repo", "secret"); + + connection.Received() + .Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/actions/secrets/secret")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositorySecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "repo", "secret")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, "secret")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", "repo", null)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "repo", "secret")); + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", "secret")); + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "repo", "")); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs new file mode 100644 index 0000000000..1476c76b4f --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs @@ -0,0 +1,20 @@ +using Octokit.Reactive; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableOrganizationActionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableOrganizationActionsClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableOrganizationSecretsClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationSecretsClientTests.cs new file mode 100644 index 0000000000..7e36b26864 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableOrganizationSecretsClientTests.cs @@ -0,0 +1,282 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableOrganizationSecretsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableOrganizationSecretsClient(null)); + } + } + + public class GetPublicKeyMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationSecretsClient(gitHubClient); + + await client.GetPublicKey("org"); + + gitHubClient.Received().Organization.Actions.Secrets.GetPublicKey("org"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableOrganizationSecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetPublicKey(null).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetPublicKey("").ToTask()); + } + } + + public class GetAllMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationSecretsClient(gitHubClient); + + await client.GetAll("org"); + + gitHubClient.Received().Organization.Actions.Secrets.GetAll("org"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableOrganizationSecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("").ToTask()); + } + } + + public class GetMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationSecretsClient(gitHubClient); + + await client.Get("org", "secret"); + + gitHubClient.Received().Organization.Actions.Secrets.Get("org", "secret"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableOrganizationSecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("org", null).ToTask()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("org", "").ToTask()); + } + } + + public class CreateOrUpdateMethod + { + [Fact] + public async Task PostsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationSecretsClient(gitHubClient); + var upsertSecret = new UpsertOrganizationSecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId", + Visibility = "private" + }; + + await client.CreateOrUpdate("org", "secret", upsertSecret); + + gitHubClient.Received().Organization.Actions.Secrets.CreateOrUpdate("org", "secret", upsertSecret); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableOrganizationSecretsClient(Substitute.For<IGitHubClient>()); + + var upsertSecret = new UpsertOrganizationSecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId" + }; + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate(null, "secret", upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", null, upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "secret", null).ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "secret", new UpsertOrganizationSecret()).ToTask()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("", "secret", upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("owner", "", upsertSecret).ToTask()); + } + } + + public class DeleteMethod + { + [Fact] + public async Task DeletesTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationSecretsClient(gitHubClient); + + await client.Delete("org", "secret"); + + gitHubClient.Received().Organization.Actions.Secrets.Delete("org", "secret"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableOrganizationSecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null).ToTask()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "").ToTask()); + } + } + + public class GetSelectedRepositoriesForSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableOrganizationSecretsClient(gitHubClient); + + await client.GetSelectedRepositoriesForSecret("org", "secret"); + + gitHubClient.Received().Organization.Actions.Secrets.GetSelectedRepositoriesForSecret("org", "secret"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableOrganizationSecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSelectedRepositoriesForSecret(null, "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSelectedRepositoriesForSecret("org", null).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetSelectedRepositoriesForSecret("", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetSelectedRepositoriesForSecret("org", "").ToTask()); + } + } + + public class SetSelectedRepositoriesForSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + var repoIds = new List<long> + { + 1, + 2, + 3 + }; + var repos = new SelectedRepositoryCollection(repoIds); + + await client.SetSelectedRepositoriesForSecret("org", "secret", repos); + + connection.Received() + .Put<SelectedRepositoryCollection>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret/repositories"), repos); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + var repoIds = new List<long> + { + 1, + 2, + 3 + }; + var repos = new SelectedRepositoryCollection(repoIds); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret(null, "secret", repos)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret("org", null, repos)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret("org", "secret", null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetSelectedRepositoriesForSecret("org", "secret", new SelectedRepositoryCollection())); + await Assert.ThrowsAsync<ArgumentException>(() => client.SetSelectedRepositoriesForSecret("", "secret", repos)); + await Assert.ThrowsAsync<ArgumentException>(() => client.SetSelectedRepositoriesForSecret("org", "", repos)); + } + } + + public class AddRepoToOrganizationSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.AddRepoToOrganizationSecret("org", "secret", 1); + + connection.Received() + .Put(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret/repositories/1")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddRepoToOrganizationSecret(null, "secret", 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddRepoToOrganizationSecret("org", null, 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.AddRepoToOrganizationSecret("", "secret", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.AddRepoToOrganizationSecret("org", "", 1)); + } + } + + public class RemoveRepoFromOrganizationSecretMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new OrganizationSecretsClient(connection); + + await client.RemoveRepoFromOrganizationSecret("org", "secret", 1); + + connection.Received() + .Delete(Arg.Is<Uri>(u => u.ToString() == "orgs/org/actions/secrets/secret/repositories/1")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new OrganizationSecretsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepoFromOrganizationSecret(null, "secret", 1)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepoFromOrganizationSecret("org", null, 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveRepoFromOrganizationSecret("", "secret", 1)); + await Assert.ThrowsAsync<ArgumentException>(() => client.RemoveRepoFromOrganizationSecret("org", "", 1)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs new file mode 100644 index 0000000000..22b79b8fbc --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs @@ -0,0 +1,20 @@ +using Octokit.Reactive; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableRepositoryActionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableRepositoryActionsClient(null)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableRepositorySecretsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositorySecretsClientTests.cs new file mode 100644 index 0000000000..92a57e1c2b --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableRepositorySecretsClientTests.cs @@ -0,0 +1,170 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableRepositorySecretsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new ObservableRepositorySecretsClient(null)); + } + } + + public class GetPublicKeyMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositorySecretsClient(gitHubClient); + + await client.GetPublicKey("owner", "repo"); + + gitHubClient.Received().Repository.Actions.Secrets.GetPublicKey("owner", "repo"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositorySecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetPublicKey(null, "repo").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetPublicKey("owner", null).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetPublicKey("", "repo").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetPublicKey("owner", "").ToTask()); + } + } + + public class GetAllMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositorySecretsClient(gitHubClient); + + await client.GetAll("owner", "repo"); + + gitHubClient.Received().Repository.Actions.Secrets.GetAll("owner", "repo"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositorySecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "repo").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null).ToTask()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "repo").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "").ToTask()); + } + } + + public class GetMethod + { + [Fact] + public async Task RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositorySecretsClient(gitHubClient); + + await client.Get("owner", "repo","secret"); + + gitHubClient.Received().Repository.Actions.Secrets.Get("owner", "repo", "secret"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositorySecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "repo", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", "repo", null).ToTask()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "repo", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "repo", "").ToTask()); + } + } + + public class CreateOrUpdateMethod + { + [Fact] + public async Task PostsTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositorySecretsClient(gitHubClient); + var upsert = new UpsertRepositorySecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId" + }; + + await client.CreateOrUpdate("owner", "repo", "secret", upsert); + + gitHubClient.Received().Repository.Actions.Secrets.CreateOrUpdate("owner", "repo", "secret", upsert); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositorySecretsClient(Substitute.For<IGitHubClient>()); + + var upsertSecret = new UpsertRepositorySecret + { + EncryptedValue = "encryptedValue", + KeyId = "keyId" + }; + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate(null, "repo", "secret", upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", null, "secret", upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "repo", null, upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "repo", "secret", null).ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CreateOrUpdate("owner", "repo", "secret", new UpsertRepositorySecret()).ToTask()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("", "repo", "secret", upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("owner", "", "secret", upsertSecret).ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.CreateOrUpdate("owner", "repo", "", upsertSecret).ToTask()); + } + } + + public class DeleteMethod + { + [Fact] + public async Task DeletesTheCorrectUrl() + { + var gitHubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositorySecretsClient(gitHubClient); + + await client.Delete("owner", "repo", "secret"); + + gitHubClient.Received().Repository.Actions.Secrets.Delete("owner", "repo", "secret"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositorySecretsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "repo", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", "repo", null).ToTask()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "repo", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", "secret").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "repo", "").ToTask()); + } + } + } +} diff --git a/Octokit/Clients/IOrganizationActionsClient.cs b/Octokit/Clients/IOrganizationActionsClient.cs new file mode 100644 index 0000000000..38dd3cd032 --- /dev/null +++ b/Octokit/Clients/IOrganizationActionsClient.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Org Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions"> Actions API documentation</a> for more information. + /// </remarks> + public interface IOrganizationActionsClient + { + /// <summary> + /// Returns a client to manage organization secrets. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets"> Secrets API documentation</a> for more information. + /// </remarks> + IOrganizationSecretsClient Secrets { get; } + } +} diff --git a/Octokit/Clients/IOrganizationSecretsClient.cs b/Octokit/Clients/IOrganizationSecretsClient.cs new file mode 100644 index 0000000000..7966ea9a63 --- /dev/null +++ b/Octokit/Clients/IOrganizationSecretsClient.cs @@ -0,0 +1,118 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Organization Secrets API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#secrets">Organization Secrets API documentation</a> for more details. + /// </remarks> + public interface IOrganizationSecretsClient + { + /// <summary> + /// Get the public signing key to encrypt secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the organization public key.</returns> + Task<SecretsPublicKey> GetPublicKey(string org); + + /// <summary> + /// List the secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-organization-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecretsCollection"/> instance for the list of organization secrets.</returns> + Task<OrganizationSecretsCollection> GetAll(string org); + + /// <summary> + /// Get a secret from an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#get-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret.</returns> + Task<OrganizationSecret> Get(string org, string secretName); + + /// <summary> + /// Create or update a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value, id of the encryption key, and visibility info to upsert</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret that was created or updated.</returns> + Task<OrganizationSecret> CreateOrUpdate(string org, string secretName, UpsertOrganizationSecret upsertSecret); + + /// <summary> + /// Delete a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task Delete(string org, string secretName); + + /// <summary> + /// Get the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task<OrganizationSecretRepositoryCollection> GetSelectedRepositoriesForSecret(string org, string secretName); + + /// <summary> + /// Set the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repositories">The list of repositories that should have access to view and use the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task SetSelectedRepositoriesForSecret(string org, string secretName, SelectedRepositoryCollection repositories); + + /// <summary> + /// Add a selected site to the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task AddRepoToOrganizationSecret(string org, string secretName, long repoId); + + /// <summary> + /// ARemoved a selected site from the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task RemoveRepoFromOrganizationSecret(string org, string secretName, long repoId); + } +} diff --git a/Octokit/Clients/IOrganizationsClient.cs b/Octokit/Clients/IOrganizationsClient.cs index 5f3f2fc6fb..d87d69387d 100644 --- a/Octokit/Clients/IOrganizationsClient.cs +++ b/Octokit/Clients/IOrganizationsClient.cs @@ -35,6 +35,11 @@ public interface IOrganizationsClient /// </summary> IOrganizationOutsideCollaboratorsClient OutsideCollaborator { get; } + /// <summary> + /// Returns a client to manage organization actions. + /// </summary> + IOrganizationActionsClient Actions { get; } + /// <summary> /// Returns the specified <see cref="Organization"/>. /// </summary> diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 56a4b7540a..b8976f0706 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -9,7 +9,7 @@ namespace Octokit /// A client for GitHub's Repositories API. /// </summary> /// <remarks> - /// See the <a href="http://developer.github.com/v3/repos/">Repositories API documentation</a> for more details. + /// See the <https://docs.github.com/en/rest/reference/repos">Repositories API documentation</a> for more details. /// </remarks> public interface IRepositoriesClient { @@ -17,10 +17,18 @@ public interface IRepositoriesClient /// Client for managing pull requests. /// </summary> /// <remarks> - /// See the <a href="http://developer.github.com/v3/pulls/">Pull Requests API documentation</a> for more details + /// See the <a href="https://docs.github.com/en/rest/reference/pulls/">Pull Requests API documentation</a> for more details /// </remarks> IPullRequestsClient PullRequest { get; } + /// <summary> + /// Client for managing Actions in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Actions API documentation</a> for more information. + /// </remarks> + IRepositoryActionsClient Actions { get; } + /// <summary> /// Client for managing branches in a repository. /// </summary> diff --git a/Octokit/Clients/IRepositoryActionsClient.cs b/Octokit/Clients/IRepositoryActionsClient.cs new file mode 100644 index 0000000000..af0aabe896 --- /dev/null +++ b/Octokit/Clients/IRepositoryActionsClient.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Repository Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Repository Actions API documentation</a> for more details. + /// </remarks> + public interface IRepositoryActionsClient + { + /// <summary> + /// Client for GitHub's Repository Actions API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/reference/actions">Deployments API documentation</a> for more details + /// </remarks> + IRepositorySecretsClient Secrets { get; } + } +} diff --git a/Octokit/Clients/IRepositorySecretsClient.cs b/Octokit/Clients/IRepositorySecretsClient.cs new file mode 100644 index 0000000000..50213bec2a --- /dev/null +++ b/Octokit/Clients/IRepositorySecretsClient.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Repository Secrets API. + /// </summary> + /// <remarks> + /// See the <a href="http://developer.github.com/v3/actions/secrets/">Repository Secrets API documentation</a> for more details. + /// </remarks> + public interface IRepositorySecretsClient + { + /// <summary> + /// Get the public signing key to encrypt secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://developer.github.com/v3/actions/secrets/#get-a-repository-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the repository public key.</returns> + Task<SecretsPublicKey> GetPublicKey(string owner, string repoName); + + /// <summary> + /// List the secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://developer.github.com/v3/actions/secrets/#list-repository-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecretsCollection"/> instance for the list of repository secrets.</returns> + Task<RepositorySecretsCollection> GetAll (string owner, string repoName); + + /// <summary> + /// Get a secret from a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://developer.github.com/v3/actions/secrets/#get-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret.</returns> + Task<RepositorySecret> Get(string owner, string repoName, string secretName); + + /// <summary> + /// Create or update a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://developer.github.com/v3/actions/secrets/#create-or-update-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value and id of the encryption key</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret that was created or updated.</returns> + Task<RepositorySecret> CreateOrUpdate(string owner, string repoName, string secretName, UpsertRepositorySecret upsertSecret); + + /// <summary> + /// Delete a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://developer.github.com/v3/actions/secrets/#delete-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + Task Delete(string owner, string repoName, string secretName); + } +} diff --git a/Octokit/Clients/OrganizationActionsClient.cs b/Octokit/Clients/OrganizationActionsClient.cs new file mode 100644 index 0000000000..639c728a9b --- /dev/null +++ b/Octokit/Clients/OrganizationActionsClient.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Org Actions API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions/"> Actions API documentation</a> for more information. + /// </remarks> + public class OrganizationActionsClient : ApiClient, IOrganizationActionsClient + { + /// <summary> + /// Initializes a new GitHub Orgs Actions API client. + /// </summary> + /// <param name="apiConnection">An API connection</param> + public OrganizationActionsClient(IApiConnection apiConnection) : base(apiConnection) + { + Secrets = new OrganizationSecretsClient(apiConnection); + } + + /// <summary> + /// Returns a client to manage organization secrets. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#secrets"> Secrets API documentation</a> for more information. + /// </remarks> + public IOrganizationSecretsClient Secrets { get; private set; } + } +} diff --git a/Octokit/Clients/OrganizationSecretsClient.cs b/Octokit/Clients/OrganizationSecretsClient.cs new file mode 100644 index 0000000000..fb126eb915 --- /dev/null +++ b/Octokit/Clients/OrganizationSecretsClient.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Organization Secrets API. + /// </summary> + /// <remarks> + /// See the <a href="http://docs.github.com/v3/actions#secrets/">Organization Secrets API documentation</a> for more details. + /// </remarks> + public class OrganizationSecretsClient : ApiClient, IOrganizationSecretsClient + { + public OrganizationSecretsClient(IApiConnection apiConnection) : base(apiConnection) { } + + /// <summary> + /// Get the public signing key to encrypt secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#get-an-organization-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the organization public key.</returns> + [ManualRoute("GET", "/orgs/{org}/actions/secrets/public-key")] + public Task<SecretsPublicKey> GetPublicKey(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return ApiConnection.Get<SecretsPublicKey>(ApiUrls.OrganizationRepositorySecretPublicKey(org)); + } + + /// <summary> + /// List the secrets for an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#list-organization-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecretsCollection"/> instance for the list of organization secrets.</returns> + [ManualRoute("GET", "/orgs/{org}/actions/secrets")] + public Task<OrganizationSecretsCollection> GetAll(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + return ApiConnection.Get<OrganizationSecretsCollection>(ApiUrls.OrganizationRepositorySecrets(org)); + } + + /// <summary> + /// Get a secret from an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#get-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret.</returns> + [ManualRoute("GET", "/orgs/{org}/actions/secrets/{secretName}")] + public Task<OrganizationSecret> Get(string org, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return ApiConnection.Get<OrganizationSecret>(ApiUrls.OrganizationRepositorySecret(org, secretName)); + } + + /// <summary> + /// Create or update a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#create-or-update-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value, id of the encryption key, and visibility info to upsert</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="OrganizationSecret"/> instance for the organization secret that was created or updated.</returns> + [ManualRoute("PUT", "/orgs/{org}/actions/secrets/{secretName}")] + public async Task<OrganizationSecret> CreateOrUpdate(string org, string secretName, UpsertOrganizationSecret upsertSecret) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(upsertSecret, nameof(upsertSecret)); + Ensure.ArgumentNotNullOrEmptyString(upsertSecret.KeyId, nameof(upsertSecret.KeyId)); + Ensure.ArgumentNotNullOrEmptyString(upsertSecret.EncryptedValue, nameof(upsertSecret.EncryptedValue)); + Ensure.ArgumentNotNullOrEmptyString(upsertSecret.Visibility, nameof(upsertSecret.Visibility)); + + await ApiConnection.Put<OrganizationSecret>(ApiUrls.OrganizationRepositorySecret(org, secretName), upsertSecret); + return await ApiConnection.Get<OrganizationSecret>(ApiUrls.OrganizationRepositorySecret(org, secretName)); + } + + /// <summary> + /// Delete a secret in an organization. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#delete-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("DELETE", "/orgs/{org}/actions/secrets/{secretName}")] + public Task Delete(string org, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return ApiConnection.Delete(ApiUrls.OrganizationRepositorySecret(org, secretName)); + } + + /// <summary> + /// Get the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#list-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("GET", "/orgs/{org}/actions/secrets/{secretName}/repositories")] + public Task<OrganizationSecretRepositoryCollection> GetSelectedRepositoriesForSecret(string org, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + return ApiConnection.Get<OrganizationSecretRepositoryCollection>(ApiUrls.OrganizationRepositorySecretRepositories(org, secretName)); + } + + /// <summary> + /// Set the list of selected sites that have access to a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#set-selected-repositories-for-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repositories">The list of repositories that should have access to view and use the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("PUT", "/orgs/{org}/actions/secrets/{secretName}/repositories")] + public async Task SetSelectedRepositoriesForSecret(string org, string secretName, SelectedRepositoryCollection repositories) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(repositories, nameof(repositories)); + Ensure.ArgumentNotNull(repositories.SelectedRepositoryIds, nameof(repositories.SelectedRepositoryIds)); + + await ApiConnection.Put<SelectedRepositoryCollection>(ApiUrls.OrganizationRepositorySecretRepositories(org, secretName), repositories); + return; + } + + /// <summary> + /// Add a selected site to the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#add-selected-repository-to-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("PUT", "/orgs/{org}/actions/secrets/{secretName}/repositories/{repoId}")] + public Task AddRepoToOrganizationSecret(string org, string secretName, long repoId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(repoId, nameof(repoId)); + + return ApiConnection.Put(ApiUrls.OrganizationRepositorySecretRepository(org, secretName, repoId)); + } + + /// <summary> + /// ARemoved a selected site from the visibility list of a secret. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#remove-selected-repository-from-an-organization-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="org">The name of the organization</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="repoId">The id of the repo to add to the visibility list of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("DELETE", "/orgs/{org}/actions/secrets/{secretName}/repositories/{repoId}")] + public Task RemoveRepoFromOrganizationSecret(string org, string secretName, long repoId) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(repoId, nameof(repoId)); + + return ApiConnection.Delete(ApiUrls.OrganizationRepositorySecretRepository(org, secretName, repoId)); + } + } +} diff --git a/Octokit/Clients/OrganizationsClient.cs b/Octokit/Clients/OrganizationsClient.cs index fb07b3a90e..57abb1e716 100644 --- a/Octokit/Clients/OrganizationsClient.cs +++ b/Octokit/Clients/OrganizationsClient.cs @@ -22,6 +22,7 @@ public OrganizationsClient(IApiConnection apiConnection) : base(apiConnection) Team = new TeamsClient(apiConnection); Hook = new OrganizationHooksClient(apiConnection); OutsideCollaborator = new OrganizationOutsideCollaboratorsClient(apiConnection); + Actions = new OrganizationActionsClient(apiConnection); } /// <summary> @@ -34,6 +35,11 @@ public OrganizationsClient(IApiConnection apiConnection) : base(apiConnection) /// </summary> public ITeamsClient Team { get; private set; } + /// <summary> + /// Returns a client to manage organization actions. + /// </summary> + public IOrganizationActionsClient Actions { get; private set; } + /// <summary> /// Returns a client to manage outside collaborators of an organization. /// </summary> diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 9de3bc7035..9d208a7b6f 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -39,6 +39,7 @@ public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection) Branch = new RepositoryBranchesClient(apiConnection); Traffic = new RepositoryTrafficClient(apiConnection); Project = new ProjectsClient(apiConnection); + Actions = new RepositoryActionsClient(apiConnection); } /// <summary> @@ -482,6 +483,14 @@ public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization, ApiOpti return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization), null, options); } + /// <summary> + /// Client for managing Actions in a repository. + /// </summary> + /// <remarks> + /// See the <a href="http://developer.github.com/v3/actions/">Repository Actions API documentation</a> for more information. + /// </remarks> + public IRepositoryActionsClient Actions { get; private set; } + /// <summary> /// A client for GitHub's Repository Branches API. /// </summary> diff --git a/Octokit/Clients/RepositoryActionsClient.cs b/Octokit/Clients/RepositoryActionsClient.cs new file mode 100644 index 0000000000..9837448eba --- /dev/null +++ b/Octokit/Clients/RepositoryActionsClient.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Repository Actions API. + /// </summary> + /// <remarks> + /// See the <a href="http://docs.github.com/v3/actions">Repository Actions API documentation</a> for more details. + /// </remarks> + public class RepositoryActionsClient : ApiClient, IRepositoryActionsClient + { + /// <summary> + /// Initializes a new GitHub Repository Actions API client. + /// </summary> + /// <param name="apiConnection">An API connection</param> + public RepositoryActionsClient(IApiConnection apiConnection) : base(apiConnection) + { + Secrets = new RepositorySecretsClient(apiConnection); + } + + /// <summary> + /// Client for GitHub's Repository Actions API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#secrets">Deployments API documentation</a> for more details + /// </remarks> + public IRepositorySecretsClient Secrets { get; set; } + } +} diff --git a/Octokit/Clients/RepositorySecretsClient.cs b/Octokit/Clients/RepositorySecretsClient.cs new file mode 100644 index 0000000000..7810955bd1 --- /dev/null +++ b/Octokit/Clients/RepositorySecretsClient.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + public class RepositorySecretsClient : ApiClient, IRepositorySecretsClient + { + /// <summary> + /// Initializes a new GitHub Repository Branches API client. + /// </summary> + /// <param name="apiConnection">An API connection</param> + public RepositorySecretsClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + /// <summary> + /// Get the public signing key to encrypt secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#get-a-repository-public-key">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="SecretsPublicKey"/> instance for the repository public key.</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/actions/secrets/public-key")] + public Task<SecretsPublicKey> GetPublicKey(string owner, string repoName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + + var url = ApiUrls.RepositorySecretsPublicKey(owner, repoName); + + return ApiConnection.Get<SecretsPublicKey>(url); + } + + /// <summary> + /// List the secrets for a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#list-repository-secrets">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecretsCollection"/> instance for the list of repository secrets.</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/actions/secrets")] + public Task<RepositorySecretsCollection> GetAll(string owner, string repoName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + + var url = ApiUrls.RepositorySecrets(owner, repoName); + + return ApiConnection.Get<RepositorySecretsCollection>(url); + } + + /// <summary> + /// Get a secret from a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#get-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret.</returns> + [ManualRoute("GET", "/repos/{owner}/{repo}/actions/secrets/{secretName}")] + public Task<RepositorySecret> Get(string owner, string repoName, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + var url = ApiUrls.RepositorySecret(owner, repoName, secretName); + + return ApiConnection.Get<RepositorySecret>(url); + } + + /// <summary> + /// Create or update a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#create-or-update-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <param name="upsertSecret">The encrypted value and id of the encryption key</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns>A <see cref="RepositorySecret"/> instance for the repository secret that was created or updated.</returns> + [ManualRoute("PUT", "/repos/{owner}/{repo}/actions/secrets/{secretName}")] + public async Task<RepositorySecret> CreateOrUpdate(string owner, string repoName, string secretName, UpsertRepositorySecret upsertSecret) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + Ensure.ArgumentNotNull(upsertSecret, nameof(upsertSecret)); + Ensure.ArgumentNotNullOrEmptyString(upsertSecret.EncryptedValue, nameof(upsertSecret.EncryptedValue)); + Ensure.ArgumentNotNullOrEmptyString(upsertSecret.KeyId, nameof(upsertSecret.KeyId)); + + var url = ApiUrls.RepositorySecret(owner, repoName, secretName); + + await ApiConnection.Put<RepositorySecret>(url, upsertSecret); + + return await Get(owner, repoName, secretName); + } + + /// <summary> + /// Delete a secret in a repository. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/v3/actions#delete-a-repository-secret">API documentation</a> for more information. + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="repoName">The name of the repository</param> + /// <param name="secretName">The name of the secret</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + [ManualRoute("DELETE", "/repos/{owner}/{repo}/actions/secrets/{secretName}")] + public Task Delete(string owner, string repoName, string secretName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); + Ensure.ArgumentNotNullOrEmptyString(secretName, nameof(secretName)); + + var url = ApiUrls.RepositorySecret(owner, repoName, secretName); + + return ApiConnection.Delete(url); + } + } +} diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index e24de63a42..c6d57704ca 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -78,6 +78,64 @@ public static Uri OrganizationRepositories(string organization) return "orgs/{0}/repos".FormatUri(organization); } + /// <summary> + /// Returns the <see cref="Uri"/> that returns all of the secrets for the specified organization in + /// response to a GET request. + /// </summary> + /// <param name="organization">The name of the organization</param> + /// <returns></returns> + public static Uri OrganizationRepositorySecrets(string organization) + { + return "orgs/{0}/actions/secrets".FormatUri(organization); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that returns a secret for the specified organization in + /// response to a GET request. A POST to this URL creates a new secret for the organization. + /// </summary> + /// <param name="organization">The name of the organization</param> + /// <param name="secret">The name of the secret</param> + /// <returns></returns> + public static Uri OrganizationRepositorySecret(string organization, string secret) + { + return "orgs/{0}/actions/secrets/{1}".FormatUri(organization,secret); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that returns the public key for signing secrets for the specified organization in + /// response to a GET request. + /// </summary> + /// <param name="organization">The name of the organization</param> + /// <returns></returns> + public static Uri OrganizationRepositorySecretPublicKey(string organization) + { + return "orgs/{0}/actions/secrets/public-key".FormatUri(organization); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that returns a list of repositories for a secret for the specified organization in + /// response to a GET request. A POST to this URL sets the full repository list for a secret in the organization. + /// </summary> + /// <param name="organization">The name of the organization</param> + /// <param name="secret">The name of the secret</param> + /// <returns></returns> + public static Uri OrganizationRepositorySecretRepositories(string organization, string secret) + { + return "orgs/{0}/actions/secrets/{1}/repositories".FormatUri(organization, secret); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that adds (PUT) or removes (DELETE) a repository from the visibility list of a secret. + /// </summary> + /// <param name="organization">The name of the organization</param> + /// <param name="secret">The name of the secret</param> + /// <param name="repoId">The id of the repo to target</param> + /// <returns></returns> + public static Uri OrganizationRepositorySecretRepository(string organization, string secret, long repoId) + { + return "orgs/{0}/actions/secrets/{1}/repositories/{2}".FormatUri(organization, secret, repoId.ToString()); + } + /// <summary> /// Returns the <see cref="Uri"/> that returns all of the organizations for the currently logged in user. /// </summary> @@ -4387,6 +4445,40 @@ public static Uri CheckSuitePreferences(string owner, string repo) return "repos/{0}/{1}/check-suites/preferences".FormatUri(owner, repo); } + /// <summary> + /// Returns the <see cref="Uri"/> that handles the repository secrets for the repository + /// </summary> + /// <param name="owner">The owner of the repo</param> + /// <param name="repo">The name of the repo</param> + /// <param name="secret">The name of the secret</param> + /// <returns>The <see cref="Uri"/> that handles the repository secrets for the repository</returns> + public static Uri RepositorySecret(string owner, string repo, string secret) + { + return "repos/{0}/{1}/actions/secrets/{2}".FormatUri(owner, repo, secret); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that handles the repository secrets for the repository + /// </summary> + /// <param name="owner">The owner of the repo</param> + /// <param name="repo">The name of the repo</param> + /// <returns>The <see cref="Uri"/> that handles the repository secrets for the repository</returns> + public static Uri RepositorySecrets(string owner, string repo) + { + return "repos/{0}/{1}/actions/secrets".FormatUri(owner, repo); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that handles the repository secrets for the repository + /// </summary> + /// <param name="owner">The owner of the repo</param> + /// <param name="repo">The name of the repo</param> + /// <returns>The <see cref="Uri"/> that handles the repository secrets for the repository</returns> + public static Uri RepositorySecretsPublicKey(string owner, string repo) + { + return "repos/{0}/{1}/actions/secrets/public-key".FormatUri(owner, repo); + } + /// <summary> /// Returns the <see cref="Uri"/> that returns all emojis in /// response to a GET request. diff --git a/Octokit/Models/Request/SelectedRepositoryCollection.cs b/Octokit/Models/Request/SelectedRepositoryCollection.cs new file mode 100644 index 0000000000..bf11200a5c --- /dev/null +++ b/Octokit/Models/Request/SelectedRepositoryCollection.cs @@ -0,0 +1,32 @@ +using Octokit.Internal; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; + +namespace Octokit +{ + /// <summary> + /// Represents request to set the repositories with visibility to the secrets in an organization. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class SelectedRepositoryCollection + { + public SelectedRepositoryCollection() + { + } + + public SelectedRepositoryCollection(IEnumerable<long> selectedRepositoryIds) + { + SelectedRepositoryIds = selectedRepositoryIds; + } + + /// <summary> + /// List of repository Ids that should have visibility to the repository + /// </summary> + [Parameter(Key = "selected_repository_ids")] + public IEnumerable<long> SelectedRepositoryIds { get; set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "SelectedRepositoryCollection: Count: {0}", SelectedRepositoryIds.Count()); + } +} diff --git a/Octokit/Models/Request/UpsertOrganizationSecret.cs b/Octokit/Models/Request/UpsertOrganizationSecret.cs new file mode 100644 index 0000000000..bd8f78fa32 --- /dev/null +++ b/Octokit/Models/Request/UpsertOrganizationSecret.cs @@ -0,0 +1,38 @@ +using Octokit.Internal; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Represents request to change the value of a secret for an organization. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class UpsertOrganizationSecret : UpsertRepositorySecret + { + public UpsertOrganizationSecret() { } + + public UpsertOrganizationSecret(string encryptedValue, string encryptionKeyId, string visibility, IEnumerable<long> selectedRepositoriesIds) + { + EncryptedValue = encryptedValue; + KeyId = encryptionKeyId; + Visibility = visibility; + SelectedRepositoriesIds = selectedRepositoriesIds; + } + + /// <summary> + /// The visibility level of the secret + /// </summary> + [Parameter(Key = "visibility")] + public string Visibility { get; set; } + + /// <summary> + /// The list of ids for the repositories with selected visibility to the secret + /// </summary> + [Parameter(Key = "selected_repository_ids")] + public IEnumerable<long> SelectedRepositoriesIds { get; set; } + + internal new string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "UpsertOrganizationSecret: Key ID: {0}", KeyId); + } +} diff --git a/Octokit/Models/Request/UpsertRepositorySecret.cs b/Octokit/Models/Request/UpsertRepositorySecret.cs new file mode 100644 index 0000000000..8fe5ee3657 --- /dev/null +++ b/Octokit/Models/Request/UpsertRepositorySecret.cs @@ -0,0 +1,35 @@ +using Octokit.Internal; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Used to create or update a repository secret + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class UpsertRepositorySecret + { + /// <summary> + /// The encrypted value of the secret. + /// </summary> + /// <remarks>See the <a href="https://developer.github.com/v3/actions/secrets/#create-or-update-a-repository-secret">API documentation</a> for more information on how to encrypt the secret</remarks> + [Parameter(Value = "encrypted_value")] + public string EncryptedValue { get; set; } + + /// <summary> + /// The id of the encryption key used to encrypt the secret. + /// </summary> + /// <remarks>Get key and id from <see cref="RepositorySecretsClient.GetPublicKey(string, string)"/> and use the <a href="https://developer.github.com/v3/actions/secrets/#create-or-update-a-repository-secret">API documentation</a> for more information on how to encrypt the secret</remarks> + [Parameter(Value = "key_id")] + public string KeyId { get; set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "KeyId: {0}", KeyId); + } + } + } +} diff --git a/Octokit/Models/Response/OrganizationSecret.cs b/Octokit/Models/Response/OrganizationSecret.cs new file mode 100644 index 0000000000..18f0cb0755 --- /dev/null +++ b/Octokit/Models/Response/OrganizationSecret.cs @@ -0,0 +1,39 @@ +using Octokit.Internal; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text; + +namespace Octokit +{ + /// <summary> + /// Represents an organization secret. + /// Does not contain the secret value + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OrganizationSecret : RepositorySecret + { + public OrganizationSecret() { } + + public OrganizationSecret(string name, DateTime createdAt, DateTime updatedAt, string visibility, string selectedRepositoriesUrl) + { + Name = name; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Visibility = visibility; + SelectedRepositoriesUrl = selectedRepositoriesUrl; + } + + /// <summary> + /// The visibility level of the secret within the organization + /// </summary> + public string Visibility { get; private set; } + + /// <summary> + /// The URL to retrieve the list of selected repositories + /// </summary> + [Parameter(Key = "selected_repositories_url")] + public string SelectedRepositoriesUrl { get; private set; } + } +} diff --git a/Octokit/Models/Response/OrganizationSecretRepositoryCollection.cs b/Octokit/Models/Response/OrganizationSecretRepositoryCollection.cs new file mode 100644 index 0000000000..e7914c7eac --- /dev/null +++ b/Octokit/Models/Response/OrganizationSecretRepositoryCollection.cs @@ -0,0 +1,38 @@ +using Octokit.Internal; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Represents response of the repositories for a secret in an organization. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OrganizationSecretRepositoryCollection + { + public OrganizationSecretRepositoryCollection() + { + } + + public OrganizationSecretRepositoryCollection(int count, IReadOnlyList<Repository> repositories) + { + Count = count; + Repositories = repositories; + } + + /// <summary> + /// The total count of repositories with visibility to the secret in the organization + /// </summary> + [Parameter(Key = "total_count")] + public int Count { get; private set; } + + /// <summary> + /// The list of repositories with visibility to the secret in the organization + /// </summary> + [Parameter(Key = "repositories")] + public IReadOnlyList<Repository> Repositories { get; private set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "OrganizationSecretRepositoryCollection: Count: {0}", Count); + } +} diff --git a/Octokit/Models/Response/OrganizationSecretsCollection.cs b/Octokit/Models/Response/OrganizationSecretsCollection.cs new file mode 100644 index 0000000000..f957de1a27 --- /dev/null +++ b/Octokit/Models/Response/OrganizationSecretsCollection.cs @@ -0,0 +1,38 @@ +using Octokit.Internal; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Represents response of secrets for an organization. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OrganizationSecretsCollection + { + public OrganizationSecretsCollection() + { + } + + public OrganizationSecretsCollection(int count, IReadOnlyList<OrganizationSecret> secrets) + { + Count = count; + Secrets = secrets; + } + + /// <summary> + /// The total count of secrets for the organization + /// </summary> + [Parameter(Key = "total_count")] + public int Count { get; private set; } + + /// <summary> + /// The list of secrets for the organization + /// </summary> + [Parameter(Key = "secrets")] + public IReadOnlyList<OrganizationSecret> Secrets { get; private set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "OrganizationSecretCollection: Count: {0}", Count); + } +} diff --git a/Octokit/Models/Response/RepositorySecret.cs b/Octokit/Models/Response/RepositorySecret.cs new file mode 100644 index 0000000000..f2559a2311 --- /dev/null +++ b/Octokit/Models/Response/RepositorySecret.cs @@ -0,0 +1,50 @@ +using Octokit.Internal; +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Represents a repository secret. + /// Does not contain the secret value + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositorySecret + { + public RepositorySecret() + { + } + + public RepositorySecret(string name, DateTimeOffset createdAt, DateTimeOffset? updatedAt) + { + Name = name; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + } + + /// <summary> + /// The name of the repository secret + /// </summary> + public string Name { get; protected set; } + + /// <summary> + /// The date and time that the secret was created + /// </summary> + public DateTimeOffset CreatedAt { get; protected set; } + + /// <summary> + /// The date and time the secret was last updated + /// </summary> + public DateTimeOffset? UpdatedAt { get; protected set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, + "RepositorySecret: Name: {0}", Name); + } + } + } +} diff --git a/Octokit/Models/Response/RepositorySecretsCollection.cs b/Octokit/Models/Response/RepositorySecretsCollection.cs new file mode 100644 index 0000000000..5f900bf6f4 --- /dev/null +++ b/Octokit/Models/Response/RepositorySecretsCollection.cs @@ -0,0 +1,36 @@ +using Octokit.Internal; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Represents response of secrets for a repository. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class RepositorySecretsCollection + { + public RepositorySecretsCollection() + { + } + + public RepositorySecretsCollection(int totalCount, IReadOnlyList<RepositorySecret> secrets) + { + TotalCount = totalCount; + Secrets = secrets; + } + + /// <summary> + /// The total count of secrets for the repository + /// </summary> + public int TotalCount { get; private set; } + + /// <summary> + /// The list of secrets for the repository + /// </summary> + public IReadOnlyList<RepositorySecret> Secrets { get; private set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "RepositorySecretsCollection: Count: {0}", TotalCount); + } +} diff --git a/Octokit/Models/Response/SecretsPublicKey.cs b/Octokit/Models/Response/SecretsPublicKey.cs new file mode 100644 index 0000000000..b7b7fda0a7 --- /dev/null +++ b/Octokit/Models/Response/SecretsPublicKey.cs @@ -0,0 +1,41 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Represents the public key used to sign the secrets to post to GitHub + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class SecretsPublicKey + { + public SecretsPublicKey() + { + } + + public SecretsPublicKey(string keyId, string key) + { + KeyId = keyId; + Key = key; + } + + /// <summary> + /// The id of this repository public key. Needed to create or update a secret + /// </summary> + public string KeyId { get; private set; } + + /// <summary> + /// The public key for this repository + /// </summary> + public string Key { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, + "RepositorySecretPublicKey: Id: {0}", KeyId); + } + } + } +} From 5b28c7ee68ceb82cd9c64516546a8b892b8fce85 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Wed, 26 Oct 2022 16:53:47 -0500 Subject: [PATCH 145/209] Update stale.yml --- .github/workflows/stale.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 20f04ff758..b8115b1e02 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -23,5 +23,5 @@ jobs: Thank you for your contributions and help in keeping things tidy! days-before-stale: 270 days-before-close: 7 - exempt-issue-labels: 'pinned, work-in-progress' - exempt-pr-labels: 'pinned, work-in-progress' + exempt-issue-labels: 'Status: Pinned' + exempt-pr-labels: 'Status: Pinned' From a6a74c29af3f8e569cf8bab6479481e9328e666c Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Mon, 31 Oct 2022 12:39:00 -0500 Subject: [PATCH 146/209] Removes references to old labels and updates release steps (#2601) --- .github/workflows/stale.yml | 4 +-- CONTRIBUTING.md | 2 +- DEPLOYMENT.md | 49 ++++--------------------------------- 3 files changed, 8 insertions(+), 47 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b8115b1e02..cfd0143c32 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -14,12 +14,12 @@ jobs: stale-issue-message: > 👋 Hey Friends, this issue has been automatically marked as `stale` because it has no recent activity. It will be closed if no further activity occurs. - Please add the `pinned` label if you feel that this issue needs to remain open/active. + Please add the `Status: Pinned` label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy! stale-pr-message: > 👋 Hey Friends, this pull request has been automatically marked as `stale` because it has no recent activity. It will be closed if no further activity occurs. - Please add the `pinned` label if you feel that this issue needs to remain open/active. + Please add the `Status: Pinned` label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy! days-before-stale: 270 days-before-close: 7 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9b948f5020..512fdc506b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ to ensure everything builds and the tests pass. ## How can I get involved? -We have an [`up-for-grabs`](https://github.com/octokit/octokit.net/labels/up-for-grabs) +We have an [`Status: Up for grabs`](https://github.com/octokit/octokit.net/labels/Status%3A%20Up%20for%20grabs) tag on our issue tracker to indicate tasks which contributors can pick up. If you've found something you'd like to contribute to, leave a comment in the issue diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index adb084c1b9..1d8de296ad 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -5,52 +5,13 @@ Creating a new release and deploying the package to nuget are administrative tasks and require that you have/do the following: 1. Admin access to the [GitHub](https://www.nuget.org/profiles/GitHub) NuGet organization 2. Admin rights to the [octokit.net](https://github.com/octokit/octokit.net) repository -3. For any PRs that should be noted in the release notes, each pull request must have a comment formatted like `release_notes: description` where description represents the details of the change. ### Publish to nuget.org 1. Run test and perform manual tests from `main` -2. [Generate](https://github.com/shiftkey/octokit.releasenotes) the release notes. `Octokit.ReleaseNotes generate main [LAST RELEASE TAG]` (i.e. `dotnet run generate main v3.0.0`) -3. When you're satisfied with this release, create a tag `git tag v#.#.#`. For example, to create a tag for 3.0.1 +2. When you're satisfied with this release, create a tag `git tag v#.#.#`. For example, to create a tag for 3.0.1 `git tag v3.0.1` -4. Push the tag to the server. `git push --tags` -5. When the tag is successfully pushed, the [publish workflow](https://github.com/octokit/octokit.net/blob/main/.github/workflows/publish.yml) will run and build and push the package to nuget -6. Verify that the package has been uploaded to [nuget.org](https://www.nuget.org/packages/Octokit/) -7. Create a [new release](https://github.com/octokit/octokit.net/releases/new) using the tag you just created and pasting in the release notes you just generated - ---- - -### Release notes generator - -Release notes [generator](https://github.com/shiftkey/octokit.releasenotes): this is used to pull details using the GitHub API to generate the release notes. - -The generator helps in that it produces release notes that are consistently formatted based on information directly from the change scope (from the previous release to the current tip i.e. the `release` branch). - -Any PRs that should be noted in the release notes, each pull request must have a comment formatted like `release_notes: description` where description represents the details of the change. Make sure for the commit range any changeset in a PR that should be represented has a comment on the PR prefixed with `release_notes:` and corresponding label. - -The nuances are mostly around how it gets and parses release notes from the PRs found in the changeset. The following are the comment prefixes that the generator currently supports: - -* `release_notes` - Having this in the comment with a corresponding "category" label on the PR will put the given note under the "Release Notes" section of the output in the group for the given label -* `advisories` - Having this in the comment will put the given note into the "Advisories and Breaking Changes" section of the output - -In addition to formatted comment parsing, the generator also looks at the following labels to generate categories with in the release notes. - -* `category: bug` - This will add the comment in the PR prefixed with `release_notes` into the `Fixes` group -* `category: docs-and-samples` - This will add the comment in the PR prefixed with `release_notes` into the `Documentation Updates` group -* `category: feature` - This will add the comment in the PR prefixed with `release_notes` into the `Features/Enhancements` group -* `category: housekeeping` - This will add the comment in the PR prefixed with `release_notes` into the `Housekeeping` group - -When these labels are added to a given PR the generator will produce and categorize comment in the release notes formatted like: - -`Comment content` - `PR Id and link` via `Contributor` -ex. "Cleans up some mentions of `master` branch in codebase - [#2306](https://github.com/octokit/octokit.net/pull/2306) via [@shiftkey](https://github.com/shiftkey)" - ----- -### Troubleshooting - -When running the release notes generator on a mac if dotnet has not been added to the PATH or there is not alias defined in your dotfiles you'll need to execute the command as follows: - -`dotnet run generate [BASE] [HEAD]` -(where `[BASE]` is the last release label (i.e. v0.50.0) and `[HEAD]` represents the `release` branch tip that was generated above) - -The tool looks for a environment variable named `OCTOKIT_OAUTHTOKEN`. This token requires a minimal scope to execute and pull the data from the repository via API. Keep in mind that if a token is not provided then you will most likely run into rate limit errors because the requests are being made anonymously. +3. Push the tag to the server. `git push --tags` +4. When the tag is successfully pushed, the [publish workflow](https://github.com/octokit/octokit.net/blob/main/.github/workflows/publish.yml) will run and build and push the package to nuget +5. Verify that the package has been uploaded to [nuget.org](https://www.nuget.org/packages/Octokit/) +6. Create a [new release](https://github.com/octokit/octokit.net/releases/new) using the tag you just created and pasting in the release notes you just generated From 1d9847081b0e7121036e12c3b4001dddec1ce872 Mon Sep 17 00:00:00 2001 From: Keegan Campbell <me@kfcampbell.com> Date: Fri, 4 Nov 2022 12:58:38 -0700 Subject: [PATCH 147/209] [maint] Add issue templates (#2604) --- .github/ISSUE_TEMPLATE/bug.yml | 41 ++++++++++++++++++++ .github/ISSUE_TEMPLATE/documentation.yml | 49 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature.yml | 49 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/maintenance.yml | 49 ++++++++++++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/documentation.yml create mode 100644 .github/ISSUE_TEMPLATE/feature.yml create mode 100644 .github/ISSUE_TEMPLATE/maintenance.yml diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000000..ccb5214668 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,41 @@ +name: Bug +description: File a bug report +title: "[BUG]: " +labels: ["Type: Bug", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: what-happened + attributes: + label: What happened? + description: What did you do? What happened? What did you expect to happen? + placeholder: Put your description of the bug here. + validations: + required: true + - type: textarea + id: versions + attributes: + label: Versions + description: What versions of the relevant software are you running? + placeholder: Octokit.js v2.0.10, Node v16.18.0 + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000000..64c1fc0754 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,49 @@ +name: Documentation +description: Update or add documentation +title: "[DOCS]: " +labels: ["Type: Documentation", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill this out! + - type: textarea + id: describe-need + attributes: + label: Describe the need + description: What do you wish was different about our docs? + placeholder: Describe the need for documentation updates here. + validations: + required: true + - type: input + id: sdk_version + attributes: + label: SDK Version + description: Do these docs apply to a specific SDK version? + placeholder: Octokit.NET v4.0.1 + validations: + required: false + - type: input + id: api_version + attributes: + label: API Version + description: Do these docs apply to a specific version of the GitHub REST API or GraphQL API? + placeholder: ex. v1.1.1 + validations: + required: false + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 0000000000..453cdfda4e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,49 @@ +name: Feature +description: Suggest an idea for a new feature or enhancement +title: "[FEAT]: " +labels: ["Type: Feature", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill this out! + - type: textarea + id: describe-need + attributes: + label: Describe the need + description: What do you want to happen? What problem are you trying to solve? + placeholder: Describe the need for the feature. + validations: + required: true + - type: input + id: sdk_version + attributes: + label: SDK Version + description: Does this feature suggestion apply to a specific SDK version? + placeholder: Octokit.rb v6.0.0 + validations: + required: false + - type: input + id: api_version + attributes: + label: API Version + description: Does this feature suggestion apply to a specific version of the GitHub REST API or GraphQL API? + placeholder: ex. v1.1.1 + validations: + required: false + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/maintenance.yml b/.github/ISSUE_TEMPLATE/maintenance.yml new file mode 100644 index 0000000000..0c5221e2c1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/maintenance.yml @@ -0,0 +1,49 @@ +name: Maintenance +description: Dependencies, cleanup, refactoring, reworking of code +title: "[MAINT]: " +labels: ["Type: Maintenance", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill this out! + - type: textarea + id: describe-need + attributes: + label: Describe the need + description: What do you want to happen? + placeholder: Describe the maintenance need here. + validations: + required: true + - type: input + id: sdk_version + attributes: + label: SDK Version + description: Does this maintenance apply to a specific SDK version? + placeholder: terraform-provider-github v5.7.0 + validations: + required: false + - type: input + id: api_version + attributes: + label: API Version + description: Does this maintenance apply to a specific version of the GitHub REST API or GraphQL API? + placeholder: ex. v1.1.1 + validations: + required: false + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true From 961a5f7b9d12f63c9d0940ae0d9e4933f35850a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 16:53:27 -0800 Subject: [PATCH 148/209] build(deps): bump Microsoft.NET.Test.Sdk from 17.3.2 to 17.4.0 (#2606) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.3.2 to 17.4.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.3.2...v17.4.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 83f08e897f..10b25a904d 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 2f045e2d84..64794c5341 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -34,7 +34,7 @@ <ItemGroup> <PackageReference Include="GitHubJwt" Version="0.0.5" /> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 88a8ea3eb2..566886467b 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> From fd9f73d95df17edf8a27cd9d00629bec35162164 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 15:15:12 -0600 Subject: [PATCH 149/209] [maint]: bump Microsoft.Bcl.AsyncInterfaces from 6.0.0 to 7.0.0 (#2605) --- .../Octokit.AsyncPaginationExtension.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj index 9360717e9e..79d58866f5 100644 --- a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj +++ b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj @@ -30,7 +30,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" /> + <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" /> </ItemGroup> <ItemGroup> From e3c06ba97be3cc5ca810637f9de90cda96b69156 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Mon, 14 Nov 2022 16:18:48 -0600 Subject: [PATCH 150/209] Add PR templates (#2612) feat: add pull_request_template.md PR template --- .github/pull_request_template.md | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..dc0794ae83 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,61 @@ +<!-- Please refer to our contributing docs for any questions on submitting a pull request --> + + +<!-- Issues are required for both bug fixes and features. --> +Resolves #ISSUE_NUMBER + +---- + +## Behavior + +### Before the change? +<!-- Please describe the current behavior that you are modifying. --> + +* + +### After the change? +<!-- Please describe the behavior or changes that are being added by this PR. --> + +* + + +### Other information +<!-- Any other information that is important to this PR --> + +* + +---- + +## Additional info + +### Pull request checklist +- [ ] Tests for the changes have been added (for bug fixes / features) +- [ ] Docs have been reviewed and added / updated if needed (for bug fixes / features) +- [ ] Added the appropriate label for the given change + +### Does this introduce a breaking change? +<!-- If this introduces a breaking change make sure to note it here any what the impact might be --> + +Please see our docs on [breaking changes](https://github.com/octokit/.github/blob/master/community/breaking_changes.md) to help! + +- [ ] Yes (Please add the `Type: Breaking change` label) +- [ ] No + +If `Yes`, what's the impact: + +* N/A + + +### Pull request type + +<!-- Please do not submit updates to dependencies unless it fixes an issue. --> +<!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. --> + +Please add the corresponding label for change this PR introduces: +- Bugfix: `Type: Bug` +- Feature/model/API additions: `Type: Feature` +- Updates to docs or samples: `Type: Documentation` +- Dependencies/code cleanup: `Type: Maintenance` + +---- + From b998d08408e49784cd6899d6f37cd400b63d364f Mon Sep 17 00:00:00 2001 From: Michal Ciechan <lndcobra@hotmail.com> Date: Wed, 16 Nov 2022 18:35:36 +0000 Subject: [PATCH 151/209] [feat]: Adding repo allowupdatebranch --- Octokit/Models/Request/RepositoryUpdate.cs | 8 ++++++++ Octokit/Models/Response/Repository.cs | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Octokit/Models/Request/RepositoryUpdate.cs b/Octokit/Models/Request/RepositoryUpdate.cs index 02dda177e3..a671fd991f 100644 --- a/Octokit/Models/Request/RepositoryUpdate.cs +++ b/Octokit/Models/Request/RepositoryUpdate.cs @@ -114,6 +114,14 @@ public RepositoryUpdate() { } /// </summary> public bool? AllowForking { get; set; } + /// <summary> + /// Optional. Get or set whether to always allow a pull request head branch that is behind its base branch + /// to be updated even if it is not required to be up to date before merging, or false otherwise. + /// The default is null (do not update). The default when created is false. + /// Available since GitHub Enterprise 3.1 (2021-05-06) + /// </summary> + public bool? AllowUpdateBranch { get; set; } + internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this); } } diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index ba7b2c697f..6de79eaaad 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -17,7 +17,7 @@ public Repository(long id) Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable<string> topics, bool? allowAutoMerge) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable<string> topics, bool? allowAutoMerge, bool? allowUpdateBranch) { Url = url; HtmlUrl = htmlUrl; @@ -65,6 +65,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st DeleteBranchOnMerge = deleteBranchOnMerge; Visibility = visibility; AllowAutoMerge = allowAutoMerge; + AllowUpdateBranch = allowUpdateBranch; } public string Url { get; private set; } @@ -158,6 +159,8 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public RepositoryVisibility? Visibility { get; private set; } public bool? AllowAutoMerge { get; private set; } + + public bool? AllowUpdateBranch { get; private set; } internal string DebuggerDisplay { From b0e02e9d2ef76bf99359c1e2ebef3cc62023e33b Mon Sep 17 00:00:00 2001 From: semyon-p <117575896+semyon-p@users.noreply.github.com> Date: Thu, 17 Nov 2022 19:49:37 +0200 Subject: [PATCH 152/209] [feat]: Added Environments API - GetAll list only feature --- .../Clients/IObservableRepositoriesClient.cs | 10 +- ...vableRepositoryDeployEnvironmentsClient.cs | 57 +++++++ .../Clients/ObservableEnvironmentsClient.cs | 52 +++++++ .../Clients/ObservableRepositoriesClient.cs | 12 +- .../Clients/EnvironmentsClientTests.cs | 145 ++++++++++++++++++ .../Clients/DeploymentEnvironmentsClient.cs | 115 ++++++++++++++ Octokit/Clients/IRepositoriesClient.cs | 10 +- .../IRepositoryDeployEnvironmentsClient.cs | 61 ++++++++ Octokit/Clients/RepositoriesClient.cs | 10 ++ Octokit/Helpers/ApiUrls.cs | 21 +++ Octokit/Models/Request/ApiOptions.cs | 4 +- .../Models/Response/DeploymentEnvironment.cs | 71 +++++++++ .../DeploymentEnvironmentsResponse.cs | 42 +++++ 13 files changed, 606 insertions(+), 4 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableRepositoryDeployEnvironmentsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableEnvironmentsClient.cs create mode 100644 Octokit.Tests/Clients/EnvironmentsClientTests.cs create mode 100644 Octokit/Clients/DeploymentEnvironmentsClient.cs create mode 100644 Octokit/Clients/IRepositoryDeployEnvironmentsClient.cs create mode 100644 Octokit/Models/Response/DeploymentEnvironment.cs create mode 100644 Octokit/Models/Response/DeploymentEnvironmentsResponse.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 169f86e2ac..8e22e4622e 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -226,10 +226,18 @@ public interface IObservableRepositoriesClient /// Client for GitHub's Repository Deployments API /// </summary> /// <remarks> - /// See the <a href="http://developer.github.com/v3/repos/deployment/">Collaborators API documentation</a> for more details + /// See the <a href="https://docs.github.com/en/rest/deployments/deployments">Deployments API documentation</a> for more details /// </remarks> IObservableDeploymentsClient Deployment { get; } + /// <summary> + /// Client for GitHub's Repository Envirinments API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/deployments/environments/">Envirinments API documentation</a> for more details + /// </remarks> + IObservableRepositoryDeployEnvironmentsClient Environment { get; } + /// <summary> /// Client for GitHub's Repository Statistics API. /// Note that the GitHub API uses caching on these endpoints, diff --git a/Octokit.Reactive/Clients/IObservableRepositoryDeployEnvironmentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryDeployEnvironmentsClient.cs new file mode 100644 index 0000000000..4ac2577dec --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableRepositoryDeployEnvironmentsClient.cs @@ -0,0 +1,57 @@ +using Octokit.Models.Response; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit.Reactive +{ + public interface IObservableRepositoryDeployEnvironmentsClient + { + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name); + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="repositoryId">The Id of the repository</param> + IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId); + + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="options">Paging options</param> + IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name, ApiOptions options); + + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="repositoryId">Repository ID</param> + /// <param name="options">Paging options</param> + IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId, ApiOptions options); + } +} diff --git a/Octokit.Reactive/Clients/ObservableEnvironmentsClient.cs b/Octokit.Reactive/Clients/ObservableEnvironmentsClient.cs new file mode 100644 index 0000000000..f100b0708c --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableEnvironmentsClient.cs @@ -0,0 +1,52 @@ +using System; +using System.Reactive.Threading.Tasks; +using Octokit.Models.Response; +using Octokit.Reactive.Internal; + +namespace Octokit.Reactive.Clients +{ + public class ObservableEnvironmentsClient : IObservableRepositoryDeployEnvironmentsClient + { + readonly IRepositoryDeployEnvironmentsClient _client; + readonly IConnection _connection; + + public ObservableEnvironmentsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + _client = client.Repository.Environment; + _connection = client.Connection; + } + + public IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return GetAll(owner, name, ApiOptions.None); + } + + public IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId) + { + return GetAll(repositoryId, ApiOptions.None); + } + + public IObservable<DeploymentEnvironmentsResponse> GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<DeploymentEnvironmentsResponse>( + ApiUrls.DeploymentEnvironments(owner, name), options); + } + + public IObservable<DeploymentEnvironmentsResponse> GetAll(long repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<DeploymentEnvironmentsResponse>( + ApiUrls.DeploymentEnvironments(repositoryId), options); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 199fc6fa00..bbef7b3968 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -27,6 +27,7 @@ public ObservableRepositoriesClient(IGitHubClient client) Forks = new ObservableRepositoryForksClient(client); Collaborator = new ObservableRepoCollaboratorsClient(client); Deployment = new ObservableDeploymentsClient(client); + Environment = new ObservableEnvironmentsClient(client); Statistics = new ObservableStatisticsClient(client); PullRequest = new ObservablePullRequestsClient(client); Branch = new ObservableRepositoryBranchesClient(client); @@ -347,10 +348,19 @@ public IObservable<Repository> GetAllForOrg(string organization, ApiOptions opti /// Client for GitHub's Repository Deployments API /// </summary> /// <remarks> - /// See the <a href="http://developer.github.com/v3/repos/deployment/">Collaborators API documentation</a> for more details + /// See the <a href="https://docs.github.com/en/rest/deployments/deployments">Deployments API documentation</a> for more details /// </remarks> public IObservableDeploymentsClient Deployment { get; private set; } + + /// <summary> + /// Client for GitHub's Repository Environments API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/deployments/environments#about-the-deployment-environments-api/">Environments API documentation</a> for more details + /// </remarks> + public IObservableRepositoryDeployEnvironmentsClient Environment { get; private set; } + /// <summary> /// Client for GitHub's Repository Statistics API /// Note that the GitHub API uses caching on these endpoints, diff --git a/Octokit.Tests/Clients/EnvironmentsClientTests.cs b/Octokit.Tests/Clients/EnvironmentsClientTests.cs new file mode 100644 index 0000000000..629845ddac --- /dev/null +++ b/Octokit.Tests/Clients/EnvironmentsClientTests.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using NSubstitute; +using Octokit; +using Octokit.Models.Response; +using Octokit.Tests; +using Xunit; + + +namespace Octokit.Tests.Clients +{ + public class EnvironmentsClientTests + { + public class TheGetAllMethod + { + const string name = "name"; + const string owner = "owner"; + const long repositoryId = 1; + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new DeploymentEnvironmentsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, name)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(owner, null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(owner, name, null)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(repositoryId, null)); + } + + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new DeploymentEnvironmentsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", name)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll(owner, "")); + } + + [Theory] + [InlineData(" ")] + [InlineData("\n")] + [InlineData("\t")] + [InlineData(" ")] + [InlineData("\n\r")] + public async Task EnsuresNonWhitespaceArguments(string whitespace) + { + var client = new DeploymentEnvironmentsClient(Substitute.For<IApiConnection>()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll(whitespace, name)); + await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll(owner, whitespace)); + } + + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new DeploymentEnvironmentsClient(connection); + var expectedUrl = string.Format("repos/{0}/{1}/environments", owner, name); + + var res = await client.GetAll(owner, name); + + connection.Received() + .Get<DeploymentEnvironmentsResponse>( + Arg.Is<Uri>(u => u.ToString() == expectedUrl)); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For<IApiConnection>(); + var client = new DeploymentEnvironmentsClient(connection); + var expectedUrl = string.Format("repositories/{0}/environments", repositoryId); + + await client.GetAll(repositoryId); + + connection.Received() + .Get<DeploymentEnvironmentsResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUrl)); + } + + [Fact] + public async Task RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For<IApiConnection>(); + var client = new DeploymentEnvironmentsClient(connection); + var expectedUrl = string.Format("repos/{0}/{1}/environments", owner, name); + + var options = new ApiOptions + { + PageSize = 10, + StartPage = 1 + }; + + await client.GetAll(owner, name, options); + + connection.Received() + .Get<DeploymentEnvironmentsResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), + Arg.Is<IDictionary<string, string>>(u => u["per_page"] == "10" && u["page"] == "1")); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() + { + var connection = Substitute.For<IApiConnection>(); + var client = new DeploymentEnvironmentsClient(connection); + var expectedUrl = string.Format("repositories/{0}/environments", repositoryId); + + var options = new ApiOptions + { + PageSize = 10, + StartPage = 1 + }; + + await client.GetAll(repositoryId, options); + + connection.Received() + .Get<DeploymentEnvironmentsResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), + Arg.Is<IDictionary<string, string>>(u => u["per_page"] == "10" && u["page"] == "1")); + } + + [Fact] + public void RequestsCorrectUrlWithPreviewAcceptHeaders() + { + var connection = Substitute.For<IApiConnection>(); + var client = new DeploymentEnvironmentsClient(connection); + var expectedUrl = string.Format("repos/{0}/{1}/environments", owner, name); + + client.GetAll(owner, name); + connection.Received() + .Get<DeploymentEnvironmentsResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUrl)); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => new DeploymentEnvironmentsClient(null)); + } + } + } +} diff --git a/Octokit/Clients/DeploymentEnvironmentsClient.cs b/Octokit/Clients/DeploymentEnvironmentsClient.cs new file mode 100644 index 0000000000..b5a245fa1c --- /dev/null +++ b/Octokit/Clients/DeploymentEnvironmentsClient.cs @@ -0,0 +1,115 @@ +using Octokit.Models.Response; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Repository Deployment Environments API. + /// Gets Deployment Environments. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/deployments/environments">Repository Deployment Environments API documentation</a> for more information. + /// </remarks> + public class DeploymentEnvironmentsClient : ApiClient, IRepositoryDeployEnvironmentsClient + { + /// <summary> + /// Instantiates a new GitHub Repository Environments API client. + /// </summary> + /// <param name="apiConnection">An API connection</param> + public DeploymentEnvironmentsClient(IApiConnection apiConnection) : base(apiConnection) { } + + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view environments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/environments")] + public Task<DeploymentEnvironmentsResponse> GetAll(string owner, string name) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + + return GetAll(owner, name, ApiOptions.None); + } + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view environments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="repositoryId">The Id of the repository</param> + [ManualRoute("GET", "/repositories/{id}/environments")] + public Task<DeploymentEnvironmentsResponse> GetAll(long repositoryId) + { + return GetAll(repositoryId, ApiOptions.None); + } + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view environments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="options">Paging options</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/environments")] + public Task<DeploymentEnvironmentsResponse> GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNull(options, nameof(options)); + + Dictionary<string, string> prms = null; + if (options != ApiOptions.None) + { + prms = new Dictionary<string, string>(); + prms.Add("per_page", options.PageSize.ToString()); + prms.Add("page", options.StartPage.ToString()); + } + + if (prms != null) + return ApiConnection.Get<DeploymentEnvironmentsResponse>(ApiUrls.DeploymentEnvironments(owner, name), prms); + else + return ApiConnection.Get<DeploymentEnvironmentsResponse>(ApiUrls.DeploymentEnvironments(owner, name)); + } + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view environments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="repositoryId">Repository ID</param> + /// <param name="options">Paging options</param> + [ManualRoute("GET", "/repositories/{id}/environments")] + public Task<DeploymentEnvironmentsResponse> GetAll(long repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, nameof(options)); + + Dictionary<string, string> prms = null; + if (options != ApiOptions.None) + { + prms = new Dictionary<string, string>(); + prms.Add("per_page", options.PageSize.ToString()); + prms.Add("page", options.StartPage.ToString()); + } + + if (prms != null) + return ApiConnection.Get<DeploymentEnvironmentsResponse>(ApiUrls.DeploymentEnvironments(repositoryId), prms); + else + return ApiConnection.Get<DeploymentEnvironmentsResponse>(ApiUrls.DeploymentEnvironments(repositoryId)); + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index b8976f0706..5ccb62c744 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -344,6 +344,14 @@ public interface IRepositoriesClient /// </remarks> IDeploymentsClient Deployment { get; } + /// <summary> + /// Client for GitHub's Repository Environments API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/deployments/environments/">Environments API documentation</a> for more details + /// </remarks> + IRepositoryDeployEnvironmentsClient Environment { get; } + /// <summary> /// Client for GitHub's Repository Statistics API. /// Note that the GitHub API uses caching on these endpoints, @@ -739,4 +747,4 @@ public interface IRepositoriesClient [ManualRoute("GET", "/repositories/{id}/codeowners/errors")] Task<RepositoryCodeOwnersErrors> GetAllCodeOwnersErrors(long repositoryId); } -} +} \ No newline at end of file diff --git a/Octokit/Clients/IRepositoryDeployEnvironmentsClient.cs b/Octokit/Clients/IRepositoryDeployEnvironmentsClient.cs new file mode 100644 index 0000000000..a67a2270a9 --- /dev/null +++ b/Octokit/Clients/IRepositoryDeployEnvironmentsClient.cs @@ -0,0 +1,61 @@ +using Octokit.Models.Response; +using System.Threading.Tasks; + +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Repository Deployment Environments API. + /// Gets Deployment Environments. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/deployments/environments">Repository Deployment Environments API documentation</a> for more information. + /// </remarks> + public interface IRepositoryDeployEnvironmentsClient + { + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + Task<DeploymentEnvironmentsResponse> GetAll(string owner, string name); + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="repositoryId">The Id of the repository</param> + Task<DeploymentEnvironmentsResponse> GetAll(long repositoryId); + + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="options">Paging options</param> + Task<DeploymentEnvironmentsResponse> GetAll(string owner, string name, ApiOptions options); + + + /// <summary> + /// Gets all the environments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// </summary> + /// <remarks> + /// https://docs.github.com/en/rest/deployments/environments#list-environments + /// </remarks> + /// <param name="repositoryId">Repository ID</param> + /// <param name="options">Paging options</param> + Task<DeploymentEnvironmentsResponse> GetAll(long repositoryId, ApiOptions options); + } +} diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 9d208a7b6f..29e8563bf2 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using System.Diagnostics.CodeAnalysis; using System.Collections.Generic; +using System.Net.Http.Headers; namespace Octokit { @@ -27,6 +28,7 @@ public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection) Collaborator = new RepoCollaboratorsClient(apiConnection); Statistics = new StatisticsClient(apiConnection); Deployment = new DeploymentsClient(apiConnection); + Environment = new DeploymentEnvironmentsClient(apiConnection); PullRequest = new PullRequestsClient(apiConnection); Comment = new RepositoryCommentsClient(apiConnection); Commit = new RepositoryCommitsClient(apiConnection); @@ -538,6 +540,14 @@ public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization, ApiOpti /// </remarks> public IDeploymentsClient Deployment { get; private set; } + /// <summary> + /// Client for GitHub's Repository Deployment Environments API + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/deployments/environments">Deployments Environments API documentation</a> for more details + /// </remarks> + public IRepositoryDeployEnvironmentsClient Environment { get; private set; } + /// <summary> /// Client for GitHub's Repository Statistics API /// Note that the GitHub API uses caching on these endpoints, diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index c6d57704ca..88a8b95270 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2478,6 +2478,17 @@ public static Uri Deployments(string owner, string name) return "repos/{0}/{1}/deployments".FormatUri(owner, name); } + /// <summary> + /// Returns the <see cref="Uri"/> for the Deployment Environments API for the given repository. + /// </summary> + /// <param name="owner">Owner of the repository</param> + /// <param name="name">Name of the repository</param> + /// <returns>The <see cref="Uri"/> for the Deployments API for the given repository.</returns> + public static Uri DeploymentEnvironments(string owner, string name) + { + return "repos/{0}/{1}/environments".FormatUri(owner, name); + } + /// <summary> /// Returns the <see cref="System.Uri"/> for the Deployment Statuses API for the given deployment. /// </summary> @@ -3137,6 +3148,16 @@ public static Uri Deployments(long repositoryId) return "repositories/{0}/deployments".FormatUri(repositoryId); } + /// <summary> + /// Returns the <see cref="Uri"/> for the Deployment Environments API for the given repository. + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <returns>The <see cref="Uri"/> for the Deployments API for the given repository.</returns> + public static Uri DeploymentEnvironments(long repositoryId) + { + return "repositories/{0}/environments".FormatUri(repositoryId); + } + /// <summary> /// Returns the <see cref="Uri"/> for the Deployment Statuses API for the given deployment. /// </summary> diff --git a/Octokit/Models/Request/ApiOptions.cs b/Octokit/Models/Request/ApiOptions.cs index cdc3cbf379..3dbfd1d40a 100644 --- a/Octokit/Models/Request/ApiOptions.cs +++ b/Octokit/Models/Request/ApiOptions.cs @@ -7,9 +7,11 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ApiOptions { + private static ApiOptions emptyOptions = new ApiOptions(); + public static ApiOptions None { - get { return new ApiOptions(); } + get { return emptyOptions; } } /// <summary> diff --git a/Octokit/Models/Response/DeploymentEnvironment.cs b/Octokit/Models/Response/DeploymentEnvironment.cs new file mode 100644 index 0000000000..88fe5c97d7 --- /dev/null +++ b/Octokit/Models/Response/DeploymentEnvironment.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Diagnostics; +using System.Text; +using System.Globalization; + +namespace Octokit.Models.Response +{ + [SuppressMessage("Microsoft.Naming", "CA1724:TypeNamesShouldNotMatchNamespaces", + Justification = "People can use fully qualified names if they want to use both.")] + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class DeploymentEnvironment + { + public DeploymentEnvironment() { } + + public DeploymentEnvironment(int 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> + /// Id of this deployment environment + /// </summary> + public int Id { get; private set; } + + /// <summary> + /// GraphQL Node Id + /// </summary> + public string NodeId{ get; private set; } + + /// <summary> + /// Environment Name + /// </summary> + public string Name { get; private set; } + + /// <summary> + /// Environment API URL + /// </summary> + public string Url { get; private set; } + + /// <summary> + /// Environment HTML URL + /// </summary> + public string HtmlUrl { get; private set; } + + /// <summary> + /// Date and time that the environment was created. + /// </summary> + public DateTimeOffset CreatedAt { get; private set; } + + /// <summary> + /// Date and time that the environment was updated. + /// </summary> + public DateTimeOffset UpdatedAt { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Name: {0}, CreatedAt: {1}", Name, CreatedAt); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/DeploymentEnvironmentsResponse.cs b/Octokit/Models/Response/DeploymentEnvironmentsResponse.cs new file mode 100644 index 0000000000..e4ef6bd412 --- /dev/null +++ b/Octokit/Models/Response/DeploymentEnvironmentsResponse.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Diagnostics; +using System.Text; +using System.Globalization; + +namespace Octokit.Models.Response +{ + [SuppressMessage("Microsoft.Naming", "CA1724:TypeNamesShouldNotMatchNamespaces", + Justification = "People can use fully qualified names if they want to use both.")] + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class DeploymentEnvironmentsResponse + { + public DeploymentEnvironmentsResponse() { } + + + public DeploymentEnvironmentsResponse(int totalCount, IReadOnlyList<DeploymentEnvironment> environments) + { + TotalCount = totalCount; + Environments = environments; + } + + /// <summary> + /// The total count of secrets for the repository + /// </summary> + public int TotalCount { get; private set; } + + /// <summary> + /// The list of secrets for the repository + /// </summary> + public IReadOnlyList<DeploymentEnvironment> Environments { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Count: {0}", TotalCount); + } + } + } +} \ No newline at end of file From 8f01a31694f0e65ae8b1d1d8ac642017e0cd63db Mon Sep 17 00:00:00 2001 From: Martin Costello <martin@martincostello.com> Date: Wed, 23 Nov 2022 15:35:58 +0000 Subject: [PATCH 153/209] [feat]: Adds Actions workflow API clients --- .../IObservableActionsArtifactsClient.cs | 12 + .../Clients/IObservableActionsCacheClient.cs | 12 + .../Clients/IObservableActionsClient.cs | 41 + .../IObservableActionsPermissionsClient.cs | 12 + ...ableActionsSelfHostedRunnerGroupsClient.cs | 12 + ...bservableActionsSelfHostedRunnersClient.cs | 12 + .../IObservableActionsWorkflowJobsClient.cs | 108 +++ .../IObservableActionsWorkflowRunsClient.cs | 265 ++++++ .../IObservableActionsWorkflowsClient.cs | 157 ++++ .../ObservableActionsArtifactsClient.cs | 18 + .../Clients/ObservableActionsCacheClient.cs | 18 + .../Clients/ObservableActionsClient.cs | 57 ++ .../ObservableActionsPermissionsClient.cs | 18 + ...ableActionsSelfHostedRunnerGroupsClient.cs | 18 + ...bservableActionsSelfHostedRunnersClient.cs | 18 + .../ObservableActionsWorkflowJobsClient.cs | 172 ++++ .../ObservableActionsWorkflowRunsClient.cs | 427 +++++++++ .../ObservableActionsWorkflowsClient.cs | 248 ++++++ .../ObservableOrganizationActionsClient.cs | 6 +- .../ObservableRepositoryActionsClient.cs | 6 +- Octokit.Reactive/IObservableGitHubClient.cs | 1 + Octokit.Reactive/ObservableGitHubClient.cs | 2 + Octokit.Reactive/Octokit.Reactive.csproj | 2 +- .../Clients/ActionsWorkflowJobsClientTests.cs | 177 ++++ .../Clients/ActionsWorkflowRunsClientTests.cs | 407 +++++++++ .../Clients/ActionsWorkflowsClientTests.cs | 195 ++++ .../Clients/OrganizationActionsClientTests.cs | 10 - .../Clients/RepositoryActionsClientTests.cs | 10 - ...bservableOrganizationActionsClientTests.cs | 10 - .../ObservableRepositoryActionsClientTests.cs | 10 - .../Clients/ActionsWorkflowJobsClientTests.cs | 223 +++++ .../Clients/ActionsWorkflowRunsClientTests.cs | 839 ++++++++++++++++++ .../Clients/ActionsWorkflowsClientTests.cs | 383 ++++++++ .../Models/CreateWorkflowDispatchTests.cs | 55 ++ .../Models/EnvironmentApprovalTests.cs | 70 ++ .../Models/PendingDeploymentReviewTests.cs | 37 + Octokit.Tests/Models/WorkflowJobStepTests.cs | 34 + Octokit.Tests/Models/WorkflowJobTests.cs | 146 +++ .../Models/WorkflowJobsResponseTests.cs | 134 +++ .../Models/WorkflowReferenceTests.cs | 27 + Octokit.Tests/Models/WorkflowRunTests.cs | 257 ++++++ Octokit.Tests/Models/WorkflowRunUsageTests.cs | 87 ++ Octokit.Tests/Models/WorkflowTests.cs | 42 + Octokit.Tests/Models/WorkflowUsageTests.cs | 39 + .../Models/WorkflowsResponseTests.cs | 52 ++ ...bservableActionsWorkflowJobsClientTests.cs | 222 +++++ ...bservableActionsWorkflowRunsClientTests.cs | 700 +++++++++++++++ .../ObservableActionsWorkflowsClientTests.cs | 362 ++++++++ ...bservableOrganizationActionsClientTests.cs | 6 +- .../ObservableRepositoryActionsClientTests.cs | 6 +- Octokit/Clients/ActionsArtifactsClient.cs | 19 + Octokit/Clients/ActionsCacheClient.cs | 19 + Octokit/Clients/ActionsClient.cs | 56 ++ Octokit/Clients/ActionsPermissionsClient.cs | 19 + .../ActionsSelfHostedRunnerGroupsClient.cs | 19 + .../Clients/ActionsSelfHostedRunnersClient.cs | 19 + Octokit/Clients/ActionsWorkflowJobsClient.cs | 173 ++++ Octokit/Clients/ActionsWorkflowRunsClient.cs | 432 +++++++++ Octokit/Clients/ActionsWorkflowsClient.cs | 263 ++++++ Octokit/Clients/IActionsArtifactsClient.cs | 15 + Octokit/Clients/IActionsCacheClient.cs | 15 + Octokit/Clients/IActionsClient.cs | 41 + Octokit/Clients/IActionsPermissionsClient.cs | 15 + .../IActionsSelfHostedRunnerGroupsClient.cs | 15 + .../IActionsSelfHostedRunnersClient.cs | 15 + Octokit/Clients/IActionsWorkflowJobsClient.cs | 107 +++ Octokit/Clients/IActionsWorkflowRunsClient.cs | 267 ++++++ Octokit/Clients/IActionsWorkflowsClient.cs | 156 ++++ Octokit/Clients/IOrganizationActionsClient.cs | 6 +- Octokit/Clients/IRepositoriesClient.cs | 5 +- Octokit/Clients/IRepositoryActionsClient.cs | 6 +- Octokit/Clients/OrganizationActionsClient.cs | 6 +- Octokit/Clients/RepositoryActionsClient.cs | 6 +- Octokit/GitHubClient.cs | 9 + Octokit/Helpers/ApiUrls.cs | 362 +++++++- Octokit/Helpers/StringExtensions.cs | 8 + Octokit/IGitHubClient.cs | 8 + .../Models/Request/CheckRunStatusFilter.cs | 34 + .../Models/Request/CreateWorkflowDispatch.cs | 41 + .../Models/Request/PendingDeploymentReview.cs | 40 + .../Request/PendingDeploymentReviewState.cs | 12 + .../Models/Request/WorkflowRunJobsRequest.cs | 22 + Octokit/Models/Request/WorkflowRunsRequest.cs | 68 ++ .../Models/Response/EnvironmentApproval.cs | 69 ++ .../Response/EnvironmentApprovalState.cs | 12 + .../Models/Response/EnvironmentApprovals.cs | 51 ++ Octokit/Models/Response/Workflow.cs | 90 ++ Octokit/Models/Response/WorkflowBillable.cs | 45 + .../Models/Response/WorkflowBillableTiming.cs | 29 + Octokit/Models/Response/WorkflowJob.cs | 139 +++ .../Models/Response/WorkflowJobConclusion.cs | 22 + Octokit/Models/Response/WorkflowJobStatus.cs | 14 + Octokit/Models/Response/WorkflowJobStep.cs | 60 ++ .../Models/Response/WorkflowJobsResponse.cs | 32 + Octokit/Models/Response/WorkflowReference.cs | 41 + Octokit/Models/Response/WorkflowRun.cs | 241 +++++ .../Models/Response/WorkflowRunBillable.cs | 45 + .../Response/WorkflowRunBillableTiming.cs | 42 + .../Models/Response/WorkflowRunConclusion.cs | 22 + .../Models/Response/WorkflowRunJobsFilter.cs | 24 + Octokit/Models/Response/WorkflowRunStatus.cs | 18 + Octokit/Models/Response/WorkflowRunTiming.cs | 35 + Octokit/Models/Response/WorkflowRunUsage.cs | 35 + .../Models/Response/WorkflowRunsResponse.cs | 32 + Octokit/Models/Response/WorkflowState.cs | 18 + Octokit/Models/Response/WorkflowUsage.cs | 29 + Octokit/Models/Response/WorkflowsResponse.cs | 32 + Octokit/Octokit.csproj | 2 +- 108 files changed, 9575 insertions(+), 84 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableActionsArtifactsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsCacheClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsPermissionsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsWorkflowJobsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsWorkflowRunsClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableActionsWorkflowsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsArtifactsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsCacheClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsPermissionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsWorkflowJobsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsWorkflowRunsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableActionsWorkflowsClient.cs create mode 100644 Octokit.Tests.Integration/Clients/ActionsWorkflowJobsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/ActionsWorkflowRunsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/ActionsWorkflowsClientTests.cs delete mode 100644 Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs delete mode 100644 Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs delete mode 100644 Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs delete mode 100644 Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs create mode 100644 Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs create mode 100644 Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs create mode 100644 Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs create mode 100644 Octokit.Tests/Models/CreateWorkflowDispatchTests.cs create mode 100644 Octokit.Tests/Models/EnvironmentApprovalTests.cs create mode 100644 Octokit.Tests/Models/PendingDeploymentReviewTests.cs create mode 100644 Octokit.Tests/Models/WorkflowJobStepTests.cs create mode 100644 Octokit.Tests/Models/WorkflowJobTests.cs create mode 100644 Octokit.Tests/Models/WorkflowJobsResponseTests.cs create mode 100644 Octokit.Tests/Models/WorkflowReferenceTests.cs create mode 100644 Octokit.Tests/Models/WorkflowRunTests.cs create mode 100644 Octokit.Tests/Models/WorkflowRunUsageTests.cs create mode 100644 Octokit.Tests/Models/WorkflowTests.cs create mode 100644 Octokit.Tests/Models/WorkflowUsageTests.cs create mode 100644 Octokit.Tests/Models/WorkflowsResponseTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableActionsWorkflowJobsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableActionsWorkflowsClientTests.cs create mode 100644 Octokit/Clients/ActionsArtifactsClient.cs create mode 100644 Octokit/Clients/ActionsCacheClient.cs create mode 100644 Octokit/Clients/ActionsClient.cs create mode 100644 Octokit/Clients/ActionsPermissionsClient.cs create mode 100644 Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs create mode 100644 Octokit/Clients/ActionsSelfHostedRunnersClient.cs create mode 100644 Octokit/Clients/ActionsWorkflowJobsClient.cs create mode 100644 Octokit/Clients/ActionsWorkflowRunsClient.cs create mode 100644 Octokit/Clients/ActionsWorkflowsClient.cs create mode 100644 Octokit/Clients/IActionsArtifactsClient.cs create mode 100644 Octokit/Clients/IActionsCacheClient.cs create mode 100644 Octokit/Clients/IActionsClient.cs create mode 100644 Octokit/Clients/IActionsPermissionsClient.cs create mode 100644 Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs create mode 100644 Octokit/Clients/IActionsSelfHostedRunnersClient.cs create mode 100644 Octokit/Clients/IActionsWorkflowJobsClient.cs create mode 100644 Octokit/Clients/IActionsWorkflowRunsClient.cs create mode 100644 Octokit/Clients/IActionsWorkflowsClient.cs create mode 100644 Octokit/Models/Request/CheckRunStatusFilter.cs create mode 100644 Octokit/Models/Request/CreateWorkflowDispatch.cs create mode 100644 Octokit/Models/Request/PendingDeploymentReview.cs create mode 100644 Octokit/Models/Request/PendingDeploymentReviewState.cs create mode 100644 Octokit/Models/Request/WorkflowRunJobsRequest.cs create mode 100644 Octokit/Models/Request/WorkflowRunsRequest.cs create mode 100644 Octokit/Models/Response/EnvironmentApproval.cs create mode 100644 Octokit/Models/Response/EnvironmentApprovalState.cs create mode 100644 Octokit/Models/Response/EnvironmentApprovals.cs create mode 100644 Octokit/Models/Response/Workflow.cs create mode 100644 Octokit/Models/Response/WorkflowBillable.cs create mode 100644 Octokit/Models/Response/WorkflowBillableTiming.cs create mode 100644 Octokit/Models/Response/WorkflowJob.cs create mode 100644 Octokit/Models/Response/WorkflowJobConclusion.cs create mode 100644 Octokit/Models/Response/WorkflowJobStatus.cs create mode 100644 Octokit/Models/Response/WorkflowJobStep.cs create mode 100644 Octokit/Models/Response/WorkflowJobsResponse.cs create mode 100644 Octokit/Models/Response/WorkflowReference.cs create mode 100644 Octokit/Models/Response/WorkflowRun.cs create mode 100644 Octokit/Models/Response/WorkflowRunBillable.cs create mode 100644 Octokit/Models/Response/WorkflowRunBillableTiming.cs create mode 100644 Octokit/Models/Response/WorkflowRunConclusion.cs create mode 100644 Octokit/Models/Response/WorkflowRunJobsFilter.cs create mode 100644 Octokit/Models/Response/WorkflowRunStatus.cs create mode 100644 Octokit/Models/Response/WorkflowRunTiming.cs create mode 100644 Octokit/Models/Response/WorkflowRunUsage.cs create mode 100644 Octokit/Models/Response/WorkflowRunsResponse.cs create mode 100644 Octokit/Models/Response/WorkflowState.cs create mode 100644 Octokit/Models/Response/WorkflowUsage.cs create mode 100644 Octokit/Models/Response/WorkflowsResponse.cs diff --git a/Octokit.Reactive/Clients/IObservableActionsArtifactsClient.cs b/Octokit.Reactive/Clients/IObservableActionsArtifactsClient.cs new file mode 100644 index 0000000000..38e6a34a9c --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsArtifactsClient.cs @@ -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 + { + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsCacheClient.cs b/Octokit.Reactive/Clients/IObservableActionsCacheClient.cs new file mode 100644 index 0000000000..29f800c427 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsCacheClient.cs @@ -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 + { + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsClient.cs b/Octokit.Reactive/Clients/IObservableActionsClient.cs new file mode 100644 index 0000000000..5397fd80e5 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsClient.cs @@ -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; } + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsPermissionsClient.cs b/Octokit.Reactive/Clients/IObservableActionsPermissionsClient.cs new file mode 100644 index 0000000000..ea3391b0b0 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsPermissionsClient.cs @@ -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 + { + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs new file mode 100644 index 0000000000..f8e82dc707 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnerGroupsClient.cs @@ -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 + { + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs new file mode 100644 index 0000000000..52ef545712 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsSelfHostedRunnersClient.cs @@ -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 + { + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsWorkflowJobsClient.cs b/Octokit.Reactive/Clients/IObservableActionsWorkflowJobsClient.cs new file mode 100644 index 0000000000..4b1362b0dc --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsWorkflowJobsClient.cs @@ -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); + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsWorkflowRunsClient.cs b/Octokit.Reactive/Clients/IObservableActionsWorkflowRunsClient.cs new file mode 100644 index 0000000000..968138fe8e --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsWorkflowRunsClient.cs @@ -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); + } +} diff --git a/Octokit.Reactive/Clients/IObservableActionsWorkflowsClient.cs b/Octokit.Reactive/Clients/IObservableActionsWorkflowsClient.cs new file mode 100644 index 0000000000..9c5f055bbc --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableActionsWorkflowsClient.cs @@ -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; } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsArtifactsClient.cs b/Octokit.Reactive/Clients/ObservableActionsArtifactsClient.cs new file mode 100644 index 0000000000..9f152cbd11 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsArtifactsClient.cs @@ -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; + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsCacheClient.cs b/Octokit.Reactive/Clients/ObservableActionsCacheClient.cs new file mode 100644 index 0000000000..cefea4b59a --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsCacheClient.cs @@ -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; + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsClient.cs b/Octokit.Reactive/Clients/ObservableActionsClient.cs new file mode 100644 index 0000000000..3b0e44620a --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsClient.cs @@ -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; } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsPermissionsClient.cs b/Octokit.Reactive/Clients/ObservableActionsPermissionsClient.cs new file mode 100644 index 0000000000..50bbec5947 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsPermissionsClient.cs @@ -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; + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs new file mode 100644 index 0000000000..e94e6a38b7 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnerGroupsClient.cs @@ -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; + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs new file mode 100644 index 0000000000..052b6f90cb --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsSelfHostedRunnersClient.cs @@ -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; + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsWorkflowJobsClient.cs b/Octokit.Reactive/Clients/ObservableActionsWorkflowJobsClient.cs new file mode 100644 index 0000000000..0d8da048e1 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsWorkflowJobsClient.cs @@ -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(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsWorkflowRunsClient.cs b/Octokit.Reactive/Clients/ObservableActionsWorkflowRunsClient.cs new file mode 100644 index 0000000000..59fe32017a --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsWorkflowRunsClient.cs @@ -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(); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableActionsWorkflowsClient.cs b/Octokit.Reactive/Clients/ObservableActionsWorkflowsClient.cs new file mode 100644 index 0000000000..bd6bb02224 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableActionsWorkflowsClient.cs @@ -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; } + } +} diff --git a/Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs index 833a88514a..072dd79d41 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationActionsClient.cs @@ -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. diff --git a/Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs index 631bbf4bf4..b49162026e 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryActionsClient.cs @@ -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. diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index f5ed4393d1..6532de7994 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -41,5 +41,6 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableLicensesClient Licenses { get; } IObservableRateLimitClient RateLimit { get; } IObservableMetaClient Meta { get; } + IObservableActionsClient Actions { get; } } } \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 648360f4c8..c3899ffc77 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -56,6 +56,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Licenses = new ObservableLicensesClient(gitHubClient); RateLimit = new ObservableRateLimitClient(gitHubClient); Meta = new ObservableMetaClient(gitHubClient); + Actions = new ObservableActionsClient(gitHubClient); } public IConnection Connection @@ -102,6 +103,7 @@ public void SetRequestTimeout(TimeSpan timeout) 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 diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 0ba912abf4..e8de439ecb 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -21,7 +21,7 @@ </PropertyGroup> <PropertyGroup> - <NoWarn>1591;1701;1702;1705</NoWarn> + <NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn> </PropertyGroup> <ItemGroup> diff --git a/Octokit.Tests.Integration/Clients/ActionsWorkflowJobsClientTests.cs b/Octokit.Tests.Integration/Clients/ActionsWorkflowJobsClientTests.cs new file mode 100644 index 0000000000..77adf8a478 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/ActionsWorkflowJobsClientTests.cs @@ -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."); + } +} diff --git a/Octokit.Tests.Integration/Clients/ActionsWorkflowRunsClientTests.cs b/Octokit.Tests.Integration/Clients/ActionsWorkflowRunsClientTests.cs new file mode 100644 index 0000000000..1feab89e4c --- /dev/null +++ b/Octokit.Tests.Integration/Clients/ActionsWorkflowRunsClientTests.cs @@ -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; + } +} diff --git a/Octokit.Tests.Integration/Clients/ActionsWorkflowsClientTests.cs b/Octokit.Tests.Integration/Clients/ActionsWorkflowsClientTests.cs new file mode 100644 index 0000000000..59f9e923a5 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/ActionsWorkflowsClientTests.cs @@ -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; + } +} diff --git a/Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs b/Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs deleted file mode 100644 index 20548d7b1f..0000000000 --- a/Octokit.Tests.Integration/Clients/OrganizationActionsClientTests.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Octokit.Tests.Integration.Clients -{ - public class OrganizationActionsClientTests - { - } -} diff --git a/Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs deleted file mode 100644 index 95f60732d1..0000000000 --- a/Octokit.Tests.Integration/Clients/RepositoryActionsClientTests.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Octokit.Tests.Integration.Clients -{ - public class RepositoryActionsClientTests - { - } -} diff --git a/Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs deleted file mode 100644 index e05a22c110..0000000000 --- a/Octokit.Tests.Integration/Reactive/ObservableOrganizationActionsClientTests.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Octokit.Tests.Integration.Reactive -{ - public class ObservableOrganizationActionsClientTests - { - } -} diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs deleted file mode 100644 index 3e2ca85d2e..0000000000 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryActionsClientTests.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Octokit.Tests.Integration.Reactive -{ - public class ObservableRepositoryActionsClientTests - { - } -} diff --git a/Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs b/Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs new file mode 100644 index 0000000000..1ec99df17b --- /dev/null +++ b/Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs @@ -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)); + } + } + } +} diff --git a/Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs b/Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs new file mode 100644 index 0000000000..21b159e152 --- /dev/null +++ b/Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs @@ -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)); + } + } + } +} diff --git a/Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs b/Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs new file mode 100644 index 0000000000..155b7e7786 --- /dev/null +++ b/Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs @@ -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)); + } + } + } +} diff --git a/Octokit.Tests/Models/CreateWorkflowDispatchTests.cs b/Octokit.Tests/Models/CreateWorkflowDispatchTests.cs new file mode 100644 index 0000000000..a5d6004d40 --- /dev/null +++ b/Octokit.Tests/Models/CreateWorkflowDispatchTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/EnvironmentApprovalTests.cs b/Octokit.Tests/Models/EnvironmentApprovalTests.cs new file mode 100644 index 0000000000..040dd14691 --- /dev/null +++ b/Octokit.Tests/Models/EnvironmentApprovalTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/PendingDeploymentReviewTests.cs b/Octokit.Tests/Models/PendingDeploymentReviewTests.cs new file mode 100644 index 0000000000..0340e6629d --- /dev/null +++ b/Octokit.Tests/Models/PendingDeploymentReviewTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowJobStepTests.cs b/Octokit.Tests/Models/WorkflowJobStepTests.cs new file mode 100644 index 0000000000..9b6410456b --- /dev/null +++ b/Octokit.Tests/Models/WorkflowJobStepTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowJobTests.cs b/Octokit.Tests/Models/WorkflowJobTests.cs new file mode 100644 index 0000000000..16a8901c43 --- /dev/null +++ b/Octokit.Tests/Models/WorkflowJobTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowJobsResponseTests.cs b/Octokit.Tests/Models/WorkflowJobsResponseTests.cs new file mode 100644 index 0000000000..1883d5535a --- /dev/null +++ b/Octokit.Tests/Models/WorkflowJobsResponseTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowReferenceTests.cs b/Octokit.Tests/Models/WorkflowReferenceTests.cs new file mode 100644 index 0000000000..040ec2caaf --- /dev/null +++ b/Octokit.Tests/Models/WorkflowReferenceTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowRunTests.cs b/Octokit.Tests/Models/WorkflowRunTests.cs new file mode 100644 index 0000000000..57158fbedc --- /dev/null +++ b/Octokit.Tests/Models/WorkflowRunTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowRunUsageTests.cs b/Octokit.Tests/Models/WorkflowRunUsageTests.cs new file mode 100644 index 0000000000..df434f4efb --- /dev/null +++ b/Octokit.Tests/Models/WorkflowRunUsageTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowTests.cs b/Octokit.Tests/Models/WorkflowTests.cs new file mode 100644 index 0000000000..a052801082 --- /dev/null +++ b/Octokit.Tests/Models/WorkflowTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowUsageTests.cs b/Octokit.Tests/Models/WorkflowUsageTests.cs new file mode 100644 index 0000000000..dbd71f00d4 --- /dev/null +++ b/Octokit.Tests/Models/WorkflowUsageTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Models/WorkflowsResponseTests.cs b/Octokit.Tests/Models/WorkflowsResponseTests.cs new file mode 100644 index 0000000000..56218f3168 --- /dev/null +++ b/Octokit.Tests/Models/WorkflowsResponseTests.cs @@ -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); + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableActionsWorkflowJobsClientTests.cs b/Octokit.Tests/Reactive/ObservableActionsWorkflowJobsClientTests.cs new file mode 100644 index 0000000000..a2f1b7af51 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableActionsWorkflowJobsClientTests.cs @@ -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)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs b/Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs new file mode 100644 index 0000000000..0344f91a4c --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs @@ -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)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableActionsWorkflowsClientTests.cs b/Octokit.Tests/Reactive/ObservableActionsWorkflowsClientTests.cs new file mode 100644 index 0000000000..0bf644a46f --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableActionsWorkflowsClientTests.cs @@ -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)); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs index 1476c76b4f..d1430a33a3 100644 --- a/Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableOrganizationActionsClientTests.cs @@ -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 diff --git a/Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs index 22b79b8fbc..78cd2746ff 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryActionsClientTests.cs @@ -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 diff --git a/Octokit/Clients/ActionsArtifactsClient.cs b/Octokit/Clients/ActionsArtifactsClient.cs new file mode 100644 index 0000000000..cc57d0c433 --- /dev/null +++ b/Octokit/Clients/ActionsArtifactsClient.cs @@ -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) + { + } + } +} diff --git a/Octokit/Clients/ActionsCacheClient.cs b/Octokit/Clients/ActionsCacheClient.cs new file mode 100644 index 0000000000..f640c845e1 --- /dev/null +++ b/Octokit/Clients/ActionsCacheClient.cs @@ -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) + { + } + } +} diff --git a/Octokit/Clients/ActionsClient.cs b/Octokit/Clients/ActionsClient.cs new file mode 100644 index 0000000000..9034b14936 --- /dev/null +++ b/Octokit/Clients/ActionsClient.cs @@ -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; } + } +} diff --git a/Octokit/Clients/ActionsPermissionsClient.cs b/Octokit/Clients/ActionsPermissionsClient.cs new file mode 100644 index 0000000000..13260589c3 --- /dev/null +++ b/Octokit/Clients/ActionsPermissionsClient.cs @@ -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) + { + } + } +} diff --git a/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs b/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs new file mode 100644 index 0000000000..d960541894 --- /dev/null +++ b/Octokit/Clients/ActionsSelfHostedRunnerGroupsClient.cs @@ -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) + { + } + } +} diff --git a/Octokit/Clients/ActionsSelfHostedRunnersClient.cs b/Octokit/Clients/ActionsSelfHostedRunnersClient.cs new file mode 100644 index 0000000000..38c86149dd --- /dev/null +++ b/Octokit/Clients/ActionsSelfHostedRunnersClient.cs @@ -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) + { + } + } +} diff --git a/Octokit/Clients/ActionsWorkflowJobsClient.cs b/Octokit/Clients/ActionsWorkflowJobsClient.cs new file mode 100644 index 0000000000..bdd040a465 --- /dev/null +++ b/Octokit/Clients/ActionsWorkflowJobsClient.cs @@ -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()); + } + } +} diff --git a/Octokit/Clients/ActionsWorkflowRunsClient.cs b/Octokit/Clients/ActionsWorkflowRunsClient.cs new file mode 100644 index 0000000000..8570ae38d2 --- /dev/null +++ b/Octokit/Clients/ActionsWorkflowRunsClient.cs @@ -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()); + } + } +} diff --git a/Octokit/Clients/ActionsWorkflowsClient.cs b/Octokit/Clients/ActionsWorkflowsClient.cs new file mode 100644 index 0000000000..7c72e98337 --- /dev/null +++ b/Octokit/Clients/ActionsWorkflowsClient.cs @@ -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; } + } +} diff --git a/Octokit/Clients/IActionsArtifactsClient.cs b/Octokit/Clients/IActionsArtifactsClient.cs new file mode 100644 index 0000000000..9905bad9cb --- /dev/null +++ b/Octokit/Clients/IActionsArtifactsClient.cs @@ -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 + { + } +} diff --git a/Octokit/Clients/IActionsCacheClient.cs b/Octokit/Clients/IActionsCacheClient.cs new file mode 100644 index 0000000000..f0aa775365 --- /dev/null +++ b/Octokit/Clients/IActionsCacheClient.cs @@ -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 + { + } +} diff --git a/Octokit/Clients/IActionsClient.cs b/Octokit/Clients/IActionsClient.cs new file mode 100644 index 0000000000..027cffc00d --- /dev/null +++ b/Octokit/Clients/IActionsClient.cs @@ -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; } + } +} diff --git a/Octokit/Clients/IActionsPermissionsClient.cs b/Octokit/Clients/IActionsPermissionsClient.cs new file mode 100644 index 0000000000..d06315bc64 --- /dev/null +++ b/Octokit/Clients/IActionsPermissionsClient.cs @@ -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 + { + } +} diff --git a/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs b/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs new file mode 100644 index 0000000000..f76ffc4a4e --- /dev/null +++ b/Octokit/Clients/IActionsSelfHostedRunnerGroupsClient.cs @@ -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 + { + } +} diff --git a/Octokit/Clients/IActionsSelfHostedRunnersClient.cs b/Octokit/Clients/IActionsSelfHostedRunnersClient.cs new file mode 100644 index 0000000000..3c429615a0 --- /dev/null +++ b/Octokit/Clients/IActionsSelfHostedRunnersClient.cs @@ -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 + { + } +} diff --git a/Octokit/Clients/IActionsWorkflowJobsClient.cs b/Octokit/Clients/IActionsWorkflowJobsClient.cs new file mode 100644 index 0000000000..a907b3b97e --- /dev/null +++ b/Octokit/Clients/IActionsWorkflowJobsClient.cs @@ -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); + } +} diff --git a/Octokit/Clients/IActionsWorkflowRunsClient.cs b/Octokit/Clients/IActionsWorkflowRunsClient.cs new file mode 100644 index 0000000000..a4b42f61f9 --- /dev/null +++ b/Octokit/Clients/IActionsWorkflowRunsClient.cs @@ -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); + } +} diff --git a/Octokit/Clients/IActionsWorkflowsClient.cs b/Octokit/Clients/IActionsWorkflowsClient.cs new file mode 100644 index 0000000000..24f0ee791f --- /dev/null +++ b/Octokit/Clients/IActionsWorkflowsClient.cs @@ -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; } + } +} diff --git a/Octokit/Clients/IOrganizationActionsClient.cs b/Octokit/Clients/IOrganizationActionsClient.cs index 38dd3cd032..c2e35c7070 100644 --- a/Octokit/Clients/IOrganizationActionsClient.cs +++ b/Octokit/Clients/IOrganizationActionsClient.cs @@ -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. diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 5ccb62c744..983fb20298 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -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 { diff --git a/Octokit/Clients/IRepositoryActionsClient.cs b/Octokit/Clients/IRepositoryActionsClient.cs index af0aabe896..02e7f3bdfe 100644 --- a/Octokit/Clients/IRepositoryActionsClient.cs +++ b/Octokit/Clients/IRepositoryActionsClient.cs @@ -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. diff --git a/Octokit/Clients/OrganizationActionsClient.cs b/Octokit/Clients/OrganizationActionsClient.cs index 639c728a9b..feec372ff9 100644 --- a/Octokit/Clients/OrganizationActionsClient.cs +++ b/Octokit/Clients/OrganizationActionsClient.cs @@ -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. diff --git a/Octokit/Clients/RepositoryActionsClient.cs b/Octokit/Clients/RepositoryActionsClient.cs index 9837448eba..6a442efa57 100644 --- a/Octokit/Clients/RepositoryActionsClient.cs +++ b/Octokit/Clients/RepositoryActionsClient.cs @@ -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. diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index ba2d8a2633..77c8dbba5e 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -118,6 +118,7 @@ public GitHubClient(IConnection connection) Licenses = new LicensesClient(apiConnection); RateLimit = new RateLimitClient(apiConnection); Meta = new MetaClient(apiConnection); + Actions = new ActionsClient(apiConnection); } /// <summary> @@ -368,6 +369,14 @@ public Uri BaseAddress /// </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)); diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 88a8b95270..c4ae3b26b9 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -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 @@ public static Uri PackageVersionRestoreUser(string username, PackageType package { 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()); + } } } diff --git a/Octokit/Helpers/StringExtensions.cs b/Octokit/Helpers/StringExtensions.cs index 30526f831f..42ed83361f 100644 --- a/Octokit/Helpers/StringExtensions.cs +++ b/Octokit/Helpers/StringExtensions.cs @@ -73,6 +73,14 @@ public static Uri ExpandUriTemplate(this string template, object values) 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(); } diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 2de41eb246..220cf3c0d7 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -39,6 +39,14 @@ public interface IGitHubClient : IApiInfoProvider /// </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> diff --git a/Octokit/Models/Request/CheckRunStatusFilter.cs b/Octokit/Models/Request/CheckRunStatusFilter.cs new file mode 100644 index 0000000000..c136f39856 --- /dev/null +++ b/Octokit/Models/Request/CheckRunStatusFilter.cs @@ -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, + } +} diff --git a/Octokit/Models/Request/CreateWorkflowDispatch.cs b/Octokit/Models/Request/CreateWorkflowDispatch.cs new file mode 100644 index 0000000000..a570a2415e --- /dev/null +++ b/Octokit/Models/Request/CreateWorkflowDispatch.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Request/PendingDeploymentReview.cs b/Octokit/Models/Request/PendingDeploymentReview.cs new file mode 100644 index 0000000000..919d3d4236 --- /dev/null +++ b/Octokit/Models/Request/PendingDeploymentReview.cs @@ -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); } + } + } +} diff --git a/Octokit/Models/Request/PendingDeploymentReviewState.cs b/Octokit/Models/Request/PendingDeploymentReviewState.cs new file mode 100644 index 0000000000..b3ac1bc9f7 --- /dev/null +++ b/Octokit/Models/Request/PendingDeploymentReviewState.cs @@ -0,0 +1,12 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum PendingDeploymentReviewState + { + [Parameter(Value = "approved")] + Approved, + [Parameter(Value = "rejected")] + Rejected, + } +} diff --git a/Octokit/Models/Request/WorkflowRunJobsRequest.cs b/Octokit/Models/Request/WorkflowRunJobsRequest.cs new file mode 100644 index 0000000000..d414b8e4ad --- /dev/null +++ b/Octokit/Models/Request/WorkflowRunJobsRequest.cs @@ -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); + } +} diff --git a/Octokit/Models/Request/WorkflowRunsRequest.cs b/Octokit/Models/Request/WorkflowRunsRequest.cs new file mode 100644 index 0000000000..a7919033d2 --- /dev/null +++ b/Octokit/Models/Request/WorkflowRunsRequest.cs @@ -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); + } +} diff --git a/Octokit/Models/Response/EnvironmentApproval.cs b/Octokit/Models/Response/EnvironmentApproval.cs new file mode 100644 index 0000000000..1f56025045 --- /dev/null +++ b/Octokit/Models/Response/EnvironmentApproval.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/EnvironmentApprovalState.cs b/Octokit/Models/Response/EnvironmentApprovalState.cs new file mode 100644 index 0000000000..4144b25f28 --- /dev/null +++ b/Octokit/Models/Response/EnvironmentApprovalState.cs @@ -0,0 +1,12 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum EnvironmentApprovalState + { + [Parameter(Value = "approved")] + Approved, + [Parameter(Value = "rejected")] + Rejected, + } +} diff --git a/Octokit/Models/Response/EnvironmentApprovals.cs b/Octokit/Models/Response/EnvironmentApprovals.cs new file mode 100644 index 0000000000..51915fdd35 --- /dev/null +++ b/Octokit/Models/Response/EnvironmentApprovals.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/Workflow.cs b/Octokit/Models/Response/Workflow.cs new file mode 100644 index 0000000000..ec8cdfefb4 --- /dev/null +++ b/Octokit/Models/Response/Workflow.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowBillable.cs b/Octokit/Models/Response/WorkflowBillable.cs new file mode 100644 index 0000000000..9ab1b7a5f1 --- /dev/null +++ b/Octokit/Models/Response/WorkflowBillable.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowBillableTiming.cs b/Octokit/Models/Response/WorkflowBillableTiming.cs new file mode 100644 index 0000000000..550ff467be --- /dev/null +++ b/Octokit/Models/Response/WorkflowBillableTiming.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowJob.cs b/Octokit/Models/Response/WorkflowJob.cs new file mode 100644 index 0000000000..34f9213a24 --- /dev/null +++ b/Octokit/Models/Response/WorkflowJob.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowJobConclusion.cs b/Octokit/Models/Response/WorkflowJobConclusion.cs new file mode 100644 index 0000000000..e940d307d3 --- /dev/null +++ b/Octokit/Models/Response/WorkflowJobConclusion.cs @@ -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, + } +} diff --git a/Octokit/Models/Response/WorkflowJobStatus.cs b/Octokit/Models/Response/WorkflowJobStatus.cs new file mode 100644 index 0000000000..80e2c955ef --- /dev/null +++ b/Octokit/Models/Response/WorkflowJobStatus.cs @@ -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, + } +} diff --git a/Octokit/Models/Response/WorkflowJobStep.cs b/Octokit/Models/Response/WorkflowJobStep.cs new file mode 100644 index 0000000000..4f51e7f3ac --- /dev/null +++ b/Octokit/Models/Response/WorkflowJobStep.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowJobsResponse.cs b/Octokit/Models/Response/WorkflowJobsResponse.cs new file mode 100644 index 0000000000..663425c3b0 --- /dev/null +++ b/Octokit/Models/Response/WorkflowJobsResponse.cs @@ -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); + } +} diff --git a/Octokit/Models/Response/WorkflowReference.cs b/Octokit/Models/Response/WorkflowReference.cs new file mode 100644 index 0000000000..056e61c36c --- /dev/null +++ b/Octokit/Models/Response/WorkflowReference.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowRun.cs b/Octokit/Models/Response/WorkflowRun.cs new file mode 100644 index 0000000000..7d1073c717 --- /dev/null +++ b/Octokit/Models/Response/WorkflowRun.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowRunBillable.cs b/Octokit/Models/Response/WorkflowRunBillable.cs new file mode 100644 index 0000000000..c11d2698c4 --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunBillable.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowRunBillableTiming.cs b/Octokit/Models/Response/WorkflowRunBillableTiming.cs new file mode 100644 index 0000000000..1a93b99aff --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunBillableTiming.cs @@ -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); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowRunConclusion.cs b/Octokit/Models/Response/WorkflowRunConclusion.cs new file mode 100644 index 0000000000..5895a31422 --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunConclusion.cs @@ -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, + } +} diff --git a/Octokit/Models/Response/WorkflowRunJobsFilter.cs b/Octokit/Models/Response/WorkflowRunJobsFilter.cs new file mode 100644 index 0000000000..c6110cf6c3 --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunJobsFilter.cs @@ -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, + } +} diff --git a/Octokit/Models/Response/WorkflowRunStatus.cs b/Octokit/Models/Response/WorkflowRunStatus.cs new file mode 100644 index 0000000000..ce0356fe07 --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunStatus.cs @@ -0,0 +1,18 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum WorkflowRunStatus + { + [Parameter(Value = "requested")] + Requested, + [Parameter(Value = "in_progress")] + InProgress, + [Parameter(Value = "completed")] + Completed, + [Parameter(Value = "queued")] + Queued, + [Parameter(Value = "waiting")] + Waiting, + } +} diff --git a/Octokit/Models/Response/WorkflowRunTiming.cs b/Octokit/Models/Response/WorkflowRunTiming.cs new file mode 100644 index 0000000000..fdba9e964d --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunTiming.cs @@ -0,0 +1,35 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class WorkflowRunTiming + { + public WorkflowRunTiming() { } + + public WorkflowRunTiming(long jobId, long durationMs) + { + JobId = jobId; + DurationMs = durationMs; + } + + /// <summary> + /// The job Id. + /// </summary> + public long JobId { get; private set; } + + /// <summary> + /// The duration of the job in milliseconds. + /// </summary> + public long DurationMs { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "JobId: {0}, DurationMs: {1}", JobId, DurationMs); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowRunUsage.cs b/Octokit/Models/Response/WorkflowRunUsage.cs new file mode 100644 index 0000000000..5a2951e2de --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunUsage.cs @@ -0,0 +1,35 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class WorkflowRunUsage + { + public WorkflowRunUsage() { } + + public WorkflowRunUsage(WorkflowRunBillable billable, long runDurationMs) + { + Billable = billable; + RunDurationMs = runDurationMs; + } + + /// <summary> + /// The billable usage. + /// </summary> + public WorkflowRunBillable Billable { get; private set; } + + /// <summary> + /// The total run duration in milliseconds. + /// </summary> + public long RunDurationMs { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Billing: {0}", Billable); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowRunsResponse.cs b/Octokit/Models/Response/WorkflowRunsResponse.cs new file mode 100644 index 0000000000..25c9bf32e1 --- /dev/null +++ b/Octokit/Models/Response/WorkflowRunsResponse.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class WorkflowRunsResponse + { + public WorkflowRunsResponse() + { + } + + public WorkflowRunsResponse(int totalCount, IReadOnlyList<WorkflowRun> workflowRuns) + { + TotalCount = totalCount; + WorkflowRuns = workflowRuns; + } + + /// <summary> + /// The total number of workflow runs. + /// </summary> + public int TotalCount { get; private set; } + + /// <summary> + /// The retrieved workflow runs. + /// </summary> + public IReadOnlyList<WorkflowRun> WorkflowRuns { get; private set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, WorkflowRuns: {1}", TotalCount, WorkflowRuns.Count); + } +} diff --git a/Octokit/Models/Response/WorkflowState.cs b/Octokit/Models/Response/WorkflowState.cs new file mode 100644 index 0000000000..d303fe42aa --- /dev/null +++ b/Octokit/Models/Response/WorkflowState.cs @@ -0,0 +1,18 @@ +using Octokit.Internal; + +namespace Octokit +{ + public enum WorkflowState + { + [Parameter(Value = "active")] + Active, + [Parameter(Value = "deleted")] + Deleted, + [Parameter(Value = "disabled_fork")] + DisabledFork, + [Parameter(Value = "disabled_inactivity")] + DisabledInactivity, + [Parameter(Value = "disabled_manually")] + DisabledManually + } +} diff --git a/Octokit/Models/Response/WorkflowUsage.cs b/Octokit/Models/Response/WorkflowUsage.cs new file mode 100644 index 0000000000..82d868df44 --- /dev/null +++ b/Octokit/Models/Response/WorkflowUsage.cs @@ -0,0 +1,29 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class WorkflowUsage + { + public WorkflowUsage() { } + + public WorkflowUsage(WorkflowBillable billable) + { + Billable = billable; + } + + /// <summary> + /// The billable usage. + /// </summary> + public WorkflowBillable Billable { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Billing: {0}", Billable); + } + } + } +} diff --git a/Octokit/Models/Response/WorkflowsResponse.cs b/Octokit/Models/Response/WorkflowsResponse.cs new file mode 100644 index 0000000000..a61ca19572 --- /dev/null +++ b/Octokit/Models/Response/WorkflowsResponse.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class WorkflowsResponse + { + public WorkflowsResponse() + { + } + + public WorkflowsResponse(int totalCount, IReadOnlyList<Workflow> workflows) + { + TotalCount = totalCount; + Workflows = workflows; + } + + /// <summary> + /// The total number of workflows. + /// </summary> + public int TotalCount { get; private set; } + + /// <summary> + /// The retrieved workflows. + /// </summary> + public IReadOnlyList<Workflow> Workflows { get; private set; } + + internal string DebuggerDisplay => string.Format(CultureInfo.CurrentCulture, "TotalCount: {0}, Workflows: {1}", TotalCount, Workflows.Count); + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index b212b79773..a55742391c 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -21,7 +21,7 @@ <PropertyGroup> <DefineConstants>$(DefineConstants);SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> - <NoWarn>1591;1701;1702;1705</NoWarn> + <NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn> </PropertyGroup> <ItemGroup> From 6c11c1edff539f4538f7aeea3edc22305aea3f79 Mon Sep 17 00:00:00 2001 From: minoura-a <57167143+minoura-a@users.noreply.github.com> Date: Thu, 24 Nov 2022 02:13:29 +0900 Subject: [PATCH 154/209] [bug]: Fixed a bug that content cannot be retrieved if "#" is included in a file or folder name. --- .../Helpers/StringExtensionsTests.cs | 25 +++++++++++++++++++ Octokit/Helpers/StringExtensions.cs | 8 +++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Helpers/StringExtensionsTests.cs b/Octokit.Tests/Helpers/StringExtensionsTests.cs index f342199ef9..e4687019db 100644 --- a/Octokit.Tests/Helpers/StringExtensionsTests.cs +++ b/Octokit.Tests/Helpers/StringExtensionsTests.cs @@ -89,5 +89,30 @@ public void EscapeDoubleQuotesEscapesAllDoubleQuotes() Assert.Equal("\\\"test milestone\\\"", input.EscapeDoubleQuotes()); } } + + public class EncodeSharpMethod + { + [Fact] + public void EncodeSharpReturnsNullForNullInput() + { + Assert.Equal(string.Empty, (null as string).EncodeSharp()); + } + + [Fact] + public void EncodeSharpReturnsInputWithoutDoubleQuotes() + { + string input = "some test input without double quotes in it"; + + Assert.Equal(input, input.EncodeSharp()); + } + + [Fact] + public void EncodeAllSharp() + { + string input = "#some test input with # in it#"; + + Assert.Equal("%23some test input with %23 in it%23", input.EncodeSharp()); + } + } } } diff --git a/Octokit/Helpers/StringExtensions.cs b/Octokit/Helpers/StringExtensions.cs index 42ed83361f..e3d288acaf 100644 --- a/Octokit/Helpers/StringExtensions.cs +++ b/Octokit/Helpers/StringExtensions.cs @@ -23,8 +23,9 @@ public static bool IsNotBlank(this string value) public static Uri FormatUri(this string pattern, params object[] args) { Ensure.ArgumentNotNullOrEmptyString(pattern, nameof(pattern)); + var uriString = string.Format(CultureInfo.InvariantCulture, pattern, args).EncodeSharp(); - return new Uri(string.Format(CultureInfo.InvariantCulture, pattern, args), UriKind.Relative); + return new Uri(uriString, UriKind.Relative); } public static string UriEncode(this string input) @@ -106,6 +107,11 @@ internal static string EscapeDoubleQuotes(this string value) return value; } + internal static string EncodeSharp(this string value) + { + return !string.IsNullOrEmpty(value) ? value?.Replace("#", "%23") : string.Empty; + } + static IEnumerable<string> SplitUpperCase(this string source) { Ensure.ArgumentNotNullOrEmptyString(source, nameof(source)); From 46b5077b16ad2b2b13858aee2f99bdaa1d81b61d Mon Sep 17 00:00:00 2001 From: notauserx <82922717+notauserx@users.noreply.github.com> Date: Thu, 1 Dec 2022 05:20:19 +0600 Subject: [PATCH 155/209] add islocked filter to SeachIssuesRequest (#2623) * add islocker filter to SeachIssuesRequest * update docs * Update docs/search.md with review suggestions Co-authored-by: Keegan Campbell <me@kfcampbell.com> Co-authored-by: notauserx <notauserx@users.noreply.github.com> Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- .../Clients/SearchClientTests.cs | 22 +++++++++++++++++++ .../Models/SearchIssuesRequestTests.cs | 11 ++++++++++ Octokit/Models/Request/SearchIssuesRequest.cs | 6 ++++- docs/search.md | 8 +++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index c64d6a02f2..9123ecdc3c 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -281,6 +281,28 @@ public async Task SearchForAllIssuesUsingTerm() Assert.NotEmpty(openedIssues); } + [IntegrationTest] + public async Task SearchForLockedUnlockedIssues() + { + + var lockedIssuesRequest = new SearchIssuesRequest(); + lockedIssuesRequest.Repos.Add("octokit", "octokit.net"); + lockedIssuesRequest.Is = new List<IssueIsQualifier> { IssueIsQualifier.Issue, IssueIsQualifier.Locked }; + + var lockedIssues = await _gitHubClient.Search.SearchIssues(lockedIssuesRequest); + + var unlockedIssuesRequest = new SearchIssuesRequest(); + + unlockedIssuesRequest.Repos.Add("octokit", "octokit.net"); + unlockedIssuesRequest.Is = new List<IssueIsQualifier> { IssueIsQualifier.Issue, IssueIsQualifier.Unlocked }; + + + var unlockedIssues = await _gitHubClient.Search.SearchIssues(unlockedIssuesRequest); + + Assert.All(lockedIssues.Items, i => Assert.True(i.Locked)); + Assert.All(unlockedIssues.Items, i => Assert.False(i.Locked)); + } + [IntegrationTest] public async Task SearchForMergedPullRequests() { diff --git a/Octokit.Tests/Models/SearchIssuesRequestTests.cs b/Octokit.Tests/Models/SearchIssuesRequestTests.cs index 9227e7a8e0..dfa5e55a69 100644 --- a/Octokit.Tests/Models/SearchIssuesRequestTests.cs +++ b/Octokit.Tests/Models/SearchIssuesRequestTests.cs @@ -170,6 +170,17 @@ public void HandlesIsAttributeCorrectly() Assert.Contains("is:pr", request.MergedQualifiers()); } + [Fact] + public void HandlesIsLockedUnlockedAttributeCorrectly() + { + var request = new SearchIssuesRequest("test"); + Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("is:")); + + request.Is = new List<IssueIsQualifier> { IssueIsQualifier.Locked, IssueIsQualifier.Unlocked }; + Assert.Contains("is:locked", request.MergedQualifiers()); + Assert.Contains("is:unlocked", request.MergedQualifiers()); + } + [Fact] public void HandlesStatusAttributeCorrectly() { diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index acb33c6f47..391e04130a 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -489,7 +489,11 @@ public enum IssueIsQualifier [Parameter(Value = "private")] Private, [Parameter(Value = "public")] - Public + Public, + [Parameter(Value = "locked")] + Locked, + [Parameter(Value = "unlocked")] + Unlocked } public enum IssueNoMetadataQualifier diff --git a/docs/search.md b/docs/search.md index 1c3e1c7f90..95dfdc218b 100644 --- a/docs/search.md +++ b/docs/search.md @@ -61,6 +61,14 @@ request.Involves = "terrajobst"; request.State = ItemState.All; // or to just search closed issues request.State = ItemState.Closed; + +// you can filter by the "Is" qualifier +// the enum IssueIsQualifier contains the supported values +// you can filter for locked issues like this: +request.Is = new List<IssueIsQualifier> { + IssueIsQualifier.Issue, + IssueIsQualifier.Locked +}; ``` There's other options available to control how the results are returned: From 978093803cd30ad0643376f9440f048770b0699d Mon Sep 17 00:00:00 2001 From: Martin Costello <martin@martincostello.com> Date: Thu, 1 Dec 2022 00:00:45 +0000 Subject: [PATCH 156/209] [bug] Fix API URLs for GitHub Enterprise Server (#2626) * Fix API URLs for GHES Fix leading slashes causing API calls to fail when used with GitHub Enterprise. * Fix tests Fix tests that should have been updated in the previous commit. Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- .../Clients/ActionsWorkflowJobsClientTests.cs | 16 ++-- .../Clients/ActionsWorkflowRunsClientTests.cs | 44 ++++----- .../Clients/ActionsWorkflowsClientTests.cs | 24 ++--- .../Clients/PackageVersionsClientTests.cs | 30 +++--- Octokit.Tests/Clients/PackagesClientTests.cs | 30 +++--- ...bservableActionsWorkflowRunsClientTests.cs | 2 +- .../ObservablePackageVersionsTests.cs | 4 +- .../Reactive/ObservablePackagesTests.cs | 12 +-- Octokit/Helpers/ApiUrls.cs | 96 +++++++++---------- 9 files changed, 129 insertions(+), 129 deletions(-) diff --git a/Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs b/Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs index 1ec99df17b..7819c4aa1a 100644 --- a/Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs +++ b/Octokit.Tests/Clients/ActionsWorkflowJobsClientTests.cs @@ -28,7 +28,7 @@ public async Task RequestsCorrectUrl() await client.Rerun("fake", "repo", 123); connection.Received().Post( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/jobs/123/rerun")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/jobs/123/rerun")); } [Fact] @@ -63,7 +63,7 @@ public async Task RequestsCorrectUrl() await client.Get("fake", "repo", 123); connection.Received().Get<WorkflowJob>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/jobs/123")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/jobs/123")); } [Fact] @@ -98,7 +98,7 @@ public async Task RequestsCorrectUrl() await client.GetLogs("fake", "repo", 123); connection.Connection.Received().Get<string>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/jobs/123/logs"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/jobs/123/logs"), null); } @@ -134,14 +134,14 @@ public async Task RequestsCorrectUrl() await client.List("fake", "repo", 123); connection.Received().GetAll<WorkflowJobsResponse>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/jobs"), + 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"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/attempts/456/jobs"), null, Args.ApiOptions); } @@ -160,7 +160,7 @@ public async Task RequestsCorrectUrlWithRequest() 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<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/jobs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 && x["filter"] == "all"), @@ -179,7 +179,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() 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<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/jobs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 1 && x["filter"] == "latest"), @@ -188,7 +188,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() 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"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/attempts/456/jobs"), null, options); } diff --git a/Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs b/Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs index 21b159e152..559d59093d 100644 --- a/Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs +++ b/Octokit.Tests/Clients/ActionsWorkflowRunsClientTests.cs @@ -30,7 +30,7 @@ public async Task RequestsCorrectUrl() await client.Approve("fake", "repo", 123); connection.Received().Post( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approve")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/approve")); } [Fact] @@ -65,7 +65,7 @@ public async Task RequestsCorrectUrl() await client.Cancel("fake", "repo", 123); connection.Received().Post( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/cancel")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/cancel")); } [Fact] @@ -100,7 +100,7 @@ public async Task RequestsCorrectUrl() await client.Delete("fake", "repo", 123); connection.Received().Delete( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123")); } [Fact] @@ -135,7 +135,7 @@ public async Task RequestsCorrectUrl() await client.DeleteLogs("fake", "repo", 123); connection.Received().Delete( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/logs")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/logs")); } [Fact] @@ -170,7 +170,7 @@ public async Task RequestsCorrectUrl() await client.Get("fake", "repo", 123); connection.Received().Get<WorkflowRun>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123"), null); } @@ -205,7 +205,7 @@ public async Task RequestsCorrectUrl() 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) + connection.GetRaw(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/logs"), null) .Returns(responseTask); var apiConnection = Substitute.For<IApiConnection>(); @@ -250,7 +250,7 @@ public async Task RequestsCorrectUrl() 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"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/attempts/456"), null); } @@ -285,7 +285,7 @@ public async Task RequestsCorrectUrl() 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) + 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>(); @@ -330,7 +330,7 @@ public async Task RequestsCorrectUrl() await client.GetReviewHistory("fake", "repo", 123); connection.Received().GetAll<EnvironmentApprovals>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approvals")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/approvals")); } [Fact] @@ -371,7 +371,7 @@ public async Task RequestsCorrectUrl() await client.GetUsage("fake", "repo", 123); connection.Received().Get<WorkflowRunUsage>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/timing"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/timing"), null); } @@ -407,7 +407,7 @@ public async Task RequestsCorrectUrl() await client.List("fake", "repo"); connection.Received().GetAll<WorkflowRunsResponse>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs"), Args.EmptyDictionary, Args.ApiOptions); } @@ -432,7 +432,7 @@ public async Task RequestsCorrectUrlWithRequest() await client.List("fake", "repo", request); connection.Received().GetAll<WorkflowRunsResponse>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 7 && x["actor"] == "octocat" @@ -458,7 +458,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() await client.List("fake", "repo", request, options); connection.Received().GetAll<WorkflowRunsResponse>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 3 && x["branch"] == "main" @@ -520,7 +520,7 @@ public async Task RequestsCorrectUrlWithId() await client.ListByWorkflow("fake", "repo", 123); connection.Received().GetAll<WorkflowRunsResponse>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/runs"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123/runs"), Args.EmptyDictionary, Args.ApiOptions); } @@ -534,7 +534,7 @@ public async Task RequestsCorrectUrlWithName() 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"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yml/runs"), Args.EmptyDictionary, Args.ApiOptions); } @@ -559,7 +559,7 @@ public async Task RequestsCorrectUrlWithIdWithRequest() 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<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123/runs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 7 && x["actor"] == "octocat" @@ -593,7 +593,7 @@ public async Task RequestsCorrectUrlWithNameWithRequest() 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<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yml/runs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 7 && x["actor"] == "octocat" @@ -619,7 +619,7 @@ public async Task RequestsCorrectUrlWithIdWithRequestWithApiOptions() 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<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123/runs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 3 && x["branch"] == "main" @@ -640,7 +640,7 @@ public async Task RequestsCorrectUrlWithNameWithRequestWithApiOptions() 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<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yml/runs"), Arg.Is<Dictionary<string, string>>(x => x.Count == 3 && x["branch"] == "main" @@ -732,7 +732,7 @@ public async Task RequestsCorrectUrl() await client.Rerun("fake", "repo", 123); connection.Received().Post( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/rerun")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/rerun")); } [Fact] @@ -769,7 +769,7 @@ public async Task RequestsCorrectUrl() await client.RerunFailedJobs("fake", "repo", 123); connection.Received().Post( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/rerun-failed-jobs")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/rerun-failed-jobs")); } [Fact] @@ -806,7 +806,7 @@ public async Task RequestsCorrectUrl() 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"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/pending_deployments"), review); } diff --git a/Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs b/Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs index 155b7e7786..45642f27fe 100644 --- a/Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs +++ b/Octokit.Tests/Clients/ActionsWorkflowsClientTests.cs @@ -42,7 +42,7 @@ public async Task RequestsCorrectUrlByWorkflowId() await client.CreateDispatch("fake", "repo", 123, createDispatch); connection.Received().Post<object>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/dispatches"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123/dispatches"), createDispatch); } @@ -57,7 +57,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName() 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"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yaml/dispatches"), createDispatch); } @@ -107,7 +107,7 @@ public async Task RequestsCorrectUrlByWorkflowId() await client.Disable("fake", "repo", 123); connection.Received().Put( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/disable")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123/disable")); } [Fact] @@ -119,7 +119,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName() await client.Disable("fake", "repo", "main.yaml"); connection.Received().Put( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/disable")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yaml/disable")); } [Fact] @@ -162,7 +162,7 @@ public async Task RequestsCorrectUrlByWorkflowId() await client.Enable("fake", "repo", 123); connection.Received().Put( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/enable")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123/enable")); } [Fact] @@ -174,7 +174,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName() await client.Enable("fake", "repo", "main.yaml"); connection.Received().Put( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml/enable")); + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yaml/enable")); } [Fact] @@ -217,7 +217,7 @@ public async Task RequestsCorrectUrlByWorkflowId() await client.Get("fake", "repo", 123); connection.Received().Get<Workflow>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123"), null); } @@ -230,7 +230,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName() await client.Get("fake", "repo", "main.yaml"); connection.Received().Get<Workflow>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/main.yaml"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yaml"), null); } @@ -274,7 +274,7 @@ public async Task RequestsCorrectUrlByWorkflowId() await client.GetUsage("fake", "repo", 123); connection.Received().Get<WorkflowUsage>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows/123/timing"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/123/timing"), null); } @@ -287,7 +287,7 @@ public async Task RequestsCorrectUrlByWorkflowFileName() 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"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows/main.yaml/timing"), null); } @@ -331,7 +331,7 @@ public async Task RequestsCorrectUrl() await client.List("fake", "repo"); connection.Received().GetAll<WorkflowsResponse>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows"), null, Args.ApiOptions); } @@ -347,7 +347,7 @@ public async Task RequestsCorrectUrlWithRequestWithApiOptions() await client.List("fake", "repo", options); connection.Received().GetAll<WorkflowsResponse>( - Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/workflows"), + Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/workflows"), null, options); } diff --git a/Octokit.Tests/Clients/PackageVersionsClientTests.cs b/Octokit.Tests/Clients/PackageVersionsClientTests.cs index 2e75aa3325..f0708719ec 100644 --- a/Octokit.Tests/Clients/PackageVersionsClientTests.cs +++ b/Octokit.Tests/Clients/PackageVersionsClientTests.cs @@ -28,7 +28,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForOrg("fake", PackageType.RubyGems, "name"); connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => - u.ToString() == "/orgs/fake/packages/rubygems/name/versions"), + u.ToString() == "orgs/fake/packages/rubygems/name/versions"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), Args.ApiOptions); } @@ -43,7 +43,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() var calls = connection.ReceivedCalls(); connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => - u.ToString() == "/orgs/fake/packages/rubygems/name/versions"), + u.ToString() == "orgs/fake/packages/rubygems/name/versions"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted"), Args.ApiOptions); } @@ -72,7 +72,7 @@ public async Task RequestsCorrectUrl() await client.GetForOrg("fake", PackageType.Npm, "name", 5); - connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/versions/5")); + connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages/npm/name/versions/5")); } [Fact] @@ -100,7 +100,7 @@ public async Task RequestsCorrectUrl() await client.DeleteForOrg("fake", PackageType.Npm, "name", 5); - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/versions/5")); + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages/npm/name/versions/5")); } [Fact] @@ -128,7 +128,7 @@ public async Task RequestsCorrectUrl() await client.RestoreForOrg("fake", PackageType.Npm, "name", 5); - connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/versions/5/restore")); + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages/npm/name/versions/5/restore")); } [Fact] @@ -157,7 +157,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForActiveUser(PackageType.RubyGems, "name"); connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => - u.ToString() == "/user/packages/rubygems/name/versions"), + u.ToString() == "user/packages/rubygems/name/versions"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), Args.ApiOptions); } @@ -172,7 +172,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() var calls = connection.ReceivedCalls(); connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => - u.ToString() == "/user/packages/rubygems/name/versions"), + u.ToString() == "user/packages/rubygems/name/versions"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted"), Args.ApiOptions); } @@ -198,7 +198,7 @@ public async Task RequestsCorrectUrl() await client.GetForActiveUser(PackageType.Npm, "name", 5); - connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/versions/5")); + connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "user/packages/npm/name/versions/5")); } [Fact] @@ -223,7 +223,7 @@ public async Task RequestsCorrectUrl() await client.DeleteForActiveUser(PackageType.Npm, "name", 5); - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/versions/5")); + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "user/packages/npm/name/versions/5")); } [Fact] @@ -248,7 +248,7 @@ public async Task RequestsCorrectUrl() await client.RestoreForActiveUser(PackageType.Npm, "name", 5); - connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/versions/5/restore")); + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "user/packages/npm/name/versions/5/restore")); } [Fact] @@ -274,7 +274,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForUser("fake", PackageType.RubyGems, "name"); connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => - u.ToString() == "/users/fake/packages/rubygems/name/versions"), + u.ToString() == "users/fake/packages/rubygems/name/versions"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state")), Args.ApiOptions); } @@ -289,7 +289,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() var calls = connection.ReceivedCalls(); connection.Received().GetAll<PackageVersion>(Arg.Is<Uri>(u => - u.ToString() == "/users/fake/packages/rubygems/name/versions"), + u.ToString() == "users/fake/packages/rubygems/name/versions"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted"), Args.ApiOptions); } @@ -318,7 +318,7 @@ public async Task RequestsCorrectUrl() await client.GetForUser("fake", PackageType.Npm, "name", 5); - connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/versions/5")); + connection.Received().Get<PackageVersion>(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages/npm/name/versions/5")); } [Fact] @@ -346,7 +346,7 @@ public async Task RequestsCorrectUrl() await client.DeleteForUser("fake", PackageType.Npm, "name", 5); - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/versions/5")); + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages/npm/name/versions/5")); } [Fact] @@ -374,7 +374,7 @@ public async Task RequestsCorrectUrl() await client.RestoreForUser("fake", PackageType.Npm, "name", 5); - connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/versions/5/restore")); + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages/npm/name/versions/5/restore")); } [Fact] diff --git a/Octokit.Tests/Clients/PackagesClientTests.cs b/Octokit.Tests/Clients/PackagesClientTests.cs index 1b056c30a4..2da109bf1f 100644 --- a/Octokit.Tests/Clients/PackagesClientTests.cs +++ b/Octokit.Tests/Clients/PackagesClientTests.cs @@ -27,7 +27,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForOrg("fake", PackageType.RubyGems); - connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); } [Fact] @@ -39,7 +39,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() await client.GetAllForOrg("fake", PackageType.RubyGems, PackageVisibility.Public); var calls = connection.ReceivedCalls(); - connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); } [Fact] @@ -63,7 +63,7 @@ public async Task RequestsCorrectUrl() await client.GetForOrg("fake", PackageType.Npm, "name"); - connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name")); + connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages/npm/name")); } [Fact] @@ -89,7 +89,7 @@ public async Task RequestsCorrectUrl() await client.DeleteForOrg("fake", PackageType.Npm, "name"); - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name")); + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages/npm/name")); } [Fact] @@ -115,7 +115,7 @@ public async Task RequestsCorrectUrl() await client.RestoreForOrg("fake", PackageType.Npm, "name"); - connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/npm/name/restore")); + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages/npm/name/restore")); } [Fact] @@ -141,7 +141,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForActiveUser(PackageType.RubyGems); - connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/user/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "user/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); } [Fact] @@ -153,7 +153,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() await client.GetAllForActiveUser(PackageType.RubyGems, PackageVisibility.Public); var calls = connection.ReceivedCalls(); - connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/user/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "user/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); } } @@ -167,7 +167,7 @@ public async Task RequestsCorrectUrl() await client.GetForActiveUser(PackageType.Npm, "name"); - connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name")); + connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "user/packages/npm/name")); } [Fact] @@ -190,7 +190,7 @@ public async Task RequestsCorrectUrl() await client.DeleteForActiveUser(PackageType.Npm, "name"); - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name")); + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "user/packages/npm/name")); } [Fact] @@ -213,7 +213,7 @@ public async Task RequestsCorrectUrl() await client.RestoreForActiveUser(PackageType.Npm, "name"); - connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/user/packages/npm/name/restore")); + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "user/packages/npm/name/restore")); } [Fact] @@ -236,7 +236,7 @@ public async Task RequestsCorrectUrl() await client.GetAllForUser("fake", PackageType.RubyGems); - connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); } [Fact] @@ -248,7 +248,7 @@ public async Task RequestsCorrectUrlWithOptionalParameter() await client.GetAllForUser("fake", PackageType.RubyGems, PackageVisibility.Public); var calls = connection.ReceivedCalls(); - connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); + connection.Received().GetAll<Package>(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); } [Fact] @@ -272,7 +272,7 @@ public async Task RequestsCorrectUrl() await client.GetForUser("fake", PackageType.Npm, "name"); - connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name")); + connection.Received().Get<Package>(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages/npm/name")); } [Fact] @@ -298,7 +298,7 @@ public async Task RequestsCorrectUrl() await client.DeleteForUser("fake", PackageType.Npm, "name"); - connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name")); + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages/npm/name")); } [Fact] @@ -324,7 +324,7 @@ public async Task RequestsCorrectUrl() await client.RestoreForUser("fake", PackageType.Npm, "name"); - connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages/npm/name/restore")); + connection.Received().Post(Arg.Is<Uri>(u => u.ToString() == "users/fake/packages/npm/name/restore")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs b/Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs index 0344f91a4c..677190e8d2 100644 --- a/Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableActionsWorkflowRunsClientTests.cs @@ -382,7 +382,7 @@ public async Task CallsGetReviewHistoryOnClient() client.GetReviewHistory("fake", "repo", 123); - connection.Connection.Received().Get<List<EnvironmentApprovals>>(Arg.Is<Uri>(u => u.ToString() == "/repos/fake/repo/actions/runs/123/approvals"), + connection.Connection.Received().Get<List<EnvironmentApprovals>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/actions/runs/123/approvals"), null); } diff --git a/Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs b/Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs index 0ba5cc3332..1942610a76 100644 --- a/Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs +++ b/Octokit.Tests/Reactive/ObservablePackageVersionsTests.cs @@ -28,7 +28,7 @@ public void RequestsCorrectUrl() client.GetAllForOrg("fake", PackageType.RubyGems, "name"); gitHubClient.Connection.Received().Get<List<PackageVersion>>( - new Uri("/orgs/fake/packages/rubygems/name/versions", UriKind.Relative), + new Uri("orgs/fake/packages/rubygems/name/versions", UriKind.Relative), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state"))); } @@ -41,7 +41,7 @@ public void RequestsCorrectUrlWithOptionalParameter() client.GetAllForOrg("fake", PackageType.RubyGems, "name", PackageVersionState.Deleted); gitHubClient.Connection.Received().Get<List<PackageVersion>>( - Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages/rubygems/name/versions"), + Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages/rubygems/name/versions"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("state") && d["state"] == "deleted")); } diff --git a/Octokit.Tests/Reactive/ObservablePackagesTests.cs b/Octokit.Tests/Reactive/ObservablePackagesTests.cs index 996da9b7bd..5e1adb848c 100644 --- a/Octokit.Tests/Reactive/ObservablePackagesTests.cs +++ b/Octokit.Tests/Reactive/ObservablePackagesTests.cs @@ -28,7 +28,7 @@ public void RequestsCorrectUrl() client.GetAllForOrg("fake", PackageType.RubyGems); gitHubClient.Connection.Received(1).Get<List<Package>>( - new Uri("/orgs/fake/packages", UriKind.Relative), + new Uri("orgs/fake/packages", UriKind.Relative), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); } @@ -41,7 +41,7 @@ public void RequestsCorrectUrlWithOptionalParameter() client.GetAllForOrg("fake", PackageType.RubyGems, PackageVisibility.Public); gitHubClient.Connection.Received().Get<List<Package>>( - Arg.Is<Uri>(u => u.ToString() == "/orgs/fake/packages"), + Arg.Is<Uri>(u => u.ToString() == "orgs/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); } @@ -143,7 +143,7 @@ public void RequestsCorrectUrl() client.GetAllForActiveUser(PackageType.RubyGems); gitHubClient.Connection.Received(1).Get<List<Package>>( - new Uri("/user/packages", UriKind.Relative), + new Uri("user/packages", UriKind.Relative), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); } @@ -156,7 +156,7 @@ public void RequestsCorrectUrlWithOptionalParameter() client.GetAllForActiveUser(PackageType.RubyGems, PackageVisibility.Public); gitHubClient.Connection.Received().Get<List<Package>>( - Arg.Is<Uri>(u => u.ToString() == "/user/packages"), + Arg.Is<Uri>(u => u.ToString() == "user/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); } } @@ -241,7 +241,7 @@ public void RequestsCorrectUrl() client.GetAllForUser("fake", PackageType.RubyGems); gitHubClient.Connection.Received(1).Get<List<Package>>( - new Uri("/users/fake/packages", UriKind.Relative), + new Uri("users/fake/packages", UriKind.Relative), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type"))); } @@ -254,7 +254,7 @@ public void RequestsCorrectUrlWithOptionalParameter() client.GetAllForUser("fake", PackageType.RubyGems, PackageVisibility.Public); gitHubClient.Connection.Received().Get<List<Package>>( - Arg.Is<Uri>(u => u.ToString() == "/users/fake/packages"), + Arg.Is<Uri>(u => u.ToString() == "users/fake/packages"), Arg.Is<Dictionary<string, string>>(d => d.ContainsKey("package_type") && d.ContainsKey("visibility"))); } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index c4ae3b26b9..9bff25de4b 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -4620,7 +4620,7 @@ public static Uri AllOrganizationCredentials(string org, string login) /// <returns>The <see cref="Uri"/> Packages endpoint.</returns> public static Uri PackagesOrg(string org) { - return "/orgs/{0}/packages".FormatUri(org); + return "orgs/{0}/packages".FormatUri(org); } /// <summary> @@ -4629,7 +4629,7 @@ public static Uri PackagesOrg(string org) /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageOrg(string org, PackageType packageType, string packageName) { - return "/orgs/{0}/packages/{1}/{2}".FormatUri(org, packageType.ToParameter(), packageName); + return "orgs/{0}/packages/{1}/{2}".FormatUri(org, packageType.ToParameter(), packageName); } /// <summary> @@ -4638,7 +4638,7 @@ public static Uri PackageOrg(string org, PackageType packageType, string package /// <returns>The <see cref="Uri"/> Package Restore endpoint.</returns> public static Uri PackageRestoreOrg(string org, PackageType packageType, string packageName) { - return "/orgs/{0}/packages/{1}/{2}/restore".FormatUri(org, packageType.ToParameter(), packageName); + return "orgs/{0}/packages/{1}/{2}/restore".FormatUri(org, packageType.ToParameter(), packageName); } /// <summary> @@ -4647,7 +4647,7 @@ public static Uri PackageRestoreOrg(string org, PackageType packageType, string /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionsOrg(string org, PackageType packageType, string packageName) { - return "/orgs/{0}/packages/{1}/{2}/versions".FormatUri(org, packageType.ToParameter(), packageName); + return "orgs/{0}/packages/{1}/{2}/versions".FormatUri(org, packageType.ToParameter(), packageName); } /// <summary> @@ -4656,7 +4656,7 @@ public static Uri PackageVersionsOrg(string org, PackageType packageType, string /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionOrg(string org, PackageType packageType, string packageName, int packageVersionId) { - return "/orgs/{0}/packages/{1}/{2}/versions/{3}".FormatUri(org, packageType.ToParameter(), packageName, packageVersionId); + return "orgs/{0}/packages/{1}/{2}/versions/{3}".FormatUri(org, packageType.ToParameter(), packageName, packageVersionId); } /// <summary> @@ -4665,7 +4665,7 @@ public static Uri PackageVersionOrg(string org, PackageType packageType, string /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionRestoreOrg(string org, PackageType packageType, string packageName, int packageVersionId) { - return "/orgs/{0}/packages/{1}/{2}/versions/{3}/restore".FormatUri(org, packageType.ToParameter(), packageName, packageVersionId); + return "orgs/{0}/packages/{1}/{2}/versions/{3}/restore".FormatUri(org, packageType.ToParameter(), packageName, packageVersionId); } /// <summary> @@ -4674,7 +4674,7 @@ public static Uri PackageVersionRestoreOrg(string org, PackageType packageType, /// <returns>The <see cref="Uri"/> Packages endpoint.</returns> public static Uri PackagesActiveUser() { - return "/user/packages".FormatUri(); + return "user/packages".FormatUri(); } /// <summary> @@ -4683,7 +4683,7 @@ public static Uri PackagesActiveUser() /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageActiveUser(PackageType packageType, string packageName) { - return "/user/packages/{0}/{1}".FormatUri(packageType.ToParameter(), packageName); + return "user/packages/{0}/{1}".FormatUri(packageType.ToParameter(), packageName); } /// <summary> @@ -4692,7 +4692,7 @@ public static Uri PackageActiveUser(PackageType packageType, string packageName) /// <returns>The <see cref="Uri"/> Package Restore endpoint.</returns> public static Uri PackageRestoreActiveUser(PackageType packageType, string packageName) { - return "/user/packages/{0}/{1}/restore".FormatUri(packageType.ToParameter(), packageName); + return "user/packages/{0}/{1}/restore".FormatUri(packageType.ToParameter(), packageName); } /// <summary> @@ -4701,7 +4701,7 @@ public static Uri PackageRestoreActiveUser(PackageType packageType, string packa /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionsActiveUser(PackageType packageType, string packageName) { - return "/user/packages/{0}/{1}/versions".FormatUri(packageType.ToParameter(), packageName); + return "user/packages/{0}/{1}/versions".FormatUri(packageType.ToParameter(), packageName); } /// <summary> @@ -4710,7 +4710,7 @@ public static Uri PackageVersionsActiveUser(PackageType packageType, string pack /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionActiveUser(PackageType packageType, string packageName, int packageVersionId) { - return "/user/packages/{0}/{1}/versions/{2}".FormatUri(packageType.ToParameter(), packageName, packageVersionId); + return "user/packages/{0}/{1}/versions/{2}".FormatUri(packageType.ToParameter(), packageName, packageVersionId); } /// <summary> @@ -4719,7 +4719,7 @@ public static Uri PackageVersionActiveUser(PackageType packageType, string packa /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionRestoreActiveUser(PackageType packageType, string packageName, int packageVersionId) { - return "/user/packages/{0}/{1}/versions/{2}/restore".FormatUri(packageType.ToParameter(), packageName, packageVersionId); + return "user/packages/{0}/{1}/versions/{2}/restore".FormatUri(packageType.ToParameter(), packageName, packageVersionId); } /// <summary> @@ -4728,7 +4728,7 @@ public static Uri PackageVersionRestoreActiveUser(PackageType packageType, strin /// <returns>The <see cref="Uri"/> Packages endpoint.</returns> public static Uri PackagesUser(string username) { - return "/users/{0}/packages".FormatUri(username); + return "users/{0}/packages".FormatUri(username); } /// <summary> @@ -4737,7 +4737,7 @@ public static Uri PackagesUser(string username) /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageUser(string username, PackageType packageType, string packageName) { - return "/users/{0}/packages/{1}/{2}".FormatUri(username, packageType.ToParameter(), packageName); + return "users/{0}/packages/{1}/{2}".FormatUri(username, packageType.ToParameter(), packageName); } /// <summary> @@ -4746,7 +4746,7 @@ public static Uri PackageUser(string username, PackageType packageType, string p /// <returns>The <see cref="Uri"/> Package Restore endpoint.</returns> public static Uri PackageRestoreUser(string username, PackageType packageType, string packageName) { - return "/users/{0}/packages/{1}/{2}/restore".FormatUri(username, packageType.ToParameter(), packageName); + return "users/{0}/packages/{1}/{2}/restore".FormatUri(username, packageType.ToParameter(), packageName); } /// <summary> @@ -4755,7 +4755,7 @@ public static Uri PackageRestoreUser(string username, PackageType packageType, s /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionsUser(string username, PackageType packageType, string packageName) { - return "/users/{0}/packages/{1}/{2}/versions".FormatUri(username, packageType.ToParameter(), packageName); + return "users/{0}/packages/{1}/{2}/versions".FormatUri(username, packageType.ToParameter(), packageName); } /// <summary> @@ -4764,7 +4764,7 @@ public static Uri PackageVersionsUser(string username, PackageType packageType, /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionUser(string username, PackageType packageType, string packageName, int packageVersionId) { - return "/users/{0}/packages/{1}/{2}/versions/{3}".FormatUri(username, packageType.ToParameter(), packageName, packageVersionId); + return "users/{0}/packages/{1}/{2}/versions/{3}".FormatUri(username, packageType.ToParameter(), packageName, packageVersionId); } /// <summary> @@ -4773,7 +4773,7 @@ public static Uri PackageVersionUser(string username, PackageType packageType, s /// <returns>The <see cref="Uri"/> Package endpoint.</returns> public static Uri PackageVersionRestoreUser(string username, PackageType packageType, string packageName, int packageVersionId) { - return "/users/{0}/packages/{1}/{2}/versions/{3}/restore".FormatUri(username, packageType.ToParameter(), packageName, packageVersionId); + return "users/{0}/packages/{1}/{2}/versions/{3}/restore".FormatUri(username, packageType.ToParameter(), packageName, packageVersionId); } /// <summary> @@ -4785,7 +4785,7 @@ public static Uri PackageVersionRestoreUser(string username, PackageType package /// <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); + return "repos/{0}/{1}/actions/workflows/{2}/dispatches".FormatUri(owner, repo, workflowId); } /// <summary> @@ -4797,7 +4797,7 @@ public static Uri ActionsDispatchWorkflow(string owner, string repo, long workfl /// <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()); + return "repos/{0}/{1}/actions/workflows/{2}/dispatches".FormatUri(owner, repo, workflowFileName.UriEncode()); } /// <summary> @@ -4809,7 +4809,7 @@ public static Uri ActionsDispatchWorkflow(string owner, string repo, string work /// <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()); + return "repos/{0}/{1}/actions/workflows/{2}/disable".FormatUri(owner, repo, workflowFileName.UriEncode()); } /// <summary> @@ -4821,7 +4821,7 @@ public static Uri ActionsDisableWorkflow(string owner, string repo, string workf /// <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); + return "repos/{0}/{1}/actions/workflows/{2}/disable".FormatUri(owner, repo, workflowId); } /// <summary> @@ -4833,7 +4833,7 @@ public static Uri ActionsDisableWorkflow(string owner, string repo, long workflo /// <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()); + return "repos/{0}/{1}/actions/workflows/{2}/enable".FormatUri(owner, repo, workflowFileName.UriEncode()); } /// <summary> @@ -4845,7 +4845,7 @@ public static Uri ActionsEnableWorkflow(string owner, string repo, string workfl /// <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); + return "repos/{0}/{1}/actions/workflows/{2}/enable".FormatUri(owner, repo, workflowId); } /// <summary> @@ -4857,7 +4857,7 @@ public static Uri ActionsEnableWorkflow(string owner, string repo, long workflow /// <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()); + return "repos/{0}/{1}/actions/workflows/{2}".FormatUri(owner, repo, workflowFileName.UriEncode()); } /// <summary> @@ -4869,7 +4869,7 @@ public static Uri ActionsGetWorkflow(string owner, string repo, string workflowF /// <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); + return "repos/{0}/{1}/actions/workflows/{2}".FormatUri(owner, repo, workflowId); } /// <summary> @@ -4881,7 +4881,7 @@ public static Uri ActionsGetWorkflow(string owner, string repo, long workflowId) /// <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()); + return "repos/{0}/{1}/actions/workflows/{2}/timing".FormatUri(owner, repo, workflowFileName.UriEncode()); } /// <summary> @@ -4893,7 +4893,7 @@ public static Uri ActionsGetWorkflowUsage(string owner, string repo, string work /// <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); + return "repos/{0}/{1}/actions/workflows/{2}/timing".FormatUri(owner, repo, workflowId); } /// <summary> @@ -4904,7 +4904,7 @@ public static Uri ActionsGetWorkflowUsage(string owner, string repo, long workfl /// <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); + return "repos/{0}/{1}/actions/workflows".FormatUri(owner, repo); } /// <summary> @@ -4916,7 +4916,7 @@ public static Uri ActionsListWorkflows(string owner, string repo) /// <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); + return "repos/{0}/{1}/actions/jobs/{2}/rerun".FormatUri(owner, repo, jobId); } /// <summary> @@ -4928,7 +4928,7 @@ public static Uri ActionsRerunWorkflowJob(string owner, string repo, long jobId) /// <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); + return "repos/{0}/{1}/actions/jobs/{2}".FormatUri(owner, repo, jobId); } /// <summary> @@ -4940,7 +4940,7 @@ public static Uri ActionsGetWorkflowJob(string owner, string repo, long jobId) /// <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); + return "repos/{0}/{1}/actions/jobs/{2}/logs".FormatUri(owner, repo, jobId); } /// <summary> @@ -4952,7 +4952,7 @@ public static Uri ActionsGetWorkflowJobLogs(string owner, string repo, long jobI /// <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); + return "repos/{0}/{1}/actions/runs/{2}/jobs".FormatUri(owner, repo, runId); } /// <summary> @@ -4965,7 +4965,7 @@ public static Uri ActionsListWorkflowJobs(string owner, string repo, long runId) /// <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); + return "repos/{0}/{1}/actions/runs/{2}/attempts/{3}/jobs".FormatUri(owner, repo, runId, attemptNumber); } /// <summary> @@ -4976,7 +4976,7 @@ public static Uri ActionsListWorkflowJobs(string owner, string repo, long runId, /// <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); + return "repos/{0}/{1}/actions/runs".FormatUri(owner, repo); } /// <summary> @@ -4988,7 +4988,7 @@ public static Uri ActionsWorkflowRuns(string owner, string repo) /// <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); + return "repos/{0}/{1}/actions/runs/{2}".FormatUri(owner, repo, runId); } /// <summary> @@ -5001,7 +5001,7 @@ public static Uri ActionsWorkflowRun(string owner, string repo, long runId) /// <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); + return "repos/{0}/{1}/actions/runs/{2}/attempts/{3}".FormatUri(owner, repo, runId, attemptNumber); } /// <summary> @@ -5013,7 +5013,7 @@ public static Uri ActionsWorkflowRunAttempt(string owner, string repo, long runI /// <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); + return "repos/{0}/{1}/actions/runs/{2}/approve".FormatUri(owner, repo, runId); } /// <summary> @@ -5025,7 +5025,7 @@ public static Uri ActionsApproveWorkflowRun(string owner, string repo, long runI /// <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); + return "repos/{0}/{1}/actions/runs/{2}/cancel".FormatUri(owner, repo, runId); } /// <summary> @@ -5037,7 +5037,7 @@ public static Uri ActionsCancelWorkflowRun(string owner, string repo, long runId /// <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); + return "repos/{0}/{1}/actions/runs/{2}/logs".FormatUri(owner, repo, runId); } /// <summary> @@ -5050,7 +5050,7 @@ public static Uri ActionsGetWorkflowRunLogs(string owner, string repo, long runI /// <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); + return "repos/{0}/{1}/actions/runs/{2}/attempts/{3}/logs".FormatUri(owner, repo, runId, attemptNumber); } /// <summary> @@ -5062,7 +5062,7 @@ public static Uri ActionsGetWorkflowRunAttemptLogs(string owner, string repo, lo /// <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); + return "repos/{0}/{1}/actions/runs/{2}/rerun".FormatUri(owner, repo, runId); } /// <summary> @@ -5074,7 +5074,7 @@ public static Uri ActionsRerunWorkflowRun(string owner, string repo, long runId) /// <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); + return "repos/{0}/{1}/actions/runs/{2}/rerun-failed-jobs".FormatUri(owner, repo, runId); } /// <summary> @@ -5086,7 +5086,7 @@ public static Uri ActionsRerunWorkflowRunFailedJobs(string owner, string repo, l /// <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); + return "repos/{0}/{1}/actions/runs/{2}/timing".FormatUri(owner, repo, runId); } /// <summary> @@ -5098,7 +5098,7 @@ public static Uri ActionsGetWorkflowRunUsage(string owner, string repo, long run /// <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); + return "repos/{0}/{1}/actions/runs/{2}/approvals".FormatUri(owner, repo, runId); } /// <summary> @@ -5110,7 +5110,7 @@ public static Uri ActionsWorkflowRunApprovals(string owner, string repo, long ru /// <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); + return "repos/{0}/{1}/actions/runs/{2}/pending_deployments".FormatUri(owner, repo, runId); } /// <summary> @@ -5122,7 +5122,7 @@ public static Uri ActionsWorkflowRunPendingDeployments(string owner, string repo /// <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); + return "repos/{0}/{1}/actions/workflows/{2}/runs".FormatUri(owner, repo, workflowId); } /// <summary> @@ -5134,7 +5134,7 @@ public static Uri ActionsListWorkflowRuns(string owner, string repo, long workfl /// <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()); + return "repos/{0}/{1}/actions/workflows/{2}/runs".FormatUri(owner, repo, workflowFileName.UriEncode()); } } } From 64614ce1d3ec38244314296fc1f1fd7b3fb0799d Mon Sep 17 00:00:00 2001 From: Zero-Point-Three Mach <45490638+Move2win@users.noreply.github.com> Date: Thu, 1 Dec 2022 18:56:06 -0500 Subject: [PATCH 157/209] Fix #2618 - Improve docs for the 'release' chapter (#2628) Fix sample code and add 'get latest' section 1. Fix the sample code for "Get All" not working. 2. Add the "Get Latest" section. --- docs/releases.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/releases.md b/docs/releases.md index 3d92c78e44..0f9a893866 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -6,7 +6,20 @@ To retrieve all releases for a repository: ```csharp var releases = await client.Repository.Release.GetAll("octokit", "octokit.net"); -var latest = releases[0]; +var latest = releases.Result.ElementAt(0); +Console.WriteLine( + "The latest release is tagged at {0} and is named {1}", + latest.TagName, + latest.Name); +``` + +### Get Latest + +To retrieve the latest release for a repository: + +```csharp +var releases = await client.Repository.Release.GetLatest("octokit", "octokit.net"); +var latest = releases.Result; Console.WriteLine( "The latest release is tagged at {0} and is named {1}", latest.TagName, From 0475f084f08e13e4412a7dd3a56d353785610e2c Mon Sep 17 00:00:00 2001 From: Matisse Hack <matissehack@github.com> Date: Thu, 1 Dec 2022 16:38:54 -0800 Subject: [PATCH 158/209] Add missing properties for meta and app payloads (#2625) * Add missing properties for meta and app payloads * Update test with actual value instead of null Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- Octokit.Tests/Clients/MetaClientTests.cs | 3 +- .../Clients/MiscellaneousClientTests.cs | 3 +- Octokit/Models/Response/GitHubApp.cs | 15 +- .../Response/InstallationPermissions.cs | 215 ++++++++++++++---- Octokit/Models/Response/Meta.cs | 12 +- 5 files changed, 203 insertions(+), 45 deletions(-) diff --git a/Octokit.Tests/Clients/MetaClientTests.cs b/Octokit.Tests/Clients/MetaClientTests.cs index 9e5b5b584b..f033b411d2 100644 --- a/Octokit.Tests/Clients/MetaClientTests.cs +++ b/Octokit.Tests/Clients/MetaClientTests.cs @@ -23,7 +23,8 @@ public async Task RequestsTheMetadataEndpoint() new[] { "1.1.6.1/24", "1.1.6.2/24" }, new[] { "1.1.7.1", "1.1.7.2" }, new[] { "1.1.8.1/24", "1.1.8.2/24" }, - new[] { "1.1.9.1", "1.1.9.2" } + new[] { "1.1.9.1", "1.1.9.2" }, + "3.7.0" ); diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index c7a974f63e..7a184d02da 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -156,7 +156,8 @@ public async Task RequestsTheMetadataEndpoint() new[] { "1.1.6.1/24", "1.1.6.2/24" }, new[] { "1.1.7.1", "1.1.7.2" }, new[] { "1.1.8.1/24", "1.1.8.2/24" }, - new[] { "1.1.9.1", "1.1.9.2" } + new[] { "1.1.9.1", "1.1.9.2" }, + "3.7.0" ); var apiConnection = Substitute.For<IApiConnection>(); diff --git a/Octokit/Models/Response/GitHubApp.cs b/Octokit/Models/Response/GitHubApp.cs index d511450340..f1dbc49c70 100644 --- a/Octokit/Models/Response/GitHubApp.cs +++ b/Octokit/Models/Response/GitHubApp.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -12,7 +13,7 @@ public class GitHubApp { public GitHubApp() { } - public GitHubApp(long id, string slug, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt) + public GitHubApp(long id, string slug, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, InstallationPermissions permissions, IReadOnlyList<string> events) { Id = id; Slug = slug; @@ -23,6 +24,8 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti HtmlUrl = htmlUrl; CreatedAt = createdAt; UpdatedAt = updatedAt; + Permissions = permissions; + Events = events; } /// <summary> @@ -70,6 +73,16 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti /// </summary> public DateTimeOffset UpdatedAt { get; private set; } + /// <summary> + /// The Permissions granted to the Installation + /// </summary> + public InstallationPermissions Permissions { get; private set; } + + /// <summary> + /// The Events subscribed to by the Installation + /// </summary> + public IReadOnlyList<string> Events { get; private set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} Name: {1}", Id, Name); } diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index fb407f4943..b45fe0bab2 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -9,111 +9,246 @@ public class InstallationPermissions { public InstallationPermissions() { } - public InstallationPermissions(InstallationPermissionLevel? metadata, InstallationPermissionLevel? administration, InstallationPermissionLevel? statuses, InstallationPermissionLevel? deployments, InstallationPermissionLevel? issues, InstallationPermissionLevel? pages, InstallationPermissionLevel? pullRequests, InstallationPermissionLevel? contents, InstallationPermissionLevel? singleFile, InstallationPermissionLevel? repositoryProjects, InstallationPermissionLevel? members, InstallationPermissionLevel? organizationProjects, InstallationPermissionLevel? teamDiscussions, InstallationPermissionLevel? checks) + public InstallationPermissions + ( + InstallationPermissionLevel? actions, + InstallationPermissionLevel? administration, + InstallationPermissionLevel? checks, + InstallationPermissionLevel? contents, + InstallationPermissionLevel? deployments, + InstallationPermissionLevel? environments, + InstallationPermissionLevel? issues, + InstallationPermissionLevel? metadata, + InstallationPermissionLevel? packages, + InstallationPermissionLevel? pages, + InstallationPermissionLevel? pullRequests, + InstallationPermissionLevel? repositoryAnnouncementBanners, + InstallationPermissionLevel? repositoryHooks, + InstallationPermissionLevel? repositoryProjects, + InstallationPermissionLevel? secretScanningAlerts, + InstallationPermissionLevel? secrets, + InstallationPermissionLevel? securityEvents, + InstallationPermissionLevel? singleFile, + InstallationPermissionLevel? statuses, + InstallationPermissionLevel? vulnerabilityAlerts, + InstallationPermissionLevel? workflows, + InstallationPermissionLevel? members, + InstallationPermissionLevel? organizationAdministration, + InstallationPermissionLevel? organizationCustomRoles, + InstallationPermissionLevel? organizationAnnouncementBanners, + InstallationPermissionLevel? organizationHooks, + InstallationPermissionLevel? organizationPlan, + InstallationPermissionLevel? organizationProjects, + InstallationPermissionLevel? organizationPackages, + InstallationPermissionLevel? organizationSecrets, + InstallationPermissionLevel? organizationSelfHostedRunners, + InstallationPermissionLevel? organizationUserBlocking, + InstallationPermissionLevel? teamDiscussions + ) { - Metadata = metadata; + Actions = actions; Administration = administration; - Statuses = statuses; + Checks = checks; + Contents = contents; Deployments = deployments; + Environments = environments; Issues = issues; + Metadata = metadata; + Packages = packages; Pages = pages; PullRequests = pullRequests; - Contents = contents; - SingleFile = singleFile; + RepositoryAnnouncementBanners = repositoryAnnouncementBanners; + RepositoryHooks = repositoryHooks; RepositoryProjects = repositoryProjects; + SecretScanningAlerts = secretScanningAlerts; + Secrets = secrets; + SecurityEvents = securityEvents; + SingleFile = singleFile; + Statuses = statuses; + VulnerabilityAlerts = vulnerabilityAlerts; + Workflows = workflows; Members = members; + OrganizationAdministration = organizationAdministration; + OrganizationCustomRoles = organizationCustomRoles; + OrganizationAnnouncementBanners = organizationAnnouncementBanners; + OrganizationHooks = organizationHooks; + OrganizationPlan = organizationPlan; OrganizationProjects = organizationProjects; + OrganizationPackages = organizationPackages; + OrganizationSecrets = organizationSecrets; + OrganizationSelfHostedRunners = organizationSelfHostedRunners; + OrganizationUserBlocking = organizationUserBlocking; TeamDiscussions = teamDiscussions; - Checks = checks; } /// <summary> - /// Repository metadata - /// Search repositories, list collaborators, and access repository metadata. + /// The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. /// </summary> - public StringEnum<InstallationPermissionLevel>? Metadata { get; private set; } + public StringEnum<InstallationPermissionLevel>? Actions { get; private set; } /// <summary> - /// Repository administration - /// Repository creation, deletion, settings, teams, and collaborators. + /// The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation. /// </summary> public StringEnum<InstallationPermissionLevel>? Administration { get; private set; } /// <summary> - /// Commit statuses - /// Commit statuses. + /// The level of permission to grant the access token for checks on code. /// </summary> - public StringEnum<InstallationPermissionLevel>? Statuses { get; private set; } + public StringEnum<InstallationPermissionLevel>? Checks { get; private set; } + + /// <summary> + /// The level of permission to grant the access token for repository contents, commits, branches, downloads, releases, and merges. + /// </summary> + public StringEnum<InstallationPermissionLevel>? Contents { get; private set; } /// <summary> - /// Deployments - /// Deployments and deployment statuses. + /// The level of permission to grant the access token for deployments and deployment statuses. /// </summary> public StringEnum<InstallationPermissionLevel>? Deployments { get; private set; } /// <summary> - /// Issues - /// Issues and related comments, assignees, labels, and milestones. + /// The level of permission to grant the access token for managing repository environments. + /// </summary> + public StringEnum<InstallationPermissionLevel>? Environments { get; private set; } + + /// <summary> + /// The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones. /// </summary> public StringEnum<InstallationPermissionLevel>? Issues { get; private set; } /// <summary> - /// Pages - /// Retrieve Pages statuses, configuration, and builds, as well as create new builds. + /// The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata. + /// </summary> + public StringEnum<InstallationPermissionLevel>? Metadata { get; private set; } + + /// <summary> + /// The level of permission to grant the access token for packages published to GitHub Packages. + /// </summary> + public StringEnum<InstallationPermissionLevel>? Packages { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to retrieve Pages statuses, configuration, and builds, as well as create new builds. /// </summary> public StringEnum<InstallationPermissionLevel>? Pages { get; private set; } /// <summary> - /// Pull requests - /// Pull requests and related comments, assignees, labels, milestones, and merges. + /// The level of permission to grant the access token for pull requests and related comments, assignees, labels, milestones, and merges. /// </summary> public StringEnum<InstallationPermissionLevel>? PullRequests { get; private set; } /// <summary> - /// Repository contents - /// Repository contents, commits, branches, downloads, releases, and merges. + /// The level of permission to grant the access token to view and manage announcement banners for a repository. /// </summary> - public StringEnum<InstallationPermissionLevel>? Contents { get; private set; } + public StringEnum<InstallationPermissionLevel>? RepositoryAnnouncementBanners { get; private set; } /// <summary> - /// Single file - /// Manage just a single file. + /// The level of permission to grant the access token to manage the post-receive hooks for a repository. /// </summary> - public StringEnum<InstallationPermissionLevel>? SingleFile { get; private set; } + public StringEnum<InstallationPermissionLevel>? RepositoryHooks { get; private set; } /// <summary> - /// Repository projects - /// Manage repository projects, columns, and cards. + /// The level of permission to grant the access token to manage repository projects, columns, and cards. /// </summary> public StringEnum<InstallationPermissionLevel>? RepositoryProjects { get; private set; } /// <summary> - /// Checks - /// Detailed information about CI checks + /// The level of permission to grant the access token to view and manage secret scanning alerts. /// </summary> - public StringEnum<InstallationPermissionLevel>? Checks { get; private set; } + public StringEnum<InstallationPermissionLevel>? SecretScanningAlerts { get; private set; } /// <summary> - /// Organization members (only applicable when installed for an Organization ) - /// Organization members and teams. + /// The level of permission to grant the access token to manage repository secrets. + /// </summary> + public StringEnum<InstallationPermissionLevel>? Secrets { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to view and manage security events like code scanning alerts. + /// </summary> + public StringEnum<InstallationPermissionLevel>? SecurityEvents { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to manage just a single file. + /// </summary> + public StringEnum<InstallationPermissionLevel>? SingleFile { get; private set; } + + /// <summary> + /// The level of permission to grant the access token for commit statuses. + /// </summary> + public StringEnum<InstallationPermissionLevel>? Statuses { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to manage Dependabot alerts. + /// </summary> + public StringEnum<InstallationPermissionLevel>? VulnerabilityAlerts { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to update GitHub Actions workflow files. + /// </summary> + public StringEnum<InstallationPermissionLevel>? Workflows { get; private set; } + + /// <summary> + /// The level of permission to grant the access token for organization teams and members. /// </summary> public StringEnum<InstallationPermissionLevel>? Members { get; private set; } /// <summary> - /// Organization projects (only applicable when installed for an Organization ) - /// Manage organization projects, columns, and cards. + /// The level of permission to grant the access token to manage access to an organization. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationAdministration { get; private set; } + + /// <summary> + /// The level of permission to grant the access token for custom roles management. This property is in beta and is subject to change. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationCustomRoles { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to view and manage announcement banners for an organization. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationAnnouncementBanners { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to manage the post-receive hooks for an organization. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationHooks { get; private set; } + + /// <summary> + /// The level of permission to grant the access token for viewing an organization's plan. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationPlan { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to manage organization projects and projects beta (where available). /// </summary> public StringEnum<InstallationPermissionLevel>? OrganizationProjects { get; private set; } /// <summary> - /// Team discussions (only applicable when installed for an Organization ) - /// Team discussions. + /// The level of permission to grant the access token for organization packages published to GitHub Packages. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationPackages { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to manage organization secrets. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationSecrets { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to view and manage GitHub Actions self-hosted runners available to an organization. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationSelfHostedRunners { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to view and manage users blocked by the organization. + /// </summary> + public StringEnum<InstallationPermissionLevel>? OrganizationUserBlocking { get; private set; } + + /// <summary> + /// The level of permission to grant the access token to manage team discussions and related comments. /// </summary> public StringEnum<InstallationPermissionLevel>? TeamDiscussions { get; private set; } internal string DebuggerDisplay { - get { return string.Format(CultureInfo.InvariantCulture, "Metadata: {0}, Contents: {1}, Issues: {2}, Single File: {3}", Metadata, Contents, Issues, SingleFile); } + get => $"Actions: {Actions}, Administration: {Administration}, Checks: {Checks}, Contents: {Contents}, Deployments: {Deployments}, Environments: {Environments}, Issues: {Issues}, Metadata: {Metadata}, Packages: {Packages}, Pages: {Pages}, PullRequests: {PullRequests}, RepositoryAnnouncementBanners: {RepositoryAnnouncementBanners}, RepositoryHooks: {RepositoryHooks}, RepositoryProjects: {RepositoryProjects}, SecretScanningAlerts: {SecretScanningAlerts}, Secrets: {Secrets}, SecurityEvents: {SecurityEvents}, SingleFile: {SingleFile}, Statuses: {Statuses}, VulnerabilityAlerts: {VulnerabilityAlerts}, Workflows: {Workflows}, Members: {Members}, OrganizationAdministration: {OrganizationAdministration}, OrganizationCustomRoles: {OrganizationCustomRoles}, OrganizationAnnouncementBanners: {OrganizationAnnouncementBanners}, OrganizationHooks: {OrganizationHooks}, OrganizationPlan: {OrganizationPlan}, OrganizationProjects: {OrganizationProjects}, OrganizationPackages: {OrganizationPackages}, OrganizationSecrets: {OrganizationSecrets}, OrganizationSelfHostedRunners: {OrganizationSelfHostedRunners}, OrganizationUserBlocking: {OrganizationUserBlocking}, TeamDiscussions: {TeamDiscussions}"; } } diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index a5a8a644b4..97b630fed5 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -7,7 +7,7 @@ namespace Octokit { /// <summary> - /// Response from the /meta endpoint that provides information about GitHub.com or a GitHub Enterprise instance. + /// Response from the /meta endpoint that provides information about GitHub.com or a GitHub Enterprise instance. /// </summary> [DebuggerDisplay("{DebuggerDisplay,nq}")] public class Meta @@ -33,6 +33,7 @@ public Meta() /// <param name="importer">An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com.</param> /// <param name="actions">An array of IP addresses in CIDR format specifying the Actions servers for GitHub</param> /// <param name="dependabot">An array of IP addresses in CIDR format specifying the Dependabot servers for GitHub</param> + /// <param name="installedVersion">The installed version of GitHub Enterprise Server</param> public Meta( bool verifiablePasswordAuthentication, string gitHubServicesSha, @@ -44,7 +45,8 @@ public Meta( IReadOnlyList<string> pages, IReadOnlyList<string> importer, IReadOnlyList<string> actions, - IReadOnlyList<string> dependabot) + IReadOnlyList<string> dependabot, + string installedVersion) { VerifiablePasswordAuthentication = verifiablePasswordAuthentication; #pragma warning disable CS0618 // Type or member is obsolete @@ -59,6 +61,7 @@ public Meta( Importer = importer; Actions = actions; Dependabot = dependabot; + InstalledVersion = installedVersion; } /// <summary> @@ -124,6 +127,11 @@ public Meta( /// </summary> public IReadOnlyList<string> Dependabot { get; private set; } + /// <summary> + /// The installed version of GitHub Enterprise Server. + /// </summary> + public string InstalledVersion { get; private set; } + internal string DebuggerDisplay { get From 0f693adce7aef393632909a60fe764287e3b6410 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Fri, 2 Dec 2022 14:19:29 -0600 Subject: [PATCH 159/209] [MAINT] Updates the stale action to use the new status labels --- .github/workflows/stale.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index cfd0143c32..bef0f316e2 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -25,3 +25,6 @@ jobs: days-before-close: 7 exempt-issue-labels: 'Status: Pinned' exempt-pr-labels: 'Status: Pinned' + operations-per-run: 100 + stale-issue-label: 'Status: Stale' + stale-pr-label: 'Status: Stale' From 826539e50fd53dfa2d7e6bc4e09671a758d3ccd6 Mon Sep 17 00:00:00 2001 From: GitHub Action <octokit@github.com> Date: Tue, 6 Dec 2022 14:58:54 +0000 Subject: [PATCH 160/209] Github Agent | Workflow has updated --- .github/workflows/add_to_octokit_project.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/add_to_octokit_project.yml diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml new file mode 100644 index 0000000000..4b06e1300c --- /dev/null +++ b/.github/workflows/add_to_octokit_project.yml @@ -0,0 +1,19 @@ +name: Add PRs and issues to Octokit org project + +on: + issues: + types: [reopened, opened] + pull_request: + types: [reopened, opened] + +jobs: + add-to-project: + name: Add issue to project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@latest + with: + project-url: https://github.com/orgs/octokit/projects/10 + github-token: ${{ secrets.OCTOKITBOT_PAT }} + labeled: 'Status: Stale' + label-operator: NOT From 45ec41eb4d413e5146a9e41c04462ee4365ca87e Mon Sep 17 00:00:00 2001 From: GitHub Action <octokit@github.com> Date: Tue, 6 Dec 2022 15:03:16 +0000 Subject: [PATCH 161/209] Github Agent | Workflow has updated --- .github/workflows/add_to_octokit_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml index 4b06e1300c..444a8bd8b0 100644 --- a/.github/workflows/add_to_octokit_project.yml +++ b/.github/workflows/add_to_octokit_project.yml @@ -11,7 +11,7 @@ jobs: name: Add issue to project runs-on: ubuntu-latest steps: - - uses: actions/add-to-project@latest + - uses: actions/add-to-project@v1 with: project-url: https://github.com/orgs/octokit/projects/10 github-token: ${{ secrets.OCTOKITBOT_PAT }} From 5b8f3b169ff64236fe4c196df4b9c5ddf8ac25e6 Mon Sep 17 00:00:00 2001 From: GitHub Action <octokit@github.com> Date: Tue, 6 Dec 2022 15:07:13 +0000 Subject: [PATCH 162/209] Github Agent | Workflow has updated --- .github/workflows/add_to_octokit_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml index 444a8bd8b0..6608a41914 100644 --- a/.github/workflows/add_to_octokit_project.yml +++ b/.github/workflows/add_to_octokit_project.yml @@ -11,7 +11,7 @@ jobs: name: Add issue to project runs-on: ubuntu-latest steps: - - uses: actions/add-to-project@v1 + - uses: actions/add-to-project@v0.4.0 with: project-url: https://github.com/orgs/octokit/projects/10 github-token: ${{ secrets.OCTOKITBOT_PAT }} From bf740bbdd1c350ff0ccce883e53dcdbef1568516 Mon Sep 17 00:00:00 2001 From: GitHub Action <octokit@github.com> Date: Tue, 6 Dec 2022 15:10:28 +0000 Subject: [PATCH 163/209] Github Agent | Workflow has updated --- .github/workflows/add_to_octokit_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml index 6608a41914..63c3338b79 100644 --- a/.github/workflows/add_to_octokit_project.yml +++ b/.github/workflows/add_to_octokit_project.yml @@ -14,6 +14,6 @@ jobs: - uses: actions/add-to-project@v0.4.0 with: project-url: https://github.com/orgs/octokit/projects/10 - github-token: ${{ secrets.OCTOKITBOT_PAT }} + github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN }} labeled: 'Status: Stale' label-operator: NOT From 84d44dc5667f9a6f31fb725148dbbb2c70945ab1 Mon Sep 17 00:00:00 2001 From: Zachary Cook <58912675+zacdirect@users.noreply.github.com> Date: Thu, 8 Dec 2022 08:27:50 -0600 Subject: [PATCH 164/209] [FEAT] Adds support listing branch/pr per commit --- .../IObservableRepositoryCommitsClients.cs | 64 ++++++ .../ObservableRepositoryCommitsClients.cs | 112 ++++++++++ .../Clients/RespositoryCommitsClientTests.cs | 58 +++++ .../ObservableRepositoryCommitsClientTests.cs | 68 ++++++ Octokit/Clients/IRepositoryCommitsClient.cs | 64 ++++++ Octokit/Clients/RepositoryCommitsClient.cs | 112 ++++++++++ Octokit/Helpers/ApiUrls.cs | 47 +++++ Octokit/Models/Response/CommitPullRequest.cs | 199 ++++++++++++++++++ 8 files changed, 724 insertions(+) create mode 100644 Octokit/Models/Response/CommitPullRequest.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs index 1766057678..f9b2c95c0e 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs @@ -11,6 +11,38 @@ namespace Octokit.Reactive /// </remarks> public interface IObservableRepositoryCommitsClient { + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + IObservable<Branch> BranchesWhereHead(long repositoryId, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + IObservable<Branch> BranchesWhereHead(long repositoryId, string sha1, ApiOptions options); + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + IObservable<Branch> BranchesWhereHead(string owner, string name, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + IObservable<Branch> BranchesWhereHead(string owner, string name, string sha1, ApiOptions options); + /// <summary> /// Compare two references in a repository /// </summary> @@ -123,5 +155,37 @@ public interface IObservableRepositoryCommitsClient /// <param name="repositoryId">The Id of the repository</param> /// <param name="reference">The repository reference</param> IObservable<string> GetSha1(long repositoryId, string reference); + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + IObservable<CommitPullRequest> PullRequests(string owner, string name, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + IObservable<CommitPullRequest> PullRequests(long repositoryId, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + IObservable<CommitPullRequest> PullRequests(long repositoryId, string sha1, ApiOptions options); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + IObservable<CommitPullRequest> PullRequests(string owner, string name, string sha1, ApiOptions options); } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs index 121bf5b4e4..a2f6ad73ff 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs @@ -23,6 +23,62 @@ public ObservableRepositoryCommitsClient(IGitHubClient client) _commit = client.Repository.Commit; } + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/branches-where-head")] + public IObservable<Branch> BranchesWhereHead(long repositoryId, string sha1) + { + return BranchesWhereHead(repositoryId, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/branches-where-head")] + public IObservable<Branch> BranchesWhereHead(long repositoryId, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<Branch>(ApiUrls.RepositoryCommitsBranchesWhereHead(repositoryId, sha1), null, options); + } + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head")] + public IObservable<Branch> BranchesWhereHead(string owner, string name, string sha1) + { + return BranchesWhereHead(owner, name, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head")] + public IObservable<Branch> BranchesWhereHead(string owner, string name, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<Branch>(ApiUrls.RepositoryCommitsBranchesWhereHead(owner, name, sha1), null, options); + } + /// <summary> /// Compare two references in a repository /// </summary> @@ -214,5 +270,61 @@ public IObservable<string> GetSha1(long repositoryId, string reference) return _commit.GetSha1(repositoryId, reference).ToObservable(); } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/pulls")] + public IObservable<CommitPullRequest> PullRequests(long repositoryId, string sha1) + { + return PullRequests(repositoryId, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/pulls")] + public IObservable<CommitPullRequest> PullRequests(long repositoryId, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<CommitPullRequest>(ApiUrls.RepositoryCommitsPull(repositoryId, sha1), null, options); + } + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/pulls")] + public IObservable<CommitPullRequest> PullRequests(string owner, string name, string sha1) + { + return PullRequests(owner, name, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/pulls")] + public IObservable<CommitPullRequest> PullRequests(string owner, string name, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return _connection.GetAndFlattenAllPages<CommitPullRequest>(ApiUrls.RepositoryCommitsPull(owner, name, sha1), null, options); + } } } diff --git a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs index 3e235c4e96..c75fe1d919 100644 --- a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs +++ b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs @@ -350,5 +350,63 @@ public async Task EnsuresNonNullArguments() await Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1(1, "")); } } + + public class ThePullRequestsMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoryCommitsClient(connection); + var options = new ApiOptions + { + PageCount = 1, + StartPage = 1, + PageSize = 1 + }; + + await client.PullRequests("fake", "repo", "ref", options); + + connection.Received().GetAll<CommitPullRequest>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/pulls"), + null, options); + } + + [Fact] + public async Task RequestsCorrectUrlWithRepositoryId() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoryCommitsClient(connection); + var options = new ApiOptions + { + PageCount = 1, + StartPage = 1, + PageSize = 1 + }; + + await client.PullRequests(1, "ref", options); + + connection.Received().GetAll<CommitPullRequest>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref/pulls"), + null, options); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new RepositoryCommitsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.PullRequests(null, "name", "ref")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.PullRequests("owner", null, "ref")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.PullRequests("owner", "name", null)); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.PullRequests(1, null)); + + await Assert.ThrowsAsync<ArgumentException>(() => client.PullRequests("", "name", "ref")); + await Assert.ThrowsAsync<ArgumentException>(() => client.PullRequests("owner", "", "ref")); + await Assert.ThrowsAsync<ArgumentException>(() => client.PullRequests("owner", "name", "")); + + await Assert.ThrowsAsync<ArgumentException>(() => client.PullRequests(1, "")); + } + } } } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs index 3aaec54682..841ef7b9e6 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs @@ -98,5 +98,73 @@ public async Task GetsCorrectUrl() .GetAll(1); } } + + public class ThePullRequestsMethod + { + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ObservableRepositoryCommitsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.PullRequests("", "name", "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.PullRequests("owner", "", "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.PullRequests("owner", "name", "").ToTask()); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositoryCommitsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.PullRequests(null, "name", "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.PullRequests("owner", null, "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.PullRequests("owner", "name", null).ToTask()); + } + + [Fact] + public void GetsCorrectUrl() + { + var githubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + + client.PullRequests("fake", "repo", "reference", options); + githubClient.Received().Repository.Commit.PullRequests("fake", "repo", "reference", options); + } + } + + public class TheBranchesWhereHeadMethod + { + [Fact] + public async Task EnsuresNonEmptyArguments() + { + var client = new ObservableRepositoryCommitsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentException>(() => client.BranchesWhereHead("", "name", "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.BranchesWhereHead("owner", "", "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentException>(() => client.BranchesWhereHead("owner", "name", "").ToTask()); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableRepositoryCommitsClient(Substitute.For<IGitHubClient>()); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.BranchesWhereHead(null, "name", "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.BranchesWhereHead("owner", null, "reference").ToTask()); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.BranchesWhereHead("owner", "name", null).ToTask()); + } + + [Fact] + public void GetsCorrectUrl() + { + var githubClient = Substitute.For<IGitHubClient>(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + + client.BranchesWhereHead("fake", "repo", "reference", options); + githubClient.Received().Repository.Commit.BranchesWhereHead("fake", "repo", "reference", options); + } + } } } diff --git a/Octokit/Clients/IRepositoryCommitsClient.cs b/Octokit/Clients/IRepositoryCommitsClient.cs index dffa3a8dab..c91f8542b3 100644 --- a/Octokit/Clients/IRepositoryCommitsClient.cs +++ b/Octokit/Clients/IRepositoryCommitsClient.cs @@ -12,6 +12,38 @@ namespace Octokit /// </remarks> public interface IRepositoryCommitsClient { + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + Task<IReadOnlyList<Branch>> BranchesWhereHead(long repositoryId, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + Task<IReadOnlyList<Branch>> BranchesWhereHead(long repositoryId, string sha1, ApiOptions options); + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + Task<IReadOnlyList<Branch>> BranchesWhereHead(string owner, string name, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + Task<IReadOnlyList<Branch>> BranchesWhereHead(string owner, string name, string sha1, ApiOptions options); + /// <summary> /// Compare two references in a repository /// </summary> @@ -124,5 +156,37 @@ public interface IRepositoryCommitsClient /// <param name="repositoryId">The Id of the repository</param> /// <param name="reference">The repository reference</param> Task<string> GetSha1(long repositoryId, string reference); + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + Task<IReadOnlyList<CommitPullRequest>> PullRequests(string owner, string name, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + Task<IReadOnlyList<CommitPullRequest>> PullRequests(long repositoryId, string sha1); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + Task<IReadOnlyList<CommitPullRequest>> PullRequests(long repositoryId, string sha1, ApiOptions options); + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + Task<IReadOnlyList<CommitPullRequest>> PullRequests(string owner, string name, string sha1, ApiOptions options); } } diff --git a/Octokit/Clients/RepositoryCommitsClient.cs b/Octokit/Clients/RepositoryCommitsClient.cs index 8f03bdc7a9..bf32ea4e68 100644 --- a/Octokit/Clients/RepositoryCommitsClient.cs +++ b/Octokit/Clients/RepositoryCommitsClient.cs @@ -16,6 +16,62 @@ public RepositoryCommitsClient(IApiConnection apiConnection) { } + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/branches-where-head")] + public Task<IReadOnlyList<Branch>> BranchesWhereHead(long repositoryId, string sha1) + { + return BranchesWhereHead(repositoryId, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/branches-where-head")] + public Task<IReadOnlyList<Branch>> BranchesWhereHead(long repositoryId, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll<Branch>(ApiUrls.RepositoryCommitsBranchesWhereHead(repositoryId, sha1), null, options); + } + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head")] + public Task<IReadOnlyList<Branch>> BranchesWhereHead(string owner, string name, string sha1) + { + return BranchesWhereHead(owner, name, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all branches where the given commit SHA is the HEAD, or latest commit for the branch</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head")] + public Task<IReadOnlyList<Branch>> BranchesWhereHead(string owner, string name, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll<Branch>(ApiUrls.RepositoryCommitsBranchesWhereHead(owner, name, sha1), null, options); + } + /// <summary> /// Compare two references in a repository /// </summary> @@ -218,5 +274,61 @@ public Task<string> GetSha1(long repositoryId, string reference) return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(repositoryId, reference), null); } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/pulls")] + public Task<IReadOnlyList<CommitPullRequest>> PullRequests(long repositoryId, string sha1) + { + return PullRequests(repositoryId, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repositories/{id}/commits/{commit_sha}/pulls")] + public Task<IReadOnlyList<CommitPullRequest>> PullRequests(long repositoryId, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll<CommitPullRequest>(ApiUrls.RepositoryCommitsPull(repositoryId, sha1), null, options); + } + + /// <summary> + /// List pull requests associated with a commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/pulls")] + public Task<IReadOnlyList<CommitPullRequest>> PullRequests(string owner, string name, string sha1) + { + return PullRequests(owner, name, sha1, ApiOptions.None); + } + + /// <summary> + /// Gets all pull requests for a given commit + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="sha1">Used to find all pull requests containing the provided commit SHA, which can be from any point in the commit history</param> + /// /// <param name="options">Options for changing the API response</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/commits/{commit_sha}/pulls")] + public Task<IReadOnlyList<CommitPullRequest>> PullRequests(string owner, string name, string sha1, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(sha1, nameof(sha1)); + Ensure.ArgumentNotNull(options, nameof(options)); + + return ApiConnection.GetAll<CommitPullRequest>(ApiUrls.RepositoryCommitsPull(owner, name, sha1), null, options); + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 9bff25de4b..7a4613b3c1 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2209,6 +2209,53 @@ public static Uri RepositoryCommits(string owner, string name) return "repos/{0}/{1}/commits".FormatUri(owner, name); } + ///repos/{owner}/{repo}/commits/{commit_sha}/ + /// <summary> + /// Returns the <see cref="Uri"/> that lists all branches where the given commit SHA is the HEAD, or latest commit for the branch. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="reference">The commit reference (SHA)</param> + /// <returns></returns> + public static Uri RepositoryCommitsBranchesWhereHead(string owner, string name, string reference) + { + return "repos/{0}/{1}/commits/{2}/branches-where-head".FormatUri(owner, name, reference); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that lists all branches where the given commit SHA is the HEAD, or latest commit for the branch. + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="reference">The commit reference (SHA)</param> + /// <returns></returns> + public static Uri RepositoryCommitsBranchesWhereHead(long repositoryId, string reference) + { + return "repositories/{0}/commits/{1}/branches-where-head".FormatUri(repositoryId, reference); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that lists the check suites for the specified reference. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="reference">The commit reference (SHA)</param> + /// <returns></returns> + public static Uri RepositoryCommitsPull(string owner, string name, string reference) + { + return "repos/{0}/{1}/commits/{2}/pulls".FormatUri(owner, name, reference); + } + + /// <summary> + /// Returns the <see cref="Uri"/> that lists the check suites for the specified reference. + /// </summary> + /// <param name="repositoryId">The Id of the repository</param> + /// <param name="reference">The commit reference (SHA)</param> + /// <returns></returns> + public static Uri RepositoryCommitsPull(long repositoryId, string reference) + { + return "repositories/{0}/commits/{1}/pulls".FormatUri(repositoryId, reference); + } + /// <summary> /// Returns the <see cref="Uri"/> for comparing two commits. /// </summary> diff --git a/Octokit/Models/Response/CommitPullRequest.cs b/Octokit/Models/Response/CommitPullRequest.cs new file mode 100644 index 0000000000..eb011fb4ba --- /dev/null +++ b/Octokit/Models/Response/CommitPullRequest.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using Octokit.Internal; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class CommitPullRequest + { + public CommitPullRequest() { } + + public CommitPullRequest(int number) + { + Number = number; + } + + public CommitPullRequest(long id, string nodeId, string url, string htmlUrl, string diffUrl, string patchUrl, string issueUrl, string statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, IReadOnlyList<User> assignees, bool draft, bool? mergeable, MergeableState? mergeableState, User mergedBy, string mergeCommitSha, Milestone milestone, IReadOnlyList<User> requestedReviewers, IReadOnlyList<Team> requestedTeams, IReadOnlyList<Label> labels) + { + Id = id; + NodeId = nodeId; + Url = url; + HtmlUrl = htmlUrl; + DiffUrl = diffUrl; + PatchUrl = patchUrl; + IssueUrl = issueUrl; + StatusesUrl = statusesUrl; + Number = number; + State = state; + Title = title; + Body = body; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + ClosedAt = closedAt; + MergedAt = mergedAt; + Head = head; + Base = @base; + User = user; + Assignee = assignee; + Assignees = assignees; + Draft = draft; + MergeCommitSha = mergeCommitSha; + Milestone = milestone; + RequestedReviewers = requestedReviewers; + RequestedTeams = requestedTeams; + Labels = labels; + } + + /// <summary> + /// The internal Id for this pull request (not the pull request number) + /// </summary> + public long Id { get; protected set; } + + /// <summary> + /// GraphQL Node Id + /// </summary> + public string NodeId { get; protected set; } + + /// <summary> + /// The URL for this pull request. + /// </summary> + public string Url { get; protected set; } + + /// <summary> + /// The URL for the pull request page. + /// </summary> + public string HtmlUrl { get; protected set; } + + /// <summary> + /// The URL for the pull request's diff (.diff) file. + /// </summary> + public string DiffUrl { get; protected set; } + + /// <summary> + /// The URL for the pull request's patch (.patch) file. + /// </summary> + public string PatchUrl { get; protected set; } + + /// <summary> + /// The URL for the specific pull request issue. + /// </summary> + public string IssueUrl { get; protected set; } + + /// <summary> + /// The URL for the pull request statuses. + /// </summary> + public string StatusesUrl { get; protected set; } + + /// <summary> + /// The pull request number. + /// </summary> + public int Number { get; protected set; } + + /// <summary> + /// Whether the pull request is open or closed. The default is <see cref="ItemState.Open"/>. + /// </summary> + public StringEnum<ItemState> State { get; protected set; } + + /// <summary> + /// Title of the pull request. + /// </summary> + public string Title { get; protected set; } + + /// <summary> + /// The body (content) contained within the pull request. + /// </summary> + public string Body { get; protected set; } + + /// <summary> + /// When the pull request was created. + /// </summary> + public DateTimeOffset CreatedAt { get; protected set; } + + /// <summary> + /// When the pull request was last updated. + /// </summary> + public DateTimeOffset UpdatedAt { get; protected set; } + + /// <summary> + /// When the pull request was closed. + /// </summary> + public DateTimeOffset? ClosedAt { get; protected set; } + + /// <summary> + /// When the pull request was merged. + /// </summary> + public DateTimeOffset? MergedAt { get; protected set; } + + /// <summary> + /// The HEAD reference for the pull request. + /// </summary> + public GitReference Head { get; protected set; } + + /// <summary> + /// The BASE reference for the pull request. + /// </summary> + public GitReference Base { get; protected set; } + + /// <summary> + /// The user who created the pull request. + /// </summary> + public User User { get; protected set; } + + /// <summary> + /// The user who is assigned the pull request. + /// </summary> + public User Assignee { get; protected set; } + + /// <summary> + ///The multiple users this pull request is assigned to. + /// </summary> + public IReadOnlyList<User> Assignees { get; protected set; } + + /// <summary> + /// The milestone, if any, that this pull request is assigned to. + /// </summary> + public Milestone Milestone { get; protected set; } + + /// <summary> + /// Whether or not the pull request is in a draft state, and cannot be merged. + /// </summary> + public bool Draft { get; protected set; } + + /// <summary> + /// Whether or not the pull request has been merged. + /// </summary> + public bool Merged + { + get { return MergedAt.HasValue; } + } + + /// <summary> + /// The value of this field changes depending on the state of the pull request. + /// Not Merged - the hash of the test commit used to determine mergeability. + /// Merged with merge commit - the hash of said merge commit. + /// Merged via squashing - the hash of the squashed commit added to the base branch. + /// Merged via rebase - the hash of the commit that the base branch was updated to. + /// </summary> + public string MergeCommitSha { get; protected set; } + + /// <summary> + /// Users requested for review + /// </summary> + public IReadOnlyList<User> RequestedReviewers { get; protected set; } + + /// <summary> + /// Teams requested for review + /// </summary> + public IReadOnlyList<Team> RequestedTeams { get; protected set; } + + public IReadOnlyList<Label> Labels { get; protected set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Number: {0} State: {1}", Number, State); } + } + } +} From 450c2a149622592a7aba7ab48744f7ee554f8b7f Mon Sep 17 00:00:00 2001 From: Octokit Bot <security+octokitbot@github.com> Date: Mon, 12 Dec 2022 13:58:13 -0600 Subject: [PATCH 165/209] Workflow linting fix (#2638) Updates for workflows --- .github/workflows/add_to_octokit_project.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml index 63c3338b79..cf66072d44 100644 --- a/.github/workflows/add_to_octokit_project.yml +++ b/.github/workflows/add_to_octokit_project.yml @@ -5,7 +5,7 @@ on: types: [reopened, opened] pull_request: types: [reopened, opened] - + jobs: add-to-project: name: Add issue to project @@ -15,5 +15,5 @@ jobs: with: project-url: https://github.com/orgs/octokit/projects/10 github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN }} - labeled: 'Status: Stale' + labeled: "Status: Stale" label-operator: NOT From b312ae6a050fdef3b5093afe6088782b002c1cd0 Mon Sep 17 00:00:00 2001 From: Octokit Bot <security+octokitbot@github.com> Date: Fri, 16 Dec 2022 13:44:07 -0600 Subject: [PATCH 166/209] Workflows have changed (#2640) Updates for workflows --- .github/workflows/add_to_octokit_project.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml index cf66072d44..d01f864853 100644 --- a/.github/workflows/add_to_octokit_project.yml +++ b/.github/workflows/add_to_octokit_project.yml @@ -5,6 +5,8 @@ on: types: [reopened, opened] pull_request: types: [reopened, opened] + pull_request_target: + types: [reopened, opened] jobs: add-to-project: From 39d5cdc4df926d93b29c5c6eb12c1ca0361f239d Mon Sep 17 00:00:00 2001 From: Idan Ben Dror <idanbendror@apiiro.com> Date: Mon, 2 Jan 2023 23:48:08 +0200 Subject: [PATCH 167/209] Add more properties to `DeployKey` --- Octokit/Models/Response/DeployKey.cs | 10 ++++++++-- Octokit/Octokit.csproj | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Octokit/Models/Response/DeployKey.cs b/Octokit/Models/Response/DeployKey.cs index 464e0b8384..298fc020a5 100644 --- a/Octokit/Models/Response/DeployKey.cs +++ b/Octokit/Models/Response/DeployKey.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.Globalization; namespace Octokit @@ -20,13 +21,18 @@ public DeployKey(int id, string key, string url, string title) public string Key { get; protected set; } public string Url { get; protected set; } public string Title { get; protected set; } + public bool Verified { get; protected set; } + public DateTimeOffset CreatedAt { get; protected set; } + public bool ReadOnly { get; protected set; } + public string AddedBy { get; protected set; } + public DateTimeOffset LastUsed { get; protected set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, - "Deploy Key: Id: {0} Key: {1} Url: {2} Title: {3}", Id, Key, Url, Title); + "Deploy Key: Id: {0} Key: {1} Url: {2} Title: {3} Verified: {4} CreatedAt: {5} ReadOnly: {6} AddedBy: {7}, LastUsed: {8}", Id, Key, Url, Title, Verified, CreatedAt, ReadOnly, AddedBy, LastUsed); } } } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 6626938264..b8f154765d 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.10</Version> + <Version>1.0.11</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From e56e37851d8f7f7f020067ef05d7c9924e0db666 Mon Sep 17 00:00:00 2001 From: Idan Ben Dror <idanbendror@apiiro.com> Date: Tue, 3 Jan 2023 00:03:48 +0200 Subject: [PATCH 168/209] Add to the constructor as well --- Octokit/Models/Response/DeployKey.cs | 7 ++++++- Octokit/Octokit.csproj | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/DeployKey.cs b/Octokit/Models/Response/DeployKey.cs index 298fc020a5..53c257cba7 100644 --- a/Octokit/Models/Response/DeployKey.cs +++ b/Octokit/Models/Response/DeployKey.cs @@ -9,12 +9,17 @@ public class DeployKey { public DeployKey() { } - public DeployKey(int id, string key, string url, string title) + public DeployKey(int id, string key, string url, string title, bool verified, DateTimeOffset createdAt, bool readOnly, string addedBy, DateTimeOffset lastUsed) { Id = id; Key = key; Url = url; Title = title; + Verified = verified; + CreatedAt = createdAt; + ReadOnly = readOnly; + AddedBy = addedBy; + LastUsed = lastUsed; } public int Id { get; protected set; } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index b8f154765d..fd65f25129 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.11</Version> + <Version>1.0.12</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From f022f0b0913bdcade38bef26ca9043d547077c42 Mon Sep 17 00:00:00 2001 From: Octokit Bot <security+octokitbot@github.com> Date: Tue, 3 Jan 2023 09:11:17 -0600 Subject: [PATCH 169/209] =?UTF-8?q?=F0=9F=9A=A7=20Workflows=20have=20chang?= =?UTF-8?q?ed=20(#2647)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates for workflows --- .github/workflows/add_to_octokit_project.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml index d01f864853..19732aa736 100644 --- a/.github/workflows/add_to_octokit_project.yml +++ b/.github/workflows/add_to_octokit_project.yml @@ -12,6 +12,7 @@ jobs: add-to-project: name: Add issue to project runs-on: ubuntu-latest + continue-on-error: true steps: - uses: actions/add-to-project@v0.4.0 with: From 04d2a8724f869b5975b305930bc2e83b46fdd9a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 11:28:49 -0800 Subject: [PATCH 170/209] build(deps): bump Microsoft.NET.Test.Sdk from 17.4.0 to 17.4.1 (#2642) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.4.0 to 17.4.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.4.0...v17.4.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 10b25a904d..9f3ce75d1c 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> </ItemGroup> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 64794c5341..ee6cc3f65b 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -34,7 +34,7 @@ <ItemGroup> <PackageReference Include="GitHubJwt" Version="0.0.5" /> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="System.IO.Compression" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 566886467b..9a3af636d2 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -33,7 +33,7 @@ </ItemGroup> <ItemGroup> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" /> <PackageReference Include="System.Net.Http" Version="4.3.4" /> <PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" /> From a8fc68c21ad243dca8a9f2509db6f7a04e30bcf9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Jan 2023 11:55:45 -0600 Subject: [PATCH 171/209] build(deps): Removes the dependency of .NET Core app 3.1 and bumps Cake.Coverlet from 2.5.4 to 3.0.2 in /build (#2616) --- .config/dotnet-tools.json | 4 ++-- .devcontainer/Dockerfile | 5 ++--- .devcontainer/devcontainer.json | 2 +- .github/workflows/netcore.yml | 4 ---- .github/workflows/publish.yml | 5 ----- .vscode/launch.json | 6 +++--- .../Octokit.AsyncPaginationExtension.csproj | 4 ++-- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- Octokit.Tests/Octokit.Tests.csproj | 2 +- build/.vscode/launch.json | 2 +- build/Build.csproj | 4 ++-- build/Context.cs | 2 +- 13 files changed, 17 insertions(+), 27 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index f319224cf0..83c3421af3 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,10 +9,10 @@ ] }, "dotnet-format": { - "version": "3.3.111304", + "version": "5.1.250801", "commands": [ "dotnet-format" ] } } -} \ No newline at end of file +} diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 048069c31a..d77cb454d4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,11 +1,10 @@ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/dotnet/.devcontainer/base.Dockerfile -# [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal +# [Choice] .NET version: 6.0, 5.0, 6.0-bullseye, 5.0-bullseye, 6.0-focal, 5.0-focal ARG VARIANT="6.0-bullseye" FROM mcr.microsoft.com/vscode/devcontainers/dotnet -# "install" the dotnet 3.1 & 5.0 runtime for tests -COPY --from=mcr.microsoft.com/dotnet/sdk:3.1 /usr/share/dotnet/shared /usr/share/dotnet/shared +# "install" the dotnet 5.0 & 6.0 runtime for tests COPY --from=mcr.microsoft.com/dotnet/sdk:5.0 /usr/share/dotnet/shared /usr/share/dotnet/shared COPY --from=mcr.microsoft.com/dotnet/sdk:6.0 /usr/share/dotnet/shared /usr/share/dotnet/shared diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2e8d25a1b7..e303b33333 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - // Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0 + // Update 'VARIANT' to pick a .NET Core version: 5.0, 6.0 // Append -bullseye or -focal to pin to an OS version. "VARIANT": "latest" } diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index d7c39fdcf9..3eb5a4e2cf 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -27,10 +27,6 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: 6.0.* - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.* - name: Build with dotnet run: ./build.sh --linksources=true --verbosity=verbose shell: bash diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e6c84a6813..8741faedfd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,11 +21,6 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: 6.0.* - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 3.1.* - - name: Build with dotnet run: ./build.sh --linksources=true --verbosity=verbose shell: bash diff --git a/.vscode/launch.json b/.vscode/launch.json index 73a4369e41..b1d5033cf1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,7 +16,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/Octokit.Tests/bin/Debug/netcoreapp3.1/Octokit.Tests.dll", + "program": "${workspaceFolder}/Octokit.Tests/bin/Debug/net6.0/Octokit.Tests.dll", "args": [], "cwd": "${workspaceFolder}/Octokit.Tests", "console": "internalConsole", @@ -27,7 +27,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/Octokit.Tests.Conventions/bin/Debug/netcoreapp3.1/Octokit.Tests.Conventions.dll", + "program": "${workspaceFolder}/Octokit.Tests.Conventions/bin/Debug/net6.0/Octokit.Tests.Conventions.dll", "args": [], "cwd": "${workspaceFolder}/Octokit.Tests.Conventions", "console": "internalConsole", @@ -38,7 +38,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/Octokit.Tests.Integration/bin/Debug/netcoreapp3.1/Octokit.Tests.Integration.dll", + "program": "${workspaceFolder}/Octokit.Tests.Integration/bin/Debug/net6.0/Octokit.Tests.Integration.dll", "args": [], "cwd": "${workspaceFolder}/Octokit.Tests.Integration", "console": "internalConsole", diff --git a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj index 79d58866f5..c7668a4dbc 100644 --- a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj +++ b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj @@ -6,7 +6,7 @@ <Authors>GitHub</Authors> <Version>0.0.0-dev</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> - <TargetFrameworks>netstandard2.0;net461</TargetFrameworks> + <TargetFrameworks>netstandard2.0;net462</TargetFrameworks> <AssemblyName>Octokit.AsyncPaginationExtension</AssemblyName> <PackageId>Octokit.AsyncPaginationExtension</PackageId> <DebugType>embedded</DebugType> @@ -25,7 +25,7 @@ <NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion> </PropertyGroup> - <ItemGroup Condition=" '$(TargetFramework)' == 'net461' "> + <ItemGroup Condition=" '$(TargetFramework)' == 'net462' "> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" /> </ItemGroup> diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 9f3ce75d1c..ae4d2c9213 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -4,7 +4,7 @@ <Description>Convention-based tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Conventions</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> + <TargetFrameworks>net6.0;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Conventions</AssemblyName> <PackageId>Octokit.Tests.Conventions</PackageId> diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index ee6cc3f65b..289a93ab49 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -4,7 +4,7 @@ <Description>Integration tests for Octokit</Description> <AssemblyTitle>Octokit.Tests.Integration</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> + <TargetFrameworks>net6.0;net462</TargetFrameworks> <SignAssembly>false</SignAssembly> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests.Integration</AssemblyName> diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 9a3af636d2..8056f00389 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -4,7 +4,7 @@ <Description>Tests for Octokit</Description> <AssemblyTitle>Octokit.Tests</AssemblyTitle> <Authors>GitHub</Authors> - <TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks> + <TargetFrameworks>net6.0;net462</TargetFrameworks> <NoWarn>$(NoWarn);CS4014;CS1998</NoWarn> <AssemblyName>Octokit.Tests</AssemblyName> <PackageId>Octokit.Tests</PackageId> diff --git a/build/.vscode/launch.json b/build/.vscode/launch.json index 1c67c5f4c1..1926babdda 100644 --- a/build/.vscode/launch.json +++ b/build/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Build.dll", + "program": "${workspaceFolder}/bin/Debug/net6.0/Build.dll", "args": [], "cwd": "${workspaceFolder}", // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window diff --git a/build/Build.csproj b/build/Build.csproj index ff64d50664..b6cc45d141 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -3,12 +3,12 @@ <PropertyGroup> <OutputType>Exe</OutputType> <SignAssembly>false</SignAssembly> - <TargetFramework>netcoreapp3.1</TargetFramework> + <TargetFramework>net6.0</TargetFramework> <RunWorkingDirectory>$(MSBuildProjectDirectory)/..</RunWorkingDirectory> </PropertyGroup> <ItemGroup> - <PackageReference Include="Cake.Coverlet" Version="2.5.4" /> + <PackageReference Include="Cake.Coverlet" Version="3.0.2" /> <PackageReference Include="Cake.Frosting" Version="2.3.0" /> </ItemGroup> diff --git a/build/Context.cs b/build/Context.cs index f9ede409e5..95ab580761 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -38,7 +38,7 @@ public DotNetTestSettings GetTestSettings() if (!this.IsRunningOnWindows()) { - var testFramework = "netcoreapp3.1"; + var testFramework = "net6.0"; this.Information($"Running tests against {testFramework} only as we're not on Windows."); settings.Framework = testFramework; From 4a77e4d0f081658d265fd41eb2d7bf42e54bde1f Mon Sep 17 00:00:00 2001 From: Octokit Bot <security+octokitbot@github.com> Date: Mon, 9 Jan 2023 16:05:16 -0600 Subject: [PATCH 172/209] =?UTF-8?q?=F0=9F=9A=A7=20Workflows=20have=20chang?= =?UTF-8?q?ed=20(#2651)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updates for workflows --- .github/workflows/add_to_octokit_project.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml index 19732aa736..6381aa5b87 100644 --- a/.github/workflows/add_to_octokit_project.yml +++ b/.github/workflows/add_to_octokit_project.yml @@ -3,8 +3,6 @@ name: Add PRs and issues to Octokit org project on: issues: types: [reopened, opened] - pull_request: - types: [reopened, opened] pull_request_target: types: [reopened, opened] From bf72b5e88600873da9e1465cd2a6ccaeddf8d6b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Jan 2023 13:36:15 -0800 Subject: [PATCH 173/209] build(deps): bump Cake.Coverlet from 3.0.2 to 3.0.4 in /build (#2652) Bumps [Cake.Coverlet](https://github.com/romanx/Cake.Coverlet) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/romanx/Cake.Coverlet/releases) - [Commits](https://github.com/romanx/Cake.Coverlet/commits) --- updated-dependencies: - dependency-name: Cake.Coverlet dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- build/Build.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.csproj b/build/Build.csproj index b6cc45d141..d4b3d7b05f 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -8,7 +8,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Cake.Coverlet" Version="3.0.2" /> + <PackageReference Include="Cake.Coverlet" Version="3.0.4" /> <PackageReference Include="Cake.Frosting" Version="2.3.0" /> </ItemGroup> From bf6678543f7dabd8645757df722bb5bdd852994e Mon Sep 17 00:00:00 2001 From: Keegan Campbell <me@kfcampbell.com> Date: Thu, 12 Jan 2023 09:56:44 -0800 Subject: [PATCH 174/209] Remove instances of lower-case h (#2655) --- Octokit.Reactive/IObservableGitHubClient.cs | 6 +++--- Octokit.Reactive/ObservableGitHubClient.cs | 2 +- Octokit/IGitHubClient.cs | 4 ++-- Octokit/Models/Response/PagesBuild.cs | 2 +- Octokit/Models/Response/PullRequestReview.cs | 2 +- .../Models/Response/PullRequestReviewComment.cs | 2 +- docs/getting-started.md | 16 ++++++++-------- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 6532de7994..10cd16e933 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -8,8 +8,8 @@ public interface IObservableGitHubClient : IApiInfoProvider /// <summary> /// Sets the timeout for the connection between the client and the server. - /// Github will terminate the request if it takes more than 10 seconds to process the request - /// Useful to set a specific timeout for lengthy operations, such as uploading release assets + /// GitHub will terminate the request if it takes more than 10 seconds to process the request + /// /// Useful to set a specific timeout for lengthy operations, such as uploading release assets /// </summary> /// <remarks> /// See more information here: https://technet.microsoft.com/library/system.net.http.httpclient.timeout(v=vs.110).aspx @@ -43,4 +43,4 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableMetaClient Meta { get; } IObservableActionsClient Actions { get; } } -} \ No newline at end of file +} diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index c3899ffc77..7507a382cf 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -66,7 +66,7 @@ public IConnection Connection /// <summary> /// Sets the timeout for the connection between the client and the server. - /// Github will terminate the request if it takes more than 10 seconds to process the request + /// GitHub will terminate the request if it takes more than 10 seconds to process the request /// Useful to set a specific timeout for lengthy operations, such as uploading release assets /// </summary> /// <remarks> diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 220cf3c0d7..9bd53eb802 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -9,7 +9,7 @@ public interface IGitHubClient : IApiInfoProvider { /// <summary> /// Sets the timeout for the connection between the client and the server. - /// Github will terminate the request if it takes more than 10 seconds to process the request + /// GitHub will terminate the request if it takes more than 10 seconds to process the request /// Useful to set a specific timeout for lengthy operations, such as uploading release assets /// </summary> /// <remarks> @@ -190,7 +190,7 @@ public interface IGitHubClient : IApiInfoProvider /// Refer to the API documentation for more information: https://docs.github.com/rest/rate-limit /// </remarks> IRateLimitClient RateLimit { get; } - + /// <summary> /// Access GitHub's Markdown API /// </summary> diff --git a/Octokit/Models/Response/PagesBuild.cs b/Octokit/Models/Response/PagesBuild.cs index 087f0de045..6b140d32b9 100644 --- a/Octokit/Models/Response/PagesBuild.cs +++ b/Octokit/Models/Response/PagesBuild.cs @@ -5,7 +5,7 @@ namespace Octokit { /// <summary> - /// Metadata of a Github Pages build. + /// Metadata of a GitHub Pages build. /// </summary> [DebuggerDisplay("{DebuggerDisplay,nq}")] public class PagesBuild diff --git a/Octokit/Models/Response/PullRequestReview.cs b/Octokit/Models/Response/PullRequestReview.cs index c90cc2ca89..38714c9620 100644 --- a/Octokit/Models/Response/PullRequestReview.cs +++ b/Octokit/Models/Response/PullRequestReview.cs @@ -60,7 +60,7 @@ public PullRequestReview(long id, string nodeId, string commitId, User user, str public string Body { get; private set; } /// <summary> - /// The URL for this review on Github.com + /// The URL for this review on GitHub.com /// </summary> public string HtmlUrl { get; private set; } diff --git a/Octokit/Models/Response/PullRequestReviewComment.cs b/Octokit/Models/Response/PullRequestReviewComment.cs index 44dbf519e3..a39b917a34 100644 --- a/Octokit/Models/Response/PullRequestReviewComment.cs +++ b/Octokit/Models/Response/PullRequestReviewComment.cs @@ -104,7 +104,7 @@ public PullRequestReviewComment(string url, int id, string nodeId, string diffHu public DateTimeOffset UpdatedAt { get; private set; } /// <summary> - /// The URL for this comment on Github.com + /// The URL for this comment on GitHub.com /// </summary> public string HtmlUrl { get; private set; } diff --git a/docs/getting-started.md b/docs/getting-started.md index 1934e849dd..b52350e895 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -41,12 +41,12 @@ var ghe = new Uri("https://github.myenterprise.com/"); var client = new GitHubClient(new ProductHeaderValue("my-cool-app"), ghe); ``` -You can use the `EnterpriseProbe` class to test whether a URL points to a Github Enterprise instance. +You can use the `EnterpriseProbe` class to test whether a URL points to a GitHub Enterprise instance. ```csharp var probe = new EnterpriseProbe(new ProductHeaderValue("my-cool-app")); var result = await probe.Probe(new Uri("http://ghe.example.com/")); -Assert.Equal(EnterpriseProbeResult.Ok, result); +Assert.Equal(EnterpriseProbeResult.Ok, result); ``` ### Get some data @@ -69,14 +69,14 @@ var user = await client.User.Current(); ### Too Much of a Good Thing: Dealing with API Rate Limits -Like any popular API, Github needs to throttle some requests. The OctoKit.NET client allows you to get some insight into how many requests you have left and when you can start making requests again. +Like any popular API, GitHub needs to throttle some requests. The OctoKit.NET client allows you to get some insight into how many requests you have left and when you can start making requests again. In fact, there are two ways to get the Rate Limits via OctoKit.NET. Calling `GitHubClient.GetLastApiInfo()` returns the Rate Limit status which has been returned with the last api call. So, calling `GitHubClient.GetLastApiInfo()` will not send any extra HTTP requests to GitHub's servers. Example usage: ```csharp -GitHubClient client; +GitHubClient client; //Create & initialize the client here // Prior to first API call, this will be null, because it only deals with the last call. @@ -90,12 +90,12 @@ var howManyRequestsDoIHaveLeft = rateLimit?.Remaining; var whenDoesTheLimitReset = rateLimit?.Reset; // UTC time ``` -However, if in some cases you need to get the Rate Limit directly from Github, you should call `GitHubClient.Miscellaneous.GetRateLimits()`. +However, if in some cases you need to get the Rate Limit directly from GitHub, you should call `GitHubClient.Miscellaneous.GetRateLimits()`. Example usage: ```csharp -GitHubClient client; +GitHubClient client; //Create & initialize the client here var miscellaneousRateLimit = await client.Miscellaneous.GetRateLimits(); @@ -115,6 +115,6 @@ var howManySearchRequestsDoIHaveLeft = searchRateLimit.Remaining; var whenDoesTheSearchLimitReset = searchRateLimit.Reset; // UTC time ``` -An authenticated client will have a significantly higher limit than an anonymous client. +An authenticated client will have a significantly higher limit than an anonymous client. -For more information on the API and understanding rate limits, you may want to consult [the Github API docs on rate limits](https://developer.github.com/v3/#rate-limiting). +For more information on the API and understanding rate limits, you may want to consult [the GitHub API docs on rate limits](https://developer.github.com/v3/#rate-limiting). From 891015c39f637e091d47572dd21e31d9bee6e2a9 Mon Sep 17 00:00:00 2001 From: notauserx <82922717+notauserx@users.noreply.github.com> Date: Sat, 21 Jan 2023 00:48:00 +0600 Subject: [PATCH 175/209] update models with updated permission enum (#2633) * update models with updated permission enum * add suppress message attribute * update integration tests * refactor: new and legacy update teams endpint * refactor: add new delete team endpoint * use TeamPermission on NewTeam * use updated delete on team context dispose * add permission enum for team response object * refactor: remove legacy suffix from method names * introduce permissions object on Team * refactor: rename enum to TeamRepositoryPermission * fix formatting * change Permission to string to match api specs * add TeamRepository * add CheckTeamPermission endpoint support * fix convention tests * update comments on TeamRepository props * add two new endpoints in TeamsClient * refactor: rename ApiUrl for TeamPermission * fix test * implement methods for new endpoints * add the integration tests * fix spelling * update comments * refactor: rename method name * fix: add end tag for remarks * refactor: remove unused method param * fix docstring comment * the unit tests are in finally * add docs for teams api * split CheckTeamPermissions into two methods * Update ObservableTeamsClientTests.cs based on review Co-authored-by: Keegan Campbell <me@kfcampbell.com> * add cref to legacy update and delete endpoints * remove editorconfig file * Update Octokit.Tests/Clients/TeamsClientTests.cs Co-authored-by: Keegan Campbell <me@kfcampbell.com> * remove unused line * rename variable based on review * rename prop to match constructor param * add comment to explain TeamPermission enum values on update Co-authored-by: notauserx <notauserx@users.noreply.github.com> Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- .../Clients/IObservableTeamsClient.cs | 107 ++- .../Clients/ObservableTeamsClient.cs | 134 +++- Octokit.Tests.Conventions/PreviewsTests.cs | 3 +- .../Clients/TeamsClientTests.cs | 225 ++++++- Octokit.Tests.Integration/Helper.cs | 6 +- .../ObservableGithubClientExtensions.cs | 7 + .../Helpers/TeamContext.cs | 2 - .../Reactive/ObservableTeamsClientTests.cs | 227 +++++++ Octokit.Tests/Clients/TeamsClientTests.cs | 205 ++++++ Octokit.Tests/SimpleJsonSerializerTests.cs | 7 +- Octokit/Clients/ITeamsClient.cs | 107 ++- Octokit/Clients/TeamsClient.cs | 195 +++++- Octokit/Helpers/AcceptHeaders.cs | 2 + Octokit/Helpers/ApiUrls.cs | 24 + Octokit/Http/ApiConnection.cs | 14 + Octokit/Http/Connection.cs | 8 +- Octokit/Http/IApiConnection.cs | 8 + Octokit/Http/IConnection.cs | 4 +- Octokit/Models/Request/NewTeam.cs | 2 +- Octokit/Models/Request/Permission.cs | 90 ++- Octokit/Models/Request/UpdateTeam.cs | 5 +- Octokit/Models/Response/Team.cs | 12 +- Octokit/Models/Response/TeamRepository.cs | 618 ++++++++++++++++++ docs/teams.md | 77 +++ 24 files changed, 2052 insertions(+), 37 deletions(-) create mode 100644 Octokit/Models/Response/TeamRepository.cs create mode 100644 docs/teams.md diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index 95d382a9bd..745aa620e3 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -124,16 +124,54 @@ public interface IObservableTeamsClient /// <returns>Newly created <see cref="Team"/></returns> IObservable<Team> Create(string org, NewTeam team); + /// <summary> + /// Updates a team + /// To edit a team, the authenticated user must either be an organization owner or a team maintainer + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team">API documentation</a> + /// for more information. + /// </remarks> + /// <returns>updated <see cref="Team" /> for the current org</returns> + IObservable<Team> Update(string org, string teamSlug, UpdateTeam team); + /// <summary> /// Returns updated <see cref="Team" /> for the current org. + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Update a team endpoint. + /// <see cref="Update(string, string, UpdateTeam)"/> /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team-legacy">API documentation</a> + /// for more information. + /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>Updated <see cref="Team"/></returns> IObservable<Team> Update(int id, UpdateTeam team); /// <summary> - /// Delete a team - must have owner permissions to this + /// To delete a team, the authenticated user must be an organization owner or team maintainer. + /// If you are an organization owner, deleting a parent team will delete all of its child teams as well. /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team">API documentation</a> + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + IObservable<Unit> Delete(string org, string teamSlug); + + /// <summary> + /// Delete a team - must have owner permissions to do this + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Delete a team endpoint. + /// <see cref="Delete(string, string)"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team-legacy">API documentation</a> + /// </remarks> + /// <param name="id">The unique identifier of the team.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> IObservable<Unit> Delete(int id); @@ -257,5 +295,72 @@ public interface IObservableTeamsClient /// <param name="options">Options to change API behaviour.</param> /// <returns></returns> IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(int id, ApiOptions options); + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <returns></returns> + IObservable<bool> CheckTeamPermissionsForARepository(string org, string teamSlug, string owner, string repo); + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + IObservable<TeamRepository> CheckTeamPermissionsForARepositoryWithCustomAcceptHeader(string org, string teamSlug, string owner, string repo); + + /// <summary> + /// Add or update team repository permissions + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <param name="permission"> + /// The permission to grant the team on this repository. We accept the following permissions to be set: + /// pull, triage, push, maintain, admin and you can also specify a custom repository role name, if the + /// owning organization has defined any. If no permission is specified, the team's permission attribute + /// will be used to determine what permission to grant the team on this repository + /// </param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + IObservable<Unit> AddOrUpdateTeamRepositoryPermissions(string org, string teamSlug, string owner, string repo, string permission); + + /// <summary> + /// Remove a repository from a team + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#remove-a-repository-from-a-team">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + IObservable<Unit> RemoveRepositoryFromATeam(string org, string teamSlug, string owner, string repo); } } diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 9fa0d3f7ba..f068d468bb 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -193,9 +193,34 @@ public IObservable<Team> Create(string org, NewTeam team) return _client.Create(org, team).ToObservable(); } + /// <summary> + /// Updates a team + /// To edit a team, the authenticated user must either be an organization owner or a team maintainer + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team">API documentation</a> + /// for more information. + /// </remarks> + /// <returns>updated <see cref="Team" /> for the current org</returns> + public IObservable<Team> Update(string org, string teamSlug, UpdateTeam team) + { + Ensure.ArgumentNotNull(org, nameof(org)); + Ensure.ArgumentNotNull(teamSlug, nameof(teamSlug)); + Ensure.ArgumentNotNull(team, nameof(team)); + + return _client.Update(org, teamSlug, team).ToObservable(); + } + /// <summary> /// Returns updated <see cref="Team" /> for the current org. + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Update a team endpoint. + /// <see cref="Update(string, string, UpdateTeam)"/>. /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team-legacy">API documentation</a> + /// for more information. + /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>Updated <see cref="Team"/></returns> public IObservable<Team> Update(int id, UpdateTeam team) @@ -206,8 +231,34 @@ public IObservable<Team> Update(int id, UpdateTeam team) } /// <summary> - /// Delete a team - must have owner permissions to this + /// To delete a team, the authenticated user must be an organization owner or team maintainer. + /// If you are an organization owner, deleting a parent team will delete all of its child teams as well. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team">API documentation</a> + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + public IObservable<Unit> Delete(string org, string teamSlug) + { + Ensure.ArgumentNotNull(org, nameof(org)); + Ensure.ArgumentNotNull(teamSlug, nameof(teamSlug)); + + return _client.Delete(org, teamSlug).ToObservable(); + } + + /// <summary> + /// Delete a team - must have owner permissions to do this + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Delete a team endpoint. + /// <see cref="Delete(string, string)"/>. /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team-legacy">API documentation</a> + /// </remarks> + /// <param name="id">The unique identifier of the team.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> public IObservable<Unit> Delete(int id) @@ -391,5 +442,86 @@ public IObservable<OrganizationMembershipInvitation> GetAllPendingInvitations(in return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.TeamPendingInvitations(id), null, options); } + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <returns></returns> + public IObservable<bool> CheckTeamPermissionsForARepository(string org, string teamSlug, string owner, string repo) + { + return _client.CheckTeamPermissionsForARepository(org, teamSlug, owner, repo).ToObservable(); + } + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + public IObservable<TeamRepository> CheckTeamPermissionsForARepositoryWithCustomAcceptHeader(string org, string teamSlug, string owner, string repo) + { + return _client.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader(org, teamSlug, owner, repo).ToObservable(); + } + + /// <summary> + /// Add or update team repository permissions + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <param name="permission"> + /// The permission to grant the team on this repository. We accept the following permissions to be set: + /// pull, triage, push, maintain, admin and you can also specify a custom repository role name, if the + /// owning organization has defined any. If no permission is specified, the team's permission attribute + /// will be used to determine what permission to grant the team on this repository + /// </param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + [ManualRoute("PUT", "/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}")] + public IObservable<Unit> AddOrUpdateTeamRepositoryPermissions(string org, string teamSlug, string owner, string repo, string permission) + { + return _client.AddOrUpdateTeamRepositoryPermissions(org, teamSlug, owner, repo, permission).ToObservable(); + } + + /// <summary> + /// Remove a repository from a team + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#remove-a-repository-from-a-team">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + [ManualRoute("DELETE", "/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}")] + public IObservable<Unit> RemoveRepositoryFromATeam(string org, string teamSlug, string owner, string repo) + { + return _client.RemoveRepositoryFromATeam(org, teamSlug, owner, repo).ToObservable(); + } } } diff --git a/Octokit.Tests.Conventions/PreviewsTests.cs b/Octokit.Tests.Conventions/PreviewsTests.cs index 8fd06610c2..6a0fdfa6e4 100644 --- a/Octokit.Tests.Conventions/PreviewsTests.cs +++ b/Octokit.Tests.Conventions/PreviewsTests.cs @@ -70,7 +70,8 @@ public void NoStalePreviews() // https://developer.github.com/v3/repos/commits/#get-a-single-commit "application/vnd.github.v3.sha", // https://developer.github.com/v3/activity/starring/#alternative-response-with-star-creation-timestamps - "application/vnd.github.v3.star+json" + "application/vnd.github.v3.star+json", + "application/vnd.github.v3.repository+json" }; var validHeaders = defaultHeaders.Concat(previewAcceptHeaders); diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index ac9260270c..0735cc2f60 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Net; using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; @@ -33,10 +32,12 @@ public async Task CreatesTeam() Assert.Equal(teamName, team.Name); Assert.Equal(teamDescription, team.Description); Assert.Equal(TeamPrivacy.Closed, team.Privacy); + // Permission defaults to pull when no permission is specified when creating a team + Assert.Equal("pull", team.Permission); Assert.Equal(1, team.MembersCount); Assert.Equal(1, team.ReposCount); - await github.Organization.Team.Delete(team.Id); + await github.Organization.Team.Delete(Helper.Organization, team.Slug); } } } @@ -445,10 +446,49 @@ public async Task UpdatesTeam() { var teamName = Helper.MakeNameWithTimestamp("updated-team"); var teamDescription = Helper.MakeNameWithTimestamp("updated description"); + var update = new UpdateTeam(teamName) { Description = teamDescription, Privacy = TeamPrivacy.Closed, + Permission = TeamPermission.Push, + ParentTeamId = parentTeamContext.TeamId + }; + + var team = await _github.Organization.Team.Update(Helper.Organization, teamContext.Team.Slug, update); + + Assert.Equal(teamName, team.Name); + Assert.Equal(teamDescription, team.Description); + Assert.Equal(TeamPrivacy.Closed, team.Privacy); + Assert.Equal("push", team.Permission); + Assert.Equal(parentTeamContext.TeamId, team.Parent.Id); + } + } + } + + public class TheUpdateLegacyMethod + { + private readonly IGitHubClient _github; + + public TheUpdateLegacyMethod() + { + _github = Helper.GetAuthenticatedClient(); + } + + [OrganizationTest] + public async Task UpdatesTeamLegacy() + { + using (var parentTeamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("parent-team")))) + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team-fixture")))) + { + var teamName = Helper.MakeNameWithTimestamp("updated-team"); + var teamDescription = Helper.MakeNameWithTimestamp("updated description"); + + var update = new UpdateTeam(teamName) + { + Description = teamDescription, + Privacy = TeamPrivacy.Closed, + Permission = TeamPermission.Push, ParentTeamId = parentTeamContext.TeamId }; @@ -457,8 +497,189 @@ public async Task UpdatesTeam() Assert.Equal(teamName, team.Name); Assert.Equal(teamDescription, team.Description); Assert.Equal(TeamPrivacy.Closed, team.Privacy); + Assert.Equal("push", team.Permission); Assert.Equal(parentTeamContext.TeamId, team.Parent.Id); } } } + + public class TheCheckTeamPermissionsForARepositoryMethod + { + private readonly IGitHubClient github; + + public TheCheckTeamPermissionsForARepositoryMethod() + { + github = Helper.GetAuthenticatedClient(); + } + + [OrganizationTest] + public async Task ChecksTeamPermissions() + { + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + github.Organization.Team.AddRepository(teamContext.TeamId, Helper.Organization, repositoryContext.RepositoryName); + + var teamPermissionResponse = await github.Organization.Team.CheckTeamPermissionsForARepository( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName); + + Assert.True(teamPermissionResponse); + } + } + + [OrganizationTest] + public async Task ChecksTeamPermissionsReturnsFalseOnNonTeamRepository() + { + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + var response = await github.Organization.Team.CheckTeamPermissionsForARepository( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName); + + Assert.False(response); + } + } + } + + public class TheCheckTeamPermissionsForARepositoryWithCustomAcceptHeaderMethod + { + private readonly IGitHubClient github; + + public TheCheckTeamPermissionsForARepositoryWithCustomAcceptHeaderMethod() + { + github = Helper.GetAuthenticatedClient(); + } + + [OrganizationTest] + public async Task ChecksTeamPermissionsWithRepositoryMediaTypeInAccepts() + { + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + github.Organization.Team.AddRepository(teamContext.TeamId, Helper.Organization, repositoryContext.RepositoryName); + + var teamPermission = await github.Organization.Team.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName); + + Assert.NotNull(teamPermission); + Assert.NotNull(teamPermission.Permissions); + Assert.True(teamPermission.Permissions.Pull); + } + } + + [OrganizationTest] + public async Task ChecksTeamPermissionsThrowsNotFoundException() + { + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + await Assert.ThrowsAsync<NotFoundException>(async () => + await github.Organization.Team.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName)); + } + } + } + + public class TheAddOrUpdateTeamRepositoryPermissionsMethod + { + [OrganizationTest] + public async Task AddsTeamRepositoryPermissions() + { + var github = Helper.GetAuthenticatedClient(); + + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repoContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) + { + var teamRepositories = await github.Organization.Team.GetAllRepositories(teamContext.TeamId); + + Assert.Equal(0, teamRepositories.Count); + + await github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "admin"); + + teamRepositories = await github.Organization.Team.GetAllRepositories(teamContext.TeamId); + + Assert.True(teamRepositories.First(x => x.Id == repoContext.RepositoryId).Permissions.Admin); + } + } + + [OrganizationTest] + public async Task UpdatesTeamRepositoryPermissions() + { + var github = Helper.GetAuthenticatedClient(); + + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repoContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) + { + await github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "admin"); + + var teamRepositories = await github.Organization.Team.GetAllRepositories(teamContext.TeamId); + + Assert.True(teamRepositories.First(x => x.Id == repoContext.RepositoryId).Permissions.Admin); + + await github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "maintain"); + + teamRepositories = await github.Organization.Team.GetAllRepositories(teamContext.TeamId); + + Assert.False(teamRepositories.First(x => x.Id == repoContext.RepositoryId).Permissions.Admin); + Assert.True(teamRepositories.First(x => x.Id == repoContext.RepositoryId).Permissions.Maintain); + } + } + } + + public class TheRemoveRepositoryFromATeamMethod + { + [OrganizationTest] + public async Task RemovesRepositoryFromATeam() + { + var github = Helper.GetAuthenticatedClient(); + + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repoContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) + { + await github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "admin"); + + await github.Organization.Team.RemoveRepositoryFromATeam( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName); + + var addedRepo = await github.Organization.Team.GetAllRepositories(teamContext.TeamId); + + Assert.Equal(0, addedRepo.Count); + } + } + } } diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 49ca013140..9c94d78f64 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -190,15 +190,15 @@ public static void DeleteRepo(IConnection connection, string owner, string name) public static void DeleteTeam(IConnection connection, Team team) { if (team != null) - DeleteTeam(connection, team.Id); + DeleteTeam(connection, team.Slug); } - public static void DeleteTeam(IConnection connection, int teamId) + public static void DeleteTeam(IConnection connection, string slug) { try { var client = new GitHubClient(connection); - client.Organization.Team.Delete(teamId).Wait(TimeSpan.FromSeconds(15)); + client.Organization.Team.Delete(Organization, slug).Wait(TimeSpan.FromSeconds(15)); } catch { } } diff --git a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs index 5c52a61246..506f27cca7 100644 --- a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs @@ -36,6 +36,13 @@ internal static async Task<TeamContext> CreateTeamContext(this IObservableGitHub return new TeamContext(client.Connection, team); } + internal static async Task<RepositoryContext> CreateOrganizationRepositoryContext(this IObservableGitHubClient client, string organizationLogin, NewRepository newRepository) + { + var repo = await client.Repository.Create(organizationLogin, newRepository); + + return new RepositoryContext(client.Connection, repo); + } + internal static async Task<EnterpriseUserContext> CreateEnterpriseUserContext(this IObservableGitHubClient client, NewUser newUser) { var user = await client.User.Administration.Create(newUser); diff --git a/Octokit.Tests.Integration/Helpers/TeamContext.cs b/Octokit.Tests.Integration/Helpers/TeamContext.cs index c04ceb2774..f4cc15a26b 100644 --- a/Octokit.Tests.Integration/Helpers/TeamContext.cs +++ b/Octokit.Tests.Integration/Helpers/TeamContext.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Octokit.Tests.Integration.Helpers { diff --git a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs index 87431a8f56..a818b20c04 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs @@ -386,12 +386,239 @@ public async Task UpdatesTeam() ParentTeamId = parentTeamContext.TeamId }; + var team = await _github.Organization.Team.Update(Helper.Organization, teamContext.Team.Slug, update); + + Assert.Equal(teamName, team.Name); + Assert.Equal(teamDescription, team.Description); + Assert.Equal(TeamPrivacy.Closed, team.Privacy); + Assert.Equal(parentTeamContext.TeamId, team.Parent.Id); + + _github.Organization.Team.Delete(Helper.Organization, team.Slug); + } + } + } + + public class TheUpdateLegacyMethod + { + private readonly IObservableGitHubClient _github; + + public TheUpdateLegacyMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + } + + [OrganizationTest] + public async Task UpdatesTeamLegacy() + { + using (var parentTeamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("parent-team")))) + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team-fixture")))) + { + var teamName = Helper.MakeNameWithTimestamp("updated-team"); + var teamDescription = Helper.MakeNameWithTimestamp("updated description"); + var update = new UpdateTeam(teamName) + { + Description = teamDescription, + Privacy = TeamPrivacy.Closed, + ParentTeamId = parentTeamContext.TeamId + }; + var team = await _github.Organization.Team.Update(teamContext.TeamId, update); Assert.Equal(teamName, team.Name); Assert.Equal(teamDescription, team.Description); Assert.Equal(TeamPrivacy.Closed, team.Privacy); Assert.Equal(parentTeamContext.TeamId, team.Parent.Id); + + _github.Organization.Team.Delete(teamContext.TeamId); + } + } + } + + public class TheCheckTeamPermissionsForARepositoryMethod + { + private readonly IObservableGitHubClient _github; + public TheCheckTeamPermissionsForARepositoryMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + } + + [OrganizationTest] + public async Task ChecksTeamPermissions() + { + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await _github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + _github.Organization.Team.AddRepository(teamContext.TeamId, Helper.Organization, repositoryContext.RepositoryName); + + var teamPermissionResponse = await _github.Organization.Team.CheckTeamPermissionsForARepository( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName); + + Assert.True(teamPermissionResponse); + } + } + + [OrganizationTest] + public async Task ChecksTeamPermissionsReturnsFalseOnNonTeamRepository() + { + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await _github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + var response = await _github.Organization.Team.CheckTeamPermissionsForARepository( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName); + + Assert.False(response); + } + } + } + + public class TheCheckTeamPermissionsForARepositoryWithCustomAcceptHeaderMethod + { + private readonly IObservableGitHubClient _github; + public TheCheckTeamPermissionsForARepositoryWithCustomAcceptHeaderMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + } + + [OrganizationTest] + public async Task ChecksTeamPermissions() + { + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await _github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + _github.Organization.Team.AddRepository(teamContext.TeamId, Helper.Organization, repositoryContext.RepositoryName); + + var teamPermissionResponse = await _github.Organization.Team.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName); + + Assert.NotNull(teamPermissionResponse); + } + } + + [OrganizationTest] + public async Task ChecksTeamPermissionsThrowsNotFoundException() + { + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repositoryContext = await _github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("teamrepo")))) + { + await Assert.ThrowsAsync<NotFoundException>(async () => + await _github.Organization.Team.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader( + Helper.Organization, + teamContext.Team.Slug, + repositoryContext.RepositoryOwner, + repositoryContext.RepositoryName)); + } + } + } + + public class TheAddOrUpdateTeamRepositoryPermissionsMethod + { + private readonly IObservableGitHubClient _github; + + public TheAddOrUpdateTeamRepositoryPermissionsMethod() + { + _github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + } + + [OrganizationTest] + public async Task AddsTeamRepositoryPermissions() + { + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) + { + var teamRepository = await _github.Organization.Team + .GetAllRepositories(teamContext.TeamId) + .FirstOrDefaultAsync(x => x.Id == repoContext.RepositoryId); + + Assert.Null(teamRepository); + + await _github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "admin"); + + teamRepository = await _github.Organization.Team + .GetAllRepositories(teamContext.TeamId) + .FirstOrDefaultAsync(x => x.Id == repoContext.RepositoryId); + + Assert.NotNull(teamRepository); + } + } + + [OrganizationTest] + public async Task UpdatesTeamRepositoryPermissions() + { + using (var teamContext = await _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repoContext = await _github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) + { + await _github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "admin"); + + var teamRepository = await _github.Organization.Team + .GetAllRepositories(teamContext.TeamId) + .FirstOrDefaultAsync(x => x.Id == repoContext.RepositoryId); + + Assert.True(teamRepository.Permissions.Admin); + + await _github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "maintain"); + + teamRepository = await _github.Organization.Team + .GetAllRepositories(teamContext.TeamId) + .FirstOrDefaultAsync(x => x.Id == repoContext.RepositoryId); + + Assert.True(teamRepository.Permissions.Maintain); + Assert.False(teamRepository.Permissions.Admin); + } + } + } + + public class TheRemoveRepositoryFromATeamMethod + { + [OrganizationTest] + public async Task RemovesRepositoryFromATeam() + { + var github = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + using (var teamContext = await github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")))) + using (var repoContext = await github.CreateOrganizationRepositoryContext(Helper.Organization, new NewRepository(Helper.MakeNameWithTimestamp("team-repository")))) + { + await github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName, + "admin"); + + await github.Organization.Team.RemoveRepositoryFromATeam( + Helper.Organization, + teamContext.Team.Slug, + repoContext.RepositoryOwner, + repoContext.RepositoryName); + + var addedRepo = await github.Organization.Team.GetAllRepositories(teamContext.TeamId).ToList(); + + Assert.Equal(0, addedRepo.Count); } } } diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index a1b7179405..b29e921c07 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -169,6 +169,36 @@ public void RequestsTheCorrectUrl() var client = new TeamsClient(connection); var team = new UpdateTeam("Octokittens"); + var org = "org"; + var slug = "slug"; + client.Update(org, slug , team); + + connection.Received().Patch<Team>( + Arg.Is<Uri>(u => u.ToString() == "orgs/org/teams/slug"), + team); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "b", new UpdateTeam("update-team"))); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("a", null, new UpdateTeam("update-team"))); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("a", "b", null)); + } + } + + public class TheUpdateTeamLegacyMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + var team = new UpdateTeam("Octokittens"); + client.Update(1, team); connection.Received().Patch<Team>( @@ -187,6 +217,34 @@ public async Task EnsuresNonNullArguments() } public class TheDeleteTeamMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + var org = "org"; + var slug = "slug"; + + client.Delete(org, slug); + + connection.Received().Delete( + Arg.Is<Uri>(u => u.ToString() == "orgs/org/teams/slug")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("a", null)); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "a")); + } + } + + public class TheDeleteTeamLegacyMethod { [Fact] public void RequestsTheCorrectUrl() @@ -413,5 +471,152 @@ public async Task RequestsTheCorrectUrl() Args.ApiOptions); } } + + public class TheCheckTeamPermissionsForARepositoryMethod + { + [Fact] + public async Task EnsuresNonNullOrEmptyArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CheckTeamPermissionsForARepository(null, "teamSlug", "owner", "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CheckTeamPermissionsForARepository("org", null, "owner", "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CheckTeamPermissionsForARepository("org", "teamSlug", null, "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.CheckTeamPermissionsForARepository("org", "teamSlug", "owner", null)); + } + + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await client.CheckTeamPermissionsForARepository("org", "teamSlug", "owner", "repo"); + + var expected = "/orgs/org/teams/teamSlug/repos/owner/repo"; + + connection.Received().Get<TeamRepository>(Arg.Is<Uri>(u => u.ToString() == expected)); + } + } + + public class TheCheckTeamPermissionsForARepositoryWithCustomAcceptHeaderMethod + { + [Fact] + public async Task EnsuresNonNullOrEmptyArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => + client.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader(null, "teamSlug", "owner", "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => + client.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader("org", null, "owner", "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => + client.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader("org", "teamSlug", null, "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => + client.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader("org", "teamSlug", "owner", null)); + } + + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await client.CheckTeamPermissionsForARepositoryWithCustomAcceptHeader("org", "teamSlug", "owner", "repo"); + + var expected = "/orgs/org/teams/teamSlug/repos/owner/repo"; + + connection.Received().Get<TeamRepository>( + Arg.Is<Uri>(u => u.ToString() == expected), + null, + Arg.Is<string>(s => s.Equals("application/vnd.github.v3.repository+json"))); + } + } + + public class TheAddOrUpdateTeamRepositoryPermissionsMethod + { + [Fact] + public async Task EnsuresNonNullOrEmptyArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddOrUpdateTeamRepositoryPermissions(null, "teamSlug", "owner", "repo", "permission")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddOrUpdateTeamRepositoryPermissions("org", null, "owner", "repo", "permission")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddOrUpdateTeamRepositoryPermissions("org", "teamSlug", null, "repo", "permission")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.AddOrUpdateTeamRepositoryPermissions("org", "teamSlug", "owner", null, "permission")); + } + + [Fact] + public async Task EnsuresNullPermissionValueDoesNotThrow() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + var exception = await Record.ExceptionAsync(() => client.AddOrUpdateTeamRepositoryPermissions("org", "teamSlug", "owner", "repo", null)); + + Assert.Null(exception); + } + + + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + var permission = "a"; + + await client.AddOrUpdateTeamRepositoryPermissions("org", "teamSlug", "owner", "repo", permission); + + var expected = "/orgs/org/teams/teamSlug/repos/owner/repo"; + + connection.Received().Put( + Arg.Is<Uri>(u => u.ToString() == expected), + Arg.Any<object>()); + } + + [Fact] + public async Task PassesTheCorrestPermission() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + var permission = "a"; + + await client.AddOrUpdateTeamRepositoryPermissions("org", "teamSlug", "owner", "repo", permission); + + connection.Received().Put( + Arg.Any<Uri>(), + Arg.Is<object>(o => o.GetType().GetProperty("permission").GetValue(o).ToString() == "a")); + } + } + + public class TheRemoveRepositoryFromATeamMethod + { + [Fact] + public async Task EnsuresNonNullOrEmptyArguments() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepositoryFromATeam(null, "teamSlug", "owner", "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepositoryFromATeam("org", null, "owner", "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepositoryFromATeam("org", "teamSlug", null, "repo")); + await Assert.ThrowsAsync<ArgumentNullException>(() => client.RemoveRepositoryFromATeam("org", "teamSlug", "owner", null)); + } + + [Fact] + public async Task RequestsTheCorrectUrl() + { + var connection = Substitute.For<IApiConnection>(); + var client = new TeamsClient(connection); + + await client.RemoveRepositoryFromATeam("org", "teamSlug", "owner", "repo"); + + var expected = "/orgs/org/teams/teamSlug/repos/owner/repo"; + + connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == expected)); + } + } } } diff --git a/Octokit.Tests/SimpleJsonSerializerTests.cs b/Octokit.Tests/SimpleJsonSerializerTests.cs index a1265bd002..040b7c107a 100644 --- a/Octokit.Tests/SimpleJsonSerializerTests.cs +++ b/Octokit.Tests/SimpleJsonSerializerTests.cs @@ -472,13 +472,10 @@ public void ShouldDeserializeParentTeamWithNullPermission() var result = new SimpleJsonSerializer().Deserialize<Team>(teamJson); // original value works as expected - Assert.Equal(PermissionLevel.Admin, result.Permission.Value); - Assert.Equal("admin", result.Permission.StringValue); + Assert.Equal("admin", result.Permission); // parent permission is marked as null and cannot be parsed - Assert.Equal("null", result.Parent.Permission.StringValue); - PermissionLevel value; - Assert.False(result.Parent.Permission.TryParse(out value)); + Assert.Null(result.Parent.Permission); } } diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index ec3321d081..9507c125e4 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -125,16 +125,54 @@ public interface ITeamsClient /// <returns>Newly created <see cref="Team"/></returns> Task<Team> Create(string org, NewTeam team); + /// <summary> + /// Updates a team + /// To edit a team, the authenticated user must either be an organization owner or a team maintainer + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team">API documentation</a> + /// for more information. + /// </remarks> + /// <returns>updated <see cref="Team" /> for the current org</returns> + Task<Team> Update(string org, string teamSlug, UpdateTeam team); + /// <summary> /// Returns updated <see cref="Team" /> for the current org. + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Update a team endpoint. + /// <see cref="Update(string, string, UpdateTeam)"/>. /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team-legacy">API documentation</a> + /// for more information. + /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>Updated <see cref="Team"/></returns> Task<Team> Update(int id, UpdateTeam team); /// <summary> - /// Delte a team - must have owner permissions to this + /// To delete a team, the authenticated user must be an organization owner or team maintainer. + /// If you are an organization owner, deleting a parent team will delete all of its child teams as well. /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team">API documentation</a> + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + Task Delete(string org, string teamSlug); + + /// <summary> + /// Delete a team - must have owner permissions to do this + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Delete a team endpoint. + /// <see cref="Delete(string, string)"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team-legacy">API documentation</a> + /// </remarks> + /// <param name="id">The unique identifier of the team.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> Task Delete(int id); @@ -249,5 +287,72 @@ public interface ITeamsClient /// <param name="options">Options to change API behaviour.</param> /// <returns></returns> Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvitations(int id, ApiOptions options); + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <returns></returns> + Task<bool> CheckTeamPermissionsForARepository(string org, string teamSlug, string owner, string repo); + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + Task<TeamRepository> CheckTeamPermissionsForARepositoryWithCustomAcceptHeader(string org, string teamSlug, string owner, string repo); + + /// <summary> + /// Add or update team repository permissions + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <param name="permission"> + /// The permission to grant the team on this repository. We accept the following permissions to be set: + /// pull, triage, push, maintain, admin and you can also specify a custom repository role name, if the + /// owning organization has defined any. If no permission is specified, the team's permission attribute + /// will be used to determine what permission to grant the team on this repository + /// </param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + Task AddOrUpdateTeamRepositoryPermissions(string org, string teamSlug, string owner, string repo, string permission); + + /// <summary> + /// Remove a repository from a team + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#remove-a-repository-from-a-team">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + Task RemoveRepositoryFromATeam(string org, string teamSlug, string owner, string repo); } } diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 2d01a3445b..af41cc3119 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -227,9 +227,36 @@ public Task<Team> Create(string org, NewTeam team) return ApiConnection.Post<Team>(endpoint, team); } + /// <summary> + /// Updates a team + /// To edit a team, the authenticated user must either be an organization owner or a team maintainer + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team">API documentation</a> + /// for more information. + /// </remarks> + /// <returns>updated <see cref="Team" /> for the current org</returns> + [ManualRoute("PATCH", "/orgs/{org}/teams/{team_slug}")] + public Task<Team> Update(string org, string teamSlug, UpdateTeam team) + { + Ensure.ArgumentNotNull(org, nameof(org)); + Ensure.ArgumentNotNull(teamSlug, nameof(teamSlug)); + Ensure.ArgumentNotNull(team, nameof(team)); + + var endpoint = ApiUrls.TeamsByOrganizationAndSlug(org, teamSlug); + return ApiConnection.Patch<Team>(endpoint, team); + } + /// <summary> /// Returns updated <see cref="Team" /> for the current org. + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Update a team endpoint. + /// <see cref="Update(string, string, UpdateTeam)"/>. /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#update-a-team-legacy">API documentation</a> + /// for more information. + /// </remarks> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns>Updated <see cref="Team"/></returns> [ManualRoute("PATCH", "/teams/{team_id}")] @@ -242,8 +269,37 @@ public Task<Team> Update(int id, UpdateTeam team) } /// <summary> - /// Delte a team - must have owner permissions to this + /// To delete a team, the authenticated user must be an organization owner or team maintainer. + /// If you are an organization owner, deleting a parent team will delete all of its child teams as well. /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team">API documentation</a> + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + [ManualRoute("DELETE", "/orgs/{org}/teams/{team_slug}")] + public Task Delete(string org, string teamSlug) + { + Ensure.ArgumentNotNull(org, nameof(org)); + Ensure.ArgumentNotNull(teamSlug, nameof(teamSlug)); + + var endpoint = ApiUrls.TeamsByOrganizationAndSlug(org, teamSlug); + + return ApiConnection.Delete(endpoint); + } + + /// <summary> + /// Delete a team - must have owner permissions to do this + /// This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Delete a team endpoint. + /// <see cref="Delete(string, string)"/>. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#delete-a-team-legacy">API documentation</a> + /// </remarks> + /// <param name="id">The unique identifier of the team.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> [ManualRoute("DELETE", "/teams/{team_id}")] @@ -332,11 +388,13 @@ public Task<IReadOnlyList<Repository>> GetAllRepositories(int id, ApiOptions opt } /// <summary> - /// Add a repository to the team + /// Add or update team repository permissions (Legacy) + /// Deprecation Notice: This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new "Add or update team repository permissions" endpoint. /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> - [ManualRoute("PUT", "/orgs/{org}/team/{team_slug}/repos/{owner}/{repo}")] + [ManualRoute("PUT", "/teams/{team_id}/repos/{owner}/{repo}")] public async Task<bool> AddRepository(int id, string organization, string repoName) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); @@ -368,7 +426,9 @@ public async Task<bool> AddRepository(int id, string organization, string repoNa } /// <summary> - /// Add a repository to the team + /// Add or update team repository permissions (Legacy) + /// Deprecation Notice: This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new "Add or update team repository permissions" endpoint. /// </summary> /// <param name="id">The team identifier.</param> /// <param name="organization">Org to associate the repo with.</param> @@ -376,7 +436,7 @@ public async Task<bool> AddRepository(int id, string organization, string repoNa /// <param name="permission">The permission to grant the team on this repository.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> - [ManualRoute("PUT", "/orgs/{org}/team/{team_slug}/repos/{owner}/{repo}")] + [ManualRoute("PUT", "/teams/{team_id}/repos/{owner}/{repo}")] public async Task<bool> AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); @@ -408,11 +468,13 @@ public async Task<bool> AddRepository(int id, string organization, string repoNa } /// <summary> - /// Remove a repository from the team + /// Remove a repository from a team (Legacy) + /// Deprecation Notice: This endpoint route is deprecated and will be removed from the Teams API. + /// We recommend migrating your existing code to use the new Remove a repository from a team endpoint. /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> - [ManualRoute("DELETE", "/orgs/:org/teams/:team_slug/repos/:owner/:repo")] + [ManualRoute("DELETE", "/teams/{team_id}/repos/{owner}/{repo}")] public async Task<bool> RemoveRepository(int id, string organization, string repoName) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); @@ -505,5 +567,124 @@ public Task<IReadOnlyList<OrganizationMembershipInvitation>> GetAllPendingInvita { return ApiConnection.GetAll<OrganizationMembershipInvitation>(ApiUrls.TeamPendingInvitations(id), null, options); } + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <returns></returns> + [ManualRoute("GET", "/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}")] + public async Task<bool> CheckTeamPermissionsForARepository(string org, string teamSlug, string owner, string repo) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(teamSlug, nameof(teamSlug)); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); + + var endpoint = ApiUrls.TeamPermissionsForARepository(org, teamSlug, owner, repo); + + try + { + var response = await ApiConnection.Get<TeamRepository>(endpoint); + return response == null; + } + catch(NotFoundException) + { + return false; + } + } + + /// <summary> + /// Checks whether a team has admin, push, maintain, triage, or pull permission for a repository. + /// Repositories inherited through a parent team will also be checked. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#check-team-permissions-for-a-repository">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + [ManualRoute("GET", "/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}")] + public Task<TeamRepository> CheckTeamPermissionsForARepositoryWithCustomAcceptHeader(string org, string teamSlug, string owner, string repo) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(teamSlug, nameof(teamSlug)); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); + + var endpoint = ApiUrls.TeamPermissionsForARepository(org, teamSlug, owner, repo); + + return ApiConnection.Get<TeamRepository>(endpoint, null, AcceptHeaders.RepositoryContentMediaType); + } + + /// <summary> + /// Add or update team repository permissions + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <param name="permission"> + /// The permission to grant the team on this repository. We accept the following permissions to be set: + /// pull, triage, push, maintain, admin and you can also specify a custom repository role name, if the + /// owning organization has defined any. If no permission is specified, the team's permission attribute + /// will be used to determine what permission to grant the team on this repository + /// </param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + [ManualRoute("PUT", "/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}")] + public Task AddOrUpdateTeamRepositoryPermissions(string org, string teamSlug, string owner, string repo, string permission) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(teamSlug, nameof(teamSlug)); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); + + var endpoint = ApiUrls.TeamPermissionsForARepository(org, teamSlug, owner, repo); + + return ApiConnection.Put(endpoint, new { permission }); + } + + /// <summary> + /// Remove a repository from a team + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#remove-a-repository-from-a-team">API Documentation</a> + /// for more information. + /// </remarks> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> + /// <returns></returns> + [ManualRoute("DELETE", "/orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}")] + public Task RemoveRepositoryFromATeam(string org, string teamSlug, string owner, string repo) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + Ensure.ArgumentNotNullOrEmptyString(teamSlug, nameof(teamSlug)); + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(repo, nameof(repo)); + + var endpoint = ApiUrls.TeamPermissionsForARepository(org, teamSlug, owner, repo); + + return ApiConnection.Delete(endpoint); + } } } diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index c39c1baddf..c43e9cbdfb 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -13,5 +13,7 @@ public static class AcceptHeaders /// </summary> /// <remarks>https://developer.github.com/v3/repos/contents/#custom-media-types</remarks> public const string RawContentMediaType = "application/vnd.github.v3.raw"; + + public const string RepositoryContentMediaType = "application/vnd.github.v3.repository+json"; } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 7a4613b3c1..82621ada5a 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -1922,6 +1922,18 @@ public static Uri Teams(int id) return "teams/{0}".FormatUri(id); } + /// <summary> + /// Returns the <see cref="Uri"/> for teams + /// use for updating, or deleteing a <see cref="Team"/>. + /// </summary> + /// <param name="org"></param> + /// <param name="teamSlug"></param> + /// <returns></returns> + public static Uri TeamsByOrganizationAndSlug(string org, string teamSlug) + { + return "orgs/{0}/teams/{1}".FormatUri(org,teamSlug); + } + /// <summary> /// returns the <see cref="Uri"/> for team member /// </summary> @@ -1961,6 +1973,18 @@ public static Uri TeamRepository(int id, string organization, string repoName) return "teams/{0}/repos/{1}/{2}".FormatUri(id, organization, repoName); } + /// <summary> + /// returns the <see cref="Uri"/> for a team repository + /// </summary> + /// <param name="org">The organization name. The name is not case sensitive.</param> + /// <param name="teamSlug">The slug of the team name.</param> + /// <param name="owner">The account owner of the repository. The name is not case sensitive.</param> + /// <param name="repo">The name of the repository. The name is not case sensitive.</param> + public static Uri TeamPermissionsForARepository(string org, string teamSlug, string owner, string repo) + { + return "/orgs/{0}/teams/{1}/repos/{2}/{3}".FormatUri(org, teamSlug, owner, repo); + } + /// <summary> /// returns the <see cref="Uri"/> for the teams pending invitations /// </summary> diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 1a5694271c..6893766b62 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -338,6 +338,20 @@ public Task Put(Uri uri) return Connection.Put(uri); } + /// <summary> + /// Creates or replaces the API resource at the specified URI + /// </summary> + /// <param name="uri">URI of the API resource to put</param> + /// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param> + /// <returns>A <see cref="Task"/> for the request's execution.</returns> + public Task Put(Uri uri, object data) + { + Ensure.ArgumentNotNull(uri, nameof(uri)); + Ensure.ArgumentNotNull(data, nameof(data)); + + return Connection.Put(uri, data); + } + /// <summary> /// Creates or replaces the API resource at the specified URI. /// </summary> diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index bcace9f7ee..6a9f065c86 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -498,14 +498,14 @@ public async Task<HttpStatusCode> Put(Uri uri) /// Performs an asynchronous HTTP PUT request that expects an empty response. /// </summary> /// <param name="uri">URI endpoint to send request to</param> - /// <param name="accepts">Specifies accepted response media types.</param> + /// <param name="body">The object to serialize as the body of the request</param> /// <returns>The returned <seealso cref="HttpStatusCode"/></returns> - public async Task<HttpStatusCode> Put(Uri uri, string accepts) + public async Task<HttpStatusCode> Put(Uri uri, object body) { Ensure.ArgumentNotNull(uri, nameof(uri)); - Ensure.ArgumentNotNull(accepts, nameof(accepts)); + Ensure.ArgumentNotNull(body, nameof(body)); - var response = await SendData<object>(uri, HttpMethod.Put, null, accepts, null, CancellationToken.None).ConfigureAwait(false); + var response = await SendData<object>(uri, HttpMethod.Put, body, null, null, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 730cd2f5d8..ce915527c7 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -234,6 +234,14 @@ public interface IApiConnection /// <returns>A <see cref="Task"/> for the request's execution.</returns> Task Put(Uri uri); + /// <summary> + /// Creates or replaces the API resource at the specified URI + /// </summary> + /// <param name="uri">URI of the API resource to put</param> + /// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param> + /// <returns>A <see cref="Task"/> for the request's execution.</returns> + Task Put(Uri uri, object data); + /// <summary> /// Creates or replaces the API resource at the specified URI. /// </summary> diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index ff4b6359f1..3eacde0494 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -251,9 +251,9 @@ Task<IApiResponse<T>> Post<T>( /// Performs an asynchronous HTTP PUT request that expects an empty response. /// </summary> /// <param name="uri">URI endpoint to send request to</param> - /// <param name="accepts">Specifies accepted response media types.</param> + /// <param name="body">The object to serialize as the body of the request</param> /// <returns>The returned <seealso cref="HttpStatusCode"/></returns> - Task<HttpStatusCode> Put(Uri uri, string accepts); + Task<HttpStatusCode> Put(Uri uri, object body); /// <summary> /// Performs an asynchronous HTTP DELETE request that expects an empty response. diff --git a/Octokit/Models/Request/NewTeam.cs b/Octokit/Models/Request/NewTeam.cs index 23ba322dec..d506705d7b 100644 --- a/Octokit/Models/Request/NewTeam.cs +++ b/Octokit/Models/Request/NewTeam.cs @@ -55,7 +55,7 @@ public NewTeam(string name) /// <summary> /// The permission that new repositories will be added to the team with when none is specified (default: Pull) /// </summary> - public Permission? Permission { get; set; } + public TeamPermission? Permission { get; set; } /// <summary> /// Id of a team to set as the parent team diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Request/Permission.cs index 8e5eca5c3f..f3f94e003b 100644 --- a/Octokit/Models/Request/Permission.cs +++ b/Octokit/Models/Request/Permission.cs @@ -1,4 +1,6 @@ +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using Octokit.Internal; namespace Octokit @@ -10,19 +12,19 @@ namespace Octokit public enum Permission { /// <summary> - /// team members can pull, push and administer these repositories. + /// team members can pull, push and administer these repositories. /// </summary> [Parameter(Value = "admin")] Admin, /// <summary> - /// team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations. + /// team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations. /// </summary> [Parameter(Value = "maintain")] Maintain, /// <summary> - /// team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations. + /// team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations. /// </summary> [Parameter(Value = "triage")] Triage, @@ -39,4 +41,86 @@ public enum Permission [Parameter(Value = "pull")] Pull } + + /// <summary> + /// Deprecated. The permission that new repositories will be added to the team with when none is specified + /// Default: pull + /// Can be one of: pull, push + /// </summary> + [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] + public enum TeamPermission + { + /// <summary> + /// team members can pull, but not push to these repositories + /// </summary> + [Parameter(Value = "pull")] + Pull, + + /// <summary> + /// team members can pull and push to these repositories + /// </summary> + [Parameter(Value = "push")] + Push + } + + /// <summary> + /// Object for team repository permissions + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class TeamRepositoryPermissions + { + public TeamRepositoryPermissions() { } + public TeamRepositoryPermissions(bool pull, bool triage, bool push, bool maintain, bool admin) + { + Pull = pull; + Triage = triage; + Push = push; + Maintain = maintain; + Admin = admin; + } + + /// <summary> + /// Can read and clone repository. + /// Can also open and comment on issues and pull requests. + /// Required + /// </summary> + public bool Pull { get; private set; } + + /// <summary> + /// Can read and clone repository. + /// Can also manage issues and pull requests. + /// Required + /// </summary> + public bool Triage { get; private set; } + + /// <summary> + /// Can read, clone, and push to repository. + /// Can also manage issues and pull requests. + /// Required + /// </summary> + public bool Push { get; private set; } + + /// <summary> + /// Can read, clone, and push to repository. + /// They can also manage issues, pull requests, and some repository settings. + /// Required + /// </summary> + public bool Maintain { get; private set; } + + /// <summary> + /// Can read, clone, and push to repository. + /// Can also manage issues, pull requests, and repository settings, including adding collaborators. + /// Required + /// </summary> + public bool Admin { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, + $"Permissions: Pull: {Pull}, Triage: {Triage}, Push: {Push}, Maintain: {Maintain}, Admin: {Admin}"); + } + } + } } diff --git a/Octokit/Models/Request/UpdateTeam.cs b/Octokit/Models/Request/UpdateTeam.cs index 960019094d..e9297a2ecf 100644 --- a/Octokit/Models/Request/UpdateTeam.cs +++ b/Octokit/Models/Request/UpdateTeam.cs @@ -36,8 +36,11 @@ public UpdateTeam(string name) /// <summary> /// The permission that new repositories will be added to the team with when none is specified (default: Pull) + /// Although permission can be one of : pull, push, or admin based on documentation, passing admin results in an error response. + /// That's why TeamPermission does not contain an admin value. + /// See the issue here https://github.com/github/rest-api-description/issues/1952 /// </summary> - public Permission? Permission { get; set; } + public TeamPermission? Permission { get; set; } /// <summary> /// Id of a team to set as the parent team diff --git a/Octokit/Models/Response/Team.cs b/Octokit/Models/Response/Team.cs index 99fba9ecca..4c4be950f6 100644 --- a/Octokit/Models/Response/Team.cs +++ b/Octokit/Models/Response/Team.cs @@ -12,7 +12,7 @@ public class Team { public Team() { } - public Team(string url, string htmlUrl, int id, string nodeId, string slug, string name, string description, TeamPrivacy privacy, PermissionLevel permission, int membersCount, int reposCount, Organization organization, Team parent, string ldapDistinguishedName) + public Team(string url, string htmlUrl, int id, string nodeId, string slug, string name, string description, TeamPrivacy privacy, string permission, TeamRepositoryPermissions teamRepositoryPermissions, int membersCount, int reposCount, Organization organization, Team parent, string ldapDistinguishedName) { Url = url; HtmlUrl = htmlUrl; @@ -23,6 +23,7 @@ public Team(string url, string htmlUrl, int id, string nodeId, string slug, stri Description = description; Privacy = privacy; Permission = permission; + TeamRepositoryPermissions = teamRepositoryPermissions; MembersCount = membersCount; ReposCount = reposCount; Organization = organization; @@ -71,9 +72,14 @@ public Team(string url, string htmlUrl, int id, string nodeId, string slug, stri public StringEnum<TeamPrivacy> Privacy { get; private set; } /// <summary> - /// permission attached to this team + /// Deprecated. The permission that new repositories will be added to the team with when none is specified /// </summary> - public StringEnum<PermissionLevel> Permission { get; private set; } + public string Permission { get; private set; } + + /// <summary> + /// + /// </summary> + public TeamRepositoryPermissions TeamRepositoryPermissions { get; private set; } /// <summary> /// how many members in this team diff --git a/Octokit/Models/Response/TeamRepository.cs b/Octokit/Models/Response/TeamRepository.cs new file mode 100644 index 0000000000..bab62979c9 --- /dev/null +++ b/Octokit/Models/Response/TeamRepository.cs @@ -0,0 +1,618 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// A teams's repository + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class TeamRepository + { + public TeamRepository() { } + + public TeamRepository(int id, + string nodeId, + string name, + string fullName, + LicenseMetadata license, + TeamRepositoryPermissions permissions, + string roleName, + User owner, + bool @private, + string htmlUrl, + string description, + bool fork, + string url, + string archiveUrl, + string assigneesUrl, + string blobsUrl, + string branchesUrl, + string collaboratorsUrl, + string commentsUrl, + string commitsUrl, + string compareUrl, + string contentsUrl, + string contributorsUrl, + string deploymentsUrl, + string downloadsUrl, + string eventsUrl, + string forksUrl, + string gitCommitUrl, + string gitRefsUrl, + string gitTagsUrl, + string gitUrl, + string issueCommentUrl, + string issueEventsUrl, + string issuesUrl, + string keysUrl, + string labelsUrl, + string languagesUrl, + string mergesUrl, + string milestonesUrl, + string notificationsUrl, + string pullsUrl, + string releasesUrl, + string sshUrl, + string stargazersUrl, + string statusesUrl, + string subscribersUrl, + string subscriptionUrl, + string tagsUrl, + string teamsUrl, + string treesUrl, + string cloneUrl, + string mirrorUrl, + string hooksUrl, + string svnUrl, + string homePage, + string language, + int forksCount, + int stargazersCount, + int watchersCount, + int size, + string defaultBranch, + int openIssuesCount, + bool isTemplate, + IReadOnlyList<string> topics, + bool hasIssues, + bool hasProjects, + bool hasWiki, + bool hasPages, + bool hasDownloads, + bool archived, + bool disabled, + RepositoryVisibility? visibility, + DateTimeOffset? pushedAt, + DateTimeOffset createdAt, + DateTimeOffset updatedAt, + bool? allowRebaseMerge, + Repository templateRepository, + string tempCloneToken, + bool? allowSquashMerge, + bool? allowAutoMerge, + bool? deleteBranchOnMerge, + bool? allowMergeCommit, + bool? allowForking, + bool? webCommitSignoffRequired, + int subscribersCount, + int networkCount, + int openIssues, + int watchers, + string masterBranch) + { + Id = id; + NodeId = nodeId; + Name = name; + FullName = fullName; + License = license; + Permissions = permissions; + RoleName = roleName; + Owner = owner; + Private = @private; + HtmlUrl = htmlUrl; + Description = description; + Fork = fork; + Url = url; + ArchiveUrl = archiveUrl; + AssigneesUrl = assigneesUrl; + BlobsUrl = blobsUrl; + BranchesUrl = branchesUrl; + CollaboratorsUrl = collaboratorsUrl; + CommentsUrl = commentsUrl; + CommitsUrl = commitsUrl; + CompareUrl = compareUrl; + ContentsUrl = contentsUrl; + ContributorsUrl = contributorsUrl; + DeploymentsUrl = deploymentsUrl; + DownloadsUrl = downloadsUrl; + EventsUrl = eventsUrl; + ForksUrl = forksUrl; + GitCommitUrl = gitCommitUrl; + GitRefsUrl = gitRefsUrl; + GitTagsUrl = gitTagsUrl; + GitUrl = gitUrl; + IssueCommentUrl = issueCommentUrl; + IssueEventsUrl = issueEventsUrl; + IssuesUrl = issuesUrl; + KeysUrl = keysUrl; + LabelsUrl = labelsUrl; + LanguagesUrl = languagesUrl; + MergesUrl = mergesUrl; + MilestonesUrl = milestonesUrl; + NotificationsUrl = notificationsUrl; + PullsUrl = pullsUrl; + ReleasesUrl = releasesUrl; + SshUrl = sshUrl; + StargazersUrl = stargazersUrl; + StatusesUrl = statusesUrl; + SubscribersUrl = subscribersUrl; + SubscriptionUrl = subscriptionUrl; + TagsUrl = tagsUrl; + TeamsUrl = teamsUrl; + TreesUrl = treesUrl; + CloneUrl = cloneUrl; + MirrorUrl = mirrorUrl; + HooksUrl = hooksUrl; + SvnUrl = svnUrl; + HomePage = homePage; + Language = language; + ForksCount = forksCount; + StargazersCount = stargazersCount; + WatchersCount = watchersCount; + Size = size; + DefaultBranch = defaultBranch; + OpenIssuesCount = openIssuesCount; + IsTemplate = isTemplate; + Topics = topics; + HasIssues = hasIssues; + HasProjects = hasProjects; + HasWiki = hasWiki; + HasPages = hasPages; + HasDownloads = hasDownloads; + Archived = archived; + Disabled = disabled; + Visibility = visibility; + PushedAt = pushedAt; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + AllowRebaseMerge = allowRebaseMerge; + TemplateRepository = templateRepository; + TempCloneToken = tempCloneToken; + AllowSquashMerge = allowSquashMerge; + AllowAutoMerge = allowAutoMerge; + DeleteBranchOnMerge = deleteBranchOnMerge; + AllowMergeCommit = allowMergeCommit; + AllowForking = allowForking; + WebCommitSignoffRequired = webCommitSignoffRequired; + SubscribersCount = subscribersCount; + NetworkCount = networkCount; + OpenIssues = openIssues; + Watchers = watchers; + MasterBranch = masterBranch; + } + + + /// <summary> + /// Unique identifier of the repository + /// </summary> + public int Id { get; private set; } + + /// <summary> + /// GraphQL Node Id + /// </summary> + public string NodeId { get; private set; } + + /// <summary> + /// The name of the repository + /// </summary> + public string Name { get; private set; } + + /// <summary> + /// example: octocat/Hello-World + /// </summary> + public string FullName { get; private set; } + + public LicenseMetadata License { get; private set; } + + public TeamRepositoryPermissions Permissions { get; private set; } + + public string RoleName { get; private set; } + + public User Owner { get; private set; } + + /// <summary> + /// hether the repository is private or public. + /// default: false + /// </summary> + public bool Private { get; private set; } + + /// <summary> + /// format: uri + /// example: https://github.com/octocat/Hello-World + /// </summary> + public string HtmlUrl { get; private set; } + + /// <summary> + /// example: This your first repo! + /// nullable: true + /// </summary> + public string Description { get; private set; } + + public bool Fork { get; private set; } + + /// <summary> + /// format: uri + /// example: https://api.github.com/repos/octocat/Hello-World + /// </summary> + public string Url { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref} + /// </summary> + public string ArchiveUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/assignees{/user} + /// </summary> + public string AssigneesUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha} + /// </summary> + public string BlobsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/branches{/branch} + /// </summary> + public string BranchesUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator} + /// </summary> + public string CollaboratorsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/comments{/number} + /// </summary> + public string CommentsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/commits{/sha} + /// </summary> + public string CommitsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head} + /// </summary> + public string CompareUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/contents/{+path} + /// </summary> + public string ContentsUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/contributors + /// </summary> + public string ContributorsUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/deployments + /// </summary> + public string DeploymentsUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/downloads + /// </summary> + public string DownloadsUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/events + /// </summary> + public string EventsUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/forks + /// </summary> + public string ForksUrl { get; private set; } + ///example: http://api.github.com/repos/octocat/Hello-World/git/commits{/sha} + public string GitCommitUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/git/refs{/sha} + /// </summary> + public string GitRefsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/git/tags{/sha} + /// </summary> + public string GitTagsUrl { get; private set; } + + /// <summary> + /// example: git:github.com/octocat/Hello-World.git + /// </summary> + public string GitUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/issues/comments{/number} + /// </summary> + public string IssueCommentUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/issues/events{/number} + /// </summary> + public string IssueEventsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/issues{/number} + /// </summary> + public string IssuesUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/keys{/key_id} + /// </summary> + public string KeysUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/labels{/name} + /// </summary> + public string LabelsUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/languages + /// </summary> + public string LanguagesUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/merges + /// </summary> + public string MergesUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/milestones{/number} + /// </summary> + public string MilestonesUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating} + /// </summary> + public string NotificationsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/pulls{/number} + /// </summary> + public string PullsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/releases{/id} + /// </summary> + public string ReleasesUrl { get; private set; } + + /// <summary> + /// example: git @github.com:octocat/Hello-World.git + /// + /// </summary> + public string SshUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/stargazers + /// </summary> + public string StargazersUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/statuses/{sha} + /// </summary> + public string StatusesUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/subscribers + /// </summary> + public string SubscribersUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/subscription + /// </summary> + public string SubscriptionUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/tags + /// </summary> + public string TagsUrl { get; private set; } + + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/teams + /// </summary> + public string TeamsUrl { get; private set; } + + /// <summary> + /// example: http://api.github.com/repos/octocat/Hello-World/git/trees{/sha} + /// </summary> + public string TreesUrl { get; private set; } + + /// <summary> + /// example: https://github.com/octocat/Hello-World.git + /// </summary> + public string CloneUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: git:git.example.com/octocat/Hello-World + /// nullable: true + /// </summary> + public string MirrorUrl { get; private set; } + + + /// <summary> + /// format: uri + /// example: http://api.github.com/repos/octocat/Hello-World/hooks + /// </summary> + public string HooksUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: https://svn.github.com/octocat/Hello-World + /// </summary> + public string SvnUrl { get; private set; } + + /// <summary> + /// format: uri + /// example: https://github.com + /// </summary> + public string HomePage { get; private set; } + + public string Language { get; private set; } + + public int ForksCount { get; private set; } + + public int StargazersCount { get; private set; } + + public int WatchersCount { get; private set; } + + public int Size { get; private set; } + + /// <summary> + /// he default branch of the repository. + /// example: master + /// </summary> + public string DefaultBranch { get; private set; } + + public int OpenIssuesCount { get; private set; } + + /// <summary> + /// Whether this repository acts as a template that can be used to generate new repositories + /// default: false + /// </summary> + public bool IsTemplate { get; private set; } + + public IReadOnlyList<string> Topics { get; private set; } + + /// <summary> + /// Whether issues are enabled. + /// </summary> + public bool HasIssues { get; private set; } + + /// <summary> + /// Whether projects are enabled. + /// </summary> + public bool HasProjects { get; private set; } + + /// <summary> + /// Whether the wiki is enabled + /// </summary> + public bool HasWiki { get; private set; } + + public bool HasPages { get; private set; } + + /// <summary> + /// Whether downloads are enabled + /// default: true + /// </summary> + public bool HasDownloads { get; private set; } + + /// <summary> + /// Whether the repository is archived + /// </summary> + public bool Archived { get; private set; } + + /// <summary> + /// Returns whether or not this repository disabled. + /// </summary> + public bool Disabled { get; private set; } + + /// <summary> + /// The repository visibility: public, private, or internal. + /// </summary> + public RepositoryVisibility? Visibility { get; private set; } + + /// <summary> + /// format: date-time + /// example: '2011-01-26T19:06:43Z' + /// </summary> + public DateTimeOffset? PushedAt { get; private set; } + + /// <summary> + /// format: date-time + /// example: '2011-01-26T19:01:12Z' + /// </summary> + public DateTimeOffset CreatedAt { get; private set; } + + /// <summary> + /// format: date-time + /// example: '2011-01-26T19:14:43Z' + /// </summary> + public DateTimeOffset UpdatedAt { get; private set; } + + /// <summary> + /// Whether to allow rebase merges for pull requests. + /// </summary> + public bool? AllowRebaseMerge { get; private set; } + + /// <summary> + /// Template repository (nullable) + /// </summary> + public Repository TemplateRepository { get; private set; } + + public string TempCloneToken { get; private set; } + + /// <summary> + /// Whether to allow squash merges for pull requests. + /// </summary> + public bool? AllowSquashMerge { get; private set; } + + /// <summary> + /// Whether to allow Auto-merge to be used on pull requests. + /// </summary> + public bool? AllowAutoMerge { get; private set; } + + /// <summary> + /// Whether to delete head branches when pull requests are merged + /// </summary> + public bool? DeleteBranchOnMerge { get; private set; } + + /// <summary> + /// hether to allow merge commits for pull requests. + /// </summary> + public bool? AllowMergeCommit { get; private set; } + + /// <summary> + /// Whether to allow forking this repo + /// </summary> + public bool? AllowForking { get; private set; } + + /// <summary> + /// Whether to require contributors to sign off on web-based commits + /// </summary> + public bool? WebCommitSignoffRequired { get; private set; } + + public int SubscribersCount { get; private set; } + + public int NetworkCount { get; private set; } + + public int OpenIssues { get; private set; } + + public int Watchers { get; private set; } + + public string MasterBranch { get; private set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} ", FullName); } + } + } +} diff --git a/docs/teams.md b/docs/teams.md new file mode 100644 index 0000000000..2bfb1f9d56 --- /dev/null +++ b/docs/teams.md @@ -0,0 +1,77 @@ +# Working with Teams + +To access the teams API, you need to be an authenticated member of the organization's team. OAuth access tokens require the read:org scope. The ITeamsClient houses the endpoints for the teams API. + +### Create, update or delete teams + +To create a new team, you need to be a member of owner of the organization. + +```csharp +var newTeam = new NewTeam("team-name") +{ + Description = "my cool team description", + Privacy = TeamPrivacy.Closed +}; +newTeam.Maintainers.Add("maintainer-name"); +newTeam.RepoNames.Add("repository-name"); + +var team = await github.Organization.Team.Create("organization-name", newTeam); +``` + +Updating and deleting a team is also possible + +```csharp +var update = new UpdateTeam("team-name",) +{ + Description = "my new team description", + Privacy = TeamPrivacy.Closed, + Permission = TeamPermission.Push, +}; + +var team = await _github.Organization.Team.Update("organization-name", "team-slug", update); +``` + +```csharp +var team = await _github.Organization.Team.Delete("organization-name", "team-slug"); +``` + +### Working with repositories for the team + +You can get the list of repositories for the team by following + +```csharp +var allRepositories = await github.Organization.Team.GetAllRepositories(teamContext.TeamId); +``` +Or check permissions for a specific repository with the CheckTeamPermissionsForARepository method. + +```csharp +await github.Organization.Team.CheckTeamPermissionsForARepository( + "organization-name", + "team-slug", + "repository-owner", + "repository-name", + false); +``` + + The following snippet shows how to add or update team repository permissions. + + Permissions can be one of pull, triage, push, maintain, admin and you can also specify a custom repository role name, if the owning organization has defined any. If no permission is specified, the team's permission attribute will be used to determine what permission to grant the team on this repository. + +```csharp +await github.Organization.Team.AddOrUpdateTeamRepositoryPermissions( + "organization-name", + "team-slug", + "repository-owner", + "repository-name", + "admin"); +``` + +To remove a repository form a team, use + +```csharp +await github.Organization.Team.RemoveRepositoryFromATeam( + "organization-name", + "team-slug", + "repository-owner", + "repository-name"); +``` \ No newline at end of file From 24398bf56d7b6fcc8f21b8f628fe1876441fa4a5 Mon Sep 17 00:00:00 2001 From: Keegan Campbell <me@kfcampbell.com> Date: Fri, 20 Jan 2023 11:54:45 -0800 Subject: [PATCH 176/209] Happy New Year! (#2660) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd0de1d7e1..405c62e69e 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,6 @@ problem. ## Copyright and License -Copyright 2017 GitHub, Inc. +Copyright 2023 GitHub, Inc. Licensed under the [MIT License](https://github.com/octokit/octokit.net/blob/main/LICENSE.txt) From aecfb4fa474b203395f3f6ee3ed9a12c60bfccbb Mon Sep 17 00:00:00 2001 From: Idan Ben Dror <idanbendror@apiiro.com> Date: Sun, 22 Jan 2023 17:50:03 +0200 Subject: [PATCH 177/209] Make DeployKey.LastUsed nullable --- Octokit/Models/Response/DeployKey.cs | 4 ++-- Octokit/Octokit.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit/Models/Response/DeployKey.cs b/Octokit/Models/Response/DeployKey.cs index 53c257cba7..4a2b9fdda1 100644 --- a/Octokit/Models/Response/DeployKey.cs +++ b/Octokit/Models/Response/DeployKey.cs @@ -9,7 +9,7 @@ public class DeployKey { public DeployKey() { } - public DeployKey(int id, string key, string url, string title, bool verified, DateTimeOffset createdAt, bool readOnly, string addedBy, DateTimeOffset lastUsed) + public DeployKey(int id, string key, string url, string title, bool verified, DateTimeOffset createdAt, bool readOnly, string addedBy, DateTimeOffset? lastUsed) { Id = id; Key = key; @@ -30,7 +30,7 @@ public DeployKey(int id, string key, string url, string title, bool verified, Da public DateTimeOffset CreatedAt { get; protected set; } public bool ReadOnly { get; protected set; } public string AddedBy { get; protected set; } - public DateTimeOffset LastUsed { get; protected set; } + public DateTimeOffset? LastUsed { get; protected set; } internal string DebuggerDisplay { diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index fd65f25129..f498d21fd8 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.12</Version> + <Version>1.0.13</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 56697b4710763e9b73853bdc8f7a3bbb8cd0840a Mon Sep 17 00:00:00 2001 From: Idan Ben Dror <81963155+idanbd@users.noreply.github.com> Date: Sun, 22 Jan 2023 17:54:40 +0200 Subject: [PATCH 178/209] Update README New dotnet nuget packages don't require to pass `true` anymore when using `no-symbols` flag --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1109d08239..be014a21eb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To push to apiiro nuget package: ```bash cd Octokit dotnet pack --configuration Release -dotnet nuget push bin/Release/Apiiro.Octokit.*.nupkg --source "github" --skip-duplicate --no-symbols true +dotnet nuget push bin/Release/Apiiro.Octokit.*.nupkg --source "github" --skip-duplicate --no-symbols ``` Octokit is a client library targeting .NET Framework 4.5+ and .NET Standard 1+ From e3e27bbe04010dbe748ee4cec538e40145e259b0 Mon Sep 17 00:00:00 2001 From: Aleksei Beliakov <106954729+beliakov-mb@users.noreply.github.com> Date: Tue, 24 Jan 2023 02:08:52 +0300 Subject: [PATCH 179/209] [feat] Add pending WorkflowRunStatus Co-authored-by: Nick Floyd <139819+nickfloyd@users.noreply.github.com> --- Octokit/Models/Response/WorkflowRunStatus.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Octokit/Models/Response/WorkflowRunStatus.cs b/Octokit/Models/Response/WorkflowRunStatus.cs index ce0356fe07..eb691b15ff 100644 --- a/Octokit/Models/Response/WorkflowRunStatus.cs +++ b/Octokit/Models/Response/WorkflowRunStatus.cs @@ -14,5 +14,7 @@ public enum WorkflowRunStatus Queued, [Parameter(Value = "waiting")] Waiting, + [Parameter(Value = "pending")] + Pending } } From 00b89daa238861eb45fdcf1651423be869411e49 Mon Sep 17 00:00:00 2001 From: Nick Floyd <139819+nickfloyd@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:14:49 -0600 Subject: [PATCH 180/209] [maint] Removes the old implementation of sourcelink and uses the newer one present in the .net SDK (#2666) * reoves the old implemetnation of sourcelink and uses the newer one present in the .net SDK * cleans up appveyor * updates proj with sourcelink props * adds deterministic build check as well. * Update docs/debugging-source.md Co-authored-by: Keegan Campbell <me@kfcampbell.com> --------- Co-authored-by: Keegan Campbell <me@kfcampbell.com> --- .config/dotnet-tools.json | 6 ---- .github/workflows/netcore.yml | 2 +- .github/workflows/publish.yml | 2 +- CONTRIBUTING.md | 4 +-- Octokit.Reactive/Octokit.Reactive.csproj | 10 +++++++ Octokit/Octokit.csproj | 10 +++++++ README.md | 8 ------ build.ps1 | 2 -- build/Context.cs | 4 --- build/Lifetime.cs | 19 +------------ build/Tasks/Build.cs | 3 +- build/Tasks/Default.cs | 3 +- build/Tasks/TestSourceLink.cs | 36 ------------------------ docs/debugging-source.md | 6 ++-- docs/shipping-releases.md | 2 +- 15 files changed, 30 insertions(+), 87 deletions(-) delete mode 100644 build/Tasks/TestSourceLink.cs diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 83c3421af3..7f35d2cb13 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -2,12 +2,6 @@ "version": 1, "isRoot": true, "tools": { - "sourcelink": { - "version": "3.1.1", - "commands": [ - "sourcelink" - ] - }, "dotnet-format": { "version": "5.1.250801", "commands": [ diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index 3eb5a4e2cf..8808440e6c 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -28,5 +28,5 @@ jobs: with: dotnet-version: 6.0.* - name: Build with dotnet - run: ./build.sh --linksources=true --verbosity=verbose + run: ./build.sh --verbosity=verbose shell: bash diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8741faedfd..be35bbd487 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,7 @@ jobs: with: dotnet-version: 6.0.* - name: Build with dotnet - run: ./build.sh --linksources=true --verbosity=verbose + run: ./build.sh --verbosity=verbose shell: bash - name: Publish to NuGet diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 512fdc506b..55a7f2a190 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,11 +72,11 @@ To install dependencies and run the CAKE build script use the following wrapper - Windows (Powershell) -`.\build.ps1 -Target <target> -Configuration Release -LinkSources [Additional Parameters]` +`.\build.ps1 -Target <target> -Configuration Release [Additional Parameters]` - Linux/OSX (bash) -`./build.sh --target=<target> --configuration==Release --linksources=true [Additional Parameters]` +`./build.sh --target=<target> --configuration==Release [Additional Parameters]` ### Running Tests diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index e8de439ecb..6182847ac8 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -22,6 +22,16 @@ <PropertyGroup> <NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn> + <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> + </PropertyGroup> + + <PropertyGroup Label="Source Link"> + <!-- Optional: Declare that the Repository URL can be published to NuSpec --> + <PublishRepositoryUrl>true</PublishRepositoryUrl> + <!-- Optional: Embed source files that are not tracked by the source control manager to the PDB --> + <EmbedUntrackedSources>true</EmbedUntrackedSources> + <!-- Optional: Include PDB in the built .nupkg --> + <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> </PropertyGroup> <ItemGroup> diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a55742391c..a1f0c9075b 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -22,6 +22,16 @@ <PropertyGroup> <DefineConstants>$(DefineConstants);SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants> <NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn> + <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> + </PropertyGroup> + + <PropertyGroup Label="Source Link"> + <!-- Optional: Declare that the Repository URL can be published to NuSpec --> + <PublishRepositoryUrl>true</PublishRepositoryUrl> + <!-- Optional: Embed source files that are not tracked by the source control manager to the PDB --> + <EmbedUntrackedSources>true</EmbedUntrackedSources> + <!-- Optional: Include PDB in the built .nupkg --> + <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> </PropertyGroup> <ItemGroup> diff --git a/README.md b/README.md index 405c62e69e..6a1e0ce6dc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Octokit - GitHub API Client Library for .NET ![Build status](https://github.com/octokit/octokit.net/workflows/CI%20Build/badge.svg) -[![Build status](https://ci.appveyor.com/api/projects/status/cego2g42yw26th26/branch/main?svg=true)](https://ci.appveyor.com/project/github-windows/octokit-net/branch/main) [![codecov](https://codecov.io/gh/octokit/octokit.net/branch/main/graph/badge.svg)](https://codecov.io/gh/octokit/octokit.net) [![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![NuGet](https://img.shields.io/nuget/v/Octokit.svg)](https://www.nuget.org/packages/Octokit) @@ -42,13 +41,6 @@ There is also an IObservable based GitHub API client library for .NET using Reac dotnet add package Octokit.Reactive ``` - -### Beta packages ### -Unstable NuGet packages that track the `main` branch of this repository are available at -[https://ci.appveyor.com/nuget/octokit-net](https://ci.appveyor.com/nuget/octokit-net) - -In Xamarin Studio you can find this option under the project's context menu: **Add | Add Packages...***. - ## Documentation Documentation is available at http://octokitnet.readthedocs.io/en/latest/. diff --git a/build.ps1 b/build.ps1 index c9d1cbf897..e98303f250 100644 --- a/build.ps1 +++ b/build.ps1 @@ -24,7 +24,6 @@ Param( [string]$Target = "Default", [ValidateSet("Release", "Debug")] [string]$Configuration = "Release", - [switch]$LinkSources, [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] [string]$Verbosity = "Normal", [switch]$WhatIf, @@ -98,7 +97,6 @@ if (!(Test-Path $NugetPath)) { $Arguments = @{ target=$Target; configuration=$Configuration; - linkSources=$LinkSources; verbosity=$Verbosity; dryrun=$WhatIf; }.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value }; diff --git a/build/Context.cs b/build/Context.cs index 95ab580761..6812eea00f 100644 --- a/build/Context.cs +++ b/build/Context.cs @@ -9,7 +9,6 @@ public class Context : FrostingContext { public string Target { get; set; } public new string Configuration { get; set; } - public bool LinkSources { get; set; } public bool FormatCode { get; set; } public BuildVersion Version { get; set; } @@ -17,11 +16,8 @@ public class Context : FrostingContext public bool IsLocalBuild { get; set; } public bool IsPullRequest { get; set; } public bool IsOriginalRepo { get; set; } - public bool IsTagged { get; set; } public bool IsMainBranch { get; set; } public bool ForcePublish { get; set; } - - public bool AppVeyor { get; set; } public bool GitHubActions { get; set; } public Project[] Projects { get; set; } diff --git a/build/Lifetime.cs b/build/Lifetime.cs index 310841b202..2a1191e481 100644 --- a/build/Lifetime.cs +++ b/build/Lifetime.cs @@ -12,7 +12,6 @@ public override void Setup(Context context) { context.Target = context.Argument("target", "Default"); context.Configuration = context.Argument("configuration", "Release"); - context.LinkSources = context.Argument("linkSources", false); context.FormatCode = context.Argument("formatCode", false); context.Artifacts = "./packaging/"; @@ -22,16 +21,8 @@ public override void Setup(Context context) context.IsLocalBuild = buildSystem.IsLocalBuild; context.GitHubActions = buildSystem.GitHubActions.IsRunningOnGitHubActions; - context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; - context.IsTagged = IsBuildTagged(buildSystem); - if (context.AppVeyor) - { - context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; - context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.AppVeyor.Environment.Repository.Name); - context.IsMainBranch = StringComparer.OrdinalIgnoreCase.Equals("main", buildSystem.AppVeyor.Environment.Repository.Branch); - } - else if (context.GitHubActions) + if (context.GitHubActions) { context.IsPullRequest = buildSystem.GitHubActions.Environment.PullRequest.IsPullRequest; context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.GitHubActions.Environment.Workflow.Repository); @@ -62,18 +53,10 @@ public override void Setup(Context context) context.Information("Version: {0}", context.Version.Prefix); context.Information("Version suffix: {0}", context.Version.Suffix); context.Information("Configuration: {0}", context.Configuration); - context.Information("LinkSources: {0}", context.LinkSources); context.Information("Target: {0}", context.Target); - context.Information("AppVeyor: {0}", context.AppVeyor); context.Information("GitHub Actions: {0}", context.GitHubActions); } - private static bool IsBuildTagged(BuildSystem buildSystem) - { - return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag - && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); - } - private static string GetEnvironmentValueOrArgument(Context context, string environmentVariable, string argumentName) { var arg = context.EnvironmentVariable(environmentVariable); diff --git a/build/Tasks/Build.cs b/build/Tasks/Build.cs index 2e1af6c0ac..23c3e1c1f8 100644 --- a/build/Tasks/Build.cs +++ b/build/Tasks/Build.cs @@ -13,8 +13,7 @@ public override void Run(Context context) { Configuration = context.Configuration, ArgumentCustomization = args => args - .Append("/p:Version={0}", context.Version.GetSemanticVersion()) - .Append("/p:SourceLinkCreate={0}", context.LinkSources.ToString().ToLower()), + .Append("/p:Version={0}", context.Version.GetSemanticVersion()), }); } } diff --git a/build/Tasks/Default.cs b/build/Tasks/Default.cs index e69c10e224..e0bebc6861 100644 --- a/build/Tasks/Default.cs +++ b/build/Tasks/Default.cs @@ -1,6 +1,5 @@ using Cake.Frosting; - -[IsDependentOn(typeof(TestSourceLink))] +[IsDependentOn(typeof(Package))] public sealed class Default : FrostingTask<Context> { } diff --git a/build/Tasks/TestSourceLink.cs b/build/Tasks/TestSourceLink.cs deleted file mode 100644 index 003c617be5..0000000000 --- a/build/Tasks/TestSourceLink.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using Cake.Common; -using Cake.Common.Diagnostics; -using Cake.Common.IO; -using Cake.Core; -using Cake.Core.IO; -using Cake.Frosting; - -[IsDependentOn(typeof(Package))] -public class TestSourceLink : FrostingTask<Context> -{ - public override void Run(Context context) - { - var nugetPackages = context.GetFiles($"./{context.Artifacts}/*.nupkg"); - - foreach (var nugetPackage in nugetPackages) - { - context.Information("Testing sourcelink info in {0}", context.Environment.WorkingDirectory.GetRelativePath(nugetPackage)); - var exitCode = context.StartProcess("dotnet", new ProcessSettings - { - WorkingDirectory = "Octokit", - Arguments = $"sourcelink test {nugetPackage.FullPath}" - }); - - if (exitCode != 0) - { - throw new Exception("Sourcelink test failed!"); - } - } - } - - public override bool ShouldRun(Context context) - { - return context.LinkSources; - } -} diff --git a/docs/debugging-source.md b/docs/debugging-source.md index c0b6b6418e..f0ecfacbce 100644 --- a/docs/debugging-source.md +++ b/docs/debugging-source.md @@ -22,11 +22,9 @@ with a specific type, and cache it in your local symbols cache. ![F11 step into symbol](https://cloud.githubusercontent.com/assets/359239/5389259/74600502-8149-11e4-94f7-10dc79a0573f.gif) -You can then set subsequent breakpoints inside the source code, to return to +You can then set subsequent breakpoints inside the source code, to return to in the debugging session. ### Acknowledgements -Thanks to [Cameron Taggart](http://blog.ctaggart.com/) for building the -[SourceLink](https://github.com/ctaggart/SourceLink) framework which we use -to support this behaviour. \ No newline at end of file +Thanks to Cameron Taggart for the initial implementation and the .NET foundation for ongoing support of [SourceLink](https://github.com/dotnet/sourcelink) which we use to provide source debugging. diff --git a/docs/shipping-releases.md b/docs/shipping-releases.md index 3d42c742c8..be46e8f41f 100644 --- a/docs/shipping-releases.md +++ b/docs/shipping-releases.md @@ -26,7 +26,7 @@ Or can be run individually: ### Create NuGet Packages -NuGet packages are automatically generated (and SourceLinked) by the CAKE build script. +NuGet packages are automatically generated (and SourceLinked) by the csproj configration. > `.\build.ps1` The output .nupkg files will be located in the `packaging` directory. From 66587ee0d19d797a5928c15e801e0dbf03c7fd0d Mon Sep 17 00:00:00 2001 From: Yankai <71268247+reny-gearset@users.noreply.github.com> Date: Tue, 7 Feb 2023 17:35:54 +0000 Subject: [PATCH 181/209] [feat] Add Response caching --- Octokit.Tests/Caching/CachedResponseTests.cs | 102 ++++++ .../Caching/CachingHttpClientTests.cs | 331 ++++++++++++++++++ Octokit.Tests/GitHubClientTests.cs | 42 +++ Octokit.Tests/Helpers/ApiInfoComparer.cs | 41 +++ Octokit.Tests/Helpers/CollectionComparer.cs | 23 ++ Octokit.Tests/Helpers/RateLimitComparer.cs | 30 ++ Octokit.Tests/Helpers/ResponseComparer.cs | 37 ++ .../Helpers/StringKeyedDictionaryComparer.cs | 23 ++ Octokit.Tests/Http/ConnectionTests.cs | 43 +++ Octokit/Caching/CachedResponse.cs | 63 ++++ Octokit/Caching/CachingHttpClient.cs | 86 +++++ Octokit/Caching/IResponseCache.cs | 12 + Octokit/GitHubClient.cs | 16 + Octokit/Http/Connection.cs | 18 +- Octokit/Http/IConnection.cs | 17 +- 15 files changed, 879 insertions(+), 5 deletions(-) create mode 100644 Octokit.Tests/Caching/CachedResponseTests.cs create mode 100644 Octokit.Tests/Caching/CachingHttpClientTests.cs create mode 100644 Octokit.Tests/Helpers/ApiInfoComparer.cs create mode 100644 Octokit.Tests/Helpers/CollectionComparer.cs create mode 100644 Octokit.Tests/Helpers/RateLimitComparer.cs create mode 100644 Octokit.Tests/Helpers/ResponseComparer.cs create mode 100644 Octokit.Tests/Helpers/StringKeyedDictionaryComparer.cs create mode 100644 Octokit/Caching/CachedResponse.cs create mode 100644 Octokit/Caching/CachingHttpClient.cs create mode 100644 Octokit/Caching/IResponseCache.cs diff --git a/Octokit.Tests/Caching/CachedResponseTests.cs b/Octokit.Tests/Caching/CachedResponseTests.cs new file mode 100644 index 0000000000..1bf57af631 --- /dev/null +++ b/Octokit.Tests/Caching/CachedResponseTests.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Net; +using NSubstitute; +using NSubstitute.ReturnsExtensions; +using Octokit.Caching; +using Octokit.Internal; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Caching +{ + public class CachedResponseTests + { + public class V1 + { + public class TheToResponseMethod + { + [Fact] + public void CreatesResponseWithSameProperties() + { + var body = new object(); + var headers = new Dictionary<string, string>(); + var apiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()); + const HttpStatusCode httpStatusCode = HttpStatusCode.OK; + const string contentType = "content-type"; + var v1 = new CachedResponse.V1(body, headers, apiInfo, httpStatusCode, contentType); + + var response = v1.ToResponse(); + + Assert.Equal(new Response(httpStatusCode, body, headers, contentType), response, new ResponseComparer()); + } + } + + public class TheCreateMethod + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws<ArgumentNullException>(() => CachedResponse.V1.Create(null)); + } + + [Fact] + public void EnsuresNonNullResponseHeader() + { + var response = Substitute.For<IResponse>(); + response.Headers.ReturnsNull(); + + Assert.Throws<ArgumentNullException>(() => CachedResponse.V1.Create(response)); + } + + [Fact] + public void CreatesV1WithSameProperties() + { + var response = Substitute.For<IResponse>(); + response.Headers.Returns(new Dictionary<string, string>()); + + var v1 = CachedResponse.V1.Create(response); + Assert.Equal(response.Body, v1.Body); + Assert.Equal(response.Headers, v1.Headers); + Assert.Equal(response.ApiInfo, v1.ApiInfo); + Assert.Equal(response.StatusCode, v1.StatusCode); + Assert.Equal(response.ContentType, v1.ContentType); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullHeaders() + { + Assert.Throws<ArgumentNullException>(() => new CachedResponse.V1("body", null, new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()), HttpStatusCode.OK, "content-type")); + } + + [Fact] + public void AllowsParametersOtherThanHeadersToBeNull() + { + new CachedResponse.V1(null, new Dictionary<string, string>(), null, HttpStatusCode.OK, null); + } + + [Fact] + public void SetsProperties() + { + var body = new object(); + var headers = new Dictionary<string, string>(); + var apiInfo = new ApiInfo(new Dictionary<string, Uri>(), new List<string>(), new List<string>(), "etag", new RateLimit()); + const HttpStatusCode httpStatusCode = HttpStatusCode.OK; + const string contentType = "content-type"; + + var v1 = new CachedResponse.V1(body, headers, apiInfo, httpStatusCode, contentType); + + Assert.Equal(body, v1.Body); + Assert.Equal(headers, v1.Headers); + Assert.Equal(apiInfo, v1.ApiInfo); + Assert.Equal(httpStatusCode, v1.StatusCode); + Assert.Equal(contentType, v1.ContentType); + } + } + } + + } +} diff --git a/Octokit.Tests/Caching/CachingHttpClientTests.cs b/Octokit.Tests/Caching/CachingHttpClientTests.cs new file mode 100644 index 0000000000..b5bcb69b8d --- /dev/null +++ b/Octokit.Tests/Caching/CachingHttpClientTests.cs @@ -0,0 +1,331 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using NSubstitute; +using NSubstitute.ExceptionExtensions; +using NSubstitute.ReturnsExtensions; +using Octokit.Caching; +using Octokit.Internal; +using Octokit.Tests.Helpers; +using Xunit; + +namespace Octokit.Tests.Caching +{ + public class CachingHttpClientTests + { + public class TheSendMethod + { + [Fact] + public void EnsuresNonNullArguments() + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + assert + Assert.ThrowsAsync<ArgumentNullException>(() => cachingHttpClient.Send(null, CancellationToken.None)); + } + + [Theory] + [MemberData(nameof(NonGetHttpMethods))] + public async Task CallsUnderlyingHttpClientMethodForNonGetRequests(HttpMethod method) + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + var request = Substitute.For<IRequest>(); + var cancellationToken = CancellationToken.None; + var expectedResponse = Substitute.For<IResponse>(); + + request.Method.Returns(method); + underlyingClient.Send(request, cancellationToken).Returns(expectedResponse); + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + var response = await cachingHttpClient.Send(request, CancellationToken.None); + + // assert + Assert.Equal(expectedResponse, response); + Assert.Empty(responseCache.ReceivedCalls()); + Assert.Single(underlyingClient.ReceivedCalls()); + underlyingClient.Received(1).Send(request, cancellationToken); + } + + public static IEnumerable<object[]> NonGetHttpMethods() + { + yield return new object[] { HttpMethod.Delete }; + yield return new object[] { HttpMethod.Post }; + yield return new object[] { HttpMethod.Put }; + yield return new object[] { HttpMethod.Trace }; + yield return new object[] { HttpMethod.Options }; + yield return new object[] { HttpMethod.Head }; + } + + [Fact] + public async Task UsesCachedResponseIfEtagIsPresentAndGithubReturns304() + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + const string etag = "my-etag"; + var request = Substitute.For<IRequest>(); + request.Method.Returns(HttpMethod.Get); + request.Headers.Returns(new Dictionary<string, string>()); + + var cachedResponse = Substitute.For<IResponse>(); + cachedResponse.Headers.Returns(new Dictionary<string, string> { { "ETag", etag } }); + + var cachedV1Response = CachedResponse.V1.Create(cachedResponse); + var cancellationToken = CancellationToken.None; + + var githubResponse = Substitute.For<IResponse>(); + githubResponse.StatusCode.Returns(HttpStatusCode.NotModified); + + underlyingClient.Send(Arg.Is<IRequest>(req => req == request && req.Headers["If-None-Matched"] == etag), cancellationToken).ReturnsForAnyArgs(githubResponse); + responseCache.GetAsync(request).Returns(cachedV1Response); + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + var response = await cachingHttpClient.Send(request, cancellationToken); + + // assert + Assert.Equal(cachedV1Response.ToResponse(), response, new ResponseComparer()); + Assert.Single(underlyingClient.ReceivedCalls()); + underlyingClient.Received(1).Send(request, cancellationToken); + Assert.Single(responseCache.ReceivedCalls()); + responseCache.Received(1).GetAsync(request); + } + + [Theory] + [MemberData(nameof(NonNotModifiedHttpStatusCodesWithSetCacheFailure))] + public async Task UsesGithubResponseIfEtagIsPresentAndGithubReturnsNon304(HttpStatusCode httpStatusCode, bool setCacheThrows) + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + const string etag = "my-etag"; + var request = Substitute.For<IRequest>(); + request.Method.Returns(HttpMethod.Get); + request.Headers.Returns(new Dictionary<string, string>()); + + var cachedResponse = Substitute.For<IResponse>(); + cachedResponse.Headers.Returns(new Dictionary<string, string> { { "ETag", etag } }); + + var cachedV1Response = CachedResponse.V1.Create(cachedResponse); + var cancellationToken = CancellationToken.None; + + var githubResponse = Substitute.For<IResponse>(); + githubResponse.StatusCode.Returns(httpStatusCode); + + underlyingClient.Send(Arg.Is<IRequest>(req => req == request && req.Headers["If-None-Matched"] == etag), cancellationToken).ReturnsForAnyArgs(githubResponse); + responseCache.GetAsync(request).Returns(cachedV1Response); + if (setCacheThrows) + { + responseCache.SetAsync(request, Arg.Any<CachedResponse.V1>()).ThrowsForAnyArgs<Exception>(); + } + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + var response = await cachingHttpClient.Send(request, cancellationToken); + + // assert + Assert.Equal(githubResponse, response, new ResponseComparer()); + Assert.Single(underlyingClient.ReceivedCalls()); + underlyingClient.Received(1).Send(request, cancellationToken); + Assert.Equal(2, responseCache.ReceivedCalls().Count()); + responseCache.Received(1).GetAsync(request); + responseCache.Received(1).SetAsync(request, Arg.Is<CachedResponse.V1>(v1 => new ResponseComparer().Equals(v1, CachedResponse.V1.Create(githubResponse)))); + } + + public static IEnumerable<object[]> NonNotModifiedHttpStatusCodesWithSetCacheFailure() + { + foreach (var statusCode in Enum.GetValues(typeof(HttpStatusCode))) + { + if (statusCode.Equals(HttpStatusCode.NotModified)) continue; + yield return new[] { statusCode, true }; + yield return new[] { statusCode, false }; + } + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task UsesGithubResponseIfCachedEntryIsNull(bool setCacheThrows) + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + var request = Substitute.For<IRequest>(); + request.Method.Returns(HttpMethod.Get); + request.Headers.Returns(new Dictionary<string, string>()); + + var cancellationToken = CancellationToken.None; + + var githubResponse = Substitute.For<IResponse>(); + + underlyingClient.Send(Arg.Is<IRequest>(req => req == request && !req.Headers.Any()), cancellationToken).ReturnsForAnyArgs(githubResponse); + responseCache.GetAsync(request).ReturnsNull(); + if (setCacheThrows) + { + responseCache.SetAsync(request, Arg.Any<CachedResponse.V1>()).ThrowsForAnyArgs<Exception>(); + } + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + var response = await cachingHttpClient.Send(request, cancellationToken); + + // assert + Assert.Equal(githubResponse, response, new ResponseComparer()); + Assert.Single(underlyingClient.ReceivedCalls()); + underlyingClient.Received(1).Send(request, cancellationToken); + Assert.Equal(2, responseCache.ReceivedCalls().Count()); + responseCache.Received(1).GetAsync(request); + responseCache.Received(1).SetAsync(request, Arg.Is<CachedResponse.V1>(v1 => new ResponseComparer().Equals(v1, CachedResponse.V1.Create(githubResponse)))); + } + + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task UsesGithubResponseIfGetCachedEntryThrows(bool setCacheThrows) + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + var request = Substitute.For<IRequest>(); + request.Method.Returns(HttpMethod.Get); + request.Headers.Returns(new Dictionary<string, string>()); + + var cancellationToken = CancellationToken.None; + + var githubResponse = Substitute.For<IResponse>(); + + underlyingClient.Send(Arg.Is<IRequest>(req => req == request && !req.Headers.Any()), cancellationToken).ReturnsForAnyArgs(githubResponse); + responseCache.GetAsync(Args.Request).ThrowsForAnyArgs<Exception>(); + if (setCacheThrows) + { + responseCache.SetAsync(request, Arg.Any<CachedResponse.V1>()).ThrowsForAnyArgs<Exception>(); + } + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + var response = await cachingHttpClient.Send(request, cancellationToken); + + // assert + Assert.Equal(githubResponse, response, new ResponseComparer()); + Assert.Single(underlyingClient.ReceivedCalls()); + underlyingClient.Received(1).Send(request, cancellationToken); + Assert.Equal(2, responseCache.ReceivedCalls().Count()); + responseCache.Received(1).GetAsync(request); + responseCache.Received(1).SetAsync(request, Arg.Is<CachedResponse.V1>(v1 => new ResponseComparer().Equals(v1, CachedResponse.V1.Create(githubResponse)))); + } + + [Theory] + [InlineData(null, true)] + [InlineData(null, false)] + [InlineData("", true)] + [InlineData("", false)] + public async Task UsesGithubResponseIfCachedEntryEtagIsNullOrEmpty(string etag, bool setCacheThrows) + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + var request = Substitute.For<IRequest>(); + request.Method.Returns(HttpMethod.Get); + request.Headers.Returns(new Dictionary<string, string>()); + + var cachedResponse = Substitute.For<IResponse>(); + cachedResponse.Headers.Returns(etag == null ? new Dictionary<string, string>() : new Dictionary<string, string> { { "ETag", etag } }); + + var cachedV1Response = CachedResponse.V1.Create(cachedResponse); + var cancellationToken = CancellationToken.None; + + var githubResponse = Substitute.For<IResponse>(); + + underlyingClient.Send(Arg.Is<IRequest>(req => req == request && !req.Headers.Any()), cancellationToken).ReturnsForAnyArgs(githubResponse); + responseCache.GetAsync(request).Returns(cachedV1Response); + if (setCacheThrows) + { + responseCache.SetAsync(request, Arg.Any<CachedResponse.V1>()).ThrowsForAnyArgs<Exception>(); + } + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + var response = await cachingHttpClient.Send(request, cancellationToken); + + // assert + Assert.Equal(githubResponse, response, new ResponseComparer()); + Assert.Single(underlyingClient.ReceivedCalls()); + underlyingClient.Received(1).Send(request, cancellationToken); + Assert.Equal(2, responseCache.ReceivedCalls().Count()); + responseCache.Received(1).GetAsync(request); + responseCache.Received(1).SetAsync(request, Arg.Is<CachedResponse.V1>(v1 => new ResponseComparer().Equals(v1, CachedResponse.V1.Create(githubResponse)))); + } + } + + public class TheSetRequestTimeoutMethod + { + [Fact] + public void SetsRequestTimeoutForUnderlyingClient() + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + var timeout = TimeSpan.Zero; + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + cachingHttpClient.SetRequestTimeout(timeout); + + // assert + underlyingClient.Received(1).SetRequestTimeout(timeout); + } + } + + public class TheDisposeMethod + { + [Fact] + public void CallsDisposeForUnderlyingClient() + { + // arrange + var underlyingClient = Substitute.For<IHttpClient>(); + var responseCache = Substitute.For<IResponseCache>(); + + var cachingHttpClient = new CachingHttpClient(underlyingClient, responseCache); + + // act + cachingHttpClient.Dispose(); + + // assert + underlyingClient.Received(1).Dispose(); + } + } + + public class TheCtor + { + [Theory] + [InlineData(true, true)] + [InlineData(true, false)] + [InlineData(false, true)] + public void EnsuresNonNullArguments(bool httpClientIsNull, bool responseCacheIsNull) + { + var httpClient = httpClientIsNull ? null : Substitute.For<IHttpClient>(); + var responseCache = responseCacheIsNull ? null : Substitute.For<IResponseCache>(); + + Assert.Throws<ArgumentNullException>(() => new CachingHttpClient(httpClient, responseCache)); + } + } + } +} diff --git a/Octokit.Tests/GitHubClientTests.cs b/Octokit.Tests/GitHubClientTests.cs index ccc2e2c404..9be895fa75 100644 --- a/Octokit.Tests/GitHubClientTests.cs +++ b/Octokit.Tests/GitHubClientTests.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Reflection; using System.Linq; +using Octokit.Caching; namespace Octokit.Tests { @@ -134,6 +135,47 @@ public void IsRetrievedFromCredentialStore() } } + public class TheResponseCacheProperty + { + [Fact] + public void WhenSetWrapsExistingHttpClientWithCachingHttpClient() + { + var responseCache = Substitute.For<IResponseCache>(); + var client = new GitHubClient(new ProductHeaderValue("OctokitTests")); + Assert.IsType<Connection>(client.Connection); + var existingConnection = (Connection) client.Connection; + var existingHttpClient = existingConnection._httpClient; + + client.ResponseCache = responseCache; + + Assert.Equal(existingConnection, client.Connection); + Assert.IsType<CachingHttpClient>(existingConnection._httpClient); + var cachingHttpClient = (CachingHttpClient) existingConnection._httpClient; + Assert.Equal(existingHttpClient, cachingHttpClient._httpClient); + Assert.Equal(responseCache, cachingHttpClient._responseCache); + } + + [Fact] + public void WhenResetWrapsUnderlyingHttpClientWithCachingHttpClient() + { + var responseCache = Substitute.For<IResponseCache>(); + + var client = new GitHubClient(new ProductHeaderValue("OctokitTests")); + Assert.IsType<Connection>(client.Connection); + var existingConnection = (Connection) client.Connection; + var existingHttpClient = existingConnection._httpClient; + client.ResponseCache = Substitute.For<IResponseCache>(); + + client.ResponseCache = responseCache; + + Assert.Equal(existingConnection, client.Connection); + Assert.IsType<CachingHttpClient>(existingConnection._httpClient); + var cachingHttpClient = (CachingHttpClient) existingConnection._httpClient; + Assert.Equal(existingHttpClient, cachingHttpClient._httpClient); + Assert.Equal(responseCache, cachingHttpClient._responseCache); + } + } + public class TheLastApiInfoProperty { [Fact] diff --git a/Octokit.Tests/Helpers/ApiInfoComparer.cs b/Octokit.Tests/Helpers/ApiInfoComparer.cs new file mode 100644 index 0000000000..d15403b707 --- /dev/null +++ b/Octokit.Tests/Helpers/ApiInfoComparer.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; + +namespace Octokit.Tests.Helpers +{ + public class ApiInfoComparer : IEqualityComparer<ApiInfo> + { + private static readonly CollectionComparer<string> _stringCollectionComparer = new CollectionComparer<string>(); + private static readonly StringKeyedDictionaryComparer<Uri> _stringKeyedDictionaryComparer = new StringKeyedDictionaryComparer<Uri>(); + private static readonly RateLimitComparer _rateLimitComparer = new RateLimitComparer(); + + public bool Equals(ApiInfo x, ApiInfo y) + { + if (ReferenceEquals(x, y)) return true; + if (ReferenceEquals(x, null)) return false; + if (ReferenceEquals(y, null)) return false; + if (x.GetType() != y.GetType()) return false; + + return _stringCollectionComparer.Equals(x.OauthScopes, y.OauthScopes) && + _stringCollectionComparer.Equals(x.AcceptedOauthScopes, y.AcceptedOauthScopes) && + x.Etag == y.Etag && + _stringKeyedDictionaryComparer.Equals(x.Links, y.Links) && + _rateLimitComparer.Equals(x.RateLimit, y.RateLimit) && + x.ServerTimeDifference.Equals(y.ServerTimeDifference); + } + + public int GetHashCode(ApiInfo obj) + { + unchecked + { + var hashCode = (obj.OauthScopes != null ? _stringCollectionComparer.GetHashCode(obj.OauthScopes) : 0); + hashCode = (hashCode * 397) ^ (obj.AcceptedOauthScopes != null ? _stringCollectionComparer.GetHashCode(obj.AcceptedOauthScopes) : 0); + hashCode = (hashCode * 397) ^ (obj.Etag != null ? obj.Etag.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (obj.Links != null ? _stringKeyedDictionaryComparer.GetHashCode(obj.Links) : 0); + hashCode = (hashCode * 397) ^ (obj.RateLimit != null ? _rateLimitComparer.GetHashCode(obj.RateLimit) : 0); + hashCode = (hashCode * 397) ^ obj.ServerTimeDifference.GetHashCode(); + return hashCode; + } + } + } +} diff --git a/Octokit.Tests/Helpers/CollectionComparer.cs b/Octokit.Tests/Helpers/CollectionComparer.cs new file mode 100644 index 0000000000..3720885c7c --- /dev/null +++ b/Octokit.Tests/Helpers/CollectionComparer.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Octokit.Tests.Helpers +{ + public class CollectionComparer<T> : IEqualityComparer<IReadOnlyCollection<T>> + { + public bool Equals(IReadOnlyCollection<T> x, IReadOnlyCollection<T> y) + { + if (ReferenceEquals(x, y)) return true; + if (ReferenceEquals(x, null)) return false; + if (ReferenceEquals(y, null)) return false; + if (x.GetType() != y.GetType()) return false; + + return x.Count == y.Count && x.Intersect(y).Count() == x.Count(); + } + + public int GetHashCode(IReadOnlyCollection<T> obj) + { + return obj.Count; + } + } +} diff --git a/Octokit.Tests/Helpers/RateLimitComparer.cs b/Octokit.Tests/Helpers/RateLimitComparer.cs new file mode 100644 index 0000000000..3f3eaa2be0 --- /dev/null +++ b/Octokit.Tests/Helpers/RateLimitComparer.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; + +namespace Octokit.Tests.Helpers +{ + public class RateLimitComparer : IEqualityComparer<RateLimit> + { + public bool Equals(RateLimit x, RateLimit y) + { + if (ReferenceEquals(x, y)) return true; + if (ReferenceEquals(x, null)) return false; + if (ReferenceEquals(y, null)) return false; + if (x.GetType() != y.GetType()) return false; + + return x.Limit == y.Limit && + x.Remaining == y.Remaining && + x.ResetAsUtcEpochSeconds == y.ResetAsUtcEpochSeconds; + } + + public int GetHashCode(RateLimit obj) + { + unchecked + { + var hashCode = obj.Limit; + hashCode = (hashCode * 397) ^ obj.Remaining; + hashCode = (hashCode * 397) ^ obj.ResetAsUtcEpochSeconds.GetHashCode(); + return hashCode; + } + } + } +} diff --git a/Octokit.Tests/Helpers/ResponseComparer.cs b/Octokit.Tests/Helpers/ResponseComparer.cs new file mode 100644 index 0000000000..ee3c2a8e92 --- /dev/null +++ b/Octokit.Tests/Helpers/ResponseComparer.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; + +namespace Octokit.Tests.Helpers +{ + public class ResponseComparer : IEqualityComparer<IResponse> + { + private static readonly StringKeyedDictionaryComparer<string> _stringKeyedDictionaryComparer = new StringKeyedDictionaryComparer<string>(); + private static readonly ApiInfoComparer _apiInfoComparer = new ApiInfoComparer(); + + public bool Equals(IResponse x, IResponse y) + { + if (ReferenceEquals(x, y)) return true; + if (ReferenceEquals(x, null)) return false; + if (ReferenceEquals(y, null)) return false; + if (x.GetType() != y.GetType()) return false; + + return Equals(x.Body, y.Body) && + _stringKeyedDictionaryComparer.Equals(x.Headers, y.Headers) && + _apiInfoComparer.Equals(x.ApiInfo, y.ApiInfo) && + x.StatusCode == y.StatusCode && + x.ContentType == y.ContentType; + } + + public int GetHashCode(IResponse obj) + { + unchecked + { + var hashCode = (obj.Body != null ? obj.Body.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ (obj.Headers != null ? _stringKeyedDictionaryComparer.GetHashCode(obj.Headers) : 0); + hashCode = (hashCode * 397) ^ (obj.ApiInfo != null ? _apiInfoComparer.GetHashCode(obj.ApiInfo) : 0); + hashCode = (hashCode * 397) ^ (int)obj.StatusCode; + hashCode = (hashCode * 397) ^ (obj.ContentType != null ? obj.ContentType.GetHashCode() : 0); + return hashCode; + } + } + } +} diff --git a/Octokit.Tests/Helpers/StringKeyedDictionaryComparer.cs b/Octokit.Tests/Helpers/StringKeyedDictionaryComparer.cs new file mode 100644 index 0000000000..f8b9309b70 --- /dev/null +++ b/Octokit.Tests/Helpers/StringKeyedDictionaryComparer.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Octokit.Tests.Helpers +{ + public class StringKeyedDictionaryComparer<T> : IEqualityComparer<IReadOnlyDictionary<string, T>> + { + public bool Equals(IReadOnlyDictionary<string, T> x, IReadOnlyDictionary<string, T> y) + { + if (ReferenceEquals(x, y)) return true; + if (ReferenceEquals(x, null)) return false; + if (ReferenceEquals(y, null)) return false; + if (x.GetType() != y.GetType()) return false; + + return x.Count == y.Count && x.Intersect(y).Count() == x.Count; + } + + public int GetHashCode(IReadOnlyDictionary<string, T> obj) + { + return obj.Count; + } + } +} diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index ced0736d57..c915386fae 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using NSubstitute; +using Octokit.Caching; using Octokit.Internal; using Xunit; @@ -859,5 +860,47 @@ public async Task ReturnsObjectIfNotNew() Assert.Equal(100, result.RateLimit.Limit); } } + + public class TheResponseCacheProperty + { + [Fact] + public void WhenSetWrapsExistingHttpClientWithCachingHttpClient() + { + var responseCache = Substitute.For<IResponseCache>(); + var httpClient = Substitute.For<IHttpClient>(); + var connection = new Connection(new ProductHeaderValue("OctokitTests"), + _exampleUri, + Substitute.For<ICredentialStore>(), + httpClient, + Substitute.For<IJsonSerializer>()); + + connection.ResponseCache = responseCache; + + Assert.IsType<CachingHttpClient>(connection._httpClient); + var cachingHttpClient = (CachingHttpClient) connection._httpClient; + Assert.Equal(httpClient, cachingHttpClient._httpClient); + Assert.Equal(responseCache, cachingHttpClient._responseCache); + } + + [Fact] + public void WhenResetWrapsUnderlyingHttpClientWithCachingHttpClient() + { + var responseCache = Substitute.For<IResponseCache>(); + var httpClient = Substitute.For<IHttpClient>(); + var connection = new Connection(new ProductHeaderValue("OctokitTests"), + _exampleUri, + Substitute.For<ICredentialStore>(), + httpClient, + Substitute.For<IJsonSerializer>()); + connection.ResponseCache = Substitute.For<IResponseCache>(); + + connection.ResponseCache = responseCache; + + Assert.IsType<CachingHttpClient>(connection._httpClient); + var cachingHttpClient = (CachingHttpClient) connection._httpClient; + Assert.Equal(httpClient, cachingHttpClient._httpClient); + Assert.Equal(responseCache, cachingHttpClient._responseCache); + } + } } } diff --git a/Octokit/Caching/CachedResponse.cs b/Octokit/Caching/CachedResponse.cs new file mode 100644 index 0000000000..4d63371aff --- /dev/null +++ b/Octokit/Caching/CachedResponse.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using System.Linq; +using System.Net; +using Octokit.Internal; + +namespace Octokit.Caching +{ + /// <remarks> + /// When implementation details of <see cref="Response"/> changes: + /// <list type="number"> + /// <item>mark <see cref="V1"/> as Obsolete</item> + /// <item>create a V2</item> + /// <item>update usages of <see cref="V1"/> to V2</item> + /// </list> + /// </remarks> + public static class CachedResponse + { + public sealed class V1 : IResponse + { + public V1(object body, IReadOnlyDictionary<string, string> headers, ApiInfo apiInfo, HttpStatusCode statusCode, string contentType) + { + Ensure.ArgumentNotNull(headers, nameof(headers)); + + StatusCode = statusCode; + Body = body; + Headers = headers; + ApiInfo = apiInfo; + ContentType = contentType; + } + + /// <summary> + /// Raw response body. Typically a string, but when requesting images, it will be a byte array. + /// </summary> + public object Body { get; private set; } + /// <summary> + /// Information about the API. + /// </summary> + public IReadOnlyDictionary<string, string> Headers { get; private set; } + /// <summary> + /// Information about the API response parsed from the response headers. + /// </summary> + public ApiInfo ApiInfo { get; internal set; } // This setter is internal for use in tests. + /// <summary> + /// The response status code. + /// </summary> + public HttpStatusCode StatusCode { get; private set; } + /// <summary> + /// The content type of the response. + /// </summary> + public string ContentType { get; private set; } + + internal Response ToResponse() => + new Response(StatusCode, Body, Headers.ToDictionary(kvp => kvp.Key, kvp => kvp.Value), ContentType); + + public static V1 Create(IResponse response) + { + Ensure.ArgumentNotNull(response, nameof(response)); + + return new V1(response.Body, response.Headers, response.ApiInfo, response.StatusCode, response.ContentType); + } + } + } +} diff --git a/Octokit/Caching/CachingHttpClient.cs b/Octokit/Caching/CachingHttpClient.cs new file mode 100644 index 0000000000..059c1aef73 --- /dev/null +++ b/Octokit/Caching/CachingHttpClient.cs @@ -0,0 +1,86 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Octokit.Internal; + +namespace Octokit.Caching +{ + public sealed class CachingHttpClient : IHttpClient + { + internal readonly IHttpClient _httpClient; + internal readonly IResponseCache _responseCache; + + public CachingHttpClient(IHttpClient httpClient, IResponseCache responseCache) + { + Ensure.ArgumentNotNull(httpClient, nameof(httpClient)); + Ensure.ArgumentNotNull(responseCache, nameof(responseCache)); + + _httpClient = httpClient is CachingHttpClient cachingHttpClient ? cachingHttpClient._httpClient : httpClient; + _responseCache = responseCache; + } + + public async Task<IResponse> Send(IRequest request, CancellationToken cancellationToken) + { + Ensure.ArgumentNotNull(request, nameof(request)); + + if (request.Method != HttpMethod.Get) + { + return await _httpClient.Send(request, cancellationToken); + } + + var cachedResponse = await TryGetCachedResponse(request); + if (cachedResponse != null && !string.IsNullOrEmpty(cachedResponse.ApiInfo.Etag)) + { + request.Headers["If-None-Match"] = cachedResponse.ApiInfo.Etag; + var conditionalResponse = await _httpClient.Send(request, cancellationToken); + if (conditionalResponse.StatusCode == HttpStatusCode.NotModified) + { + return cachedResponse; + } + + TrySetCachedResponse(request, conditionalResponse); + return conditionalResponse; + } + + var response = await _httpClient.Send(request, cancellationToken); + TrySetCachedResponse(request, response); + return response; + } + + private async Task<IResponse> TryGetCachedResponse(IRequest request) + { + try + { + return (await _responseCache.GetAsync(request))?.ToResponse(); + } + catch (Exception) + { + return null; + } + } + + private async Task TrySetCachedResponse(IRequest request, IResponse response) + { + try + { + await _responseCache.SetAsync(request, CachedResponse.V1.Create(response)); + } + catch (Exception) + { + // ignored + } + } + + public void SetRequestTimeout(TimeSpan timeout) + { + _httpClient.SetRequestTimeout(timeout); + } + + public void Dispose() + { + _httpClient.Dispose(); + } + } +} diff --git a/Octokit/Caching/IResponseCache.cs b/Octokit/Caching/IResponseCache.cs new file mode 100644 index 0000000000..0c2b817140 --- /dev/null +++ b/Octokit/Caching/IResponseCache.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using Octokit.Internal; + +namespace Octokit.Caching +{ + public interface IResponseCache + { + Task<CachedResponse.V1> GetAsync(IRequest request); + + Task SetAsync(IRequest request, CachedResponse.V1 cachedResponse); + } +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index 77c8dbba5e..367dbdf5c1 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -1,4 +1,5 @@ using System; +using Octokit.Caching; using Octokit.Internal; namespace Octokit @@ -163,6 +164,21 @@ public Credentials Credentials } } + /// <summary> + /// Convenience property for setting response cache. + /// </summary> + /// <remarks> + /// Setting this property will wrap existing <see cref="IHttpClient"/> in <see cref="CachingHttpClient"/>. + /// </remarks> + public IResponseCache ResponseCache + { + set + { + Ensure.ArgumentNotNull(value, nameof(value)); + Connection.ResponseCache = value; + } + } + /// <summary> /// The base address of the GitHub API. This defaults to https://api.github.com, /// but you can change it if needed (to talk to a GitHub:Enterprise server for instance). diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 6a9f065c86..3ade4de912 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; +using Octokit.Caching; using Octokit.Internal; namespace Octokit @@ -23,7 +24,7 @@ public class Connection : IConnection readonly Authenticator _authenticator; readonly JsonHttpPipeline _jsonPipeline; - readonly IHttpClient _httpClient; + internal IHttpClient _httpClient; /// <summary> /// Creates a new connection instance used to make requests of the GitHub API. @@ -650,6 +651,21 @@ public Credentials Credentials } } + /// <summary> + /// Sets response cache used by the connection. + /// </summary> + /// <remarks> + /// Setting this property will wrap existing <see cref="IHttpClient"/> in <see cref="CachingHttpClient"/>. + /// </remarks> + public IResponseCache ResponseCache + { + set + { + Ensure.ArgumentNotNull(value, nameof(value)); + _httpClient = new CachingHttpClient(_httpClient, value); + } + } + async Task<IApiResponse<string>> GetHtml(IRequest request) { request.Headers.Add("Accept", AcceptHeaders.StableVersionHtml); diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 3eacde0494..1f0e052fa8 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -3,6 +3,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; +using Octokit.Caching; using Octokit.Internal; namespace Octokit @@ -302,7 +303,7 @@ Task<IApiResponse<T>> Post<T>( /// <typeparam name="T">The type to map the response to</typeparam> /// <param name="uri">URI endpoint to send request to</param> /// <param name="data">The object to serialize as the body of the request</param> - /// <param name="accepts">Specifies accept response media type</param> + /// <param name="accepts">Specifies accept response media type</param> Task<IApiResponse<T>> Delete<T>(Uri uri, object data, string accepts); /// <summary> @@ -319,13 +320,21 @@ Task<IApiResponse<T>> Post<T>( /// Gets or sets the credentials used by the connection. /// </summary> /// <remarks> - /// You can use this property if you only have a single hard-coded credential. Otherwise, pass in an - /// <see cref="ICredentialStore"/> to the constructor. - /// Setting this property will change the <see cref="ICredentialStore"/> to use + /// You can use this property if you only have a single hard-coded credential. Otherwise, pass in an + /// <see cref="ICredentialStore"/> to the constructor. + /// Setting this property will change the <see cref="ICredentialStore"/> to use /// the default <see cref="InMemoryCredentialStore"/> with just these credentials. /// </remarks> Credentials Credentials { get; set; } + /// <summary> + /// Sets response cache used by the connection. + /// </summary> + /// <remarks> + /// Setting this property will wrap existing <see cref="IHttpClient"/> in <see cref="CachingHttpClient"/>. + /// </remarks> + IResponseCache ResponseCache { set; } + /// <summary> /// Sets the timeout for the connection between the client and the server. /// </summary> From 8ba882e98d4dca6ce893d3ac3b5684b25cbe8a53 Mon Sep 17 00:00:00 2001 From: Heath Stewart <heaths@outlook.com> Date: Tue, 21 Feb 2023 14:03:20 -0800 Subject: [PATCH 182/209] Add StateReason to IssueUpdate (#2665) Fixes #2664 Co-authored-by: Nick Floyd <139819+nickfloyd@users.noreply.github.com> --- .../Clients/IssuesClientTests.cs | 40 +++++++++++++++++++ Octokit.Tests/Models/IssueTest.cs | 2 + Octokit/Models/Request/IssueRequest.cs | 24 +++++++++++ Octokit/Models/Request/IssueUpdate.cs | 7 +++- Octokit/Models/Response/Issue.cs | 10 ++++- 5 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 2a92b35b59..0edfcbdcfe 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -213,6 +213,46 @@ public async Task CanCreateRetrieveAndCloseIssue() } } + [IntegrationTest] + public async Task CanCreateCloseAndReopenIssue() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + newIssue.Labels.Add("test"); + newIssue.Assignees.Add(_context.RepositoryOwner); + + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + Assert.NotNull(issue); + Assert.True(issue.Assignees.All(x => x.Login == _context.RepositoryOwner)); + + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.True(retrieved.Assignees.Count == 1); + Assert.True(retrieved.Assignees[0].Login == _context.RepositoryOwner); + + var update = retrieved.ToUpdate(); + update.State = ItemState.Closed; + update.StateReason = ItemStateReason.NotPlanned; + + var closed = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, update); + Assert.NotNull(closed); + Assert.Equal(ItemState.Closed, closed.State); + Assert.Equal(ItemStateReason.NotPlanned, closed.StateReason); + + retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.Equal(ItemState.Closed, retrieved.State); + Assert.Equal(ItemStateReason.NotPlanned, retrieved.StateReason); + + update = retrieved.ToUpdate(); + update.State = ItemState.Open; + update.StateReason = ItemStateReason.Reopened; + + var reopened = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, update); + Assert.NotNull(reopened); + Assert.Equal(ItemState.Open, reopened.State); + Assert.Equal(ItemStateReason.Reopened, reopened.StateReason); + } + [IntegrationTest] public async Task CanCreateRetrieveAndCloseIssueWithRepositoryId() { diff --git a/Octokit.Tests/Models/IssueTest.cs b/Octokit.Tests/Models/IssueTest.cs index 7d0e910f5e..8e34033383 100644 --- a/Octokit.Tests/Models/IssueTest.cs +++ b/Octokit.Tests/Models/IssueTest.cs @@ -145,6 +145,7 @@ public void CreatesAnIssueUpdateRequestObject() ""html_url"": ""https://github.com/octocat/Hello-World/issues/1347"", ""number"": 1347, ""state"": ""open"", +""state_reason"": ""reopened"", ""title"": ""Found a bug"", ""body"": ""I'm having a problem with this."", ""user"": { @@ -283,6 +284,7 @@ public void CreatesAnIssueUpdateRequestObject() Assert.NotNull(update.Labels); Assert.Equal(1, update.Milestone.GetValueOrDefault()); Assert.Equal("octocat", update.Assignees.FirstOrDefault()); + Assert.Equal(ItemStateReason.Reopened, update.StateReason.GetValueOrDefault()); } } } diff --git a/Octokit/Models/Request/IssueRequest.cs b/Octokit/Models/Request/IssueRequest.cs index 8c6edc9a0f..c58792e967 100644 --- a/Octokit/Models/Request/IssueRequest.cs +++ b/Octokit/Models/Request/IssueRequest.cs @@ -167,6 +167,30 @@ public enum ItemState Closed } + /// <summary> + /// The reason for the state change. + /// </summary> + public enum ItemStateReason + { + /// <summary> + /// Item closed as completed. + /// </summary> + [Parameter(Value = "completed")] + Completed, + + /// <summary> + /// Item closed as unplanned. + /// </summary> + [Parameter(Value = "not_planned")] + NotPlanned, + + /// <summary> + /// Item reopened. + /// </summary> + [Parameter(Value = "reopened")] + Reopened + } + /// <summary> /// The available properties to sort issues by. /// </summary> diff --git a/Octokit/Models/Request/IssueUpdate.cs b/Octokit/Models/Request/IssueUpdate.cs index 8837e1e32a..34a4821244 100644 --- a/Octokit/Models/Request/IssueUpdate.cs +++ b/Octokit/Models/Request/IssueUpdate.cs @@ -53,6 +53,11 @@ public class IssueUpdate /// </summary> public ItemState? State { get; set; } + /// <summary> + /// The reason for the state change. Ignored unless <see cref="State"/> is changed. + /// </summary> + public ItemStateReason? StateReason { get; set; } + internal string DebuggerDisplay { get @@ -157,4 +162,4 @@ public void RemoveLabel(string name) } } } -} \ No newline at end of file +} diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index ef25f3c26f..b18e99c931 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -12,7 +12,7 @@ public class Issue { public Issue() { } - public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList<Label> labels, User assignee, IReadOnlyList<User> assignees, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, string nodeId, bool locked, Repository repository, ReactionSummary reactions, LockReason? activeLockReason) + public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList<Label> labels, User assignee, IReadOnlyList<User> assignees, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, string nodeId, bool locked, Repository repository, ReactionSummary reactions, LockReason? activeLockReason, ItemStateReason? stateReason) { Id = id; NodeId = nodeId; @@ -39,6 +39,7 @@ public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, i Repository = repository; Reactions = reactions; ActiveLockReason = activeLockReason; + StateReason = stateReason; } /// <summary> @@ -81,6 +82,11 @@ public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, i /// </summary> public StringEnum<ItemState> State { get; private set; } + /// <summary> + /// The reason for the state change. Ignored unless <see cref="State"/> is changed. + /// </summary> + public StringEnum<ItemStateReason>? StateReason { get; private set; } + /// <summary> /// Title of the issue /// </summary> @@ -186,11 +192,13 @@ public IssueUpdate ToUpdate() : Labels.Select(x => x.Name); ItemState state; + ItemStateReason stateReason; var issueUpdate = new IssueUpdate { Body = Body, Milestone = milestoneId, State = (State.TryParse(out state) ? (ItemState?)state : null), + StateReason = (StateReason.HasValue && StateReason.Value.TryParse(out stateReason) ? (ItemStateReason?)stateReason : null), Title = Title }; From 24c17478b44a5f0ace8e76d2448d7fd6bf45494c Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Mon, 27 Feb 2023 16:23:52 +0200 Subject: [PATCH 183/209] Fix conflicts --- .../Octokit.AsyncPaginationExtension.csproj | 2 +- Octokit.Tests/Models/InstallationTest.cs | 2 +- Octokit/Clients/GitHubAppsClient.cs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj index c7668a4dbc..9a9b805a74 100644 --- a/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj +++ b/Octokit.AsyncPaginationExtension/Octokit.AsyncPaginationExtension.csproj @@ -6,7 +6,7 @@ <Authors>GitHub</Authors> <Version>0.0.0-dev</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> - <TargetFrameworks>netstandard2.0;net462</TargetFrameworks> + <TargetFramework>net6.0</TargetFramework> <AssemblyName>Octokit.AsyncPaginationExtension</AssemblyName> <PackageId>Octokit.AsyncPaginationExtension</PackageId> <DebugType>embedded</DebugType> diff --git a/Octokit.Tests/Models/InstallationTest.cs b/Octokit.Tests/Models/InstallationTest.cs index 3505c360f0..ae872b045a 100644 --- a/Octokit.Tests/Models/InstallationTest.cs +++ b/Octokit.Tests/Models/InstallationTest.cs @@ -64,6 +64,6 @@ public void CanBeDeserialized() var installation = serializer.Deserialize<Installation>(json); Assert.Equal(1, installation.Id); - Assert.Equal(InstallationPermissionLevel.Write, installation.Permissions.SecretScanningAlert); + Assert.Equal(InstallationPermissionLevel.Write, installation.Permissions.SecretScanningAlerts); } } diff --git a/Octokit/Clients/GitHubAppsClient.cs b/Octokit/Clients/GitHubAppsClient.cs index 89253bfac7..6e50173c61 100644 --- a/Octokit/Clients/GitHubAppsClient.cs +++ b/Octokit/Clients/GitHubAppsClient.cs @@ -198,7 +198,6 @@ public Task<Installation> GetUserInstallationForCurrent(string user) /// </summary> /// <remarks>https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app</remarks> /// <param name="installationId">The Id of the GitHub App Installation</param> - [Preview("machine-man")] [ManualRoute("DELETE", "/app/installations/{installationId}")] public Task DeleteInstallationForCurrent(long installationId) { From 0ef005346bb8befc0bc12331c453935f27d09ec3 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Mon, 27 Feb 2023 17:34:06 +0200 Subject: [PATCH 184/209] Fix unit test --- Octokit.Tests/Models/InstallationTest.cs | 2 +- Octokit/Caching/CachingHttpClient.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Octokit.Tests/Models/InstallationTest.cs b/Octokit.Tests/Models/InstallationTest.cs index ae872b045a..72f84aecee 100644 --- a/Octokit.Tests/Models/InstallationTest.cs +++ b/Octokit.Tests/Models/InstallationTest.cs @@ -40,7 +40,7 @@ public void CanBeDeserialized() ""checks"": ""write"", ""metadata"": ""read"", ""contents"": ""read"", - ""secret_scanning_alert"": ""write"" + ""secret_scanning_alerts"": ""write"" }, ""events"": [ ""push"", diff --git a/Octokit/Caching/CachingHttpClient.cs b/Octokit/Caching/CachingHttpClient.cs index 059c1aef73..c906bbf64c 100644 --- a/Octokit/Caching/CachingHttpClient.cs +++ b/Octokit/Caching/CachingHttpClient.cs @@ -30,7 +30,7 @@ public async Task<IResponse> Send(IRequest request, CancellationToken cancellati return await _httpClient.Send(request, cancellationToken); } - var cachedResponse = await TryGetCachedResponse(request); + var cachedResponse = await TryGetCachedResponseAsync(request); if (cachedResponse != null && !string.IsNullOrEmpty(cachedResponse.ApiInfo.Etag)) { request.Headers["If-None-Match"] = cachedResponse.ApiInfo.Etag; @@ -40,16 +40,16 @@ public async Task<IResponse> Send(IRequest request, CancellationToken cancellati return cachedResponse; } - TrySetCachedResponse(request, conditionalResponse); + await TrySetCachedResponseAsync(request, conditionalResponse); return conditionalResponse; } var response = await _httpClient.Send(request, cancellationToken); - TrySetCachedResponse(request, response); + await TrySetCachedResponseAsync(request, response); return response; } - private async Task<IResponse> TryGetCachedResponse(IRequest request) + private async Task<IResponse> TryGetCachedResponseAsync(IRequest request) { try { @@ -61,7 +61,7 @@ private async Task<IResponse> TryGetCachedResponse(IRequest request) } } - private async Task TrySetCachedResponse(IRequest request, IResponse response) + private async Task TrySetCachedResponseAsync(IRequest request, IResponse response) { try { From 49e6b99564b9046635921224a28fe1e22b29506b Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Mon, 27 Feb 2023 17:37:42 +0200 Subject: [PATCH 185/209] Bump version --- Octokit/Octokit.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 91d6768582..27c125cffa 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.13</Version> + <Version>1.0.14</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 47fc6ced30f7e0e50eae4f135545d2d1163b1334 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Mon, 27 Feb 2023 18:49:11 +0200 Subject: [PATCH 186/209] Test --- samples/linqpad-samples/01-introducing-octokit.linq | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/linqpad-samples/01-introducing-octokit.linq b/samples/linqpad-samples/01-introducing-octokit.linq index 350137fee9..5f21fa80af 100644 --- a/samples/linqpad-samples/01-introducing-octokit.linq +++ b/samples/linqpad-samples/01-introducing-octokit.linq @@ -1,5 +1,5 @@ <Query Kind="Program"> - <NuGetReference>Octokit</NuGetReference> + <NuGetReference>Apiiro.Octokit</NuGetReference> <NuGetReference>Octokit.Reactive</NuGetReference> <Namespace>Octokit</Namespace> <Namespace>System.Reactive.Linq</Namespace> From 337da8ab45a60773e6556ca2bb199dc78be46baa Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Mon, 27 Feb 2023 18:58:47 +0200 Subject: [PATCH 187/209] test --- build/Tasks/ValidateLINQPadSamples.cs | 2 +- samples/linqpad-samples/01-introducing-octokit.linq | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index 77797757f5..256f0326cb 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -17,7 +17,7 @@ public override void Run(Context context) .Combine("Octokit.Reactive") .Combine("bin") .Combine(context.Configuration) - .Combine("netstandard2.0") + .Combine("net6.0") .MakeAbsolute(context.Environment) .FullPath; diff --git a/samples/linqpad-samples/01-introducing-octokit.linq b/samples/linqpad-samples/01-introducing-octokit.linq index 5f21fa80af..350137fee9 100644 --- a/samples/linqpad-samples/01-introducing-octokit.linq +++ b/samples/linqpad-samples/01-introducing-octokit.linq @@ -1,5 +1,5 @@ <Query Kind="Program"> - <NuGetReference>Apiiro.Octokit</NuGetReference> + <NuGetReference>Octokit</NuGetReference> <NuGetReference>Octokit.Reactive</NuGetReference> <Namespace>Octokit</Namespace> <Namespace>System.Reactive.Linq</Namespace> From e7c7691bd5182deb69f38c7bc91ddf8a70c0cf45 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Mon, 27 Feb 2023 19:14:12 +0200 Subject: [PATCH 188/209] test --- Octokit.Reactive/Octokit.Reactive.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index cdc9f5be84..28d4bf4f17 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -7,6 +7,7 @@ <Version>0.0.0-dev</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <TargetFramework>net6.0</TargetFramework> + <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <AssemblyName>Octokit.Reactive</AssemblyName> <PackageId>Octokit.Reactive</PackageId> <DebugType>embedded</DebugType> From 727d9e069d028e9c43a26f54529316db99209214 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Tue, 28 Feb 2023 10:54:48 +0200 Subject: [PATCH 189/209] test --- build/Tasks/ValidateLINQPadSamples.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index 256f0326cb..cbbdea6ca4 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -83,7 +83,7 @@ private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); writer.WriteLine("ref {0}\\Octokit.dll;", directory); writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", directory); - writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); + // writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); writer.WriteLine(); var xmlText = text.Substring(openTagIndex, endOfMetadata); From c74a17c6fdc84a8c3af0170bbef123792f1d3170 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Tue, 28 Feb 2023 11:02:50 +0200 Subject: [PATCH 190/209] test --- build/Tasks/ValidateLINQPadSamples.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index cbbdea6ca4..602d44f5b3 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -80,7 +80,7 @@ private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, using (var writer = new StreamWriter(stream)) { // reference all known assemblies - writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); + //writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); writer.WriteLine("ref {0}\\Octokit.dll;", directory); writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", directory); // writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); From 49e1637f258e6c40603c0c9e9a2cfef56e5cb3ae Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Tue, 28 Feb 2023 11:08:51 +0200 Subject: [PATCH 191/209] test --- build/Tasks/ValidateLINQPadSamples.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index 602d44f5b3..cfed6cbce7 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -80,7 +80,9 @@ private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, using (var writer = new StreamWriter(stream)) { // reference all known assemblies - //writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); + writer.WriteLine("ref {0}\\System.Threading.Tasks.dll;", directory); + writer.WriteLine("ref {0}\\System.Net.Http.dll;", directory); + writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); writer.WriteLine("ref {0}\\Octokit.dll;", directory); writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", directory); // writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); From 323a18f7bda8bb30854dcd27e9273198f36404ef Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Tue, 28 Feb 2023 14:42:02 +0200 Subject: [PATCH 192/209] Revert "test" This reverts commit 49e1637f258e6c40603c0c9e9a2cfef56e5cb3ae. --- build/Tasks/ValidateLINQPadSamples.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index cfed6cbce7..602d44f5b3 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -80,9 +80,7 @@ private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, using (var writer = new StreamWriter(stream)) { // reference all known assemblies - writer.WriteLine("ref {0}\\System.Threading.Tasks.dll;", directory); - writer.WriteLine("ref {0}\\System.Net.Http.dll;", directory); - writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); + //writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); writer.WriteLine("ref {0}\\Octokit.dll;", directory); writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", directory); // writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); From dc0593fb77cb6096c371855fdfb78dcd773b1479 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Tue, 28 Feb 2023 14:42:12 +0200 Subject: [PATCH 193/209] Revert "test" This reverts commit c74a17c6fdc84a8c3af0170bbef123792f1d3170. --- build/Tasks/ValidateLINQPadSamples.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index 602d44f5b3..cbbdea6ca4 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -80,7 +80,7 @@ private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, using (var writer = new StreamWriter(stream)) { // reference all known assemblies - //writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); + writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); writer.WriteLine("ref {0}\\Octokit.dll;", directory); writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", directory); // writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); From 260ea36c7ad185279172b7a9a1f47c91538fdce0 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Tue, 28 Feb 2023 14:42:16 +0200 Subject: [PATCH 194/209] Revert "test" This reverts commit 727d9e069d028e9c43a26f54529316db99209214. --- build/Tasks/ValidateLINQPadSamples.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Tasks/ValidateLINQPadSamples.cs b/build/Tasks/ValidateLINQPadSamples.cs index cbbdea6ca4..256f0326cb 100644 --- a/build/Tasks/ValidateLINQPadSamples.cs +++ b/build/Tasks/ValidateLINQPadSamples.cs @@ -83,7 +83,7 @@ private static string RewriteLinqpadScriptToUseLocalAssemblies(string directory, writer.WriteLine("ref {0}\\System.Reactive.dll;", directory); writer.WriteLine("ref {0}\\Octokit.dll;", directory); writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", directory); - // writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); + writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.6\\System.Net.Http.dll;"); writer.WriteLine(); var xmlText = text.Substring(openTagIndex, endOfMetadata); From 5bee5d2e2c7a5c77d1885070087fa0e64d40ee52 Mon Sep 17 00:00:00 2001 From: Tal Fin <talfin@apiiro.com> Date: Sun, 5 Mar 2023 10:50:33 +0200 Subject: [PATCH 195/209] Required changes to support response caching --- Octokit/Http/ApiInfo.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Octokit/Http/ApiInfo.cs b/Octokit/Http/ApiInfo.cs index 1ff348d85f..b82f338457 100644 --- a/Octokit/Http/ApiInfo.cs +++ b/Octokit/Http/ApiInfo.cs @@ -28,30 +28,34 @@ public ApiInfo(IDictionary<string, Uri> links, ServerTimeDifference = serverTimeDifference; } + public ApiInfo() + { + } + /// <summary> /// Oauth scopes that were included in the token used to make the request. /// </summary> - public IReadOnlyList<string> OauthScopes { get; private set; } + public IReadOnlyList<string> OauthScopes { get; set; } /// <summary> /// Oauth scopes accepted for this particular call. /// </summary> - public IReadOnlyList<string> AcceptedOauthScopes { get; private set; } + public IReadOnlyList<string> AcceptedOauthScopes { get; set; } /// <summary> /// Etag /// </summary> - public string Etag { get; private set; } + public string Etag { get; set; } /// <summary> /// Links to things like next/previous pages /// </summary> - public IReadOnlyDictionary<string, Uri> Links { get; private set; } + public IReadOnlyDictionary<string, Uri> Links { get; set; } /// <summary> /// Information about the API rate limit /// </summary> - public RateLimit RateLimit { get; private set; } + public RateLimit RateLimit { get; set; } /// <summary> /// The best-effort time difference between the server and the client. From f2d1c821078f04c4348b12ad8a137fb7a3737464 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Tue, 20 Jun 2023 10:30:43 +0300 Subject: [PATCH 196/209] init impl --- Octokit/Clients/AuditLogClient.cs | 15 +++++++ Octokit/Clients/AuditOrganizationsClient.cs | 41 ++++++++++++++++++++ Octokit/Clients/IAuditLogClient.cs | 16 ++++++++ Octokit/Clients/IAuditOrganizationsClient.cs | 19 +++++++++ Octokit/GitHubClient.cs | 10 +++++ Octokit/Helpers/ApiUrls.cs | 14 +++++++ Octokit/Models/Response/AuditLogActivity.cs | 10 +++++ 7 files changed, 125 insertions(+) create mode 100644 Octokit/Clients/AuditLogClient.cs create mode 100644 Octokit/Clients/AuditOrganizationsClient.cs create mode 100644 Octokit/Clients/IAuditLogClient.cs create mode 100644 Octokit/Clients/IAuditOrganizationsClient.cs create mode 100644 Octokit/Models/Response/AuditLogActivity.cs diff --git a/Octokit/Clients/AuditLogClient.cs b/Octokit/Clients/AuditLogClient.cs new file mode 100644 index 0000000000..cf1ecc733f --- /dev/null +++ b/Octokit/Clients/AuditLogClient.cs @@ -0,0 +1,15 @@ +namespace Octokit +{ + public class AuditLogClient : ApiClient, IAuditLogClient + { + public AuditLogClient(IApiConnection apiConnection) : base(apiConnection) + { + Organizations = new AuditOrganizationsClient(apiConnection); + } + + /// <summary> + /// Client for the Organization audit log + /// </summary> + public IAuditOrganizationsClient Organizations { get; } + } +} diff --git a/Octokit/Clients/AuditOrganizationsClient.cs b/Octokit/Clients/AuditOrganizationsClient.cs new file mode 100644 index 0000000000..1ff2bf0088 --- /dev/null +++ b/Octokit/Clients/AuditOrganizationsClient.cs @@ -0,0 +1,41 @@ +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace Octokit +{ + public class AuditOrganizationsClient : ApiClient, IAuditOrganizationsClient + { + /// <summary> + /// Instantiates a new GitHub Issue Events API client. + /// </summary> + /// <param name="apiConnection">An API connection</param> + public AuditOrganizationsClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + [ManualRoute("GET", "/organizations/{org}/audit-log?phrase=actor:{user}+repo:{org}/{repo}")] + public async Task<DateTime?> GetUserLastActivityDate(string organization, string repository, string user) + { + Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); + + var options = new ApiOptions() + { + PageCount = 1, + PageSize = 1 + }; + var auditLogs = await ApiConnection.GetAll<AuditLogActivity>(ApiUrls.AuditLog(organization, repository, user), options); + + if (!auditLogs.Any()) return null; + + var auditLog = auditLogs.Single(); + + var dateTimeOffSet = DateTimeOffset.FromUnixTimeMilliseconds(auditLog.CreatedAt); + var dateTime = dateTimeOffSet.DateTime; + + return dateTime; + + } + } +} diff --git a/Octokit/Clients/IAuditLogClient.cs b/Octokit/Clients/IAuditLogClient.cs new file mode 100644 index 0000000000..73206b2c9b --- /dev/null +++ b/Octokit/Clients/IAuditLogClient.cs @@ -0,0 +1,16 @@ +namespace Octokit +{ + /// <summary> + /// A client for GitHub's Activity API. + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/reviewing-the-audit-log-for-your-organization">Organization Audit Log API documentation</a> for more information. + /// </remarks> + public interface IAuditLogClient + { + /// <summary> + /// Client for the Audit Log Organizations API + /// </summary> + public IAuditOrganizationsClient Organizations { get; } + } +} diff --git a/Octokit/Clients/IAuditOrganizationsClient.cs b/Octokit/Clients/IAuditOrganizationsClient.cs new file mode 100644 index 0000000000..572f669905 --- /dev/null +++ b/Octokit/Clients/IAuditOrganizationsClient.cs @@ -0,0 +1,19 @@ +using System; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IAuditOrganizationsClient + { + /// <summary> + /// Gets all the events for a given repository + /// </summary> + /// <remarks> + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// </remarks> + /// <param name="organization">The organization</param> + /// <param name="repository">The organization</param> + /// <param name="user">The user</param> + Task<DateTime?> GetUserLastActivityDate(string organization, string repository, string user); + } +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index 367dbdf5c1..5fce13bd9d 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -120,6 +120,7 @@ public GitHubClient(IConnection connection) RateLimit = new RateLimitClient(apiConnection); Meta = new MetaClient(apiConnection); Actions = new ActionsClient(apiConnection); + AuditLog = new AuditLogClient(apiConnection); } /// <summary> @@ -208,6 +209,15 @@ public Uri BaseAddress /// Refer to the API documentation for more information: https://developer.github.com/v3/activity/ /// </remarks> public IActivitiesClient Activity { get; private set; } + + /// <summary> + /// Access GitHub's Audit Log API. + /// </summary> + /// <remarks> + /// Refer to the API documentation for more information: https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/using-the-audit-log-api-for-your-enterprise + /// </remarks> + public IAuditLogClient AuditLog { get; private set; } + /// <summary> /// Access GitHub's Emojis API. diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 82621ada5a..7f01309c50 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -5207,5 +5207,19 @@ public static Uri ActionsListWorkflowRuns(string owner, string repo, string work { return "repos/{0}/{1}/actions/workflows/{2}/runs".FormatUri(owner, repo, workflowFileName.UriEncode()); } + + + /// <summary> + /// Creates the relative <see cref="Uri"/> for getting the contents of the specified repository and path + /// </summary> + /// <param name="organization">The organization</param> + /// <param name="user">The user</param> + /// <param name="repository">The repository</param> + /// <returns>The <see cref="Uri"/> for getting the contents of the specified repository and path</returns> + public static Uri AuditLog(string organization, string repository, string user) + { + return "organizations/{0}/audit-log?phrase=actor:{1} repo:{2}/{3}" + .FormatUri(organization, user, organization, repository); + } } } diff --git a/Octokit/Models/Response/AuditLogActivity.cs b/Octokit/Models/Response/AuditLogActivity.cs new file mode 100644 index 0000000000..64c2944d4d --- /dev/null +++ b/Octokit/Models/Response/AuditLogActivity.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace Octokit +{ + public class AuditLogActivity + { + [JsonPropertyName("created_at")] + public long CreatedAt; + } +} From 78012903e4829a03cb5fab84786407934cb9a590 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Tue, 20 Jun 2023 10:35:23 +0300 Subject: [PATCH 197/209] increase version --- Octokit/Octokit.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 27c125cffa..c17cf24cc8 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.14</Version> + <Version>1.0.15</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 247dab1d727ce207aeab97cb914d40a75dd84f2a Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Tue, 20 Jun 2023 11:58:46 +0300 Subject: [PATCH 198/209] fix UTs --- .../Clients/IObservableAuditLogClient.cs | 6 ++++++ .../IObservableAuditOrganizationsClient.cs | 9 +++++++++ .../Clients/ObservableAuditLogClient.cs | 13 +++++++++++++ .../ObservableAuditOrganizationsClient.cs | 19 +++++++++++++++++++ Octokit.Reactive/IObservableGitHubClient.cs | 1 + Octokit.Reactive/ObservableGitHubClient.cs | 2 ++ Octokit/IGitHubClient.cs | 1 + 7 files changed, 51 insertions(+) create mode 100644 Octokit.Reactive/Clients/IObservableAuditLogClient.cs create mode 100644 Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableAuditLogClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs diff --git a/Octokit.Reactive/Clients/IObservableAuditLogClient.cs b/Octokit.Reactive/Clients/IObservableAuditLogClient.cs new file mode 100644 index 0000000000..74ec4d5775 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableAuditLogClient.cs @@ -0,0 +1,6 @@ +namespace Octokit.Reactive; + +public interface IObservableAuditLogClient +{ + public IObservableAuditOrganizationsClient Organizations { get; } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs b/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs new file mode 100644 index 0000000000..2690ffd00c --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs @@ -0,0 +1,9 @@ +using System; +using System.Reactive; + +namespace Octokit.Reactive; + +public interface IObservableAuditOrganizationsClient +{ + IObservable<DateTime?> GetUserLastActivityDate(string organization, string repository, string user); +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableAuditLogClient.cs b/Octokit.Reactive/Clients/ObservableAuditLogClient.cs new file mode 100644 index 0000000000..ae2fd5e960 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableAuditLogClient.cs @@ -0,0 +1,13 @@ +namespace Octokit.Reactive; + +public class ObservableAuditLogClient : IObservableAuditLogClient +{ + + public ObservableAuditLogClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, nameof(client)); + + Organizations = new ObservableAuditOrganizationsClient(client); + } + public IObservableAuditOrganizationsClient Organizations { get; } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs new file mode 100644 index 0000000000..095f8b37fb --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs @@ -0,0 +1,19 @@ +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive; + +public class ObservableAuditOrganizationsClient : IObservableAuditOrganizationsClient +{ + readonly IAuditOrganizationsClient _client; + public ObservableAuditOrganizationsClient(IGitHubClient client) + { + _client = client.AuditLog.Organizations; + } + + public IObservable<DateTime?> GetUserLastActivityDate(string organization, string repository, string user) + { + return _client.GetUserLastActivityDate(organization, repository, user).ToObservable(); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 10cd16e933..c0afabadda 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -42,5 +42,6 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableRateLimitClient RateLimit { get; } IObservableMetaClient Meta { get; } IObservableActionsClient Actions { get; } + IObservableAuditLogClient AuditLog { get; } } } diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 7507a382cf..1159a742fb 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -57,6 +57,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) RateLimit = new ObservableRateLimitClient(gitHubClient); Meta = new ObservableMetaClient(gitHubClient); Actions = new ObservableActionsClient(gitHubClient); + AuditLog = new ObservableAuditLogClient(gitHubClient); } public IConnection Connection @@ -104,6 +105,7 @@ public void SetRequestTimeout(TimeSpan timeout) public IObservableRateLimitClient RateLimit { get; private set; } public IObservableMetaClient Meta { get; private set; } public IObservableActionsClient Actions { get; private set; } + public IObservableAuditLogClient AuditLog { get; private set; } /// <summary> /// Gets the latest API Info - this will be null if no API calls have been made diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 9bd53eb802..3ef3e3f875 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -215,5 +215,6 @@ public interface IGitHubClient : IApiInfoProvider /// </remarks> ILicensesClient Licenses { get; } IEmojisClient Emojis { get; } + IAuditLogClient AuditLog { get; } } } From bdc1ae421daa8f07ade6510d898d8a46e08fa24d Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Tue, 20 Jun 2023 13:14:48 +0300 Subject: [PATCH 199/209] Dont run CI Build on windows --- .github/workflows/netcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/netcore.yml b/.github/workflows/netcore.yml index 8808440e6c..6f319b68fb 100644 --- a/.github/workflows/netcore.yml +++ b/.github/workflows/netcore.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] + platform: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.platform }} From 0ac8af1b4922b23073ac4a894fd99dc6ca67e4c2 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Wed, 21 Jun 2023 11:23:57 +0300 Subject: [PATCH 200/209] Fix PR comments --- .../IObservableAuditOrganizationsClient.cs | 1 - .../ObservableAuditOrganizationsClient.cs | 1 - Octokit/Clients/AuditOrganizationsClient.cs | 3 +- Octokit/Models/Response/AuditLogActivity.cs | 10 -- Octokit/Models/Response/AuditLogEvent.cs | 142 ++++++++++++++++++ 5 files changed, 144 insertions(+), 13 deletions(-) delete mode 100644 Octokit/Models/Response/AuditLogActivity.cs create mode 100644 Octokit/Models/Response/AuditLogEvent.cs diff --git a/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs b/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs index 2690ffd00c..85ebbd019d 100644 --- a/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs @@ -1,5 +1,4 @@ using System; -using System.Reactive; namespace Octokit.Reactive; diff --git a/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs index 095f8b37fb..890b82eefa 100644 --- a/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs @@ -1,5 +1,4 @@ using System; -using System.Reactive; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive; diff --git a/Octokit/Clients/AuditOrganizationsClient.cs b/Octokit/Clients/AuditOrganizationsClient.cs index 1ff2bf0088..44fbbf32ab 100644 --- a/Octokit/Clients/AuditOrganizationsClient.cs +++ b/Octokit/Clients/AuditOrganizationsClient.cs @@ -18,6 +18,7 @@ public AuditOrganizationsClient(IApiConnection apiConnection) : base(apiConnecti public async Task<DateTime?> GetUserLastActivityDate(string organization, string repository, string user) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); + Ensure.ArgumentNotNullOrEmptyString(repository, nameof(repository)); Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); var options = new ApiOptions() @@ -25,7 +26,7 @@ public AuditOrganizationsClient(IApiConnection apiConnection) : base(apiConnecti PageCount = 1, PageSize = 1 }; - var auditLogs = await ApiConnection.GetAll<AuditLogActivity>(ApiUrls.AuditLog(organization, repository, user), options); + var auditLogs = await ApiConnection.GetAll<AuditLogEvent>(ApiUrls.AuditLog(organization, repository, user), options); if (!auditLogs.Any()) return null; diff --git a/Octokit/Models/Response/AuditLogActivity.cs b/Octokit/Models/Response/AuditLogActivity.cs deleted file mode 100644 index 64c2944d4d..0000000000 --- a/Octokit/Models/Response/AuditLogActivity.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Octokit -{ - public class AuditLogActivity - { - [JsonPropertyName("created_at")] - public long CreatedAt; - } -} diff --git a/Octokit/Models/Response/AuditLogEvent.cs b/Octokit/Models/Response/AuditLogEvent.cs new file mode 100644 index 0000000000..48a9cec6ff --- /dev/null +++ b/Octokit/Models/Response/AuditLogEvent.cs @@ -0,0 +1,142 @@ +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AuditLogEvent + { + public AuditLogEvent() { } + + public AuditLogEvent(string action, bool? active, bool? activeWas, string actor, long? actorId, string actorIp, object actorLocation, + string blockedUser, string business, long? businessId, + object config, object configWas, string contentType, long createdAt, + object data, string deployKeyFingerprint, string documentId, + string emoji, object events, object eventsWere, string explanation, + string fingerPrint, + string hashedToken, long? hookId, + bool? limitedAvailability, + string message, + string name, + string oldUser, string opensshPublicKey, string operationType, IReadOnlyList<string> org, IReadOnlyList<long> orgId, + string previousVisibility, bool? publicRepo, long? pullRequestId, string pullRequestTitle, string pullRequestUrl, + bool? readOnly, string repo, long? repoId, string repository, bool? repositoryPublic, + string targetLogin, string team, long? transportProtocol, string transportProtocolName, long timestamp, + string user, string userAgent, long? userId, + string visibility) + { + Action = action; + Active = active; + ActiveWas = activeWas; + Actor = actor; + ActorId = actorId; + ActorIp = actorIp; + ActorLocation = actorLocation; + BlockedUser = blockedUser; + Business = business; + BusinessId = businessId; + Config = config; + ConfigWas = configWas; + ContentType = contentType; + CreatedAt = createdAt; + Data = data; + DeployKeyFingerprint = deployKeyFingerprint; + DocumentId = documentId; + Emoji = emoji; + Events = events; + EventsWere = eventsWere; + Explanation = explanation; + Fingerprint = fingerPrint; + HashedToken = hashedToken; + HookId = hookId; + LimitedAvailability = limitedAvailability; + Message = message; + Name = name; + OldUser = oldUser; + OpensshPublicKey = opensshPublicKey; + OperationType = operationType; + Org = org; + OrgId = orgId; + PreviousVisibility = previousVisibility; + PublicRepo = publicRepo; + PullRequestId = pullRequestId; + PullRequestTitle = pullRequestTitle; + PullRequestUrl = pullRequestUrl; + ReadOnly = readOnly; + Repo = repo; + RepoId = repoId; + Repository = repository; + RepositoryPublic = repositoryPublic; + TargetLogin = targetLogin; + Team = team; + Timestamp = timestamp; + TransportProtocol = transportProtocol; + TransportProtocolName = transportProtocolName; + User = user; + UserAgent = userAgent; + UserId = userId; + Visibility = visibility; + } + + public string Action { get; private set; } + public bool? Active { get; private set; } + public bool? ActiveWas { get; private set; } + public string Actor { get; private set; } + public long? ActorId { get; private set; } + public string ActorIp { get; private set; } + public object ActorLocation { get; private set; } + public string BlockedUser { get; private set; } + public string Business { get; private set; } + public long? BusinessId { get; private set; } + public object Config { get; private set; } + public object ConfigWas { get; private set; } + public string ContentType { get; private set; } + public long CreatedAt { get; private set; } + public object Data { get; private set; } + public string DeployKeyFingerprint { get; private set; } + public string DocumentId { get; private set; } + public string Emoji { get; private set; } + public object Events { get; private set; } + public object EventsWere { get; private set; } + public string Explanation { get; private set; } + public string Fingerprint { get; private set; } + public string HashedToken { get; private set; } + public long? HookId { get; private set; } + public bool? LimitedAvailability { get; private set; } + public string Message { get; private set; } + public string Name { get; private set; } + public string OldUser { get; private set; } + public string OpensshPublicKey { get; private set; } + public string OperationType { get; private set; } + public IReadOnlyList<string> Org { get; private set; } + public IReadOnlyList<long> OrgId { get; private set; } + public string PreviousVisibility { get; private set; } + public bool? PublicRepo { get; private set; } + public long? PullRequestId { get; private set; } + public string PullRequestTitle { get; private set; } + public string PullRequestUrl { get; private set; } + public bool? ReadOnly { get; private set; } + public string Repo { get; private set; } + public long? RepoId { get; private set; } + public string Repository { get; private set; } + public bool? RepositoryPublic { get; private set; } + public string TargetLogin { get; private set; } + public string Team { get; private set; } + public long Timestamp { get; private set; } + public long? TransportProtocol { get; private set; } + public string TransportProtocolName { get; private set; } + public string User { get; private set; } + public string UserAgent { get; private set; } + public long? UserId { get; private set; } + public string Visibility { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Action: {0}, Actor: {1}, DocumentID: {2}", Action, Actor, DocumentId); + } + } + } +} From 6b53bc2c5415a8c095e92b034f6b914dd7637d10 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Tue, 4 Jul 2023 10:29:53 +0300 Subject: [PATCH 201/209] wip --- Octokit/Clients/AuditOrganizationsClient.cs | 14 ++++++++++---- Octokit/Octokit.csproj | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Octokit/Clients/AuditOrganizationsClient.cs b/Octokit/Clients/AuditOrganizationsClient.cs index 44fbbf32ab..eddde0a5a9 100644 --- a/Octokit/Clients/AuditOrganizationsClient.cs +++ b/Octokit/Clients/AuditOrganizationsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -23,14 +24,19 @@ public AuditOrganizationsClient(IApiConnection apiConnection) : base(apiConnecti var options = new ApiOptions() { - PageCount = 1, PageSize = 1 }; - var auditLogs = await ApiConnection.GetAll<AuditLogEvent>(ApiUrls.AuditLog(organization, repository, user), options); - - if (!auditLogs.Any()) return null; + IDictionary<string, string> parameters = new Dictionary<string, string>(); + Pagination.Setup(parameters, options); + var auditLogs = await ApiConnection.Get<List<AuditLogEvent>>(ApiUrls.AuditLog(organization, repository, user), parameters); + + if (!auditLogs.Any()) + { + return null; + } var auditLog = auditLogs.Single(); + if (auditLog == null) return null; var dateTimeOffSet = DateTimeOffset.FromUnixTimeMilliseconds(auditLog.CreatedAt); var dateTime = dateTimeOffSet.DateTime; diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index c17cf24cc8..e5e8f7d1c8 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.15</Version> + <Version>1.0.16</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 8fc35ca5bea8525c154965187bfdd65b00282457 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Tue, 4 Jul 2023 17:32:56 +0300 Subject: [PATCH 202/209] wip --- .../IObservableAuditOrganizationsClient.cs | 2 +- .../ObservableAuditOrganizationsClient.cs | 4 +-- Octokit/Clients/AuditOrganizationsClient.cs | 13 +++++--- Octokit/Clients/IAuditOrganizationsClient.cs | 5 ++- Octokit/Helpers/ApiUrls.cs | 8 ++--- .../Models/Request/AuditLogPhraseOptions.cs | 33 +++++++++++++++++++ Octokit/Octokit.csproj | 2 +- 7 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 Octokit/Models/Request/AuditLogPhraseOptions.cs diff --git a/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs b/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs index 85ebbd019d..ad3c66989c 100644 --- a/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableAuditOrganizationsClient.cs @@ -4,5 +4,5 @@ namespace Octokit.Reactive; public interface IObservableAuditOrganizationsClient { - IObservable<DateTime?> GetUserLastActivityDate(string organization, string repository, string user); + IObservable<DateTime?> GetUserLastActivityDate(string organization, AuditLogPhraseOptions phraseOptions); } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs index 890b82eefa..f5d295f21e 100644 --- a/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableAuditOrganizationsClient.cs @@ -11,8 +11,8 @@ public ObservableAuditOrganizationsClient(IGitHubClient client) _client = client.AuditLog.Organizations; } - public IObservable<DateTime?> GetUserLastActivityDate(string organization, string repository, string user) + public IObservable<DateTime?> GetUserLastActivityDate(string organization, AuditLogPhraseOptions phraseOptions) { - return _client.GetUserLastActivityDate(organization, repository, user).ToObservable(); + return _client.GetUserLastActivityDate(organization, phraseOptions).ToObservable(); } } \ No newline at end of file diff --git a/Octokit/Clients/AuditOrganizationsClient.cs b/Octokit/Clients/AuditOrganizationsClient.cs index eddde0a5a9..1eb0c7fa5a 100644 --- a/Octokit/Clients/AuditOrganizationsClient.cs +++ b/Octokit/Clients/AuditOrganizationsClient.cs @@ -15,12 +15,13 @@ public AuditOrganizationsClient(IApiConnection apiConnection) : base(apiConnecti { } - [ManualRoute("GET", "/organizations/{org}/audit-log?phrase=actor:{user}+repo:{org}/{repo}")] - public async Task<DateTime?> GetUserLastActivityDate(string organization, string repository, string user) + [ManualRoute("GET", "/organizations/{org}/audit-log?phrase={phrase}")] + public async Task<DateTime?> GetUserLastActivityDate(string organization, AuditLogPhraseOptions auditLogPhraseOptions) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); - Ensure.ArgumentNotNullOrEmptyString(repository, nameof(repository)); - Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); + Ensure.ArgumentNotNull(auditLogPhraseOptions, nameof(auditLogPhraseOptions)); + Ensure.ArgumentNotNullOrEmptyString(auditLogPhraseOptions.Repository, nameof(AuditLogPhraseOptions.Repository)); + Ensure.ArgumentNotNullOrEmptyString(auditLogPhraseOptions.User, nameof(AuditLogPhraseOptions.User)); var options = new ApiOptions() { @@ -28,7 +29,9 @@ public AuditOrganizationsClient(IApiConnection apiConnection) : base(apiConnecti }; IDictionary<string, string> parameters = new Dictionary<string, string>(); Pagination.Setup(parameters, options); - var auditLogs = await ApiConnection.Get<List<AuditLogEvent>>(ApiUrls.AuditLog(organization, repository, user), parameters); + + var phrase = auditLogPhraseOptions.BuildPhrase(organization); + var auditLogs = await ApiConnection.Get<List<AuditLogEvent>>(ApiUrls.AuditLog(organization, phrase), parameters); if (!auditLogs.Any()) { diff --git a/Octokit/Clients/IAuditOrganizationsClient.cs b/Octokit/Clients/IAuditOrganizationsClient.cs index 572f669905..2a3da7c4bb 100644 --- a/Octokit/Clients/IAuditOrganizationsClient.cs +++ b/Octokit/Clients/IAuditOrganizationsClient.cs @@ -12,8 +12,7 @@ public interface IAuditOrganizationsClient /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository /// </remarks> /// <param name="organization">The organization</param> - /// <param name="repository">The organization</param> - /// <param name="user">The user</param> - Task<DateTime?> GetUserLastActivityDate(string organization, string repository, string user); + /// <param name="auditLogPhraseOptions">The query phrase options</param> + Task<DateTime?> GetUserLastActivityDate(string organization, AuditLogPhraseOptions auditLogPhraseOptions); } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 7f01309c50..bd9abb0c4a 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -5213,13 +5213,11 @@ public static Uri ActionsListWorkflowRuns(string owner, string repo, string work /// Creates the relative <see cref="Uri"/> for getting the contents of the specified repository and path /// </summary> /// <param name="organization">The organization</param> - /// <param name="user">The user</param> - /// <param name="repository">The repository</param> + /// <param name="phrase">The query phrase to filter results</param> /// <returns>The <see cref="Uri"/> for getting the contents of the specified repository and path</returns> - public static Uri AuditLog(string organization, string repository, string user) + public static Uri AuditLog(string organization, string phrase) { - return "organizations/{0}/audit-log?phrase=actor:{1} repo:{2}/{3}" - .FormatUri(organization, user, organization, repository); + return "organizations/{0}/audit-log?phrase={1}".FormatUri(organization, phrase); } } } diff --git a/Octokit/Models/Request/AuditLogPhraseOptions.cs b/Octokit/Models/Request/AuditLogPhraseOptions.cs new file mode 100644 index 0000000000..ce4f4aac04 --- /dev/null +++ b/Octokit/Models/Request/AuditLogPhraseOptions.cs @@ -0,0 +1,33 @@ +using System; +using System.Text; + +namespace Octokit +{ + public class AuditLogPhraseOptions + { + public string User { get; set; } + public string Repository { get; set; } + public DateTime? Created { get; set; } + + public string BuildPhrase(string organization) + { + var sb = new StringBuilder(); + if (!string.IsNullOrWhiteSpace(User)) + { + sb.Append($"actor:{User} "); + } + + if (!string.IsNullOrWhiteSpace(Repository)) + { + sb.Append($"repo:{organization}/{Repository} "); + } + + if (Created.HasValue) + { + sb.Append($"created:>={Created.Value:yyyy-MM-dd}"); + } + + return sb.ToString(); + } + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index e5e8f7d1c8..547deb9e0a 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.16</Version> + <Version>1.0.17</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 5fc98f0e8828aba10b0aee7f298f8ce596b119ca Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Wed, 27 Dec 2023 11:53:48 +0200 Subject: [PATCH 203/209] wip --- .../Clients/IObservableICopilotClient.cs | 9 +++++ .../Clients/ObservableICopilotClient.cs | 19 ++++++++++ Octokit/Clients/CopilotClient.cs | 35 +++++++++++++++++++ Octokit/Clients/ICopilotClient.cs | 11 ++++++ Octokit/Clients/IOrganizationsClient.cs | 5 +++ Octokit/Clients/OrganizationsClient.cs | 3 ++ Octokit/Helpers/ApiUrls.cs | 10 ++++++ .../Response/Copilot/CopilotAssignee.cs | 13 +++++++ .../Models/Response/Copilot/CopilotSeat.cs | 15 ++++++++ .../Response/Copilot/CopilotSeatsResponse.cs | 16 +++++++++ Octokit/Octokit.csproj | 2 +- 11 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 Octokit.Reactive/Clients/IObservableICopilotClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableICopilotClient.cs create mode 100644 Octokit/Clients/CopilotClient.cs create mode 100644 Octokit/Clients/ICopilotClient.cs create mode 100644 Octokit/Models/Response/Copilot/CopilotAssignee.cs create mode 100644 Octokit/Models/Response/Copilot/CopilotSeat.cs create mode 100644 Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs diff --git a/Octokit.Reactive/Clients/IObservableICopilotClient.cs b/Octokit.Reactive/Clients/IObservableICopilotClient.cs new file mode 100644 index 0000000000..714da510b7 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableICopilotClient.cs @@ -0,0 +1,9 @@ +using System; +using Octokit.Copilot; + +namespace Octokit.Reactive; + +public interface IObservableICopilotClient +{ + IObservable<CopilotSeatsResponse> GetAllSeats(string org); +} diff --git a/Octokit.Reactive/Clients/ObservableICopilotClient.cs b/Octokit.Reactive/Clients/ObservableICopilotClient.cs new file mode 100644 index 0000000000..d51ba9c310 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableICopilotClient.cs @@ -0,0 +1,19 @@ +using System; +using System.Reactive.Threading.Tasks; +using Octokit.Copilot; + +namespace Octokit.Reactive; + +public class ObservableICopilotClient : IObservableICopilotClient +{ + private readonly ICopilotClient _client; + public ObservableICopilotClient(IGitHubClient client) + { + _client = client.Organization.Copilot; + } + + public IObservable<CopilotSeatsResponse> GetAllSeats(string org) + { + return _client.GetAllSeats(org).ToObservable(); + } +} diff --git a/Octokit/Clients/CopilotClient.cs b/Octokit/Clients/CopilotClient.cs new file mode 100644 index 0000000000..b3449317a9 --- /dev/null +++ b/Octokit/Clients/CopilotClient.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Octokit.Copilot; + +namespace Octokit +{ + public class CopilotClient : ApiClient, ICopilotClient + { + public CopilotClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + [ManualRoute("GET", "/orgs/{org}/copilot/billing/seats")] + public async Task<CopilotSeatsResponse> GetAllSeats(string org) + { + Ensure.ArgumentNotNullOrEmptyString(org, nameof(org)); + + var results = await ApiConnection.GetAll<CopilotSeatsResponse>(ApiUrls.CopilotSeats(org), ApiOptions.None); + if (results.Count == 0) + { + return new CopilotSeatsResponse { TotalSeats = 0 }; + } + + var totalSeats = results[0].TotalSeats; + var seats = new List<CopilotSeat>(); + + foreach (var copilotSeatsResponse in results) + { + seats.AddRange(copilotSeatsResponse.Seats); + } + + return new CopilotSeatsResponse { TotalSeats = totalSeats, Seats = seats }; + } + } +} diff --git a/Octokit/Clients/ICopilotClient.cs b/Octokit/Clients/ICopilotClient.cs new file mode 100644 index 0000000000..aa39c6b0b9 --- /dev/null +++ b/Octokit/Clients/ICopilotClient.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Octokit.Copilot; + +namespace Octokit +{ + public interface ICopilotClient + { + Task<CopilotSeatsResponse> GetAllSeats(string org); + } +} diff --git a/Octokit/Clients/IOrganizationsClient.cs b/Octokit/Clients/IOrganizationsClient.cs index d87d69387d..e3da0a9412 100644 --- a/Octokit/Clients/IOrganizationsClient.cs +++ b/Octokit/Clients/IOrganizationsClient.cs @@ -39,6 +39,11 @@ public interface IOrganizationsClient /// Returns a client to manage organization actions. /// </summary> IOrganizationActionsClient Actions { get; } + + /// <summary> + /// Returns a client to manage organization Copilot seats. + /// </summary> + ICopilotClient Copilot { get; } /// <summary> /// Returns the specified <see cref="Organization"/>. diff --git a/Octokit/Clients/OrganizationsClient.cs b/Octokit/Clients/OrganizationsClient.cs index 57abb1e716..05e23b765f 100644 --- a/Octokit/Clients/OrganizationsClient.cs +++ b/Octokit/Clients/OrganizationsClient.cs @@ -23,6 +23,7 @@ public OrganizationsClient(IApiConnection apiConnection) : base(apiConnection) Hook = new OrganizationHooksClient(apiConnection); OutsideCollaborator = new OrganizationOutsideCollaboratorsClient(apiConnection); Actions = new OrganizationActionsClient(apiConnection); + Copilot = new CopilotClient(apiConnection); } /// <summary> @@ -40,6 +41,8 @@ public OrganizationsClient(IApiConnection apiConnection) : base(apiConnection) /// </summary> public IOrganizationActionsClient Actions { get; private set; } + public ICopilotClient Copilot { get; } + /// <summary> /// Returns a client to manage outside collaborators of an organization. /// </summary> diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index bd9abb0c4a..2f65c8a5c4 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -5219,5 +5219,15 @@ public static Uri AuditLog(string organization, string phrase) { return "organizations/{0}/audit-log?phrase={1}".FormatUri(organization, phrase); } + + /// <summary> + /// Returns the <see cref="Uri"/> that returns all of the copilot seats of the organization + /// </summary> + /// <param name="org">The organization</param> + /// <returns></returns> + public static Uri CopilotSeats(string org) + { + return "orgs/{0}/copilot/billing/seats".FormatUri(org); + } } } diff --git a/Octokit/Models/Response/Copilot/CopilotAssignee.cs b/Octokit/Models/Response/Copilot/CopilotAssignee.cs new file mode 100644 index 0000000000..0403bc8575 --- /dev/null +++ b/Octokit/Models/Response/Copilot/CopilotAssignee.cs @@ -0,0 +1,13 @@ +namespace Octokit.Copilot +{ + public class CopilotAssignee + { + public CopilotAssignee() + { + } + + public string Login { get; set; } + + public long Id { get; set; } + } +} diff --git a/Octokit/Models/Response/Copilot/CopilotSeat.cs b/Octokit/Models/Response/Copilot/CopilotSeat.cs new file mode 100644 index 0000000000..b37906122f --- /dev/null +++ b/Octokit/Models/Response/Copilot/CopilotSeat.cs @@ -0,0 +1,15 @@ +using System; + +namespace Octokit.Copilot +{ + public class CopilotSeat + { + public CopilotSeat() {} + + public DateTime CreatedAt { get; set; } + + public DateTime UpdatedAt { get; set; } + + public CopilotAssignee Assignee { get; set; } + } +} diff --git a/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs b/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs new file mode 100644 index 0000000000..58ccdf8280 --- /dev/null +++ b/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace Octokit.Copilot +{ + /// <summary> + /// Represents a Copilot seats response on GitHub. + /// </summary> + public class CopilotSeatsResponse + { + public CopilotSeatsResponse() {} + + public int TotalSeats { get; set; } + + public IReadOnlyList<CopilotSeat> Seats { get; set; } + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 547deb9e0a..28f89a3921 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.17</Version> + <Version>1.0.18</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 33f43d04027dc96eaffab22049f6e032202a2c64 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Wed, 27 Dec 2023 11:59:03 +0200 Subject: [PATCH 204/209] wip --- Octokit/Models/Response/Copilot/CopilotAssignee.cs | 13 ------------- Octokit/Models/Response/Copilot/CopilotSeat.cs | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 Octokit/Models/Response/Copilot/CopilotAssignee.cs diff --git a/Octokit/Models/Response/Copilot/CopilotAssignee.cs b/Octokit/Models/Response/Copilot/CopilotAssignee.cs deleted file mode 100644 index 0403bc8575..0000000000 --- a/Octokit/Models/Response/Copilot/CopilotAssignee.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Octokit.Copilot -{ - public class CopilotAssignee - { - public CopilotAssignee() - { - } - - public string Login { get; set; } - - public long Id { get; set; } - } -} diff --git a/Octokit/Models/Response/Copilot/CopilotSeat.cs b/Octokit/Models/Response/Copilot/CopilotSeat.cs index b37906122f..54e1a7976b 100644 --- a/Octokit/Models/Response/Copilot/CopilotSeat.cs +++ b/Octokit/Models/Response/Copilot/CopilotSeat.cs @@ -10,6 +10,6 @@ public CopilotSeat() {} public DateTime UpdatedAt { get; set; } - public CopilotAssignee Assignee { get; set; } + public User Assignee { get; set; } } } From b37591c2be1593688e9b117ad640a6f62d9ed724 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Wed, 27 Dec 2023 14:56:34 +0200 Subject: [PATCH 205/209] fix ut --- Octokit/Clients/CopilotClient.cs | 4 ++-- Octokit/Models/Response/Copilot/CopilotSeat.cs | 13 ++++++++++--- .../Response/Copilot/CopilotSeatsResponse.cs | 14 +++++++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Octokit/Clients/CopilotClient.cs b/Octokit/Clients/CopilotClient.cs index b3449317a9..a9baa541df 100644 --- a/Octokit/Clients/CopilotClient.cs +++ b/Octokit/Clients/CopilotClient.cs @@ -18,7 +18,7 @@ public async Task<CopilotSeatsResponse> GetAllSeats(string org) var results = await ApiConnection.GetAll<CopilotSeatsResponse>(ApiUrls.CopilotSeats(org), ApiOptions.None); if (results.Count == 0) { - return new CopilotSeatsResponse { TotalSeats = 0 }; + return new CopilotSeatsResponse (0, new List<CopilotSeat>()); } var totalSeats = results[0].TotalSeats; @@ -29,7 +29,7 @@ public async Task<CopilotSeatsResponse> GetAllSeats(string org) seats.AddRange(copilotSeatsResponse.Seats); } - return new CopilotSeatsResponse { TotalSeats = totalSeats, Seats = seats }; + return new CopilotSeatsResponse (totalSeats, seats); } } } diff --git a/Octokit/Models/Response/Copilot/CopilotSeat.cs b/Octokit/Models/Response/Copilot/CopilotSeat.cs index 54e1a7976b..24daab4d26 100644 --- a/Octokit/Models/Response/Copilot/CopilotSeat.cs +++ b/Octokit/Models/Response/Copilot/CopilotSeat.cs @@ -6,10 +6,17 @@ public class CopilotSeat { public CopilotSeat() {} - public DateTime CreatedAt { get; set; } + public CopilotSeat(DateTime createdAt, DateTime updatedAt, User assignee) + { + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Assignee = assignee; + } + + public DateTime CreatedAt { get; private set; } - public DateTime UpdatedAt { get; set; } + public DateTime UpdatedAt { get; private set; } - public User Assignee { get; set; } + public User Assignee { get; private set; } } } diff --git a/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs b/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs index 58ccdf8280..b7047950f0 100644 --- a/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs +++ b/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs @@ -7,10 +7,18 @@ namespace Octokit.Copilot /// </summary> public class CopilotSeatsResponse { - public CopilotSeatsResponse() {} + public CopilotSeatsResponse() + { + } - public int TotalSeats { get; set; } + public CopilotSeatsResponse(int totalSeats, IReadOnlyList<CopilotSeat> seats) + { + TotalSeats = totalSeats; + Seats = seats; + } - public IReadOnlyList<CopilotSeat> Seats { get; set; } + public int TotalSeats { get; private set;} + + public IReadOnlyList<CopilotSeat> Seats { get; private set;} } } From 5973de64274df8fb9def05cc71b669e4178febbf Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Wed, 27 Dec 2023 15:15:44 +0200 Subject: [PATCH 206/209] wip --- Octokit/Models/Response/Copilot/CopilotSeat.cs | 8 ++++++++ Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/Octokit/Models/Response/Copilot/CopilotSeat.cs b/Octokit/Models/Response/Copilot/CopilotSeat.cs index 24daab4d26..c39d94b94a 100644 --- a/Octokit/Models/Response/Copilot/CopilotSeat.cs +++ b/Octokit/Models/Response/Copilot/CopilotSeat.cs @@ -1,7 +1,11 @@ using System; +using System.Diagnostics; +using System.Globalization; namespace Octokit.Copilot { + [ExcludeFromCtorWithAllPropertiesConventionTest(nameof(Type))] + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CopilotSeat { public CopilotSeat() {} @@ -18,5 +22,9 @@ public CopilotSeat(DateTime createdAt, DateTime updatedAt, User assignee) public DateTime UpdatedAt { get; private set; } public User Assignee { get; private set; } + + internal string DebuggerDisplay => + string.Format(CultureInfo.InvariantCulture, + "User: Id: {0} Login: {1}", Assignee.Id, Assignee.Login); } } diff --git a/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs b/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs index b7047950f0..34ac07d410 100644 --- a/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs +++ b/Octokit/Models/Response/Copilot/CopilotSeatsResponse.cs @@ -1,10 +1,15 @@ +using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; namespace Octokit.Copilot { /// <summary> /// Represents a Copilot seats response on GitHub. /// </summary> + [ExcludeFromCtorWithAllPropertiesConventionTest(nameof(Type))] + [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CopilotSeatsResponse { public CopilotSeatsResponse() @@ -20,5 +25,9 @@ public CopilotSeatsResponse(int totalSeats, IReadOnlyList<CopilotSeat> seats) public int TotalSeats { get; private set;} public IReadOnlyList<CopilotSeat> Seats { get; private set;} + + internal string DebuggerDisplay => + string.Format(CultureInfo.InvariantCulture, + "TotalSeats: {0}", TotalSeats); } } From 95dece72afe3b62f5962f628aae724975e660bd2 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Wed, 27 Dec 2023 15:36:21 +0200 Subject: [PATCH 207/209] wip --- ...bservableICopilotClient.cs => IObservableCopilotClient.cs} | 2 +- Octokit.Reactive/Clients/IObservableOrganizationsClient.cs | 2 ++ ...ObservableICopilotClient.cs => ObservableCopilotClient.cs} | 4 ++-- Octokit.Reactive/Clients/ObservableOrganizationsClient.cs | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) rename Octokit.Reactive/Clients/{IObservableICopilotClient.cs => IObservableCopilotClient.cs} (75%) rename Octokit.Reactive/Clients/{ObservableICopilotClient.cs => ObservableCopilotClient.cs} (74%) diff --git a/Octokit.Reactive/Clients/IObservableICopilotClient.cs b/Octokit.Reactive/Clients/IObservableCopilotClient.cs similarity index 75% rename from Octokit.Reactive/Clients/IObservableICopilotClient.cs rename to Octokit.Reactive/Clients/IObservableCopilotClient.cs index 714da510b7..e71a7fbf2e 100644 --- a/Octokit.Reactive/Clients/IObservableICopilotClient.cs +++ b/Octokit.Reactive/Clients/IObservableCopilotClient.cs @@ -3,7 +3,7 @@ namespace Octokit.Reactive; -public interface IObservableICopilotClient +public interface IObservableCopilotClient { IObservable<CopilotSeatsResponse> GetAllSeats(string org); } diff --git a/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs index d44a187990..3aa03fbe18 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationsClient.cs @@ -30,6 +30,8 @@ public interface IObservableOrganizationsClient /// Returns a client to manage organization actions. /// </summary> IObservableOrganizationActionsClient Actions { get; } + + IObservableCopilotClient Copilot { get; } /// <summary> /// Returns the specified organization. diff --git a/Octokit.Reactive/Clients/ObservableICopilotClient.cs b/Octokit.Reactive/Clients/ObservableCopilotClient.cs similarity index 74% rename from Octokit.Reactive/Clients/ObservableICopilotClient.cs rename to Octokit.Reactive/Clients/ObservableCopilotClient.cs index d51ba9c310..b90208d8e9 100644 --- a/Octokit.Reactive/Clients/ObservableICopilotClient.cs +++ b/Octokit.Reactive/Clients/ObservableCopilotClient.cs @@ -4,10 +4,10 @@ namespace Octokit.Reactive; -public class ObservableICopilotClient : IObservableICopilotClient +public class ObservableCopilotClient : IObservableCopilotClient { private readonly ICopilotClient _client; - public ObservableICopilotClient(IGitHubClient client) + public ObservableCopilotClient(IGitHubClient client) { _client = client.Organization.Copilot; } diff --git a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs index e90bac920f..dcb1ff05cf 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationsClient.cs @@ -23,6 +23,7 @@ public ObservableOrganizationsClient(IGitHubClient client) Hook = new ObservableOrganizationHooksClient(client); OutsideCollaborator = new ObservableOrganizationOutsideCollaboratorsClient(client); Actions = new ObservableOrganizationActionsClient(client); + Copilot = new ObservableCopilotClient(client); _client = client.Organization; _connection = client.Connection; @@ -54,6 +55,9 @@ public ObservableOrganizationsClient(IGitHubClient client) /// </summary> public IObservableOrganizationActionsClient Actions { get; private set; } + + public IObservableCopilotClient Copilot { get; } + /// <summary> /// Returns the specified organization. /// </summary> From 9cd88cbc6cab99a4daf2c4fb1285905aa6d49f08 Mon Sep 17 00:00:00 2001 From: alexanderpalvanov <alex.p@apiiro.com> Date: Mon, 29 Jan 2024 14:52:21 +0200 Subject: [PATCH 208/209] wip --- Octokit/Clients/IRepositoryBranchesClient.cs | 11 ++++ Octokit/Clients/RepositoryBranchesClient.cs | 19 ++++++ Octokit/Helpers/ApiUrls.cs | 12 ++++ .../Models/Response/BranchProtectionRule.cs | 59 +++++++++++++++++++ Octokit/Octokit.csproj | 2 +- 5 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 Octokit/Models/Response/BranchProtectionRule.cs diff --git a/Octokit/Clients/IRepositoryBranchesClient.cs b/Octokit/Clients/IRepositoryBranchesClient.cs index eec7c6026c..2ca79c6195 100644 --- a/Octokit/Clients/IRepositoryBranchesClient.cs +++ b/Octokit/Clients/IRepositoryBranchesClient.cs @@ -76,6 +76,17 @@ public interface IRepositoryBranchesClient /// <param name="branch">The name of the branch</param> [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task<Branch> Get(long repositoryId, string branch); + + /// <summary> + /// Get the branch rules for the specified branch + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/repos/rules#get-rules-for-a-branch">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="branch">The name of the branch</param> + Task<List<BranchProtectionRule>> GetBranchRules(string owner, string name, string branch); /// <summary> /// Get the branch protection settings for the specified branch diff --git a/Octokit/Clients/RepositoryBranchesClient.cs b/Octokit/Clients/RepositoryBranchesClient.cs index 8126fc0ea6..4374fb76a8 100644 --- a/Octokit/Clients/RepositoryBranchesClient.cs +++ b/Octokit/Clients/RepositoryBranchesClient.cs @@ -122,6 +122,25 @@ public Task<Branch> Get(long repositoryId, string branch) return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(repositoryId, branch), null); } + /// <summary> + /// Get the branch rules for the specified branch + /// </summary> + /// <remarks> + /// See the <a href="https://docs.github.com/en/rest/repos/rules#get-rules-for-a-branch">API documentation</a> for more details + /// </remarks> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="branch">The name of the branch</param> + [ManualRoute("GET", "/repos/{owner}/{repo}/rules/branches/{branch}")] + public Task<List<BranchProtectionRule>> GetBranchRules(string owner, string name, string branch) + { + Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); + Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); + Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); + + return ApiConnection.Get<List<BranchProtectionRule>>(ApiUrls.RepoBranchRules(owner, name, branch), null); + } + /// <summary> /// Get the branch protection settings for the specified branch /// </summary> diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 2f65c8a5c4..6ef11e0aed 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2311,6 +2311,18 @@ public static Uri RepoBranch(string owner, string name, string branchName) { return "repos/{0}/{1}/branches/{2}".FormatUri(owner, name, branchName); } + + /// <summary> + /// Returns the <see cref="Uri"/> for a repository branches rules. + /// </summary> + /// <param name="owner">The owner of the repository</param> + /// <param name="name">The name of the repository</param> + /// <param name="branchName">The name of the branch</param> + /// <returns></returns> + public static Uri RepoBranchRules(string owner, string name, string branchName) + { + return "repos/{0}/{1}/rules/branches/{2}".FormatUri(owner, name, branchName); + } /// <summary> /// Returns the <see cref="Uri"/> for a repository branches protection. diff --git a/Octokit/Models/Response/BranchProtectionRule.cs b/Octokit/Models/Response/BranchProtectionRule.cs new file mode 100644 index 0000000000..86d24274e8 --- /dev/null +++ b/Octokit/Models/Response/BranchProtectionRule.cs @@ -0,0 +1,59 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// <summary> + /// Protection rule set for a <see cref="Branch"/>. + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class BranchProtectionRule + { + public BranchProtectionRule() + { + } + + public BranchProtectionRule(string type, string rulesetSourceType, long rulesetId, BranchProtectionRuleParameters parameters) + { + Type = type; + RulesetSourceType = rulesetSourceType; + RulesetId = rulesetId; + Parameters = parameters; + } + + public string Type { get; private set; } + public string RulesetSourceType { get; private set; } + public long RulesetId { get; private set; } + public BranchProtectionRuleParameters Parameters { get; private set; } + + internal string DebuggerDisplay => + string.Format(CultureInfo.InvariantCulture, + "Type: {0} RulesetSourceType {1} RulesetId: {2} Parameters: {3}", + Type, + RulesetSourceType, + RulesetId, + Parameters?.DebuggerDisplay ?? "disabled"); + } + + /// <summary> + /// Specifies settings for status checks which must pass before branches can be merged into the protected branch + /// </summary> + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class BranchProtectionRuleParameters + { + public BranchProtectionRuleParameters() + { + } + + public BranchProtectionRuleParameters(int requiredApprovingReviewCount) + { + RequiredApprovingReviewCount = requiredApprovingReviewCount; + } + + public int RequiredApprovingReviewCount { get; private set; } + + internal string DebuggerDisplay => + string.Format(CultureInfo.InvariantCulture, + "RequiredApprovingReviewCount: {0}", RequiredApprovingReviewCount); + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 28f89a3921..abd98b0fed 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -4,7 +4,7 @@ <Description>An async-based GitHub API client library for .NET and .NET Core</Description> <AssemblyTitle>Octokit</AssemblyTitle> <Authors>GitHub</Authors> - <Version>1.0.18</Version> + <Version>1.0.19</Version> <GenerateDocumentationFile>true</GenerateDocumentationFile> <AssemblyName>Octokit</AssemblyName> <PackageId>Apiiro.Octokit</PackageId> From 41b67a5cd75c867156e92b6c27ca618a9b714364 Mon Sep 17 00:00:00 2001 From: snirburkush <snir@apiiro.com> Date: Sun, 25 Feb 2024 19:44:40 +0200 Subject: [PATCH 209/209] Update Issue.cs --- Octokit/Models/Response/Issue.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index b18e99c931..94f8c49460 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -45,7 +45,7 @@ public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, i /// <summary> /// The internal Id for this issue (not the issue number) /// </summary> - public int Id { get; private set; } + public long Id { get; private set; } /// <summary> /// GraphQL Node Id