Skip to content

Commit

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

* New updates to generated code
  • Loading branch information
octokitbot authored Aug 2, 2024
1 parent 30282f2 commit c639ee8
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 32 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
push:
branches:
- 3.11

jobs:
build:
runs-on: ubuntu-latest
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ To install the package, you can use either of the following options:
- Type `Install-Package GitHub.Octokit.SDK` into the Package Manager Console, or
- Type `dotnet add ./path/to/myproject.csproj package GitHub.Octokit.SDK` in a terminal (replace `./path/to/myproject.csproj` by the path to the _*.csproj_ file you want to add the dependency)


### Initializing

Given that the GHES platform is a self hosted instance when using this SDK you'll need to initialize it with your host and protocol:

```csharp
var tokenProvider = new TokenProvider(Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? "");
var adapter = RequestAdapter.Create(new TokenAuthProvider(tokenProvider), "https://hosted.instance");
var gitHubClient = new GitHubClient(adapter);
```

### Make your first request

```csharp
Expand All @@ -48,8 +59,8 @@ using GitHub.Octokit.Client;
using GitHub.Octokit.Client.Authentication;

var token = Environment.GetEnvironmentVariable("GITHUB_TOKEN") ?? "";
var request = RequestAdapter.Create(new TokenAuthProvider(new TokenProvider(token)));
var gitHubClient = new GitHubClient(request);
var adapter = RequestAdapter.Create(new TokenAuthProvider(tokenProvider), "https://hosted.instance");
var gitHubClient = new GitHubClient(adapter);

var pullRequests = await gitHubClient.Repos["octokit"]["octokit.net"].Pulls.GetAsync();

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

try
Expand Down
21 changes: 21 additions & 0 deletions src/Client/RequestAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ public static HttpClientRequestAdapter Create(IAuthenticationProvider authentica
clientFactory,
null);

return gitHubRequestAdapter;
}
public static HttpClientRequestAdapter Create(IAuthenticationProvider authenticationProvider, string baseUrl, HttpClient? clientFactory = null)
{
if (string.IsNullOrEmpty(baseUrl))
{
throw new ArgumentException("Base URL cannot be null or empty.", nameof(baseUrl));
}

clientFactory ??= ClientFactory.Create();

var gitHubRequestAdapter = new HttpClientRequestAdapter(
authenticationProvider,
null, // Node Parser
null, // Serializer
clientFactory,
null)
{
BaseUrl = baseUrl
};

return gitHubRequestAdapter;
}
}
6 changes: 3 additions & 3 deletions src/GitHub/Events/EventsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public EventsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : bas
{
}
/// <summary>
/// We delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// API method documentation <see href="https://docs.github.com/[email protected]/rest/activity/events#list-public-events" />
/// </summary>
/// <returns>A List&lt;Event&gt;</returns>
Expand All @@ -58,7 +58,7 @@ public async Task<List<Event>> GetAsync(Action<RequestConfiguration<EventsReques
return collectionResult?.ToList();
}
/// <summary>
/// We delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
Expand Down Expand Up @@ -86,7 +86,7 @@ public EventsRequestBuilder WithUrl(string rawUrl)
return new EventsRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// We delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
public class EventsRequestBuilderGetQueryParameters
{
Expand Down
6 changes: 3 additions & 3 deletions src/GitHub/Models/PullRequestReview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class PullRequestReview : IAdditionalDataHolder, IParsable
public string HtmlUrl { get; set; }
#endif
/// <summary>Unique identifier of the review</summary>
public int? Id { get; set; }
public long? Id { get; set; }
/// <summary>The _links property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand Down Expand Up @@ -129,7 +129,7 @@ public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{"body_text", n => { BodyText = n.GetStringValue(); } },
{"commit_id", n => { CommitId = n.GetStringValue(); } },
{"html_url", n => { HtmlUrl = n.GetStringValue(); } },
{"id", n => { Id = n.GetIntValue(); } },
{"id", n => { Id = n.GetLongValue(); } },
{"_links", n => { Links = n.GetObjectValue<PullRequestReview__links>(PullRequestReview__links.CreateFromDiscriminatorValue); } },
{"node_id", n => { NodeId = n.GetStringValue(); } },
{"pull_request_url", n => { PullRequestUrl = n.GetStringValue(); } },
Expand All @@ -151,7 +151,7 @@ public virtual void Serialize(ISerializationWriter writer)
writer.WriteStringValue("body_text", BodyText);
writer.WriteStringValue("commit_id", CommitId);
writer.WriteStringValue("html_url", HtmlUrl);
writer.WriteIntValue("id", Id);
writer.WriteLongValue("id", Id);
writer.WriteObjectValue<PullRequestReview__links>("_links", Links);
writer.WriteStringValue("node_id", NodeId);
writer.WriteStringValue("pull_request_url", PullRequestUrl);
Expand Down
7 changes: 5 additions & 2 deletions src/GitHub/Networks/Item/Item/Events/EventsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public EventsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : bas
{
}
/// <summary>
/// List public events for a network of repositories
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// API method documentation <see href="https://docs.github.com/[email protected]/rest/activity/events#list-public-events-for-a-network-of-repositories" />
/// </summary>
/// <returns>A List&lt;Event&gt;</returns>
Expand All @@ -57,6 +57,9 @@ public async Task<List<Event>> GetAsync(Action<RequestConfiguration<EventsReques
var collectionResult = await RequestAdapter.SendCollectionAsync<Event>(requestInfo, Event.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <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
Expand All @@ -83,7 +86,7 @@ public EventsRequestBuilder WithUrl(string rawUrl)
return new EventsRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// List public events for a network of repositories
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
public class EventsRequestBuilderGetQueryParameters
{
Expand Down
7 changes: 5 additions & 2 deletions src/GitHub/Orgs/Item/Events/EventsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public EventsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : bas
{
}
/// <summary>
/// List public organization events
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// API method documentation <see href="https://docs.github.com/[email protected]/rest/activity/events#list-public-organization-events" />
/// </summary>
/// <returns>A List&lt;Event&gt;</returns>
Expand All @@ -50,6 +50,9 @@ public async Task<List<Event>> GetAsync(Action<RequestConfiguration<EventsReques
var collectionResult = await RequestAdapter.SendCollectionAsync<Event>(requestInfo, Event.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <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
Expand All @@ -76,7 +79,7 @@ public EventsRequestBuilder WithUrl(string rawUrl)
return new EventsRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// List public organization events
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
public class EventsRequestBuilderGetQueryParameters
{
Expand Down
6 changes: 3 additions & 3 deletions src/GitHub/Users/Item/Events/EventsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public EventsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : bas
{
}
/// <summary>
/// If you are authenticated as the given user, you will see your private events. Otherwise, you&apos;ll only see public events.
/// If you are authenticated as the given user, you will see your private events. Otherwise, you&apos;ll only see public events.&gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// API method documentation <see href="https://docs.github.com/[email protected]/rest/activity/events#list-events-for-the-authenticated-user" />
/// </summary>
/// <returns>A List&lt;Event&gt;</returns>
Expand All @@ -63,7 +63,7 @@ public async Task<List<Event>> GetAsync(Action<RequestConfiguration<EventsReques
return collectionResult?.ToList();
}
/// <summary>
/// If you are authenticated as the given user, you will see your private events. Otherwise, you&apos;ll only see public events.
/// If you are authenticated as the given user, you will see your private events. Otherwise, you&apos;ll only see public events.&gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
Expand Down Expand Up @@ -91,7 +91,7 @@ public EventsRequestBuilder WithUrl(string rawUrl)
return new EventsRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// If you are authenticated as the given user, you will see your private events. Otherwise, you&apos;ll only see public events.
/// If you are authenticated as the given user, you will see your private events. Otherwise, you&apos;ll only see public events.&gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
public class EventsRequestBuilderGetQueryParameters
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public WithOrgItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter)
{
}
/// <summary>
/// This is the user&apos;s organization dashboard. You must be authenticated as the user to view this.
/// This is the user&apos;s organization dashboard. You must be authenticated as the user to view this.&gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// API method documentation <see href="https://docs.github.com/[email protected]/rest/activity/events#list-organization-events-for-the-authenticated-user" />
/// </summary>
/// <returns>A List&lt;Event&gt;</returns>
Expand All @@ -51,7 +51,7 @@ public async Task<List<Event>> GetAsync(Action<RequestConfiguration<WithOrgItemR
return collectionResult?.ToList();
}
/// <summary>
/// This is the user&apos;s organization dashboard. You must be authenticated as the user to view this.
/// This is the user&apos;s organization dashboard. You must be authenticated as the user to view this.&gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
Expand Down Expand Up @@ -79,7 +79,7 @@ public WithOrgItemRequestBuilder WithUrl(string rawUrl)
return new WithOrgItemRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// This is the user&apos;s organization dashboard. You must be authenticated as the user to view this.
/// This is the user&apos;s organization dashboard. You must be authenticated as the user to view this.&gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
public class WithOrgItemRequestBuilderGetQueryParameters
{
Expand Down
7 changes: 5 additions & 2 deletions src/GitHub/Users/Item/Events/Public/PublicRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public PublicRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : bas
{
}
/// <summary>
/// List public events for a user
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// API method documentation <see href="https://docs.github.com/[email protected]/rest/activity/events#list-public-events-for-a-user" />
/// </summary>
/// <returns>A List&lt;Event&gt;</returns>
Expand All @@ -50,6 +50,9 @@ public async Task<List<Event>> GetAsync(Action<RequestConfiguration<PublicReques
var collectionResult = await RequestAdapter.SendCollectionAsync<Event>(requestInfo, Event.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <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
Expand All @@ -76,7 +79,7 @@ public PublicRequestBuilder WithUrl(string rawUrl)
return new PublicRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// List public events for a user
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
public class PublicRequestBuilderGetQueryParameters
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public PublicRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : bas
{
}
/// <summary>
/// List public events received by a user
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// API method documentation <see href="https://docs.github.com/[email protected]/rest/activity/events#list-public-events-received-by-a-user" />
/// </summary>
/// <returns>A List&lt;Event&gt;</returns>
Expand All @@ -50,6 +50,9 @@ public async Task<List<Event>> GetAsync(Action<RequestConfiguration<PublicReques
var collectionResult = await RequestAdapter.SendCollectionAsync<Event>(requestInfo, Event.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <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
Expand All @@ -76,7 +79,7 @@ public PublicRequestBuilder WithUrl(string rawUrl)
return new PublicRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// List public events received by a user
/// &gt; [!NOTE]&gt; This API is not built to serve real-time use cases. Depending on the time of day, event latency can be anywhere from 30s to 6h.
/// </summary>
public class PublicRequestBuilderGetQueryParameters
{
Expand Down
Loading

0 comments on commit c639ee8

Please sign in to comment.