Skip to content

Commit

Permalink
GHES 3.10: Changes in generated code (#37)
Browse files Browse the repository at this point in the history
* New updates to generated code

* New updates to generated code

* New updates to generated code

* New updates to generated code
  • Loading branch information
octokitbot authored Aug 15, 2024
1 parent 1595e31 commit 9144590
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 51 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
> [!IMPORTANT]
> This SDK is not yet stable. Breaking changes may occur at any time.
# Octokit: .NET SDK

[![Build and test .NET SDK](https://github.com/octokit/dotnet-sdk/actions/workflows/build.yml/badge.svg)](https://github.com/octokit/dotnet-sdk/actions/workflows/build.yml) [![CodeQL](https://github.com/octokit/dotnet-sdk/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/octokit/dotnet-sdk/actions/workflows/github-code-scanning/codeql) [![Publish Release to NuGet](https://github.com/octokit/dotnet-sdk/actions/workflows/publish.yml/badge.svg)](https://github.com/octokit/dotnet-sdk/actions/workflows/publish.yml)
[![Build and test .NET SDK](https://github.com/octokit/dotnet-sdk-enterprise-server/actions/workflows/build.yml/badge.svg)](https://github.com/octokit/dotnet-sdk-enterprise-server/actions/workflows/build.yml) [![CodeQL](https://github.com/octokit/dotnet-sdk-enterprise-server/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/octokit/dotnet-sdk-enterprise-server/actions/workflows/github-code-scanning/codeql) [![Publish Release to NuGet](https://github.com/octokit/dotnet-sdk-enterprise-server/actions/workflows/publish.yml/badge.svg)](https://github.com/octokit/dotnet-sdk-enterprise-server/actions/workflows/publish.yml)

An "alpha" version of a generated .NET SDK in C# for GitHub's Enterprise Server products, generated from [GitHub's OpenAPI spec](https://github.com/github/rest-api-description), built on [Kiota](https://github.com/microsoft/kiota). View on [NuGet](https://www.nuget.org/packages/GitHub.Octokit.SDK/).

Expand All @@ -12,11 +15,13 @@ You may also want:
- [NuGet link](https://www.nuget.org/packages/GitHub.Octokit.SDK)
- For GitHub Enterprise Cloud
- [dotnet-sdk-enterprise-cloud repository](https://github.com/octokit/dotnet-sdk-enterprise-cloud)
- [NuGet link](https://www.nuget.org/packages/GitHub.Octokit.GHEC.SDK/)
- For GitHub Enterprise Server
- [dotnet-sdk-enterprise-server repository](https://github.com/octokit/dotnet-sdk-enterprise-server)
- [NuGet link](https://www.nuget.org/packages?q=GitHub.Octokit.GHES.SDK)
- For our classic non-generated, hand-maintained Octokit.net project
- [Octokit.net repository](https://github.com/octokit/octokit.net)
- For why we're building generative SDKs, see [Why a generated SDK?](#why-a-generated-sdk) below
- [NuGet link](https://www.nuget.org/packages/Octokit/)
- Go
- For the standard GitHub.com product
- [go-sdk repository](https://github.com/octokit/go-sdk)
Expand All @@ -29,6 +34,7 @@ You may also want:
- [pkg.go.dev docs link](https://pkg.go.dev/github.com/octokit/go-sdk-enterprise-server)
- [source-generator](https://github.com/octokit/source-generator) (the repository that creates these generated SDKs)
- Contributions to this repository should take place in source-generator instead, as they'll be distributed here through mechanisms there.
- For why we're building generative SDKs, see [Why a generated SDK?](#why-a-generated-sdk) below

## How do I use it?

Expand Down Expand Up @@ -70,9 +76,6 @@ foreach (var pullRequest in pullRequests)
}
```

> [!IMPORTANT]
> This SDK is not yet stable. Breaking changes may occur at any time.
### Authentication

This SDK supports [Personal Access Tokens (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic), [fine-grained Personal Access Tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#fine-grained-personal-access-tokens), and [GitHub Apps](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/about-authentication-with-a-github-app) authentication.
Expand Down Expand Up @@ -110,17 +113,15 @@ Note that the SDK **does not yet** support authenticating as the App itself and

## Why a generated SDK?

We want to...
1. provide 100% coverage of the API in our SDK
1. use this as a building block for future SDK tooling
Please take a moment and head over to the GitHub blog to read more about the [why's and how's behind our move to Generative SDKs](https://github.blog/news-insights/product-news/our-move-to-generated-sdks/).

## Why .NET?

We have a substantial userbase that uses .NET and we wanted them to get access to our generated SDK as early as possible.

## How can I report on my experience or issues with the SDK?

Please use this project's [issues](https://github.com/octokit/dotnet-sdk/issues)!
Please use this project's [issues](https://github.com/octokit/dotnet-sdk-enterprise-server/issues)!

## Source organization

Expand All @@ -138,7 +139,7 @@ Currently this project is fairly simple (we hope it can stay that way). All of
- Generate test report: `dotnet reportgenerator -targetdir:$(pwd)/test/coverage/Report/ -reports:$(pwd)/test/coverage/coverage.opencover.xml`
- Note that this requires installing [ReportGenerator](https://github.com/danielpalme/ReportGenerator), whose installation instructions can be found [here](https://github.com/danielpalme/ReportGenerator?tab=readme-ov-file#install-the-package-matching-your-platform-and-needs)
- We're using the `dotnet-reportgenerator-globaltool`, so follow that set of installation instructions
- The test report can be viewed by opening the generated report file (logged to CLI output, something like `/path/to/your/repo/dotnet-sdk/test/coverage/Report/index.html`) in a browser
- The test report can be viewed by opening the generated report file (logged to CLI output, something like `/path/to/your/repo/dotnet-sdk-enterprise-server/test/coverage/Report/index.html`) in a browser

## More details on this SDK and repo

Expand Down
6 changes: 5 additions & 1 deletion cli/Authentication/AppInstallationToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ public class AppInstallationToken

public static async Task Run()
{
// The GitHub Enterprise Server URL
var baseUrl = Environment.GetEnvironmentVariable("GITHUB_BASE_URL") ?? "https://api.github.com";


var githubAppTokenProvider = new GitHubAppTokenProvider();
var rsa = RSA.Create();
rsa.ImportFromPem(PRIVATE_KEY_PATH);

var aiAccessTokenProvider = new AppInstallationTokenProvider(CLIENT_ID, rsa, INSTALLATION_ID, githubAppTokenProvider);
var aiAdapter = RequestAdapter.Create(new AppInstallationAuthProvider(aiAccessTokenProvider));
var aiAdapter = RequestAdapter.Create(new AppInstallationAuthProvider(aiAccessTokenProvider), baseUrl);
var aiGitHubClient = new GitHubClient(aiAdapter);

try
Expand Down
4 changes: 3 additions & 1 deletion cli/Authentication/PersonalAccessToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public static async Task Run()
{
// Personal Access Token authentication
var tokenProvider = new TokenProvider(Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? "");
var adapter = RequestAdapter.Create(new TokenAuthProvider(tokenProvider), "https://api.github.com");
// The GitHub Enterprise Server URL
var baseUrl = Environment.GetEnvironmentVariable("GITHUB_BASE_URL") ?? "https://api.github.com";
var adapter = RequestAdapter.Create(new TokenAuthProvider(tokenProvider), baseUrl);
var gitHubClient = new GitHubClient(adapter);

try
Expand Down
20 changes: 0 additions & 20 deletions src/GitHub/Models/ApiOverview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,8 @@ namespace GitHub.Models {
/// </summary>
public class ApiOverview : IAdditionalDataHolder, IParsable
{
/// <summary>The actions_macos property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public List<string>? ActionsMacos { get; set; }
#nullable restore
#else
public List<string> ActionsMacos { get; set; }
#endif
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData { get; set; }
/// <summary>The dependabot property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public List<string>? Dependabot { get; set; }
#nullable restore
#else
public List<string> Dependabot { get; set; }
#endif
/// <summary>The domains property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand Down Expand Up @@ -79,8 +63,6 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{"actions_macos", n => { ActionsMacos = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
{"dependabot", n => { Dependabot = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
{"domains", n => { Domains = n.GetObjectValue<ApiOverview_domains>(ApiOverview_domains.CreateFromDiscriminatorValue); } },
{"installed_version", n => { InstalledVersion = n.GetStringValue(); } },
{"packages", n => { Packages = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
Expand All @@ -94,8 +76,6 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
public virtual void Serialize(ISerializationWriter writer)
{
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteCollectionOfPrimitiveValues<string>("actions_macos", ActionsMacos);
writer.WriteCollectionOfPrimitiveValues<string>("dependabot", Dependabot);
writer.WriteObjectValue<ApiOverview_domains>("domains", Domains);
writer.WriteStringValue("installed_version", InstalledVersion);
writer.WriteCollectionOfPrimitiveValues<string>("packages", Packages);
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub/Orgs/Item/Repos/ReposPostRequestBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ReposPostRequestBody : IAdditionalDataHolder, IParsable
#endif
/// <summary>The default value for a merge commit message.- `PR_TITLE` - default to the pull request&apos;s title.- `PR_BODY` - default to the pull request&apos;s body.- `BLANK` - default to a blank commit message.</summary>
public ReposPostRequestBody_merge_commit_message? MergeCommitMessage { get; set; }
/// <summary>The default value for a merge commit title.- `PR_TITLE` - default to the pull request&apos;s title.- `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name).</summary>
/// <summary>Required when using `merge_commit_message`.The default value for a merge commit title.- `PR_TITLE` - default to the pull request&apos;s title.- `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name).</summary>
public ReposPostRequestBody_merge_commit_title? MergeCommitTitle { get; set; }
/// <summary>The name of the repository.</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
Expand All @@ -81,7 +81,7 @@ public class ReposPostRequestBody : IAdditionalDataHolder, IParsable
public bool? Private { get; set; }
/// <summary>The default value for a squash merge commit message:- `PR_BODY` - default to the pull request&apos;s body.- `COMMIT_MESSAGES` - default to the branch&apos;s commit messages.- `BLANK` - default to a blank commit message.</summary>
public ReposPostRequestBody_squash_merge_commit_message? SquashMergeCommitMessage { get; set; }
/// <summary>The default value for a squash merge commit title:- `PR_TITLE` - default to the pull request&apos;s title.- `COMMIT_OR_PR_TITLE` - default to the commit&apos;s title (if only one commit) or the pull request&apos;s title (when more than one commit).</summary>
/// <summary>Required when using `squash_merge_commit_message`.The default value for a squash merge commit title:- `PR_TITLE` - default to the pull request&apos;s title.- `COMMIT_OR_PR_TITLE` - default to the commit&apos;s title (if only one commit) or the pull request&apos;s title (when more than one commit).</summary>
public ReposPostRequestBody_squash_merge_commit_title? SquashMergeCommitTitle { get; set; }
/// <summary>The id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization.</summary>
public int? TeamId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.Serialization;
using System;
namespace GitHub.Orgs.Item.Repos {
/// <summary>The default value for a merge commit title.- `PR_TITLE` - default to the pull request&apos;s title.- `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name).</summary>
/// <summary>Required when using `merge_commit_message`.The default value for a merge commit title.- `PR_TITLE` - default to the pull request&apos;s title.- `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name).</summary>
public enum ReposPostRequestBody_merge_commit_title
{
[EnumMember(Value = "PR_TITLE")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.Serialization;
using System;
namespace GitHub.Orgs.Item.Repos {
/// <summary>The default value for a squash merge commit title:- `PR_TITLE` - default to the pull request&apos;s title.- `COMMIT_OR_PR_TITLE` - default to the commit&apos;s title (if only one commit) or the pull request&apos;s title (when more than one commit).</summary>
/// <summary>Required when using `squash_merge_commit_message`.The default value for a squash merge commit title:- `PR_TITLE` - default to the pull request&apos;s title.- `COMMIT_OR_PR_TITLE` - default to the commit&apos;s title (if only one commit) or the pull request&apos;s title (when more than one commit).</summary>
public enum ReposPostRequestBody_squash_merge_commit_title
{
[EnumMember(Value = "PR_TITLE")]
Expand Down
6 changes: 3 additions & 3 deletions src/GitHub/Orgs/Item/Teams/Item/Teams/TeamsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public TeamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<List<GitHub.Models.Team>?> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
public async Task<List<Team>?> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
{
#nullable restore
#else
public async Task<List<GitHub.Models.Team>> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
public async Task<List<Team>> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
{
#endif
var requestInfo = ToGetRequestInformation(requestConfiguration);
var collectionResult = await RequestAdapter.SendCollectionAsync<GitHub.Models.Team>(requestInfo, GitHub.Models.Team.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
var collectionResult = await RequestAdapter.SendCollectionAsync<Team>(requestInfo, Team.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/GitHub/Orgs/Item/Teams/TeamsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ public TeamsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base
/// <exception cref="BasicError">When receiving a 403 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<List<GitHub.Models.Team>?> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
public async Task<List<Team>?> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
{
#nullable restore
#else
public async Task<List<GitHub.Models.Team>> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
public async Task<List<Team>> GetAsync(Action<RequestConfiguration<TeamsRequestBuilderGetQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
{
#endif
var requestInfo = ToGetRequestInformation(requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
{
{"403", BasicError.CreateFromDiscriminatorValue},
};
var collectionResult = await RequestAdapter.SendCollectionAsync<GitHub.Models.Team>(requestInfo, GitHub.Models.Team.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
var collectionResult = await RequestAdapter.SendCollectionAsync<Team>(requestInfo, Team.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub/Repos/Item/Item/RepoPatchRequestBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class RepoPatchRequestBody : IAdditionalDataHolder, IParsable
public bool? IsTemplate { get; set; }
/// <summary>The default value for a merge commit message.- `PR_TITLE` - default to the pull request&apos;s title.- `PR_BODY` - default to the pull request&apos;s body.- `BLANK` - default to a blank commit message.</summary>
public RepoPatchRequestBody_merge_commit_message? MergeCommitMessage { get; set; }
/// <summary>The default value for a merge commit title.- `PR_TITLE` - default to the pull request&apos;s title.- `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name).</summary>
/// <summary>Required when using `merge_commit_message`.The default value for a merge commit title.- `PR_TITLE` - default to the pull request&apos;s title.- `MERGE_MESSAGE` - default to the classic title for a merge message (e.g., Merge pull request #123 from branch-name).</summary>
public RepoPatchRequestBody_merge_commit_title? MergeCommitTitle { get; set; }
/// <summary>The name of the repository.</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
Expand All @@ -81,7 +81,7 @@ public class RepoPatchRequestBody : IAdditionalDataHolder, IParsable
#endif
/// <summary>The default value for a squash merge commit message:- `PR_BODY` - default to the pull request&apos;s body.- `COMMIT_MESSAGES` - default to the branch&apos;s commit messages.- `BLANK` - default to a blank commit message.</summary>
public RepoPatchRequestBody_squash_merge_commit_message? SquashMergeCommitMessage { get; set; }
/// <summary>The default value for a squash merge commit title:- `PR_TITLE` - default to the pull request&apos;s title.- `COMMIT_OR_PR_TITLE` - default to the commit&apos;s title (if only one commit) or the pull request&apos;s title (when more than one commit).</summary>
/// <summary>Required when using `squash_merge_commit_message`.The default value for a squash merge commit title:- `PR_TITLE` - default to the pull request&apos;s title.- `COMMIT_OR_PR_TITLE` - default to the commit&apos;s title (if only one commit) or the pull request&apos;s title (when more than one commit).</summary>
public RepoPatchRequestBody_squash_merge_commit_title? SquashMergeCommitTitle { get; set; }
/// <summary>Either `true` to allow squash-merge commits to use pull request title, or `false` to use commit message. **This property has been deprecated. Please use `squash_merge_commit_title` instead.</summary>
[Obsolete("")]
Expand Down
Loading

0 comments on commit 9144590

Please sign in to comment.