Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: adds 409 status codes to ShaItemRequestBuilder, CommitsRequestBuilder, RefItemRequestBuilde, updates code comments and docs #52

Merged
merged 1 commit into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/GitHub/Organizations/OrganizationsRequestBuilder.cs
Expand Up @@ -28,7 +28,7 @@ public class OrganizationsRequestBuilder : BaseRequestBuilder {
public OrganizationsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/organizations{?per_page*,since*}", rawUrl) {
}
/// <summary>
/// Lists all organizations, in the order that they were created on GitHub.**Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
/// Lists all organizations, in the order that they were created.**Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
/// API method documentation <see href="https://docs.github.com/rest/orgs/orgs#list-organizations" />
/// </summary>
/// <returns>A List&lt;OrganizationSimple&gt;</returns>
Expand All @@ -46,7 +46,7 @@ public class OrganizationsRequestBuilder : BaseRequestBuilder {
return collectionResult?.ToList();
}
/// <summary>
/// Lists all organizations, in the order that they were created on GitHub.**Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
/// Lists all organizations, in the order that they were created.**Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
/// </summary>
/// <returns>A <see cref="RequestInformation"/></returns>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
Expand All @@ -71,7 +71,7 @@ public class OrganizationsRequestBuilder : BaseRequestBuilder {
return new OrganizationsRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// Lists all organizations, in the order that they were created on GitHub.**Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
/// Lists all organizations, in the order that they were created.**Note:** Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers) to get the URL for the next page of organizations.
/// </summary>
public class OrganizationsRequestBuilderGetQueryParameters {
/// <summary>The number of results per page (max 100). For more information, see &quot;[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).&quot;</summary>
Expand Down
Expand Up @@ -34,6 +34,7 @@ public class BranchesWhereHeadRequestBuilder : BaseRequestBuilder {
/// <returns>A List&lt;BranchShort&gt;</returns>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
/// <exception cref="ValidationError">When receiving a 422 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand All @@ -44,6 +45,7 @@ public class BranchesWhereHeadRequestBuilder : BaseRequestBuilder {
#endif
var requestInfo = ToGetRequestInformation(requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"409", BasicError.CreateFromDiscriminatorValue},
{"422", ValidationError.CreateFromDiscriminatorValue},
};
var collectionResult = await RequestAdapter.SendCollectionAsync<BranchShort>(requestInfo, BranchShort.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
Expand Down
Expand Up @@ -70,6 +70,7 @@ public class Commit_shaItemRequestBuilder : BaseRequestBuilder {
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 404 status code</exception>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
/// <exception cref="ValidationError">When receiving a 422 status code</exception>
/// <exception cref="BasicError">When receiving a 500 status code</exception>
/// <exception cref="Commit503Error">When receiving a 503 status code</exception>
Expand All @@ -83,6 +84,7 @@ public class Commit_shaItemRequestBuilder : BaseRequestBuilder {
var requestInfo = ToGetRequestInformation(requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"404", BasicError.CreateFromDiscriminatorValue},
{"409", BasicError.CreateFromDiscriminatorValue},
{"422", ValidationError.CreateFromDiscriminatorValue},
{"500", BasicError.CreateFromDiscriminatorValue},
{"503", Commit503Error.CreateFromDiscriminatorValue},
Expand Down
Expand Up @@ -34,6 +34,7 @@ public class PullsRequestBuilder : BaseRequestBuilder {
/// <returns>A List&lt;PullRequestSimple&gt;</returns>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<List<PullRequestSimple>?> GetAsync(Action<RequestConfiguration<PullsRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) {
Expand All @@ -42,7 +43,10 @@ public class PullsRequestBuilder : BaseRequestBuilder {
public async Task<List<PullRequestSimple>> GetAsync(Action<RequestConfiguration<PullsRequestBuilderGetQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default) {
#endif
var requestInfo = ToGetRequestInformation(requestConfiguration);
var collectionResult = await RequestAdapter.SendCollectionAsync<PullRequestSimple>(requestInfo, PullRequestSimple.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"409", BasicError.CreateFromDiscriminatorValue},
};
var collectionResult = await RequestAdapter.SendCollectionAsync<PullRequestSimple>(requestInfo, PullRequestSimple.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
Expand Down
Expand Up @@ -36,6 +36,7 @@ public class WithFile_shaItemRequestBuilder : BaseRequestBuilder {
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 403 status code</exception>
/// <exception cref="BasicError">When receiving a 404 status code</exception>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
/// <exception cref="ValidationError">When receiving a 422 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand All @@ -48,6 +49,7 @@ public class WithFile_shaItemRequestBuilder : BaseRequestBuilder {
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"403", BasicError.CreateFromDiscriminatorValue},
{"404", BasicError.CreateFromDiscriminatorValue},
{"409", BasicError.CreateFromDiscriminatorValue},
{"422", ValidationError.CreateFromDiscriminatorValue},
};
return await RequestAdapter.SendAsync<Blob>(requestInfo, Blob.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
Expand Down
Expand Up @@ -45,6 +45,7 @@ public class CommitsRequestBuilder : BaseRequestBuilder {
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 404 status code</exception>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
/// <exception cref="ValidationError">When receiving a 422 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand All @@ -57,6 +58,7 @@ public class CommitsRequestBuilder : BaseRequestBuilder {
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"404", BasicError.CreateFromDiscriminatorValue},
{"409", BasicError.CreateFromDiscriminatorValue},
{"422", ValidationError.CreateFromDiscriminatorValue},
};
return await RequestAdapter.SendAsync<GitCommit>(requestInfo, GitCommit.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
Expand Down
Expand Up @@ -35,6 +35,7 @@ public class WithCommit_shaItemRequestBuilder : BaseRequestBuilder {
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 404 status code</exception>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<GitCommit?> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) {
Expand All @@ -45,6 +46,7 @@ public class WithCommit_shaItemRequestBuilder : BaseRequestBuilder {
var requestInfo = ToGetRequestInformation(requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"404", BasicError.CreateFromDiscriminatorValue},
{"409", BasicError.CreateFromDiscriminatorValue},
};
return await RequestAdapter.SendAsync<GitCommit>(requestInfo, GitCommit.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
}
Expand Down
Expand Up @@ -34,6 +34,7 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
/// <returns>A List&lt;GitRef&gt;</returns>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<List<GitRef>?> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) {
Expand All @@ -42,7 +43,10 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
public async Task<List<GitRef>> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default) {
#endif
var requestInfo = ToGetRequestInformation(requestConfiguration);
var collectionResult = await RequestAdapter.SendCollectionAsync<GitRef>(requestInfo, GitRef.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"409", BasicError.CreateFromDiscriminatorValue},
};
var collectionResult = await RequestAdapter.SendCollectionAsync<GitRef>(requestInfo, GitRef.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
return collectionResult?.ToList();
}
/// <summary>
Expand Down
Expand Up @@ -35,6 +35,7 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 404 status code</exception>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<GitRef?> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) {
Expand All @@ -45,6 +46,7 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
var requestInfo = ToGetRequestInformation(requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"404", BasicError.CreateFromDiscriminatorValue},
{"409", BasicError.CreateFromDiscriminatorValue},
};
return await RequestAdapter.SendAsync<GitRef>(requestInfo, GitRef.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
}
Expand Down
Expand Up @@ -33,6 +33,7 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
/// </summary>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
/// <exception cref="ValidationError">When receiving a 422 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand All @@ -43,6 +44,7 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
#endif
var requestInfo = ToDeleteRequestInformation(requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"409", BasicError.CreateFromDiscriminatorValue},
{"422", ValidationError.CreateFromDiscriminatorValue},
};
await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false);
Expand All @@ -55,6 +57,7 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
/// <param name="body">The request body</param>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
/// <exception cref="ValidationError">When receiving a 422 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand All @@ -66,6 +69,7 @@ public class WithRefItemRequestBuilder : BaseRequestBuilder {
_ = body ?? throw new ArgumentNullException(nameof(body));
var requestInfo = ToPatchRequestInformation(body, requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"409", BasicError.CreateFromDiscriminatorValue},
{"422", ValidationError.CreateFromDiscriminatorValue},
};
return await RequestAdapter.SendAsync<GitRef>(requestInfo, GitRef.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
Expand Down
2 changes: 2 additions & 0 deletions src/GitHub/Repos/Item/Item/Git/Refs/RefsRequestBuilder.cs
Expand Up @@ -44,6 +44,7 @@ public class RefsRequestBuilder : BaseRequestBuilder {
/// <param name="body">The request body</param>
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
/// <exception cref="ValidationError">When receiving a 422 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
Expand All @@ -55,6 +56,7 @@ public class RefsRequestBuilder : BaseRequestBuilder {
_ = body ?? throw new ArgumentNullException(nameof(body));
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"409", BasicError.CreateFromDiscriminatorValue},
{"422", ValidationError.CreateFromDiscriminatorValue},
};
return await RequestAdapter.SendAsync<GitRef>(requestInfo, GitRef.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
Expand Down
Expand Up @@ -35,6 +35,7 @@ public class WithTag_shaItemRequestBuilder : BaseRequestBuilder {
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
/// <exception cref="BasicError">When receiving a 404 status code</exception>
/// <exception cref="BasicError">When receiving a 409 status code</exception>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public async Task<GitTag?> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) {
Expand All @@ -45,6 +46,7 @@ public class WithTag_shaItemRequestBuilder : BaseRequestBuilder {
var requestInfo = ToGetRequestInformation(requestConfiguration);
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
{"404", BasicError.CreateFromDiscriminatorValue},
{"409", BasicError.CreateFromDiscriminatorValue},
};
return await RequestAdapter.SendAsync<GitTag>(requestInfo, GitTag.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
}
Expand Down